341 lines
18 KiB
Markdown
341 lines
18 KiB
Markdown
---
|
|
source_files:
|
|
- DataPRO/SensorDB/StreamInputSettingDefaults.cs
|
|
- DataPRO/SensorDB/FactorySensorModel.cs
|
|
- DataPRO/SensorDB/ThermocouplerSetting.cs
|
|
- DataPRO/SensorDB/DigitalOutputDefaults.cs
|
|
- DataPRO/SensorDB/CANSetting.cs
|
|
- DataPRO/SensorDB/StreamInputSetting.cs
|
|
- DataPRO/SensorDB/StreamOutputSetting.cs
|
|
- DataPRO/SensorDB/CanSettingDefaults.cs
|
|
- DataPRO/SensorDB/StringResources.Designer.cs
|
|
- DataPRO/SensorDB/SensorRange.cs
|
|
- DataPRO/SensorDB/UartSetting.cs
|
|
- DataPRO/SensorDB/DigitalInputSensorDefault.cs
|
|
- DataPRO/SensorDB/SquibSettingDefaults.cs
|
|
- DataPRO/SensorDB/SquibSetting.cs
|
|
- DataPRO/SensorDB/UartSettingDefaults.cs
|
|
- DataPRO/SensorDB/DigitalOutputSetting.cs
|
|
- DataPRO/SensorDB/SensorDBBase.cs
|
|
generated_at: "2026-04-17T15:44:30.164459+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "5fdd463375d7a71e"
|
|
---
|
|
|
|
# DTS.SensorDB Module Documentation
|
|
|
|
## 1. Purpose
|
|
|
|
This module provides data models, factory methods, and default settings management for various sensor types in the DTS system. It encompasses configuration classes for CAN, UART, Stream I/O, Thermocoupler, Squib, and Digital I/O sensors, along with mechanisms for persisting settings to database storage and user preferences. The module serves as the bridge between sensor hardware configuration and the application's data layer, handling serialization, validation, and default value management.
|
|
|
|
---
|
|
|
|
## 2. Public Interface
|
|
|
|
### StreamInputSettingDefaults
|
|
**Implements:** `DTS.Common.Base.BasePropertyChanged`, `IStreamInputSettingDefaults`
|
|
|
|
Manages default UDP stream input settings.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `UDPAddress` | `string` property (get/set) | Proxies to `_defaultStreamInput.StreamInUDPAddress` |
|
|
| `Validate` | `bool Validate()` | Returns `true` if UDPAddress starts with "udp" and is a well-formed absolute URI |
|
|
| `CommitChange` | `static void CommitChange(StreamInputSettingDefaults settingDefaults, int userID)` | Persists UDP address via `TestSetupDefaults.SetUserSetting` |
|
|
| `GetStreamInputSettingsDefault` | `static StreamInputSettingDefaults GetStreamInputSettingsDefault(int userID)` | Loads defaults from user settings |
|
|
| `GetStreamInputSettingsDefault` | `static StreamInputSettingDefaults GetStreamInputSettingsDefault(string user)` | Loads defaults from sensor collection using `SensorConstants.TEST_SPECIFIC_STREAM_IN_SERIAL` |
|
|
|
|
---
|
|
|
|
### FactorySensorModel
|
|
**Static factory class**
|
|
|
|
Creates `SensorModel` instances from sensor data.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `CreateModelFromSensor` | `static SensorModel CreateModelFromSensor(SensorData sd, SensorCalibration sc, User currentUser)` | Creates a new `SensorModel` populated from `SensorData` and `SensorCalibration`; sets `LastModified` to `DateTime.Now` and `LastUpdatedBy` to `currentUser.UserName` |
|
|
|
|
---
|
|
|
|
### ThermocouplerSetting
|
|
**Inherits:** `SensorData`
|
|
|
|
Represents thermocoupler sensor configuration.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| Constructor | `ThermocouplerSetting()` | Default constructor; calls `SetDefaults(this)` |
|
|
| Constructor | `ThermocouplerSetting(ThermocouplerSetting copy)` | Copy constructor |
|
|
| Constructor | `ThermocouplerSetting(IThermocouplerRecord record)` | Constructs from database record; catches and logs exceptions |
|
|
| `SetDefaults` | `static void SetDefaults(SensorData sd)` | Sets `Bridge` to `SensorConstants.BridgeType.Thermocoupler`, `NumberOfAxes` to 1, `BridgeResistance` to `double.NaN`, `Model` to "Thermocoupler Setting", etc. |
|
|
|
|
---
|
|
|
|
### DigitalOutputDefaults
|
|
**Implements:** `DTS.Common.Base.BasePropertyChanged`, `IDigitalOutDefaults`
|
|
**Sealed**
|
|
|
|
Manages default digital output (squib) settings.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `OutputMode` | `DigitalOutputModes` property (get/set) | Proxies to `_defaultOut.DigitalOutputMode` |
|
|
| `AvailableModes` | `DigitalOutputModes[]` property (get) | Returns static array: `CCNC`, `CCNO`, `FVHL`, `FVLH` |
|
|
| `DelayMS` | `double` property (get/set) | Proxies to `_defaultOut.DigitalOutputDelayMS` |
|
|
| `LimitDuration` | `bool` property (get/set) | Proxies with `OnPropertyChanged` notification |
|
|
| `DurationMS` | `double` property (get/set) | Proxies to `_defaultOut.DigitalOutputDurationMS` |
|
|
| `CommitChange` | `static void CommitChange(DigitalOutputDefaults settingDefaults, string user)` | Commits via `SensorsCollection.SensorsList.Commit` |
|
|
| `GetDigitalOutDefault` | `static DigitalOutputDefaults GetDigitalOutDefault(string user)` | Retrieves via `SensorConstants.TEST_SPECIFIC_DIGITAL_OUT_SERIAL` |
|
|
|
|
---
|
|
|
|
### CanSetting
|
|
**Inherits:** `SensorData`
|
|
|
|
Represents CAN bus sensor configuration.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| Constructor | `CanSetting()` | Default constructor |
|
|
| Constructor | `CanSetting(CanSetting copy)` | Copy constructor |
|
|
| Constructor | `CanSetting(ICANRecord record)` | Constructs from `ICANRecord` |
|
|
| `SetDefaults` | `static void SetDefaults(SensorData sd)` | Sets `Bridge` to `SensorConstants.BridgeType.CAN`, `Model` to "CAN Setting" |
|
|
| `Commit` | `static void Commit(SensorData setting)` | Persists via `DbOperations.SensorsCanUpdateInsert`; updates `DatabaseId` on success (hr == 0) |
|
|
|
|
---
|
|
|
|
### StreamInputSetting
|
|
**Inherits:** `SensorData`
|
|
|
|
Represents stream input configuration.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| Constructor | `StreamInputSetting()` | Default constructor |
|
|
| Constructor | `StreamInputSetting(StreamInputSetting copy)` | Copy constructor |
|
|
| Constructor | `StreamInputSetting(IStreamInputRecord record)` | Constructs from `IStreamInputRecord`; catches and logs exceptions |
|
|
| `SetDefaults` | `static void SetDefaults(SensorData sd)` | Sets `Bridge` to `SensorConstants.BridgeType.StreamIn`, `Model` to "Stream Input Setting" |
|
|
| `Commit` | `static void Commit(SensorData setting)` | Persists via `DbOperations.SensorsStreamInputUpdateInsert` |
|
|
|
|
---
|
|
|
|
### StreamOutputSetting
|
|
**Inherits:** `SensorData`
|
|
|
|
Represents stream output configuration with UDP and IRIG time settings.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| Constructor | `StreamOutputSetting()` | Default constructor |
|
|
| Constructor | `StreamOutputSetting(StreamOutputSetting copy)` | Copy constructor |
|
|
| Constructor | `StreamOutputSetting(IStreamOutputRecord record)` | Constructs from `IStreamOutputRecord`; populates UDP profile, address, channel IDs, TMNS config, IRIG intervals |
|
|
| `SetDefaults` | `static void SetDefaults(SensorData sd)` | Sets `Bridge` to `SensorConstants.BridgeType.StreamOut`, `Model` to "Stream Output Setting" |
|
|
| `Commit` | `static void Commit(SensorData setting)` | Persists via `DbOperations.SensorsStreamOutputUpdateInsert` |
|
|
|
|
---
|
|
|
|
### CanSettingDefaults
|
|
**Implements:** `DTS.Common.Base.BasePropertyChanged`, `ICanSettingDefaults`
|
|
**Sealed**
|
|
|
|
Manages default CAN bus settings.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `IsFD` | `bool` property (get/set) | CAN FD mode flag |
|
|
| `ArbBaseBitrate` | `int` property (get/set) | Arbitration base bitrate |
|
|
| `ArbBaseSJW` | `int` property (get/set) | Arbitration base SJW |
|
|
| `DataBitrate` | `int` property (get/set) | Data bitrate |
|
|
| `DataSJW` | `int` property (get/set) | Data SJW |
|
|
| `FileType` | `string` property (get/set) | CAN file type |
|
|
| `Validate` | `bool Validate()` | Always returns `true` |
|
|
| `CommitChange` | `static void CommitChange(CanSettingDefaults settingDefaults, int userID)` | Persists all properties via `TestSetupDefaults.SetUserSetting` |
|
|
| `GetCanSettingsDefault` | `static CanSettingDefaults GetCanSettingsDefault(int userID)` | Loads from user settings |
|
|
| `RestoreDefaults` | `static void RestoreDefaults(ICanSettingDefaults sensorDefaults)` | Restores from `EmbeddedSensors` constants |
|
|
|
|
---
|
|
|
|
### SensorRange
|
|
**Implements:** `INotifyPropertyChanged`
|
|
|
|
Represents a three-tier sensor range (Low, Medium, High).
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `Low`, `Medium`, `High` | `double` properties | Range values |
|
|
| Constructor | `SensorRange(string value)` | Parses comma-separated string; throws `InvalidDataException` if not exactly 3 values |
|
|
| Constructor | `SensorRange(double low, double medium, double high)` | Direct value constructor |
|
|
| Constructor | `internal SensorRange(XElement elem, string prefix, string tblName, string id)` | XML deserialization |
|
|
| `ToSerializeString` | `string ToSerializeString()` | Returns invariant-culture comma-separated string |
|
|
| `ToXElement` | `internal XElement ToXElement(string prefix)` | XML serialization |
|
|
| `Update` | `internal void Update(XElement elem, string prefix)` | Updates existing XML element |
|
|
|
|
---
|
|
|
|
### UartSetting
|
|
**Inherits:** `SensorData`
|
|
|
|
Represents UART sensor configuration.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| Constructor | `UartSetting()` | Default constructor |
|
|
| Constructor | `UartSetting(UartSetting copy)` | Copy constructor |
|
|
| Constructor | `UartSetting(IUARTRecord record)` | Constructs from `IUARTRecord` |
|
|
| `SetDefaults` | `static void SetDefaults(SensorData sd)` | Sets `Bridge` to `SensorConstants.BridgeType.UART`, `Model` to "UART Setting" |
|
|
| `Commit` | `static void Commit(SensorData setting)` | Persists via `DbOperations.SensorsUARTUpdateInsert` |
|
|
|
|
---
|
|
|
|
### DigitalInputSensorDefault
|
|
**Implements:** `DTS.Common.Base.BasePropertyChanged`, `IDigitalInputDefaults`
|
|
|
|
Manages default digital input settings.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `ConstantCurrentBreakpointADC` | `double` property | Breakpoint for CCNO/CCNC modes |
|
|
| `VoltageBreakpointADC` | `double` property | Breakpoint for THL/TLH modes |
|
|
| `DisplaySPDADC` | `bool` property | Whether to display analog SLICE PRO DIGITAL ADC data |
|
|
| `Validate` | `bool Validate()` | Always returns `true` |
|
|
| `GetDigitalInputDefaults` | `static IDigitalInputDefaults GetDigitalInputDefaults(string user)` | Loads from `SettingsDB` with fallback to `DigitalInputs` constants |
|
|
| `Save` | `static void Save(IDigitalInputDefaults defaults)` | Persists to `SettingsDB` and updates `DigitalInputs` constants |
|
|
| `RestoreDefaults` | `static void RestoreDefaults(IDigitalInputDefaults sensorDefaults)` | Restores from `DigitalInputs` default constants |
|
|
|
|
---
|
|
|
|
### SquibSettingDefaults
|
|
**Implements:** `DTS.Common.Base.BasePropertyChanged`, `ISquibSettingDefaults`
|
|
**Sealed**
|
|
|
|
Manages default squib (explosive initiator) settings.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `ToleranceLowDefault` | `double` property | Low tolerance; notifies `ToleranceValid` on change |
|
|
| `ToleranceHighDefault` | `double` property | High tolerance; notifies `ToleranceValid` on change |
|
|
| `OutputCurrentDefault` | `double` property | Output current |
|
|
| `MeasurementTypeDefault` | `SquibMeasurementType` property | Measurement type |
|
|
| `FireModeDefault` | `SquibFireMode` property | Fire mode; notifies `IsConstantCurrent` on change |
|
|
| `AvailableModes` | `SquibFireMode[]` property | Returns `CAP`, `CONSTANT` |
|
|
| `IsConstantCurrent` | `bool` property | `true` if `FireModeDefault == SquibFireMode.CONSTANT` |
|
|
| `LimitDurationDefault` | `bool` property | Duration limit flag |
|
|
| `FireDurationMS` | `double` property | Fire duration in milliseconds |
|
|
| `FireDelayMS` | `double` property | Fire delay in milliseconds |
|
|
| `ToleranceValid` | `bool` property | `true` if `ToleranceLowDefault < ToleranceHighDefault` |
|
|
| `Validate` | `bool Validate()` | Returns `ToleranceValid` |
|
|
| `CommitChange` | `static void CommitChange(SquibSettingDefaults settingDefaults, string user)` | Commits via `SensorsCollection.SensorsList.Commit` |
|
|
| `GetSquibSettingsDefault` | `static SquibSettingDefaults GetSquibSettingsDefault(string user)` | Retrieves via `SensorConstants.TEST_SPECIFIC_SQUIB_SERIAL` |
|
|
|
|
---
|
|
|
|
### SquibSetting
|
|
**Inherits:** `SensorData`
|
|
|
|
Represents squib sensor configuration.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `SquibDescription` | `string` property (get/set) | Proxies to `SerialNumber` with property change notification |
|
|
| `BypassCurrentFilter` | `bool` property (get/set) | Uses `SetProperty` with backing field `_bypassCurrentFilter` |
|
|
| `BypassVoltageFilter` | `bool` property (get/set) | Uses `SetProperty` with backing field `_bypassVoltageFilter` |
|
|
| `ArticleId` | `string` property (get/set) | Proxies to `EID` |
|
|
| Constructor | `SquibSetting()` | Default constructor |
|
|
| Constructor | `SquibSetting(SquibSetting copy)` | Copy constructor |
|
|
| Constructor | `SquibSetting(ISquibDbRecord record)` | Constructs from database record |
|
|
| `SetDefaults` | `static void SetDefaults(SensorData sd)` | Sets `Bridge` to `SensorConstants.BridgeType.SQUIB`, `Capacity` to 5, `DisplayUnit` to "V" |
|
|
| `Commit` | `static void Commit(SensorData setting)` | Persists via `DbOperations.SensorsSquibUpdateInsert` |
|
|
|
|
---
|
|
|
|
### UartSettingDefaults
|
|
**Implements:** `DTS.Common.Base.BasePropertyChanged`, `IUartSettingDefaults`
|
|
**Sealed**
|
|
|
|
Manages default UART settings.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `BaudRate` | `uint` property | Baud rate |
|
|
| `DataBits` | `uint` property | Data bits |
|
|
| `StopBits` | `StopBits` property | Stop bits |
|
|
| `AvailableStopBits` | `StopBits[]` property | `None`, `One`, `OnePointFive`, `Two` |
|
|
| `Parity` | `Parity` property | Parity setting |
|
|
| `AvailableParities` | `Parity[]` property | `None`, `Odd`, `Even`, `Mark`, `Space` |
|
|
| `FlowControl` | `Handshake` property | **Hardcoded to `Handshake.None`** |
|
|
| `AvailableFlowControls` | `Handshake[]` property | Only contains `Handshake.None` |
|
|
| `DataFormat` | `UartDataFormat` property | Data format |
|
|
| `AvailableDataFormats` | `UartDataFormat[]` property | `Binary`, `PlainText`, `NMEA` |
|
|
| `Validate` | `bool Validate()` | Always returns `true` |
|
|
| `CommitChange` | `static void CommitChange(UartSettingDefaults settingDefaults, int userID)` | Persists via `TestSetupDefaults.SetUserSetting` |
|
|
| `GetUartSettingsDefault` | `static UartSettingDefaults GetUartSettingsDefault(int userID)` | Loads from user settings |
|
|
| `RestoreDefaults` | `static void RestoreDefaults(IUartSettingDefaults sensorDefaults)` | Restores from `EmbeddedSensors` and `UARTRecord` constants |
|
|
|
|
---
|
|
|
|
### DigitalOutputSetting
|
|
**Inherits:** `SensorData`
|
|
|
|
Represents digital output configuration.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `ChannelDescription` | `string` property (get/set) | Proxies to `SerialNumber` with notification |
|
|
| Constructor | `DigitalOutputSetting()` | Default constructor |
|
|
| Constructor | `DigitalOutputSetting(DigitalOutputSetting copy)` | Copy constructor |
|
|
| Constructor | `DigitalOutputSetting(IDigitalOutDbRecord copy)` | Constructs from database record |
|
|
| Constructor | `DigitalOutputSetting(IDataRecord reader)` | Constructs from `IDataRecord` |
|
|
| `Commit` | `static void Commit(SensorData setting)` | Persists via `DbOperations.SensorsDigitalOutUpdateInsert` |
|
|
|
|
---
|
|
|
|
### SensorDBBase
|
|
**Abstract base class**
|
|
|
|
Provides XML parsing utilities for sensor database operations.
|
|
|
|
| Member | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `GetTagValueSafe` | `static XElement GetTagValueSafe(XElement elem, string tag, string id, String TableName)` | Returns element or null; suppresses exceptions |
|
|
| `GetTagValue` | `static XElement GetTagValue(XElement elem, string tag, string id, String TableName)` | Returns element or throws with context |
|
|
| `GetValue` | Multiple overloads for `string`, `int`, `SensorStatus`, `double`, `bool`, `SensorConstants.BridgeType`, `ShuntMode`, `BridgeLeg`, `ExcitationVoltageOption`, `DateTime`, `FilterClassType`, `ZeroMethodType` | Parses XML element values with error handling |
|
|
|
|
---
|
|
|
|
## 3. Invariants
|
|
|
|
1. **UDP Address Validation**: `StreamInputSettingDefaults.Validate()` requires `UDPAddress` to start with "udp" (case-insensitive) AND be a well-formed absolute URI string.
|
|
|
|
2. **Squib Tolerance Ordering**: `SquibSettingDefaults.ToleranceValid` requires `ToleranceLowDefault < ToleranceHighDefault`. `Validate()` returns this value.
|
|
|
|
3. **SensorRange Parsing**: When constructing from string, exactly 3 comma-separated values are required; otherwise `InvalidDataException` is thrown.
|
|
|
|
4. **Database ID Assignment**: All `Commit` methods update `setting.DatabaseId` from the record ID only when the database operation returns `hr == 0`.
|
|
|
|
5. **SetDefaults Pattern**: All sensor type classes (`CanSetting`, `StreamInputSetting`, `StreamOutputSetting`, `UartSetting`, `ThermocouplerSetting`, `SquibSetting`, `DigitalOutputSetting`) call `SetDefaults(this)` in every constructor and in their `Commit` method.
|
|
|
|
6. **Bridge Type Assignment**: Each sensor type has a fixed `Bridge` value set in `SetDefaults` (e.g., `SensorConstants.BridgeType.CAN`, `SensorConstants.BridgeType.UART`).
|
|
|
|
---
|
|
|
|
## 4. Dependencies
|
|
|
|
### This module depends on:
|
|
- `DTS.Common.Enums` - `PropertyEnums`, `ShuntMode`, `BridgeLeg`, `FilterClassType`, `ZeroMethodType`
|
|
- `DTS.Common.Enums.Sensors` - `ExcitationVoltageOptions`, `DigitalOutputModes`, `SquibFireMode`, `SquibMeasurementType`, `UartDataFormat`, `SensorConstants`
|
|
- `DTS.Common.Interface.Sensors` - `ISensorData`, `ICANRecord`, `IStreamInputRecord`, `IStreamOutputRecord`, `IUARTRecord`, `IThermocouplerRecord`, `ISquibDbRecord`, `IDigitalOutDbRecord`, `IStreamInputSettingDefaults`, `IDigitalOutDefaults`, `ICanSettingDefaults`, `ISquibSettingDefaults`, `IUartSettingDefaults`, `IDigitalInputDefaults`
|
|
- `DTS.Common.Classes.Sensors` - `SensorData`, `SensorCalibration`
|
|
- `DTS.Common.Storage` - `DbOperations`, record types (`CANRecord`, `StreamInputRecord`, `StreamOutputRecord`, `UARTRecord`, `SquibDbRecord`, `DigitalOutDbRecord`)
|
|
- `DTS.Common.Utilities.Logging` - `APILogger`
|
|
- `DTS.Common.Base` - `BasePropertyChanged`
|
|
- `DTS.Common.Settings` - `SettingsDB`
|
|
- `DTS.Common.Constant` - `DigitalInputs`, `EmbeddedSensors` constants
|
|
- `DTS.Slice.Users` - `User`
|
|
- `DTS.Slice.Users.UserSettings` - `TestSetupDefaults`
|
|
- `System.IO.Ports` - `StopBits`, `Parity`, `Handshake`
|
|
- `System.Xml.Linq` - XML serialization support
|
|
|
|
### What depends on this module (inferred):
|
|
- `DTS.SensorDB.SensorsCollection.SensorsList` - Refer |