251 lines
17 KiB
Markdown
251 lines
17 KiB
Markdown
|
|
---
|
||
|
|
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-17T15:28:19.491445+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "526a6c5ad42fed58"
|
||
|
|
---
|
||
|
|
|
||
|
|
# DTS.Common.Classes.Sensors Documentation
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module provides sensor-related data structures, database record classes, and utility functions for the DTS system. It serves as the data layer for sensor management, handling persistence and serialization of sensor configurations including thermocouplers, CAN bus sensors, UART devices, stream input/output channels, digital outputs, and calibration records. The module bridges database representations with domain interfaces, providing `IDataReader` constructors for hydration and interface-based copy constructors for transformation between layers.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### DisplayedCalibrationBehavior
|
||
|
|
Simple data class pairing a calibration behavior enum with a display string.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `CalibrationBehavior` | `public DTS.Common.Enums.Sensors.CalibrationBehaviors CalibrationBehavior` | Public field holding the calibration behavior enum value. |
|
||
|
|
| `DisplayString` | `public string DisplayString` | Public field holding the human-readable display text. |
|
||
|
|
| `ToString()` | `public override string ToString()` | Returns `DisplayString`. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ChannelSerialNumber (static)
|
||
|
|
Utility for resolving serial numbers based on sensor embedding context.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `SerialNumberFromChannel` | `public static string SerialNumberFromChannel(bool isTestSpecificEmbedded, string testSpecificEmbeddedSensor, string sensorDataSerialNumber)` | Returns `testSpecificEmbeddedSensor` if `isTestSpecificEmbedded` is true; otherwise returns `sensorDataSerialNumber`. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ChannelTypeUtility (static)
|
||
|
|
Utility for parsing known channel type codes from sensor names.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `ParseSensorKnownChannelType` | `public static string ParseSensorKnownChannelType(string sensorName)` | Extracts the first 2 characters of `sensorName`, converts to uppercase, and returns it if it matches a value in `KnownChannelTypes` enum; otherwise returns `string.Empty`. Returns `string.Empty` for null/empty strings or strings shorter than 2 characters. |
|
||
|
|
|
||
|
|
#### KnownChannelTypes (enum)
|
||
|
|
Defined within `ChannelTypeUtility`:
|
||
|
|
- `VS`, `VU`, `SB`, `TI`, `TC`, `CT`, `XP`, `P4`, `VF`, `NB`, `EX`, `X1`, `R1`, `VO`, `CO`, `CP`
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### SensorDbRecord
|
||
|
|
Database record for sensor models, implements `ISensorDbRecord`.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `TagType` | `public override TagTypes TagType => TagTypes.SensorModels` | Returns the tag type for this record. |
|
||
|
|
| `id` | `public int id { get; set; }` | Database primary key. |
|
||
|
|
| `SensorType` | `public short SensorType { get; set; }` | Sensor type identifier. |
|
||
|
|
| `SerialNumber` | `public string SerialNumber { get; set; }` | Sensor serial number. |
|
||
|
|
| **Constructor** | `public SensorDbRecord(IDataReader reader)` | Hydrates from database reader using columns: `id`, `SensorType`, `SerialNumber`. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ZeroRef
|
||
|
|
Helper class for zero reference configuration in SIFs, serialized to/from integer strings.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `ZeroType` (enum) | `AverageOverTime`, `UsePreEventDiagnostics`, `UseZeroMv` | Enumeration of zero reference methods. |
|
||
|
|
| `ZeroMethod` | `public ZeroType ZeroMethod { get; }` | The configured zero method (read-only). |
|
||
|
|
| **Constructor** | `public ZeroRef(string zeroref)` | Parses string: `"0"` → `AverageOverTime`, `"1"` → `UsePreEventDiagnostics`, `"2"` → `UseZeroMv`. Throws `NotSupportedException` for invalid values. |
|
||
|
|
| **Constructor** | `public ZeroRef(ZeroType type)` | Constructs from enum value. |
|
||
|
|
| `ToString()` | `public override string ToString()` | Serializes to string: `AverageOverTime` → `"0"`, `UsePreEventDiagnostics` → `"1"`, `UseZeroMv` → `"2"`. Throws `NotSupportedException` for unhandled enum values. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### CalMode
|
||
|
|
Helper class for calibration mode in SIFs, represented as a 3-character sequence (shunt/bridge/filter).
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `ShuntCheck` | `public bool ShuntCheck { get; set; }` | Shunt check enabled. |
|
||
|
|
| `FullBridge` | `public bool FullBridge { get; set; }` | Full bridge mode. |
|
||
|
|
| `Filter` | `public bool Filter { get; set; }` | Filter enabled. |
|
||
|
|
| **Constructor** | `public CalMode(string value)` | Parses 3-character string: Position 0 (`'S'`=true, `'I'`=false), Position 1 (`'D'`=true, `'S'`=false), Position 2 (`'F'`=true, `'B'`=false). Throws `NotSupportedException` for invalid characters. |
|
||
|
|
| **Constructor** | `public CalMode()` | Parameterless constructor. |
|
||
|
|
| `ToString()` | `public override string ToString()` | Serializes to 3-character string: `ShuntCheck ? 'S' : 'I'`, `FullBridge ? 'D' : 'S'`, `Filter ? 'F' : 'B'`. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ThermocouplerRecord
|
||
|
|
Database record for thermocoupler sensors, implements `IThermocouplerRecord`.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `TagType` | `public override TagTypes TagType => TagTypes.Sensors` | Returns `TagTypes.Sensors`. |
|
||
|
|
| `Id` | `public int Id { get; set; }` | Database primary key. |
|
||
|
|
| `SerialNumber` | `public string SerialNumber { get; set; }` | Sensor serial number. |
|
||
|
|
| `LastModified` | `public DateTime LastModified { get; set; }` | Last modification timestamp. |
|
||
|
|
| `LastUpdatedBy` | `public string LastUpdatedBy { get; set; }` | User who last modified. |
|
||
|
|
| `DoNotUse` | `public bool DoNotUse { get; set; }` | Flag indicating sensor should not be used. |
|
||
|
|
| `Broken` | `public bool Broken { get; set; }` | Flag indicating sensor is broken. |
|
||
|
|
| **Constructor** | `public ThermocouplerRecord(ISensorData sd)` | Constructs from `ISensorData` interface. Catches and logs exceptions. |
|
||
|
|
| **Constructor** | `public ThermocouplerRecord(IDataReader reader)` | Hydrates from database reader using columns: `Id`, `SerialNumber`, `Broken`, `DoNotUse`, `LastModified`, `LastModifiedBy`. Catches and logs exceptions. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### StreamInputRecord
|
||
|
|
Database record for stream input sensors, implements `IStreamInputRecord`.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `TagType` | `public override TagTypes TagType => TagTypes.Sensors` | Returns `TagTypes.Sensors`. |
|
||
|
|
| `Id`, `SerialNumber`, `LastModified`, `LastUpdatedBy`, `DoNotUse`, `Broken` | (Same as ThermocouplerRecord) | Standard sensor record properties. |
|
||
|
|
| `DEFAULT_UDP_ADDRESS` | `public const string DEFAULT_UDP_ADDRESS = "UDP://239.1.2.10:8400"` | Default UDP multicast address. |
|
||
|
|
| `StreamInUDPAddress` | `public string StreamInUDPAddress { get; set; }` | UDP address for stream input. |
|
||
|
|
| **Constructor** | `public StreamInputRecord(ISensorData sd)` | Constructs from `ISensorData`. Catches and logs exceptions. |
|
||
|
|
| **Constructor** | `public StreamInputRecord(IDataReader reader)` | Hydrates from reader using columns: `Id`, `SerialNumber`, `UDPAddress`, `Broken`, `DoNotUse`, `LastModified`, `LastModifiedBy`. Catches and logs exceptions. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### CANRecord
|
||
|
|
Database record for CAN bus sensors, implements `ICANRecord`.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `TagType` | `public override TagTypes TagType => TagTypes.Sensors` | Returns `TagTypes.Sensors`. |
|
||
|
|
| `Id`, `SerialNumber`, `LastModified`, `LastUpdatedBy`, `DoNotUse`, `Broken` | (Same as ThermocouplerRecord) | Standard sensor record properties. |
|
||
|
|
| `CanIsFD` | `public bool CanIsFD { get; set; }` | CAN FD mode flag. Default from `EmbeddedSensors.CANISFD_DEFAULT`. |
|
||
|
|
| `CanArbBaseBitrate` | `public int CanArbBaseBitrate { get; set; }` | Arbitration base bitrate. Default from `EmbeddedSensors.CANFD_ARB_BASE_BITRATE_DEFAULT`. |
|
||
|
|
| `CanArbBaseSJW` | `public int CanArbBaseSJW { get; set; }` | Arbitration base SJW. Default from `EmbeddedSensors.CANFD_1000000_ARB_BASE_SJW_MAX`. |
|
||
|
|
| `CanDataBitrate` | `public int CanDataBitrate { get; set; }` | Data bitrate. Default from `EmbeddedSensors.DATA_BITRATE_DEFAULT`. |
|
||
|
|
| `CanDataSJW` | `public int CanDataSJW { get; set; }` | Data SJW. Default from `EmbeddedSensors.DATA_SJW_DEFAULT`. |
|
||
|
|
| `CanFileType` | `public string CanFileType { get; set; }` | File type. Default from `EmbeddedSensors.FILETYPE_DEFAULT`. |
|
||
|
|
| **Constructor** | `public CANRecord(ISensorData sensor)` | Constructs from `ISensorData`. |
|
||
|
|
| **Constructor** | `public CANRecord(IDataReader reader)` | Hydrates from reader using columns: `Id`, `SerialNumber`, `IsFD`, `ArbBaseBitrate`, `ArbBaseSJW`, `DataBitrate`, `DataSJW`, `FileType`, `Broken`, `DoNotUse`, `LastModified`, `LastModifiedBy`. Catches and logs exceptions. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### UARTRecord
|
||
|
|
Database record for UART sensors, implements `IUARTRecord`.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `TagType` | `public override TagTypes TagType => TagTypes.Sensors` | Returns `TagTypes.Sensors`. |
|
||
|
|
| `Id`, `SerialNumber`, `LastModified`, `LastUpdatedBy`, `DoNotUse`, `Broken` | (Same as ThermocouplerRecord) | Standard sensor record properties. |
|
||
|
|
| `UartBaudRate` | `public uint UartBaudRate { get; set; }` | Baud rate. Default from `DTS.Common.Constant.EmbeddedSensors.BAUD_RATE_DEFAULT`. |
|
||
|
|
| `UART_DATABITS_DEFAULT` | `public const uint UART_DATABITS_DEFAULT = 8` | Default data bits. |
|
||
|
|
| `UartDataBits` | `public uint UartDataBits { get; set; }` | Data bits setting. |
|
||
|
|
| `UART_STOPBITS_DEFAULT` | `public const StopBits UART_STOPBITS_DEFAULT = StopBits.None` | Default stop bits. |
|
||
|
|
| `UartStopBits` | `public StopBits UartStopBits { get; set; }` | Stop bits setting. |
|
||
|
|
| `UART_DATAFORMAT_DEFAULT` | `public const UartDataFormat UART_DATAFORMAT_DEFAULT = UartDataFormat.Binary` | Default data format. |
|
||
|
|
| `UART_FLOWCONTROL_DEFAULT` | `public const Handshake UART_FLOWCONTROL_DEFAULT = Handshake.None` | Default flow control. |
|
||
|
|
| `UartFlowControl` | `public Handshake UartFlowControl { get; set; }` | Flow control setting. |
|
||
|
|
| `UartDataFormat` | `public UartDataFormat UartDataFormat { get; set; }` | Data format setting. |
|
||
|
|
| `UART_PARITY_DEFAULT` | `public const Parity UART_PARITY_DEFAULT = Parity.None` | Default parity. |
|
||
|
|
| `UartParity` | `public Parity UartParity { get; set; }` | Parity setting. |
|
||
|
|
| **Constructor** | `public UARTRecord(ISensorData sensor)` | Constructs from `ISensorData`. |
|
||
|
|
| **Constructor** | `public UARTRecord(IDataReader reader)` | Hydrates from reader using columns: `Id`, `SerialNumber`, `BaudRate`, `DataBits`, `StopBits`, `Parity`, `FlowControl`, `DataFormat`, `Broken`, `DoNotUse`, `LastModified`, `LastModifiedBy`. Parses enum values from strings. Catches and logs exceptions. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ParseParameters
|
||
|
|
Internal helper class for passing parameters between CSV import methods.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `ImportContainedSensorRanges` | `public bool ImportContainedSensorRanges { get; set; }` | Flag for sensor ranges in import. Default: `false`. |
|
||
|
|
| `SensorData` | `public ISensorData SensorData { get; set; }` | Sensor data object. |
|
||
|
|
| `ImportCulture` | `public IFormatProvider ImportCulture { get; set; }` | Culture for parsing. |
|
||
|
|
| `Errors` | `public List<string> Errors { get; set; }` | Collection of error messages. |
|
||
|
|
| `IrtraccExponent` | `public double IrtraccExponent { get; set; }` | IR-Tracc exponent value. |
|
||
|
|
| `SensorCal` | `public ISensorCalibration SensorCal { get; set; }` | Sensor calibration object. |
|
||
|
|
| `Sensitivity` | `public double Sensitivity { get; set; }` | Sensitivity value. |
|
||
|
|
| `SavedIsProportional` | `public bool SavedIsProportional { get; set; }` | Saved proportional flag. |
|
||
|
|
| `SavedRemoveOffset` | `public bool SavedRemoveOffset { get; set; }` | Saved remove offset flag. |
|
||
|
|
| `StripBackslash` | `public bool StripBackslash { get; set; }` | Flag to strip backslash characters. |
|
||
|
|
| `OriginalOffset` | `public double OriginalOffset { get; set; }` | Original offset value. Default: `double.NaN`. |
|
||
|
|
| `ZeroType` | `public ZeroMethodType ZeroType { get; set; }` | Zero method type. |
|
||
|
|
| `ZeroEnd` | `public double ZeroEnd { get; set; }` | Zero method end value. |
|
||
|
|
| `ZeroStart` | `public double ZeroStart { get; set; }` | Zero method start value. |
|
||
|
|
| `SquibDefaults` | `public ISquibSettingDefaults SquibDefaults { get; set; }` | Squib setting defaults. |
|
||
|
|
| `DigitalOutDefaults` | `public IDigitalOutDefaults DigitalOutDefaults { get; set; }` | Digital output defaults. |
|
||
|
|
| `SensorGroupNameLookup` | `public Dictionary<string, string> SensorGroupNameLookup { get; set; }` | Lookup dictionary for sensor group names. |
|
||
|
|
| `SensorGroupTypeLookup` | `public Dictionary<string, string> SensorGroupTypeLookup { get; set; }` | Lookup dictionary for sensor group types. |
|
||
|
|
| `GroupNameToTestObjectLookup` | `public Dictionary<string, string> GroupNameToTestObjectLookup { get; set; }` | Lookup dictionary for test objects. |
|
||
|
|
| `SensorTestObject` | `public string SensorTestObject { get; set; }` | Sensor test object name. |
|
||
|
|
| `UseISOCodeFilterMapping` | `public bool UseISOCodeFilterMapping { get; set; }` | Flag for ISO code filter mapping. |
|
||
|
|
| `UseZeroForUnfiltered` | `public bool UseZeroForUnfiltered { get; set; }` | Flag for zero value on unfiltered data. |
|
||
|
|
| `SensorISOCode` | `public Dictionary<string, string> SensorISOCode { get; set; }` | ISO code lookup. |
|
||
|
|
| `SensorISOChannelName` | `public Dictionary<string, string> SensorISOChannelName { get; set; }` | ISO channel name lookup. |
|
||
|
|
| `SensorUserCode` | `public Dictionary<string, string> SensorUserCode { get; set; }` | User code lookup. |
|
||
|
|
| `SensorUserChannelName` | `public Dictionary<string, string> SensorUserChannelName { get; set; }` | User channel name lookup. |
|
||
|
|
| `SensorDASSerialNumber` | `public Dictionary<string, string> SensorDASSerialNumber { get; set; }` | DAS serial number lookup. |
|
||
|
|
| `SensorDASChannelIndex` | `public Dictionary<string, int> SensorDASChannelIndex { get; set; }` | DAS channel index lookup. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### DigitalInputScaleMultiplier
|
||
|
|
Scaler for transforming digital input data, implements `IDigitalInputScaleMultiplier`.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `Form` | `public Forms Form { get; set; }` | Scaler form type. Default: `Forms.ArbitraryLowAndHigh`. |
|
||
|
|
| `DefaultValue` | `public double DefaultValue { get; set; }` | Value for OFF state (0). Default: `0D`. |
|
||
|
|
| `ActiveValue` | `public double ActiveValue { get; set; }` | Value for ON state (1). Default: `1D`. |
|
||
|
|
| `SimpleEquals` | `public bool SimpleEquals(IDigitalInputScaleMultiplier rhs)` | Compares `Form`, `DefaultValue`, and `ActiveValue`. |
|
||
|
|
| `Equals` | `public override bool Equals(object obj)` | Type-checked equality comparison. |
|
||
|
|
| `GetHashCode` | `public override int GetHashCode()` | Custom hash using primes 31, 79, 127, 23 to avoid collisions. |
|
||
|
|
| **Constructor** | `public DigitalInputScaleMultiplier()` | Default constructor, sets `DefaultValue = 0D`. |
|
||
|
|
| **Constructor** | `public DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)` | Copy constructor. |
|
||
|
|
| `ToSerializeDbString` | `public string ToSerializeDbString()` | Serializes to string using invariant culture list separator. Throws `NotSupportedException` for unsupported forms. |
|
||
|
|
| `FromDbSerializeString` | `public void FromDbSerializeString(string s)` | Deserializes from string. Logs warning and returns early if string is null. Throws `NotSupportedException` for invalid formats. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### DigitalOutDbRecord
|
||
|
|
Database record for digital output sensors, implements `IDigitalOutDbRecord`.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| `SerialNumber` | `public string SerialNumber { get; set; }` | Sensor serial number. |
|
||
|
|
| `DODelay` | `public double DODelay { get; set; }` | Digital output delay in milliseconds. Default: `0D`. |
|
||
|
|
| `DODuration` | `public double DODuration { get; set; }` | Digital output duration in milliseconds. Default: `0D`. |
|
||
|
|
| `ModifiedBy` | `public string ModifiedBy { get; set; }` | User who last modified. |
|
||
|
|
| `LastModified` | `public DateTime LastModified { get; set; }` | Last modification timestamp. |
|
||
|
|
| `DatabaseId` | `public int DatabaseId { get; set; }` | Database primary key. Default: `-1`. |
|
||
|
|
| `ISOCode` | `public string ISOCode { get; set; }` | ISO code. |
|
||
|
|
| `ISOChannelName` | `public string ISOChannelName { get; set; }` | ISO channel name. |
|
||
|
|
| `UserCode` | `public string UserCode { get; set; }` | User code. |
|
||
|
|
| `UserChannelName` | `public string UserChannelName { get; set; }` | User channel name. |
|
||
|
|
| `Broken` | `public bool Broken { get; set; }` | Broken flag. Default: `false`. |
|
||
|
|
| `DoNotUse` | `public bool DoNotUse { get; set; }` | Do not use flag. Default: `false`. |
|
||
|
|
| `DOMode` | `public DigitalOutputModes DOMode { get; set; }` | Digital output mode. Default: `DigitalOutputModes.CCNC`. |
|
||
|
|
| `LimitDuration` | `public bool
|