--- source_files: - Common/DTS.Common/Classes/Sensors/DisplayedCalibrationBehavior.cs - Common/DTS.Common/Classes/Sensors/ChannelSerialNumber.cs - Common/DTS.Common/Classes/Sensors/ChannelTypeUtility.cs - Common/DTS.Common/Classes/Sensors/SensorDbRecord.cs - Common/DTS.Common/Classes/Sensors/ZeroRef.cs - Common/DTS.Common/Classes/Sensors/CalMode.cs - Common/DTS.Common/Classes/Sensors/ThermocouplerRecord.cs - Common/DTS.Common/Classes/Sensors/StreamInputRecord.cs - Common/DTS.Common/Classes/Sensors/CANRecord.cs - Common/DTS.Common/Classes/Sensors/UARTRecord.cs - Common/DTS.Common/Classes/Sensors/ParseParameters.cs - Common/DTS.Common/Classes/Sensors/DigitalInputScaleMultiplier.cs - Common/DTS.Common/Classes/Sensors/DigitalOutDbRecord.cs - Common/DTS.Common/Classes/Sensors/SensorCalDbRecord.cs - Common/DTS.Common/Classes/Sensors/StreamOutputRecord.cs generated_at: "2026-04-16T03:14:41.949051+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "584219a9653a657a" --- # Sensor Data Model Documentation ## 1. Purpose This module provides core data structures and utility classes for representing sensor metadata, calibration, and configuration within the DTS system. It serves as the foundational data layer for sensor management, enabling serialization/deserialization of sensor records from databases, handling of various sensor types (thermocouple, stream input/output, CAN, UART, digital output), and supporting calibration workflows including zero-reference methods and calibration mode configurations. The module bridges raw database records and higher-level business logic by encapsulating sensor-specific properties, validation rules, and conversion utilities. ## 2. Public Interface ### Classes #### `DisplayedCalibrationBehavior` - **Properties**: - `CalibrationBehavior` (`DTS.Common.Enums.Sensors.CalibrationBehaviors`): The underlying calibration behavior enum value. - `DisplayString` (`string`): Human-readable string representation of the behavior. - **Methods**: - `ToString()`: Returns `DisplayString`. #### `ChannelSerialNumber` - **Methods**: - `SerialNumberFromChannel(bool isTestSpecificEmbedded, string testSpecificEmbeddedSensor, string sensorDataSerialNumber)`: Returns `testSpecificEmbeddedSensor` if `isTestSpecificEmbedded` is true; otherwise returns `sensorDataSerialNumber`. #### `ChannelTypeUtility` - **Nested Enum**: - `KnownChannelTypes`: Enum of known 2-character channel type codes (VS, VU, SB, TI, TC, CT, XP, P4, VF, NB, EX, X1, R1, VO, CO, CP). - **Methods**: - `ParseSensorKnownChannelType(string sensorName)`: Extracts the first two characters of `sensorName` (uppercased) and returns them if they match a `KnownChannelTypes` value; otherwise returns `string.Empty`. Returns `string.Empty` if `sensorName` is null/empty or shorter than 2 characters. #### `ZeroRef` - **Nested Enum**: - `ZeroType`: Defines zeroing methods: `AverageOverTime` (0), `UsePreEventDiagnostics` (1), `UseZeroMv` (2). - **Properties**: - `ZeroMethod` (`ZeroType`): The selected zeroing method. - **Constructors**: - `ZeroRef(string zeroref)`: Parses `zeroref` ("0", "1", or "2") into `ZeroType`; throws `NotSupportedException` for invalid values. - `ZeroRef(ZeroType type)`: Initializes with specified `ZeroType`. - **Methods**: - `ToString()`: Returns "0", "1", or "2" based on `ZeroMethod`. #### `CalMode` - **Properties**: - `ShuntCheck` (`bool`): True if first character is 'S', false if 'I'. - `FullBridge` (`bool`): True if second character is 'D', false if 'S'. - `Filter` (`bool`): True if third character is 'F', false if 'B'. - **Constructors**: - `CalMode(string value)`: Parses a 3-character string (`value[0]` = shunt, `value[1]` = bridge, `value[2]` = filter); throws `NotSupportedException` for invalid characters. - `CalMode()`: Parameterless constructor (properties default to `false`). - **Methods**: - `ToString()`: Returns a 3-character string in format `[S/I][D/S][F/B]`. #### `SensorDbRecord` - **Properties**: - `id` (`int`): Database ID. - `SensorType` (`short`): Sensor type identifier. - `SerialNumber` (`string`): Sensor serial number. - **Constructors**: - `SensorDbRecord(IDataReader reader)`: Initializes properties from database reader using `Utility.GetInt`, `Utility.GetShort`, and `Utility.GetString`. - **Inherits**: - `TagAwareBase` with `TagType` overridden to `TagTypes.SensorModels`. #### `ThermocouplerRecord` - **Properties**: - `Id` (`int`): Database ID. - `SerialNumber` (`string`): Serial number. - `LastModified` (`DateTime`): Last modification timestamp. - `LastUpdatedBy` (`string`): User who last modified. - `DoNotUse` (`bool`): Flag indicating sensor should not be used. - `Broken` (`bool`): Flag indicating sensor is broken. - **Constructors**: - `ThermocouplerRecord(ISensorData sd)`: Initializes from `ISensorData` interface. - `ThermocouplerRecord(IDataReader reader)`: Initializes from database reader using `Utility` methods. - **Inherits**: - `TagAwareBase` with `TagType` overridden to `TagTypes.Sensors`. - **Note**: All constructors include try/catch blocks logging failures via `APILogger`. #### `StreamInputRecord` - **Properties**: - `Id` (`int`): Database ID. - `SerialNumber` (`string`): Serial number. - `LastModified` (`DateTime`): Last modification timestamp. - `LastUpdatedBy` (`string`): User who last modified. - `DoNotUse` (`bool`): Flag indicating sensor should not be used. - `Broken` (`bool`): Flag indicating sensor is broken. - `StreamInUDPAddress` (`string`): UDP address for streaming input; defaults to `"UDP://239.1.2.10:8400"`. - **Constructors**: - `StreamInputRecord(ISensorData sd)`: Initializes from `ISensorData`. - `StreamInputRecord(IDataReader reader)`: Initializes from database reader. - **Inherits**: - `TagAwareBase` with `TagType` overridden to `TagTypes.Sensors`. #### `CANRecord` - **Properties**: - `Id` (`int`): Database ID. - `SerialNumber` (`string`): Serial number. - `LastModified` (`DateTime`): Last modification timestamp. - `LastUpdatedBy` (`string`): User who last modified. - `DoNotUse` (`bool`): Flag indicating sensor should not be used. - `Broken` (`bool`): Flag indicating sensor is broken. - `CanIsFD` (`bool`): Indicates if CAN FD is enabled; defaults to `EmbeddedSensors.CANISFD_DEFAULT`. - `CanArbBaseBitrate` (`int`): Arbitration base bitrate; defaults to `EmbeddedSensors.CANFD_ARB_BASE_BITRATE_DEFAULT`. - `CanArbBaseSJW` (`int`): Arbitration base SJW; defaults to `EmbeddedSensors.CANFD_1000000_ARB_BASE_SJW_MAX`. - `CanDataBitrate` (`int`): Data bitrate; defaults to `EmbeddedSensors.DATA_BITRATE_DEFAULT`. - `CanDataSJW` (`int`): Data SJW; defaults to `EmbeddedSensors.DATA_SJW_DEFAULT`. - `CanFileType` (`string`): File type; defaults to `EmbeddedSensors.FILETYPE_DEFAULT`. - **Constructors**: - `CANRecord(ISensorData sensor)`: Initializes from `ISensorData`. - `CANRecord(IDataReader reader)`: Initializes from database reader. - **Inherits**: - `TagAwareBase` with `TagType` overridden to `TagTypes.Sensors`. #### `UARTRecord` - **Properties**: - `Id` (`int`): Database ID. - `SerialNumber` (`string`): Serial number. - `LastModified` (`DateTime`): Last modification timestamp. - `LastUpdatedBy` (`string`): User who last modified. - `DoNotUse` (`bool`): Flag indicating sensor should not be used. - `Broken` (`bool`): Flag indicating sensor is broken. - `UartBaudRate` (`uint`): Baud rate; defaults to `EmbeddedSensors.BAUD_RATE_DEFAULT`. - `UartDataBits` (`uint`): Data bits; defaults to `8`. - `UartStopBits` (`StopBits`): Stop bits; defaults to `StopBits.None`. - `UartParity` (`Parity`): Parity; defaults to `Parity.None`. - `UartFlowControl` (`Handshake`): Flow control; defaults to `Handshake.None`. - `UartDataFormat` (`UartDataFormat`): Data format; defaults to `UartDataFormat.Binary`. - **Constructors**: - `UARTRecord(ISensorData sensor)`: Initializes from `ISensorData`. - `UARTRecord(IDataReader reader)`: Initializes from database reader using `Enum.Parse` for enum properties. - **Inherits**: - `TagAwareBase` with `TagType` overridden to `TagTypes.Sensors`. #### `DigitalOutDbRecord` - **Properties**: - `SerialNumber` (`string`): Serial number. - `DODelay` (`double`): Digital output delay in ms. - `DODuration` (`double`): Digital output duration in ms. - `ModifiedBy` (`string`): User who last modified. - `LastModified` (`DateTime`): Last modification timestamp. - `DatabaseId` (`int`): Database ID. - `ISOCode` (`string`): ISO code. - `ISOChannelName` (`string`): ISO channel name. - `UserCode` (`string`): User code. - `UserChannelName` (`string`): User channel name. - `Broken` (`bool`): Flag indicating sensor is broken. - `DoNotUse` (`bool`): Flag indicating sensor should not be used. - `DOMode` (`DigitalOutputModes`): Digital output mode; defaults to `DigitalOutputModes.CCNC`. - `LimitDuration` (`bool`): Flag limiting duration; defaults to `true`. - `Version` (`int`): Record version. - `TagsBlobBytes` (`byte[]`): Binary blob for user tags. - **Constructors**: - `DigitalOutDbRecord()`: Parameterless constructor. - `DigitalOutDbRecord(ISensorData copy, byte[] tagsBlobBytes)`: Initializes from `ISensorData`. - `DigitalOutDbRecord(IDigitalOutDbRecord copy)`: Copy constructor. - `DigitalOutDbRecord(IDataReader reader)`: Initializes from database reader. - **Inherits**: - `BasePropertyChanged`. #### `SensorCalDbRecord` - **Properties**: - `CalibrationId` (`int?`): Database calibration ID; null if unknown. - `SerialNumber` (`string`): Sensor serial number. - `CalibrationDate` (`DateTime`): Calibration date. - `Username` (`string`): User who performed calibration. - `LocalOnly` (`bool`): Flag indicating local-only calibration. - `NonLinear` (`bool`): Flag indicating non-linear calibration. - `Records` (`ICalibrationRecords`): Calibration records. - `ModifyDate` (`DateTime`): Last modification date. - `IsProportional` (`bool`): Flag indicating proportional calibration. - `RemoveOffset` (`bool`): Flag indicating offset removal. - `SensitivityInspection` (`SensitivityInspectionType`): Sensitivity inspection type. - `CalibrationNote` (`string`): Calibration note (max 2048 chars). - `UsageCount` (`int`): Number of times calibration has been used. - `ZeroMethods` (`ZeroMethods`): Zeroing method definitions. - `CertificationDocuments` (`string[]`): Array of certification document paths. - `InitialOffsets` (`InitialOffsets`): Initial offset values. - `LinearAdded` (`bool`): Computed property indicating if linearization was added (based on `NonLinear`, `Records`, and `ZeroMethods` structure). - **Constructors**: - `SensorCalDbRecord()`: Parameterless constructor. - `SensorCalDbRecord(ISensorCalDbRecord copy)`: Copy constructor. - `SensorCalDbRecord(IDataReader reader, int actualDbVersion)`: Initializes from database reader; handles version-specific fields. - **Inherits**: - `BasePropertyChanged`. - **Note**: Constructors include try/catch blocks logging failures via `APILogger`. `NonLinear` setter has side effects: sets `Records.Records[0].Sensitivity = 1D`, `RemoveOffset = false`. #### `StreamOutputRecord` - **Properties**: - `Id` (`int`): Database ID. - `SerialNumber` (`string`): Serial number. - `LastModified` (`DateTime`): Last modification timestamp. - `LastUpdatedBy` (`string`): User who last modified. - `DoNotUse` (`bool`): Flag indicating sensor should not be used. - `Broken` (`bool`): Flag indicating sensor is broken. - `StreamOutUDPProfile` (`UDPStreamProfile`): UDP streaming profile; defaults to `UDPStreamProfile.CH10_ANALOG_2HDR`. - `StreamOutUDPAddress` (`string`): UDP address; defaults to `"UDP://239.1.2.10:8400"`. - `StreamOutUDPTimeChannelId` (`ushort`): Time channel ID; defaults to `1`, range `[10, 100]`. - `StreamOutUDPDataChannelId` (`ushort`): Data channel ID; defaults to `3`, range `[10, 100]`. - `StreamOutUDPTmNSConfig` (`string`): TMNS config; defaults to `"(1,6,60,0,0,0,0,0)"`. - `StreamOutIRIGTimeDataPacketIntervalMs` (`ushort`): IRIG time data packet interval; defaults to `500`, range `[10, 1000]`. - `StreamOutTMATSIntervalMs` (`ushort`): TMATS interval; defaults to `1000`, range `[0, 65535]`. - **Constructors**: - `StreamOutputRecord(ISensorData sd)`: Initializes from `ISensorData`. - `StreamOutputRecord(IDataReader reader, int ClientDbVersion, int ConnectionDbVersion)`: Initializes from database reader; conditionally loads `TMATS_IntervalMS` based on version checks. - **Static Methods**: - `AvailableUDPStreamProfiles(int ConnectionDbVersion, bool UseAdvancedStreamingProfiles)`: Returns array of supported `UDPStreamProfile` values based on version and flag. - **Inherits**: - `TagAwareBase` with `TagType` overridden to `TagTypes.Sensors`. #### `DigitalInputScaleMultiplier` - **Properties**: - `Form` (`Forms`): Scaling form; defaults to `Forms.ArbitraryLowAndHigh`. - `DefaultValue` (`double`): Value for digital 0 (OFF); defaults to `0`. - `ActiveValue` (`double`): Value for digital 1 (ON); defaults to `1`. - **Constructors**: - `DigitalInputScaleMultiplier()`: Initializes `DefaultValue = 0`. - `DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)`: Copy constructor. - **Methods**: - `SimpleEquals(IDigitalInputScaleMultiplier rhs)`: Compares `Form`, `DefaultValue`, and `ActiveValue`. - `Equals(object obj)`: Overrides `Equals` for equality comparison. - `GetHashCode()`: Overrides `GetHashCode` using primes (31, 79, 127, 23). - `ToSerializeDbString()`: Serializes to string (only `ArbitraryLowAndHigh` supported). - `FromDbSerializeString(string s)`: Deserializes from string; throws `NotSupportedException` for invalid formats. - **Inherits**: - `IDigitalInputScaleMultiplier`. #### `ParseParameters` - **Purpose**: Internal helper class to bundle parameters for CSV import operations (used in Wizard and DataPRO CSV import code). - **Properties**: - `ImportContainedSensorRanges` (`bool`): Default `false`. - `SensorData` (`ISensorData`): Sensor data source. - `ImportCulture` (`IFormatProvider`): Culture for parsing. - `Errors` (`List`): Error list. - `IrtraccExponent` (`double`): IRTRACC exponent. - `SensorCal` (`ISensorCalibration`): Calibration data. - `Sensitivity` (`double`): Sensitivity value. - `SavedIsProportional` (`bool`): Saved proportional flag. - `SavedRemoveOffset` (`bool`): Saved remove offset flag. - `StripBackslash` (`bool`): Flag for backslash stripping. - `OriginalOffset` (`double`): Original offset value; defaults to `double.NaN`. - `ZeroType` (`ZeroMethodType`): Zero method type. - `ZeroEnd` (`double`): Zero method end value. - `ZeroStart` (`double`): Zero method start value. - `SquibDefaults` (`ISquibSettingDefaults`): Squib defaults. - `DigitalOutDefaults` (`IDigitalOutDefaults`): Digital output defaults. - `SensorGroupNameLookup` (`Dictionary`): Sensor group name lookup. - `SensorGroupTypeLookup` (`Dictionary`): Sensor group type lookup. - `GroupNameToTestObjectLookup` (`Dictionary`): Group name to test object lookup. - `SensorTestObject` (`string`): Sensor test object. - `UseISOCodeFilterMapping` (`bool`): Flag for ISO code filter mapping. - `UseZeroForUnfiltered` (`bool`): Flag for zeroing unfiltered data. - `SensorISOCode` (`Dictionary`): Sensor ISO code mapping. - `SensorISOChannelName` (`Dictionary`): Sensor ISO channel name mapping. - `SensorUserCode` (`Dictionary`): Sensor user code mapping. - `SensorUserChannelName` (`Dictionary`): Sensor user channel name mapping. - `SensorDASSerialNumber` (`Dictionary`): Sensor DAS serial number mapping. - `SensorDASChannelIndex` (`Dictionary`): Sensor DAS channel index mapping. - **Note**: Documentation states this class is internal and may be refactored when DataPRO CSV import is removed. ## 3. Invariants - **`ChannelSerialNumber.SerialNumberFromChannel`**: Returns exactly one of the two input serial number strings based on `isTestSpecificEmbedded`; never returns `