16 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T02:42:02.216397+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | b14dada51ccb8b95 |
TestSetups Module Documentation
1. Purpose
This module provides core data structures and helper utilities for representing and managing test setup configurations within the DTS system. It defines record classes that model database entities (e.g., hardware assignments, ROIs, calculated channels, graphs) and supporting types for handling ISF sensor file I/O and test setup naming. The module serves as the data layer abstraction for test setup management, enabling persistence, serialization, and UI binding for test configuration data.
2. Public Interface
SimpleHardware
SimpleHardware(string serialNumber, string parentDAS, int dasId, int dasType)
Constructor initializing a tuple-based record for hardware metadata.SerialNumber(string)
Gets the hardware serial number (fromItem1).ParentDAS(string)
Gets the parent DAS identifier (fromItem2).DASId(int)
Gets the DAS identifier (fromItem3).DASType(int)
Gets the DAS type identifier (fromItem4).
TestSetupHelper
ClearTestSetupNames()
Clears the internal dictionary mapping IDs to test setup names.SetTestSetupName(int id, string name)
Sets or updates the name for a given test setup ID.GetTestSetupName(int Id)→ string
Returns the name associated with the given ID, orstring.Emptyif not found.
ROIPeriodChannelRecord
TestSetupROIId(int)
Gets/sets the foreign key toTestSetupROIs.TestSetupROIId.ChannelName(string)
Gets/sets the channel name assigned to this ROI period.ROIPeriodChannelRecord(IDataReader reader)
Constructor populating fields from a database reader usingUtility.GetInt/Utility.GetString.
ExtraProperty
Key(string)
Gets/sets the property key; raisesPropertyChangedon change.Value(string)
Gets/sets the property value; raisesPropertyChangedon change.PasteCommand(ICommand)
Gets/sets the paste command; raisesPropertyChangedon change.ItemStatus(UIItemStatus)
Gets/sets the UI item status; raisesPropertyChangedon change.ExtraProperty(IExtraProperty iep)/ExtraProperty(string key, string value)/ExtraProperty()
Constructors for copying, initializing with key/value, or default initialization.
TestSetupHardwareRecord
DASId(int)
Gets/sets the DAS identifier.TestSetupId(int)
Gets/sets the test setup identifier.AddDAS(bool)
Gets/sets whether to add (true) or remove (false) the DAS.SamplesPerSecond(int)
Gets/sets the sampling rate.IsClockMaster(bool)
Gets/sets whether this DAS is the clock master.PTPDomainId(byte)
Gets/sets the PTP domain ID.AntiAliasFilterRate(int)
Gets/sets the anti-alias filter rate.TestSetupHardwareRecord()
Default constructor.TestSetupHardwareRecord(IDataReader reader)
Constructor populating fields from a database reader.TestSetupHardwareRecord(ITestSetupHardwareRecord copy)
Copy constructor.
TestSetupROIsRecord
TestSetupROIId(int)
Gets/sets the primary key.TestSetupId(int)
Gets/sets the foreign key toTestSetups.Suffix(string)
Gets/sets the ROI period suffix (e.g.,"_ROI Period 1").ROIStart(double)
Gets/sets the start time of the ROI period.ROIEnd(double)
Gets/sets the end time of the ROI period.IsEnabled(bool)
Gets/sets whether the ROI period is enabled.IsDefault(bool)
Gets/sets whether this is the default ROI period.TestSetupROIsRecord(IDataReader reader)
Constructor populating fields from a database reader.
CalculatedChannelRecord
Name(string)
Gets/sets the calculated channel name.TestSetupName(string)
Gets/sets the associated test setup name.Id(int)
Gets/sets the database record ID.Operation(Operations)
Gets/sets the operation to apply (e.g.,SUM).CalculatedValueCode(string)
Gets/sets the ISO/user code associated with the calculated value.InputChannelIds(string[])
Gets/sets the array of input channel IDs (CSV-separated in DB).CFCForInputChannels(string)
Gets/sets the CFC to apply to input channels.ChannelFilterClassForOutput(string)
Gets/sets the CFC to apply to the output.TestSetupId(int)
Gets/sets the test setup database ID.ViewInRealtime(bool)
Gets/sets whether the channel is viewable in real-time.ClipLength(int)
Gets/sets the clip length for calculations (e.g., max over clip).CalculatedChannelRecord()/CalculatedChannelRecord(ICalculatedChannelRecord record)/CalculatedChannelRecord(IDataReader reader)
Constructors for default, copy, and database population.
ISFFile
HeaderLine1(char[])
Gets/sets the first header line (80 chars); padding with spaces.TestSetupName(char[8])
Gets/sets the test setup name at offset 7.NumberOfRecords(char[5])
Gets/sets the number of records at offset 15.TestType(char[22])
Gets/sets the test type at offset 20.TestDivision(char[30])
Gets/sets the test division at offset 42.TCFile(char[8])
Gets/sets the TC file name (without extension) at offset 72.Records(IISFSensorRecord[])
Gets the array of sensor records.AddRecord(IISFSensorRecord record)
Adds a record, sets its data channel number, and updatesNumberOfRecords.WriteToFile(string pathToFile)
Writes the ISF file to disk (HeaderLine1–3 + all records).AddSensors(ISensorData[] sensors)
ConvertsISensorDatatoISFSensorRecords and adds them.ISFFile()
Constructor initializing header with spaces.
GraphRecord
GraphId(int)
Gets/sets the graph database ID.TestSetupId(int)
Gets/sets the test setup database ID.GraphName(string)
Gets/sets the graph name (max 50 chars).GraphDescription(string)
Gets/sets the graph description (max 50 chars).ChannelsString(string)
Gets/sets the channel list (max 2048 chars).UseDomainMin/DomainMin(bool/double)
Gets/sets domain axis min constraints.UseDomainMax/DomainMax(bool/double)
Gets/sets domain axis max constraints.UseRangeMin/RangeMin(bool/double)
Gets/sets range axis min constraints.UseRangeMax/RangeMax(bool/double)
Gets/sets range axis max constraints.ThresholdsString(string)
Gets/sets threshold/line definitions (max 2048 chars).LocalOnly(bool)
Gets/sets whether to sync with central DB (deprecated).GraphRecord()/GraphRecord(IGraphRecord copy)/GraphRecord(IDataReader reader)
Constructors.
RegionOfInterest
Deserializing(static bool)
Flag to suppress notifications during deserialization.Suffix(string)
Gets/sets the ROI suffix (ensures leading underscore).Start(double)
Gets/sets ROI start time; clamps if ≥End.End(double)
Gets/sets ROI end time; clamps if ≤Start.IsEnabled(bool)
Gets/sets whether ROI is active.IsDefault(bool)
Gets/sets whether this is the default ROI.ChannelNames(string[])
Gets/sets channel names; raisesRegionOfInterestChangedEventon change (unlessDeserializing).RegionOfInterest(string suffix, bool isDefault, double start, double end)
Constructor with parameters.ResetSuffix()
Clears the suffix.SetChannelNamesNoNotify(string[] names)
Sets channel names without raising notifications.GetAnalogChanName(...)/GetChanName(...)/RemoveParentDASName(...)/RemoveAssignedByIDFromHardwareString(...)
Static utility methods for channel name formatting and parsing.
ISFSensorRecord
Record1–Record4(char[80] each)
Raw ISF record buffers.Tag(char[2])
Sensor tag at offset 75 of Record1.DataChannelNumber(char[5])
Data channel number at offset 7 of Record1.UserIdSensorIDIsNotSpecified(bool)
Gets/sets bit at offset 15 of Record1.CapacityCharacters/SetCapacity(...)/GetCapacity()
Capacity field (offset 19) with conversion helpers.SerialNumber(char[12])
Serial number at offset 30 of Record1.Sensitivity/SetSensitivity(...)/GetSensitivity()
Sensitivity field (offset 42) with conversion helpers.BridgeResistance/SetBridgeResistance(...)
Bridge resistance field (offset 53).EngineeringUnits(char[12])
Engineering units at offset 7 of Record2.C1/SetC1(...)/GetC1()
Calibration coefficient C1 (offset 20 of Record2).EID(char[17])
EID at offset 31 of Record2.TOMConfigurationName(char[8])
TOM config name (default"STANDARD").FireDelay/SetFireDelay(...)
Fire delay (offset 55 of Record2, TOM-only).CommentPart1–CommentPart3/SetSensorComment(...)
Comment fields across Records 3 & 4.SensorType(char[20])
Sensor type (offset 30 of Record4).C2/SetC2(...)/C3/SetC3(...)
Calibration coefficients C2/C3 (offsets 50/61 of Record4).Write(BinaryWriter writer)
Writes all four records to stream.ISFSensorRecord()
Constructor initializing all records with spaces.SetSensor(ISensorData sensor)
Populates record fields fromISensorData.
Extension Methods (ArrayExtensions)
Fill<T>(this T[] source, T with)
Fills entire array with value.SubFill<T>(this T[] source, T with, int startIndex, int finalIndex)
Fills fromstartIndextofinalIndex(exclusive).SetValues<T>(this T[] source, T[] with, int startIndex, int length, T pad)
Copieswithintosourcestarting atstartIndex, padding remainder withpad.GetValues<T>(this T[] source, int startIndex, int length)→ T[]
Returns a copy oflengthelements starting atstartIndex.
3. Invariants
SimpleHardware: Inherits fromTuple<string, string, int, int>; fields are immutable after construction.TestSetupROIsRecord.TestSetupId: In the constructor, the database column"TestSetupROIId"is used for bothTestSetupROIIdandTestSetupId. This is likely a bug (see Gotchas).RegionOfInterest.StartandEnd:Startis clamped to be< End, andEndis clamped to be> Start(with a 0.01 minimum gap).RegionOfInterest.Suffix: Automatically prepends"_"if missing and not whitespace-only; ensures format"_<name>".ISFFile.NumberOfRecords: Updated toRecords.Length * 4on eachAddRecordcall (4 physical records per logical record).ISFSensorRecord.TOMConfigurationName: Defaults to"STANDARD"in constructor.CalculatedChannelRecord.InputChannelIds: Stored asstring[]; in DB, stored as CSV usingCultureInfo.InvariantCulture.ListSeparator.GraphRecord.ChannelsString/ThresholdsString: Max length enforced via[MaxLength]attribute (50 for name/description, 2048 for strings).ExtraProperty: ImplementsINotifyPropertyChanged; all property setters raisePropertyChanged.
4. Dependencies
Internal Dependencies
DTS.Common.Base: Base classes (BasePropertyChanged) used byROIPeriodChannelRecord,TestSetupROIsRecord,CalculatedChannelRecord,GraphRecord.DTS.Common.Interface.*: Interfaces implemented by record classes (e.g.,ITestSetupHardwareRecord,IROIPeriodChannelRecord,ICalculatedChannelRecord,IGraphRecord,IISFSensorRecord,IExtraProperty,IRegionOfInterest).DTS.Common.Enums:Operationsenum used byCalculatedChannelRecord.DTS.Common.Enums.Sensors:SensorConstantsused byRegionOfInterest.DTS.Common.Events.RegionOfInterest:IEventAggregator,RegionOfInterestChangedEventused for ROI change notifications.Microsoft.Practices.Prism.Events: Prism event aggregator for ROI notifications.Microsoft.Practices.ServiceLocation:ServiceLocatorused inRegionOfInterest.NotifyChanged.System.Data:IDataReaderused in record constructors.System.ComponentModel.DataAnnotations:[MaxLength]attributes onGraphRecord.DTS.Common.Base:Utilityclass for safe DB value extraction (GetInt,GetString,GetDouble,GetBool,GetStringArray).
External Dependencies
System: Core types (string,Action,EventHandler, etc.).System.IO:FileStream,BinaryWriter,FileMode,File.Existsused inISFFile.WriteToFile.System.Linq: Used inCalculatedChannelRecordcopy constructor (Any()).
5. Gotchas
-
TestSetupROIsRecordconstructor bug:
TestSetupId = Utility.GetInt(reader, "TestSetupROIId");
Should likely be"TestSetupId"instead of"TestSetupROIId"(same asTestSetupROIId). This will cause incorrectTestSetupIdvalues. -
ISFFile.NumberOfRecordssemantics:
NumberOfRecordsis set toRecords.Length * 4, implying it counts physical records (4 per logical sensor), not logical sensors. This may be non-intuitive. -
RegionOfInterest.Deserializingstatic flag:
A global flag to suppress notifications during deserialization. This is fragile in multi-threaded or concurrent deserialization scenarios and may cause missed notifications. -
RegionOfInterest.GetAnalogChanNamelogic:
The condition!hardwareChannelName.StartsWith($"[{startOfHardware}")is unusual and may be error-prone ifstartOfHardwarechanges or is not consistently formatted. -
ISFSensorRecord.GetCapacity()/GetSensitivity()etc.:
UseCapacityCharacters.ToString()(which yields astringrepresentation of thechar[]array, not the string content). This is likely a bug; should usenew string(CapacityCharacters).Trim(). -
ISFFile.HeaderLine1setter:
UsesArray.Copy(value, _HeaderLine1, Math.Min(...))which may truncate or misalign ifvalue.Length≠ 80. Padding is only applied before copy viaFill(' '), but copy may overwrite padding. -
CalculatedChannelRecord.InputChannelIdscopy constructor:
Usesnew string[record.InputChannelIds.Length]; record.InputChannelIds.CopyTo(_inputChannelIds, 0);— but_inputChannelIdsis initialized tonew[] { "-1" }. This is safe, but the initial value is overwritten. -
ExtraPropertypaste command:
_pasteCommandis never initialized; consumers must set it explicitly. -
GraphRecord.LocalOnly:
Marked as[deprecated]but still present in data model and copy constructor. -
RegionOfInterestchannel name formatting:
Methods likeGetChanNameandRemoveParentDASNameassume specific formats (e.g