Files
DP44/enriched-qwen3-coder-next/Common/DTS.CommonCore/Classes/TestSetups.md
2026-04-17 14:55:32 -04:00

16 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.CommonCore/Classes/TestSetups/SimpleHardware.cs
Common/DTS.CommonCore/Classes/TestSetups/TestSetupHelper.cs
Common/DTS.CommonCore/Classes/TestSetups/ROIPeriodChannelRecord.cs
Common/DTS.CommonCore/Classes/TestSetups/ExtraProperties.cs
Common/DTS.CommonCore/Classes/TestSetups/TestSetupHardwareRecord.cs
Common/DTS.CommonCore/Classes/TestSetups/TestSetupROIsRecord.cs
Common/DTS.CommonCore/Classes/TestSetups/CalculatedChannelRecord.cs
Common/DTS.CommonCore/Classes/TestSetups/ISFFile.cs
Common/DTS.CommonCore/Classes/TestSetups/GraphRecord.cs
Common/DTS.CommonCore/Classes/TestSetups/RegionOfInterest.cs
Common/DTS.CommonCore/Classes/TestSetups/ISFSensorRecord.cs
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 (from Item1).
  • ParentDAS (string)
    Gets the parent DAS identifier (from Item2).
  • DASId (int)
    Gets the DAS identifier (from Item3).
  • DASType (int)
    Gets the DAS type identifier (from Item4).

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, or string.Empty if not found.

ROIPeriodChannelRecord

  • TestSetupROIId (int)
    Gets/sets the foreign key to TestSetupROIs.TestSetupROIId.
  • ChannelName (string)
    Gets/sets the channel name assigned to this ROI period.
  • ROIPeriodChannelRecord(IDataReader reader)
    Constructor populating fields from a database reader using Utility.GetInt/Utility.GetString.

ExtraProperty

  • Key (string)
    Gets/sets the property key; raises PropertyChanged on change.
  • Value (string)
    Gets/sets the property value; raises PropertyChanged on change.
  • PasteCommand (ICommand)
    Gets/sets the paste command; raises PropertyChanged on change.
  • ItemStatus (UIItemStatus)
    Gets/sets the UI item status; raises PropertyChanged on 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 to TestSetups.
  • 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 updates NumberOfRecords.
  • WriteToFile(string pathToFile)
    Writes the ISF file to disk (HeaderLine13 + all records).
  • AddSensors(ISensorData[] sensors)
    Converts ISensorData to ISFSensorRecords 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; raises RegionOfInterestChangedEvent on change (unless Deserializing).
  • 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

  • Record1Record4 (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).
  • CommentPart1CommentPart3 / 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 from ISensorData.

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 from startIndex to finalIndex (exclusive).
  • SetValues<T>(this T[] source, T[] with, int startIndex, int length, T pad)
    Copies with into source starting at startIndex, padding remainder with pad.
  • GetValues<T>(this T[] source, int startIndex, int length) → T[]
    Returns a copy of length elements starting at startIndex.

3. Invariants

  • SimpleHardware: Inherits from Tuple<string, string, int, int>; fields are immutable after construction.
  • TestSetupROIsRecord.TestSetupId: In the constructor, the database column "TestSetupROIId" is used for both TestSetupROIId and TestSetupId. This is likely a bug (see Gotchas).
  • RegionOfInterest.Start and End: Start is clamped to be < End, and End is 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 to Records.Length * 4 on each AddRecord call (4 physical records per logical record).
  • ISFSensorRecord.TOMConfigurationName: Defaults to "STANDARD" in constructor.
  • CalculatedChannelRecord.InputChannelIds: Stored as string[]; in DB, stored as CSV using CultureInfo.InvariantCulture.ListSeparator.
  • GraphRecord.ChannelsString / ThresholdsString: Max length enforced via [MaxLength] attribute (50 for name/description, 2048 for strings).
  • ExtraProperty: Implements INotifyPropertyChanged; all property setters raise PropertyChanged.

4. Dependencies

Internal Dependencies

  • DTS.Common.Base: Base classes (BasePropertyChanged) used by ROIPeriodChannelRecord, TestSetupROIsRecord, CalculatedChannelRecord, GraphRecord.
  • DTS.Common.Interface.*: Interfaces implemented by record classes (e.g., ITestSetupHardwareRecord, IROIPeriodChannelRecord, ICalculatedChannelRecord, IGraphRecord, IISFSensorRecord, IExtraProperty, IRegionOfInterest).
  • DTS.Common.Enums: Operations enum used by CalculatedChannelRecord.
  • DTS.Common.Enums.Sensors: SensorConstants used by RegionOfInterest.
  • DTS.Common.Events.RegionOfInterest: IEventAggregator, RegionOfInterestChangedEvent used for ROI change notifications.
  • Microsoft.Practices.Prism.Events: Prism event aggregator for ROI notifications.
  • Microsoft.Practices.ServiceLocation: ServiceLocator used in RegionOfInterest.NotifyChanged.
  • System.Data: IDataReader used in record constructors.
  • System.ComponentModel.DataAnnotations: [MaxLength] attributes on GraphRecord.
  • DTS.Common.Base: Utility class 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.Exists used in ISFFile.WriteToFile.
  • System.Linq: Used in CalculatedChannelRecord copy constructor (Any()).

5. Gotchas

  • TestSetupROIsRecord constructor bug:
    TestSetupId = Utility.GetInt(reader, "TestSetupROIId");
    Should likely be "TestSetupId" instead of "TestSetupROIId" (same as TestSetupROIId). This will cause incorrect TestSetupId values.

  • ISFFile.NumberOfRecords semantics:
    NumberOfRecords is set to Records.Length * 4, implying it counts physical records (4 per logical sensor), not logical sensors. This may be non-intuitive.

  • RegionOfInterest.Deserializing static 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.GetAnalogChanName logic:
    The condition !hardwareChannelName.StartsWith($"[{startOfHardware}") is unusual and may be error-prone if startOfHardware changes or is not consistently formatted.

  • ISFSensorRecord.GetCapacity() / GetSensitivity() etc.:
    Use CapacityCharacters.ToString() (which yields a string representation of the char[] array, not the string content). This is likely a bug; should use new string(CapacityCharacters).Trim().

  • ISFFile.HeaderLine1 setter:
    Uses Array.Copy(value, _HeaderLine1, Math.Min(...)) which may truncate or misalign if value.Length ≠ 80. Padding is only applied before copy via Fill(' '), but copy may overwrite padding.

  • CalculatedChannelRecord.InputChannelIds copy constructor:
    Uses new string[record.InputChannelIds.Length]; record.InputChannelIds.CopyTo(_inputChannelIds, 0); — but _inputChannelIds is initialized to new[] { "-1" }. This is safe, but the initial value is overwritten.

  • ExtraProperty paste command:
    _pasteCommand is never initialized; consumers must set it explicitly.

  • GraphRecord.LocalOnly:
    Marked as [deprecated] but still present in data model and copy constructor.

  • RegionOfInterest channel name formatting:
    Methods like GetChanName and RemoveParentDASName assume specific formats (e.g