--- source_files: - Common/DTS.CommonCore/Classes/Sensors/DisplayedCalibrationBehavior.cs - Common/DTS.CommonCore/Classes/Sensors/SensorDbRecord.cs - Common/DTS.CommonCore/Classes/Sensors/ZeroRef.cs - Common/DTS.CommonCore/Classes/Sensors/CalMode.cs - Common/DTS.CommonCore/Classes/Sensors/StreamInputRecord.cs - Common/DTS.CommonCore/Classes/Sensors/UARTRecord.cs - Common/DTS.CommonCore/Classes/Sensors/ParseParameters.cs - Common/DTS.CommonCore/Classes/Sensors/DigitalInputScaleMultiplier.cs - Common/DTS.CommonCore/Classes/Sensors/DigitalOutDbRecord.cs - Common/DTS.CommonCore/Classes/Sensors/SensorCalDbRecord.cs - Common/DTS.CommonCore/Classes/Sensors/StreamOutputRecord.cs - Common/DTS.CommonCore/Classes/Sensors/ZeroMethod.cs generated_at: "2026-04-16T02:39:12.436129+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "f64af1453db763cc" --- # Sensor Data Model Documentation ## 1. Purpose This module defines core data structures for representing sensor metadata, calibration, and configuration within the DTS system. It provides concrete implementations of interfaces for database persistence (`SensorDbRecord`, `StreamInputRecord`, `UARTRecord`, `StreamOutputRecord`, `DigitalOutDbRecord`, `SensorCalDbRecord`), helper classes for parsing and serializing configuration strings (`ZeroRef`, `CalMode`, `DigitalInputScaleMultiplier`), and supporting infrastructure for calibration and zeroing behavior (`ZeroMethod`, `ZeroMethods`, `DisplayedCalibrationBehavior`). These classes serve as the foundational data layer for sensor management, enabling consistent representation of sensor properties across database operations, CSV import/export workflows, and UI binding contexts. ## 2. Public Interface ### `DisplayedCalibrationBehavior` - **`CalibrationBehavior`** (`DTS.Common.Enums.Sensors.CalibrationBehaviors`): Stores the underlying calibration behavior enum value. - **`DisplayString`** (`string`): Human-readable string representation of the calibration behavior. - **`ToString()`** (`override string`): Returns `DisplayString`. ### `SensorDbRecord` - **`id`** (`int`): Database ID of the sensor model record. - **`SensorType`** (`short`): Sensor type identifier. - **`SerialNumber`** (`string`): Serial number of the sensor model. - **`TagType`** (`override TagTypes`): Returns `TagTypes.SensorModels`. - **Constructor `SensorDbRecord(IDataReader reader)`**: Initializes fields from database reader using `Utility.GetInt`, `Utility.GetShort`, and `Utility.GetString`. ### `ZeroRef` - **`ZeroType`** (`enum`): Defines zeroing methods: - `AverageOverTime` (serialized as `"0"`) - `UsePreEventDiagnostics` (serialized as `"1"`) - `UseZeroMv` (serialized as `"2"`) - **`ZeroMethod`** (`ZeroType`): The selected zeroing method. - **Constructor `ZeroRef(string zeroref)`**: Parses string (`"0"`, `"1"`, or `"2"`) into `ZeroMethod`; throws `NotSupportedException` for invalid input. - **Constructor `ZeroRef(ZeroType type)`**: Initializes `ZeroMethod` directly. - **`ToString()`** (`override string`): Returns `"0"`, `"1"`, or `"2"` based on `ZeroMethod`. ### `CalMode` - **`ShuntCheck`** (`bool`): `true` if shunt check enabled (`'S'` in position 0), `false` otherwise (`'I'`). - **`FullBridge`** (`bool`): `true` if full bridge mode (`'D'` in position 1), `false` otherwise (`'S'`). - **`Filter`** (`bool`): `true` if filter enabled (`'F'` in position 2), `false` otherwise (`'B'`). - **Constructor `CalMode(string value)`**: Parses 3-character string (e.g., `"SDF"`) into properties; throws `NotSupportedException` for invalid characters at any position. - **Constructor `CalMode()`**: Default constructor initializes all properties to `false`. - **`ToString()`** (`override string`): Serializes to 3-character string (e.g., `"SDF"`). ### `StreamInputRecord` - **`Id`** (`int`): Database ID of the sensor. - **`SerialNumber`** (`string`): Sensor serial number. - **`LastModified`** (`DateTime`): Timestamp of last modification. - **`LastUpdatedBy`** (`string`): User who last modified the record. - **`DoNotUse`** (`bool`): Flag indicating sensor should be excluded from use. - **`Broken`** (`bool`): Flag indicating sensor is broken. - **`StreamInUDPAddress`** (`string`): UDP address for streaming input; defaults to `"UDP://239.1.2.10:8400"`. - **`TagType`** (`override TagTypes`): Returns `TagTypes.Sensors`. - **Constructor `StreamInputRecord(ISensorData sd)`**: Initializes from `ISensorData` interface; logs exceptions via `APILogger`. - **Constructor `StreamInputRecord(IDataReader reader)`**: Initializes from database reader; logs exceptions via `APILogger`. ### `UARTRecord` - **`Id`** (`int`): Database ID. - **`SerialNumber`** (`string`): Serial number. - **`UartBaudRate`** (`uint`): Baud rate; default `57600`. - **`UartDataBits`** (`uint`): Data bits; default `8`. - **`UartStopBits`** (`StopBits`): Stop bits; default `StopBits.None`. - **`UartParity`** (`Parity`): Parity; default `Parity.None`. - **`UartFlowControl`** (`Handshake`): Flow control; default `Handshake.None`. - **`UartDataFormat`** (`UartDataFormat`): Data format; default `UartDataFormat.Binary`. - **`LastModified`** (`DateTime`): Last modification timestamp. - **`LastUpdatedBy`** (`string`): Last modifier. - **`DoNotUse`** (`bool`): Exclusion flag. - **`Broken`** (`bool`): Broken flag. - **`TagType`** (`TagTypes`): Returns `TagTypes.Sensors`. - **Constructor `UARTRecord(ISensorData sensor)`**: Initializes from `ISensorData`. - **Constructor `UARTRecord(IDataReader reader)`**: Initializes from database reader; parses enum fields via `Enum.Parse`; logs exceptions. ### `ParseParameters` - **`SensorData`** (`ISensorData`): Sensor data source. - **`ImportCulture`** (`IFormatProvider`): Culture for parsing during import. - **`Errors`** (`List`): Accumulated errors during parsing. - **`IrtraccExponent`** (`double`): Exponent for IrTracc scaling. - **`SensorCal`** (`ISensorCalibration`): Calibration data. - **`Sensitivity`** (`double`): Sensitivity value. - **`SavedIsProportional`** (`bool`): Proportional flag. - **`SavedRemoveOffset`** (`bool`): Remove offset flag. - **`StripBackslash`** (`bool`): Backslash stripping flag. - **`OriginalOffset`** (`double`): Original offset value. - **`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`**, **`SensorGroupTypeLookup`**, etc.: Multiple `Dictionary` fields for mapping group names, ISO codes, user codes, DAS serial numbers, and channel indices. - **`SensorTestObject`** (`string`): Test object identifier. - **`UseISOCodeFilterMapping`**, **`UseZeroForUnfiltered`** (`bool`): Filtering flags. - **`SensorISOCode`**, **`SensorUserCode`**, etc.: Dictionaries for channel mappings. ### `DigitalInputScaleMultiplier` - **`Form`** (`Forms`): Scaling form; defaults to `Forms.ArbitraryLowAndHigh`. - **`DefaultValue`** (`double`): Value displayed for digital input `0` (OFF); defaults to `0`. - **`ActiveValue`** (`double`): Value displayed for digital input `1` (ON); defaults to `1`. - **`SimpleEquals(IDigitalInputScaleMultiplier rhs)`** (`bool`): Compares `Form`, `DefaultValue`, and `ActiveValue`. - **`Equals(object obj)`** (`override bool`): Deep equality check. - **`GetHashCode()`** (`override int`): Hash code using primes `31` and `79`. - **Constructor `DigitalInputScaleMultiplier()`**: Initializes `DefaultValue = 0`. - **Constructor `DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)`**: Copy constructor. - **`ToSerializeDbString()`** (`string`): Serializes to format `"ArbitraryLowAndHigh,defaultValue,activeValue"`. - **`FromDbSerializeString(string s)`** (`void`): Deserializes from string; throws `NotSupportedException` on invalid format. ### `DigitalOutDbRecord` - **`SerialNumber`** (`string`): Serial number. - **`DODelay`** (`double`): Digital output delay in ms; default `0`. - **`DODuration`** (`double`): Digital output duration in ms; default `0`. - **`ModifiedBy`** (`string`): Last modifier. - **`LastModified`** (`DateTime`): Last modification timestamp. - **`DatabaseId`** (`int`): Database ID; default `-1`. - **`ISOCode`**, **`ISOChannelName`**, **`UserCode`**, **`UserChannelName`** (`string`): Channel identification fields. - **`Broken`** (`bool`): Broken flag; default `false`. - **`DoNotUse`** (`bool`): Exclusion flag; default `false`. - **`DOMode`** (`DigitalOutputModes`): Output mode; default `DigitalOutputModes.CCNC`. - **`LimitDuration`** (`bool`): Duration limit flag; default `true`. - **`Version`** (`int`): Record version; default `0`. - **`TagsBlobBytes`** (`byte[]`): Binary tags blob. - **Constructor `DigitalOutDbRecord()`**: Default constructor. - **Constructor `DigitalOutDbRecord(ISensorData copy, byte[] tagsBlobBytes)`**: Initializes from `ISensorData` and tags blob. - **Constructor `DigitalOutDbRecord(IDigitalOutDbRecord copy)`**: Copy constructor. - **Constructor `DigitalOutDbRecord(IDataReader reader)`**: Initializes from database reader. ### `SensorCalDbRecord` - **`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`): Local-only flag. - **`NonLinear`** (`bool`): Non-linear calibration flag; setting to `true` sets `RemoveOffset = false`. - **`Records`** (`ICalibrationRecords`): Calibration records. - **`ModifyDate`** (`DateTime`): Last modification date. - **`IsProportional`** (`bool`): Proportional calibration flag. - **`RemoveOffset`** (`bool`): Remove offset flag. - **`ZeroMethods`** (`ZeroMethods`): Zeroing method definitions. - **`CertificationDocuments`** (`string[]`): Array of certification document paths. - **`InitialOffsets`** (`InitialOffsets`): Initial offset definitions. - **`LinearAdded`** (`bool`): Indicates if linear calibration is added (requires non-linear, polynomial, and multiple zero methods). - **Constructor `SensorCalDbRecord()`**: Default constructor. - **Constructor `SensorCalDbRecord(ISensorCalDbRecord copy)`**: Copy constructor; deep copies arrays and marks linearization valid. - **Constructor `SensorCalDbRecord(IDataReader reader)`**: Initializes from database reader; logs exceptions. ### `StreamOutputRecord` - **`Id`** (`int`): Database ID. - **`SerialNumber`** (`string`): Serial number. - **`LastModified`** (`DateTime`): Last modification timestamp. - **`LastUpdatedBy`** (`string`): Last modifier. - **`DoNotUse`** (`bool`): Exclusion flag. - **`Broken`** (`bool`): Broken flag. - **`StreamOutUDPProfile`** (`UDPStreamProfile`): Stream profile; default `UDPStreamProfile.CH10_ANALOG_2HDR`. - **`StreamOutUDPAddress`** (`string`): UDP address; defaults to `"UDP://239.1.2.10:8400"`. - **`StreamOutUDPTimeChannelId`** (`ushort`): Time channel ID; range `[10, 100]`, default `1`. - **`StreamOutUDPDataChannelId`** (`ushort`): Data channel ID; range `[10, 100]`, default `3`. - **`StreamOutUDPTmNSConfig`** (`string`): TMNS configuration; default `"(1,6,60,0,0,0,0,0)"`. - **`StreamOutIRIGTimeDataPacketIntervalMs`** (`ushort`): IRIG time data packet interval; range `[10, 1000]`, default `500`. - **`StreamOutTMATSIntervalMs`** (`ushort`): TMATS interval; range `[0, 65535]`, default `1000`. - **`TagType`** (`override TagTypes`): Returns `TagTypes.Sensors`. - **`AvailableUDPStreamProfiles(int ConnectionDbVersion, bool UseAdvancedStreamingProfiles)`** (`static UDPStreamProfile[]`): Returns list of supported profiles based on version and profile type. - **Constructor `StreamOutputRecord(ISensorData sd)`**: Initializes from `ISensorData`. - **Constructor `StreamOutputRecord(IDataReader reader, int ClientDbVersion, int ConnectionDbVersion)`**: Initializes from database reader; conditionally reads `TMATS_IntervalMS` if versions permit. ### `ZeroMethod` - **`Method`** (`ZeroMethodType`): Zeroing method type; defaults to `SensorConstants.DefaultZeroMethodType`. - **`Start`** (`double`): Start value for zeroing window; defaults to `SensorConstants.DefaultZeroMethodStart`. - **`End`** (`double`): End value for zeroing window; defaults to `SensorConstants.DefaultZeroMethodEnd`. - **`PropertyChanged`** (`event PropertyChangedEventHandler`): Implements `INotifyPropertyChanged`. - **Constructor `ZeroMethod(ZeroMethodType zm, double start, double end)`**: Initializes all fields. - **Constructor `ZeroMethod(string zm, CultureInfo culture)`**: Parses `"Method,Start,End"` string. - **Constructor `ZeroMethod(ZeroMethod copy)`**: Deep copy constructor. - **`ToDbString()`** (`string`): Serializes to `"Method,Start,End"`. - **`ToXElement(string prefix)`** (`XElement`): Serializes to XML element. - **`Update(XElement elem, string prefix)`** (`void`): Updates XML element in-place. - **`ToSerializeString()`** (`string`): Same as `ToDbString()`. - **`ToDisplayString(...)`** (`string`): Human-readable display string based on `Method`. ### `ZeroMethods` - **`Methods`** (`ZeroMethod[]`): Array of zero methods. - **Constructor `ZeroMethods()`**: Default (empty array). - **Constructor `ZeroMethods(string methods)`**: Parses serialized string using `"__x__"` separator. - **Constructor `ZeroMethods(ZeroMethod[] copyMethods)`**: Deep copy constructor. - **`FromSerializedString(string s)`** (`void`): Parses serialized string. - **`ToSerializedString()`** (`string`): Serializes using `"__x__"` separator; escapes separator characters. - **`ToDisplayString(...)`** (`string`): Human-readable display string for all methods. - **`ToString()`** (`override string`): Calls `ToDisplayString` with localized format strings. ## 3. Invariants - **`ZeroRef`**: String serialization is strictly `"0"`, `"1"`, or `"2"`; invalid inputs throw `NotSupportedException`. - **`CalMode`**: String serialization is exactly 3 characters; positions 0, 1, 2 must be `S/I`, `D/S`, and `F/B` respectively; invalid inputs throw `NotSupportedException`. - **`DigitalInputScaleMultiplier`**: Serialization format is `"Form,DefaultValue,ActiveValue"`; only `Forms.ArbitraryLowAndHigh` is supported; invalid formats throw `NotSupportedException`. - **`ZeroMethod`**: Serialization format is `"Method,Start,End"`; XML serialization uses `"UsePreCalZero"` as legacy alias for `UsePreEventDiagnosticsZero`. - **`ZeroMethods`**: Serialization uses `"__x__"` as primary separator and `"___xx___"` as backup escape sequence; `ToString()` uses localized format strings. - **`SensorCalDbRecord.NonLinear`**: Setting to `true` forces `RemoveOffset = false`. - **`StreamOutputRecord.StreamOutUDPTimeChannelId`** and **`StreamOutUDPDataChannelId`**: Valid range is `[10, 100]`. - **`StreamOutputRecord.StreamOutIRIGTimeDataPacketIntervalMs`**: Valid range is `[10, 1000]`. - **`UARTRecord`**: All UART configuration fields have defined default values (`UartBaudRate=57600`, `UartDataBits=8`, `UartStopBits=None`, `UartParity=None`, `UartFlowControl=None`, `UartDataFormat=Binary`). - **`StreamInputRecord.StreamInUDPAddress`**: Defaults to `"UDP://239.1.2.10:8400"`. - **`StreamOutputRecord.StreamOutUDPAddress`**: Defaults to `"UDP://239.1.2.10:8400"`. - **`DigitalOutDbRecord.DatabaseId`**: Default is `-1` (indicating no database assignment). - **`DigitalOutDbRecord.LimitDuration`**: Defaults to `true`. - **`DigitalOutDbRecord.DOMode`**: Defaults to `DigitalOutputModes.CCNC`. ## 4. Dependencies ### Dependencies *of* this module: - **`DTS.Common.Base`**: Provides `BasePropertyChanged` (used by `DigitalOutDbRecord`, `SensorCalDbRecord`, `ZeroMethod`). - **`DTS.Common.Interface.Tags`**: Provides `TagAwareBase` (base class for `SensorDbRecord`, `StreamInputRecord`, `StreamOutputRecord`). - **`DTS.Common.Interface.Sensors`**: Provides core interfaces (`ISensorData`, `ISensorCalDbRecord`, `IDigitalOutDbRecord`, `IDigitalInputScaleMultiplier`, `IUARTRecord`, `IStreamInputRecord`, `IStreamOutputRecord`, `ISensorCalibration`, `ISquibSettingDefaults`, `IDigitalOutDefaults`). - **`