12 KiB
12 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:18:08.842826+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 9bc5c021742b55c0 |
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 immutable and mutable record types that model database entities (e.g., hardware assignments, ROIs, calculated channels, graphs), along with supporting infrastructure for ISF file I/O and test setup naming. The module serves as the data layer abstraction for test setup management—enabling serialization/deserialization from database queries, file formats (ISF), and interoperation with UI and business logic layers through interfaces and property change notifications.
2. Public Interface
Classes
SimpleHardware
- Signature:
public class SimpleHardware : Tuple<string, string, int, int> - Behavior: A lightweight, immutable tuple-based representation of hardware configuration. Exposes
SerialNumber,ParentDAS,DASId, andDASTypevia named properties derived from tuple items. Used for passing hardware metadata without database persistence.
TestSetupHelper
- Signature:
public abstract class TestSetupHelper - Behavior: A static helper class for managing test setup names by ID. Provides
SetTestSetupName,GetTestSetupName, andClearTestSetupNamesmethods. Maintains an internal dictionary mapping integer IDs to string names.
ExtraProperty
- Signature:
[Serializable] public class ExtraProperty : IExtraProperty - Behavior: A mutable, INotifyPropertyChanged-enabled class representing a key-value pair for extra properties. Supports two constructors: parameterized (
key,value) and copy constructor fromIExtraProperty. IncludesPasteCommandandItemStatusproperties (ignored during JSON serialization via[ScriptIgnore]).
ROIPeriodChannelRecord
- Signature:
public class ROIPeriodChannelRecord : BasePropertyChanged, IROIPeriodChannelRecord - Behavior: Represents a record from the
ROIPeriodChannelsdatabase table. Properties:TestSetupROIId,ChannelName,ChannelId. Constructor acceptsIDataReaderandstoredProcedureVersionToUse;ChannelIdis set to-1if the DB version predates its introduction (Constants.ROIPERIODCHANNELS_CHANNELID_DB_VERSION).
TestSetupHardwareRecord
- Signature:
public class TestSetupHardwareRecord : Base.BasePropertyChanged, ITestSetupHardwareRecord - Behavior: Represents a record from the
TestSetupHardwaretable. Properties:DASId,TestSetupId,AddDAS,SamplesPerSecond,IsClockMaster,PTPDomainId,AntiAliasFilterRate. Supports three constructors: default,IDataReader(with version-awarePTPDomainIdparsing), and copy constructor fromITestSetupHardwareRecord.
TestSetupROIsRecord
- Signature:
public class TestSetupROIsRecord : BasePropertyChanged, ITestSetupROIRecord - Behavior: Represents a record from the
TestSetupROIstable. Properties:TestSetupROIId,TestSetupId,Suffix,ROIStart,ROIEnd,IsEnabled,IsDefault. Constructor acceptsIDataReader; note:TestSetupIdis incorrectly assigned from"TestSetupROIId"column in constructor (see Gotchas).
CalculatedChannelRecord
- Signature:
public class CalculatedChannelRecord : BasePropertyChanged, ICalculatedChannelRecord - Behavior: Represents a calculated channel record. Properties include
Name,TestSetupName,Id,Operation,CalculatedValueCode,InputChannelIds(string array),CFCForInputChannels,ChannelFilterClassForOutput,TestSetupId,ViewInRealtime,ClipLength. Supports default, copy (ICalculatedChannelRecord), andIDataReaderconstructors. Input channel IDs are parsed from CSV usingCultureInfo.InvariantCulture.TextInfo.ListSeparator.
ISFFile
- Signature:
public class ISFFile - Behavior: Handles reading/writing ISF (Instrumentation Sensor Format) files. Contains fixed-length header fields (
TestSetupName,NumberOfRecords,TestType,TestDivision,TCFile) and a list ofIISFSensorRecordobjects. Methods:AddRecord,WriteToFile,AddSensors. Header line parsing uses fixed offsets and padding with spaces.
GraphRecord
- Signature:
public class GraphRecord : BasePropertyChanged, IGraphRecord - Behavior: Represents a graph configuration record. Properties:
GraphId,TestSetupId,GraphName,GraphDescription,ChannelsString, axis range flags (UseDomainMin,UseDomainMax,UseRangeMin,UseRangeMax) and their corresponding min/max values,ThresholdsString,LocalOnly(deprecated). Supports default, copy, andIDataReaderconstructors.
RegionOfInterest
- Signature:
[Serializable] public class RegionOfInterest : IRegionOfInterest - Behavior: A mutable, INotifyPropertyChanged-enabled class modeling a time-based ROI. Properties:
Suffix,Start,End,IsEnabled,IsDefault,ChannelNames,ChannelIds. Includes validation to ensureStart < End. Notifies viaRegionOfInterestChangedEvent(via Prism EventAggregator) on value changes, unlessDeserializingis true. Provides utility methods for channel name formatting (GetAnalogChanName,GetChanName,RemoveParentDASName,RemoveAssignedByIDFromHardwareString) and silent assignment (SetChannelNamesNoNotify,SetChannelIdsNoNotify).
ISFSensorRecord
- Signature:
public class ISFSensorRecord : IISFSensorRecord - Behavior: Represents a single sensor record in an ISF file (comprising 4 fixed-length records of
RECORD_LENGTHchars each). Exposes structured properties for sensor metadata (e.g.,DataChannelNumber,Tag,SerialNumber,Sensitivity,Capacity,EngineeringUnits,C1,C2,C3,EID,CommentPart1/2/3,SensorType,TOMConfigurationName). Includes methods to set/get values andWritetoBinaryWriter. Default constructor initializesTOMConfigurationNameto"STANDARD".
Extension Methods (in ISFFile)
Fill<T>(this T[] sourceArray, T with): Fills entire array with value.SubFill<T>(this T[] source, T with, int startIndex, int finalIndex): Fills fromstartIndextofinalIndex(exclusive), respecting array bounds.SetValues<T>(this T[] source, T[] with, int startIndex, int length, T pad): Copieswitharray intosourcestarting atstartIndex, padding remaining space withpad.GetValues<T>(this T[] source, int startIndex, int length): Returns a new array oflengthelements starting atstartIndex.
3. Invariants
SimpleHardware: Immutable after construction; tuple item mapping is fixed (Item1→SerialNumber,Item2→ParentDAS,Item3→DASId,Item4→DASType).TestSetupROIsRecordconstructor:TestSetupIdis incorrectly assigned from"TestSetupROIId"column (see Gotchas); no invariant violation is enforced by code.RegionOfInterest.StartandEnd:Start < Endis enforced via setter logic (Startcapped atEnd - 0.01,Endcapped atStart + 0.01). Infinity values are explicitly excluded from notifications (per comment referencing "FB 43462").ISFFileheader fields: All fields are fixed-width and space-padded.NumberOfRecordsis derived as4 * number of sensor records.ISFSensorRecord: Each record consists of exactly 4 fixed-lengthchar[]arrays (Record1–Record4), each of lengthConstantsAndEnums.RECORD_LENGTH.CalculatedChannelRecord.InputChannelIds: Stored as a string array; parsed from CSV usingListSeparator(e.g., comma in invariant culture).GraphRecordaxis flags:UseDomainMin/MaxandUseRangeMin/Maxflags control whether corresponding min/max values are applied.
4. Dependencies
Internal Dependencies
DTS.Common.Base: Base classes (BasePropertyChanged) used byROIPeriodChannelRecord,TestSetupROIsRecord,CalculatedChannelRecord,GraphRecord.DTS.Common.Interface.*: Interfaces implemented by record classes:IROIPeriodChannelRecord,ITestSetupHardwareRecord,ITestSetupROIRecord,ICalculatedChannelRecord,IGraphRecord,IISFSensorRecord,IExtraProperty,IRegionOfInterest.
DTS.Common.Enums:Operationsenum used byCalculatedChannelRecord.DTS.Common.Interface.Sensors:ISensorDataused byISFSensorRecord.SetSensor.DTS.Common.Events.RegionOfInterest:RegionOfInterestChangedEventused byRegionOfInterest.Prism.*:IEventAggregator,IContainerProvider,ContainerLocatorused byRegionOfInterest.NotifyChanged.
External Dependencies
- System.Data:
IDataReaderfor database record construction. - System.ComponentModel:
INotifyPropertyChangedviaPropertyChangedEventHandler. - System.Web.Script.Serialization:
[ScriptIgnore]attribute. - System.Linq: Used for array equality checks (
SequenceEqual) and LINQ queries. - System: Core types (
string,char[],double,int,long,short,byte,bool,ICommand).
Inferred Usage
- Database: All record classes with
IDataReaderconstructors imply usage with stored procedures (e.g.,sp_ROIPeriodChannelsGet,sp_TestSetupROIsGet). - ISF I/O:
ISFFileandISFSensorRecordare used for writing sensor data to ISF files. - UI:
ExtraProperty,RegionOfInterest, and record classes implementINotifyPropertyChanged, indicating use in data-bound UI layers (e.g., WPF).
5. Gotchas
TestSetupROIsRecordconstructor bug:TestSetupId = Utility.GetInt(reader, "TestSetupROIId");incorrectly reads from"TestSetupROIId"instead of"TestSetupId". This will cause incorrectTestSetupIdvalues when constructing from database reader.ISFSensorRecord.GetCapacity(),GetSensitivity(), etc.: Methods likeCapacityCharacters.ToString()return the underlyingchar[]'sToString()(i.e., type name), not the string content. Correct usage requiresnew string(char[])orstring.Concat(char[]). This is likely a bug.RegionOfInterest.Suffixvalidation: Enforces that non-empty suffixes must start with"_"and be otherwise whitespace-free. If input violates this, it is auto-corrected (e.g.,"ROI1"→"_ROI1").RegionOfInterest.Deserializingflag: A static flag used to suppress change notifications during deserialization (e.g., to avoid triggering UI updates or event publishing during object construction). Requires careful coordination to avoid missed updates.ISFFile.NumberOfRecordssemantics:SetNumberOfRecordssetsNumberOfRecordsto4 * Records.Length, implying each sensor record occupies 4 "records" in the ISF file (consistent withISFSensorRecordhaving 4char[]fields).CalculatedChannelRecord.InputChannelIdscopy constructor: UsesCopyToonrecord.InputChannelIdsinto_inputChannelIds, but_inputChannelIdsis initialized tonew string[0]before the copy, causingArgumentExceptionifrecord.InputChannelIds.Length > 0. Should initialize_inputChannelIdstonew string[record.InputChannelIds.Length]first.ISFSensorRecord.TOMConfigurationName: Default value"STANDARD"is hardcoded; other values are not supported per comments.RegionOfInterest.GetAnalogChanNamelogic: Distinguishes"TEST_SPECIFIC_ANALOG_SERIAL"and"VOLTAGE_INPUT"DAS types for special channel name parsing. Relies onSensorConstantsvalues (not shown in source).TestSetupHelper.TestSetupNames: Static dictionary is shared across all usages;ClearTestSetupNames()affects all callers. No thread-safety is evident.