Files

251 lines
15 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.CommonCore/Enums/Sensors/SensorChangeTypes.cs
- Common/DTS.CommonCore/Enums/Sensors/SensorStatus.cs
- Common/DTS.CommonCore/Enums/Sensors/PossibleFilters.cs
- Common/DTS.CommonCore/Enums/Sensors/LinearizationFormula.cs
- Common/DTS.CommonCore/Enums/Sensors/CalibrationEnforcement.cs
- Common/DTS.CommonCore/Enums/Sensors/CalibrationBehaviors.cs
- Common/DTS.CommonCore/Enums/Sensors/InitialOffsetTypes.cs
- Common/DTS.CommonCore/Enums/Sensors/FilterClassType.cs
- Common/DTS.CommonCore/Enums/Sensors/ZeroMethodType.cs
- Common/DTS.CommonCore/Enums/Sensors/CSVImportTags.cs
- Common/DTS.CommonCore/Enums/Sensors/SensorConstants.cs
generated_at: "2026-04-16T02:43:43.565732+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "5790c6a0caacf995"
---
# Sensor Enums and Constants Module Documentation
## 1. Purpose
This module defines a comprehensive set of enumerations and constants used throughout the DTS system to represent sensor metadata, configuration, calibration behavior, and I/O channel types. It serves as the canonical source of truth for sensor-related semantic values—enabling consistent interpretation of sensor data, configuration, and import/export formats across the application. The module supports legacy compatibility (e.g., CSV import versions, zero method ordering), provides unit and range defaults for specific sensor families (e.g., TSR AIR), and includes helper methods for serial number classification and sensitivity unit parsing.
## 2. Public Interface
### Enums
#### `SensorChangeTypes`
- **Members**: `OffsetTolerance`
- **Purpose**: Represents types of changes that can be tracked for sensors. Currently only supports `OffsetTolerance`.
#### `SensorStatus`
- **Members**: `Available`, `InUse`, `OutForService`, `OutForCalibration`, `Retired`
- **Purpose**: Represents the current lifecycle status of a physical sensor.
#### `PossibleFilters`
- **Members**: `All`, `Analog`, `Squib`, `DigitalIn`, `DigitalOut`, `UART`, `StreamOut`, `StreamIn`
- **Purpose**: Specifies filter categories for channel/sensor selection (e.g., in UI or channel grouping).
#### `NonLinearStyles`
- **Members**: `IRTraccManual`, `IRTraccDiagnosticsZero`, `IRTraccZeroMMmV`, `IRTraccAverageOverTime`, `Polynomial`, `IRTraccCalFactor`
- **Purpose**: Defines nonlinear calibration styles for sensors (primarily IR-TRACC).
#### `NonLinearSLICEWareStyles`
- **Members**: `Manual`, `DiagnosticZeroMMmV`, `ZeroMMmV`, `AverageOverTime`, `Polynomial`
- **Purpose**: Defines nonlinear calibration styles specific to SLICEWare devices.
#### `CalibrationEnforcement`
- **Members**: `None`, `NonLinear`, `Linear`
- **Purpose**: Indicates whether calibration enforcement is applied and which type (linear/nonlinear). Uses `EnumDescriptionTypeConverter` and `[Description]` attributes.
#### `CalibrationBehaviors`
- **Members**: `LinearIfAvailable`, `NonLinearIfAvailable`, `UseBothIfAvailable`
- **Purpose**: Specifies preference for calibration style when both linear and nonlinear calibrations are available. Uses `EnumDescriptionTypeConverter` and `[Description]` attributes.
#### `InitialOffsetTypes`
- **Members**: `None = 0`, `EU = 1`, `EUAtMV = 2`, `LHS = 3`, `RHS = 4`, `FRONTAL = 5`
- **Purpose**: Indicates the format and meaning of the initial offset value. Uses `EnumDescriptionTypeConverter` and `[Description]` attributes.
#### `FilterClassType`
- **Members**: `None = 0`, `AdHoc = -1`, `Unfiltered = -2`, `CFC10 = 17`, `CFC60 = 100`, `CFC180 = 300`, `CFC600 = 1000`, `CFC1000 = 1650`
- **Purpose**: Represents SAE filter class definitions (e.g., CFC 100 = 100 Hz cutoff). Uses `EnumDescriptionResource` attributes for localization.
#### `ZeroMethodType`
- **Members**: `AverageOverTime = 0`, `UsePreEventDiagnosticsZero = 1`, `None = 2`
- **Purpose**: Specifies the method used to compute the software zero reference. Legacy ordering is preserved for CSV import compatibility. Uses `EnumDescriptionTypeConverter`.
#### `OriginalZeroMethodType`
- **Members**: `AverageOverTime`, `UsePreCalZero`, `None`
- **Purpose**: Original version of zero method types; likely retained for backward compatibility or migration.
#### `SensorConstants.SensorType`
- **Members**: `Analog`, `DigitalIn`, `DigitalOut`, `Squib`, `Clock`, `UART`, `StreamOut`, `StreamIn`
- **Purpose**: High-level classification of sensor/channel types.
#### `SensorConstants.BridgeType`
- **Members**: `IEPE`, `QuarterBridge`, `HalfBridge`, `FullBridge`, `DigitalInput`, `SQUIB`, `TOMDigital`, `HalfBridge_SigPlus`, `RTC`, `UART`, `StreamOut`, `StreamIn`
- **Purpose**: Bitmask-style enumeration representing bridge configuration and channel type. Includes helper methods `ConvertIntToBridgeType` and `ConvertBridgeToInt`.
#### `SensorConstants.SensUnits`
- **Members**: `NONE`, `mV`, `mVperV`, `mVperVperEU`, `mVperEU`
- **Purpose**: Sensitivity unit types. Includes `SensUnitStringConverter.ConvertFromString` for parsing.
#### `SensorConstants.SensorCalPolicy`
- **Members**: `AllowAlways`, `DONT_ALLOW`
- **Purpose**: Policy for handling out-of-calibration sensors.
#### `SensorConstants.CouplingModes`
- **Members**: `AC = 0`, `DC`
- **Purpose**: IEPE/analog coupling mode.
#### `SensorConstants.AvailableRangesLowG`
- **Members**: `LowG64D`, `LowG32D`, `LowG16D`, `LowG8D`
- **Purpose**: Valid low-g ranges for TSR AIR sensors.
#### `SensorConstants.AvailableRangesARS`
- **Members**: `ARS2000D`, `ARS250D`
- **Purpose**: Valid angular rate sensor (ARS) ranges.
### Constants & Static Properties (in `SensorConstants`)
#### Unit Strings
- `VOLTAGE_INSERTION_UNIT = "mV"`
- `TSRAIR_ACCEL_UNIT = "g"`
- `TSRAIR_ARS_UNIT = "deg/sec"`
- `TSRAIR_TEMPERATURE_UNIT = "C"`
- `TSRAIR_HUMIDITY_UNIT = "%"`
- `TSRAIR_PRESSURE_UNIT = "PSI"`
- `DEGREES = "deg"`
- `DEGREE_ANGLE = "deg-ang"`
- `LinearValuesSeparator = "||"`
#### Bridge Resistance Limits
- `MIN_BRIDGE_RESISTANCE_OHMS = 1`
- `MAX_BRIDGE_RESISTANCE_OHMS = 32000`
#### Calibration Defaults
- `SENSOR_FIRST_USE_DEFAULT = false`
- `UseSensorFirstUseDate = false` *(cached, mutable)*
- `UseISOCodeFilterMapping = true` *(cached, mutable)*
- `DefaultZeroMethodType = ZeroMethodType.AverageOverTime` *(cached, mutable)*
- `DefaultZeroMethodStart = -0.05D`
- `DefaultZeroMethodEnd = -0.02D`
- `CAL_SENSOR_POLICY_DEFAULT = DONT_ALLOW`
- `CAL_SENSOR_POLICY_WARNING_DAYS_DEFAULT = 14`
- `SensorCalOutOfDateWarningPeriodDays = 14` *(mutable)*
- `SensorCalPolicyCurrent = DONT_ALLOW` *(mutable)*
#### TSR AIR Default Ranges
- `DefaultRangeHiG = 400D`
- `DefaultRangeLowG = 64D`
- `DefaultRangeLowGDisplay = 50D`
- `DefaultRangeARS = 2000D`
- `DefaultRangeTemperature = 85D`
- `DefaultRangeHumidity = 100D`
- `DefaultRangePressure = 16D`
#### Squib & Digital Output Defaults (for "Restore Defaults")
- `SQUIB_DELAY_CONSTANT = 0D`
- `SQUIB_LIMIT_DURATION_CONSTANT = true`
- `SQUIB_DURATION_CONSTANT = 10D`
- `SQUIB_LOW_TOLERANCE_CONSTANT = 1D`
- `SQUIB_HIGH_TOLERANCE_CONSTANT = 10D`
- `SQUIB_CURRENT_CONSTANT = 1.5D`
- `DIGITALOUT_DELAY_CONSTANT = 0D`
- `DIGITALOUT_LIMITDURATION_CONSTANT = true`
- `DIGITALOUT_DURATION_CONSTANT = 10D`
#### UART Defaults
- `UART_BAUDRATE_CONSTANT = 57600`
- `UART_DATABITS_CONSTANT = 8`
- `UART_STOPBITS_CONSTANT = StopBits.One`
- `UART_PARITY_CONSTANT = Parity.None`
- `UART_FLOWCONTROL_CONSTANT = Handshake.None`
- `UART_DATAFORMAT_CONSTANT = UartDataFormat.Binary`
#### Stream I/O Defaults
- `STREAMIN_ADDRESS_CONSTANT = "UDP://239.1.2.10:8400"`
- `STREAMOUT_PROFILE_CONSTANT = UDPStreamProfile.CH10_PCM_128BIT_2HDR`
- `STREAMOUT_ADDRESS_CONSTANT = "UDP://239.1.2.10:8400"`
- `STREAMOUT_TIME_CHID_CONSTANT = 1`
- `STREAMOUT_DATA_CHID_CONSTANT = 3`
- `STREAMOUT_TMNS_CONFIG_CONSTANT = "(1,6,60,0,0,0,0,0)"`
- `STREAMOUT_IRIG_TDP_INTERVAL_CONSTANT = 500`
#### Test-Specific Serial Number Prefixes
- `TEST_SPECIFIC_DOUT = "TSD_"`
- `TEST_SPECIFIC_SQUIB = "TSQ_"`
- `TEST_SPECIFIC_DIN = "TSI_"`
- `TEST_SPECIFIC_EMB = "TSA_"`
- `TEST_SPECIFIC_EMB_CLK = "TSC_"`
- `TEST_SPECIFIC_UART = "TSU_"`
- `TEST_SPECIFIC_STREAM_OUT = "TSS_"`
- `TEST_SPECIFIC_STREAM_IN = "TSN_"`
#### Helper Methods
- `IsTestSpecificDigitalOut(string sn)`
- `IsTestSpecificSquib(string sn)`
- `IsTestSpecificDigitalIn(string sn)`
- `IsTestSpecificEmbedded(string sn)`
- `IsTestSpecificEmbeddedClock(string sn)`
- `IsTestSpecificStreamOut(string sn)`
- `IsTestSpecificStreamIn(string sn)`
- `IsTestSpecificUart(string sn)`
- `IsTSRAirHighGChannel(string moduleSerialNumber)`
- `IsTSRAirLowGChannel(string moduleSerialNumber)`
- `IsTSRAirARSChannel(string moduleSerialNumber)`
- `IsTSRAirAtmChannel(string moduleSerialNumber)`
- `IsTSRAirHumidityChannel(string moduleSerialNumber, int channelNumber)`
### `CSVImportTags` (abstract class)
#### Constants
- `MIN_VALID_VERSION = 0`
- `MAX_VALID_VERSION = 6`
- `IsSensorTag(int version)``bool` (returns `true` for versions `{0, 2, 3, 4}`)
#### Static Methods
- `GetVersionTags(int version)``Tags[]`
- `GetStringForTag(Tags tag)``string`
- `GetTagForString(string s)``Tags` (returns `Tags.Unknown` if not found)
- `GetVersionForTag(Tags t)``int` (returns `int.MaxValue` if not found)
#### `CSVImportTags.Tags` Enum (partial list)
- **Version 0**: `DatabaseReferenceNumber`, `SensorSN`, `ChannelName`, `Location`, `SensorType`, `EU`, `FullScale`, `Exc`, `OutputAtEXCFSmV`, `Sensitivity`, `FilterClass`, `SoftwareZeroReference`, `SoftwareZeroEquivalentEU`, `OffsetToleranceLow`, `OffsetToleranceHigh`, `BridgeResistance`, `ShuntResistorValue`, `CalInterval`, `ZeroMethod`, `ZeroMethodStart`, `ZeroMethodEnd`, `InitialOffset`, `NonLinear`, `NonLinearCalibration`, `DisplayUnits`, `UserCode`, `UserChannelName`, `ISOChannelName`, `UserChannelName`, `AdditionalLinearSensitivity`, `AdditionalLinearZeroMethod`, `AdditionalInitialOffsets`, `GroupName`, `GroupType`, `DASSerialNumber`, `DASChannelIndex`, `StreamProfile`, `UDPAddress`, `TimeChannelId`, `DataChannelId`, `TmNSConfig`, `IRIGTimeDataPacketIntervalMS`, `TMATSIntervalMS`, `BaudRate`, `DataBits`, `StopBits`, `Parity`, `DataFormat`, `TestUserCode`, `TestUserChannelName`, `TestIsoCode`, `TestIsoChannelName`, `ClockMasterInputType`, `ClockMasterOutputType`, `ManageClocksOutsideDPMaster`, `ManageClocksOutsideDPSlave`, `ClockSlaveInputType`, `ClockSlaveOutputType`, `DASSerial`, `DASSampleRate`, `PTPDomainId`, `ClockMaster`, `Version`, `TestSetupName`, `TestSetupDescription`, `RecordingMode`, `SampleRate`, `PreTriggerSec`, `PostTriggerSec`, `Tags`, `TwoVoltExcSensitivity`, `FiveVoltExcSensitivity`, `TenVoltExcSensitivity`, `RangeLow`, `RangeMedium`, `RangeHigh`, `SupportedExcitation`, `BridgeType`, `Unipolar`, `AxisNumber`, `NumberOfAxes`, `Polarity`, `PhysicalDimension`, `Direction`, `CheckOffset`, `Broken`, `DoNotUse`, `AtCapacity`, `CapacityOutputIsBasedOn`, `SensitivityUnits`, `CouplingMode`, `DelayMS`, `DigitalOutputDelayMS`, `DurationMS`, `DigitalOutputDurationMS`, `DigitalOutputMode`, `LimitDuration`, `SquibFireMode`, `SquibMeasurementType`, `SquibOutputCurrent`, `DigitalScaleMultiplier`, `DigitalInputMode`, `ZeroMethod`, `ZeroMethodStart`, `ZeroMethodEnd`, `BridgeLegMode`, `Created`, `TimesUsed`, `IRTRACCExponent`, `Unknown`
- **Version 1**: Adds `Version`, `TestSetupName`, `TestSetupDescription`, `RecordingMode`, `SampleRate`, `PreTriggerSec`, `PostTriggerSec`, `Tags`
- **Version 2**: Adds many fields (e.g., `TwoVoltExcSensitivity`, `ZeroMethod`, `InitialOffset`, `NonLinear`, `DigitalOutputMode`, `SquibFireMode`, `CouplingMode`, `DelayMS`, `DigitalOutputDelayMS`, `DurationMS`, `DigitalOutputDurationMS`, `DigitalOutputMode`, `LimitDuration`, `SquibFireMode`, `SquibMeasurementType`, `SquibOutputCurrent`, `DigitalScaleMultiplier`, `DigitalInputMode`, `NonLinearCalibration`, `DisplayUnits`, `AtCapacity`, `CapacityOutputIsBasedOn`, `SensitivityUnits`, `CheckOffset`, `Broken`, `DoNotUse`, `ISOChannelName`, `UserCode`, `UserChannelName`, `AdditionalLinearSensitivity`, `AdditionalLinearZeroMethod`, `AdditionalInitialOffsets`, `GroupName`, `GroupType`, `DASSerialNumber`, `DASChannelIndex`, `StreamProfile`, `UDPAddress`, `TimeChannelId`, `DataChannelId`, `TmNSConfig`, `IRIGTimeDataPacketIntervalMS`, `TMATSIntervalMS`, `BaudRate`, `DataBits`, `StopBits`, `Parity`, `DataFormat`, `TestUserCode`, `TestUserChannelName`, `TestIsoCode`, `TestIsoChannelName`, `ClockMasterInputType`, `ClockMasterOutputType`, `ManageClocksOutsideDPMaster`, `ManageClocksOutsideDPSlave`, `ClockSlaveInputType`, `ClockSlaveOutputType`, `DASSerial`, `DASSampleRate`, `PTPDomainId`, `ClockMaster`)
- **Version 3**: Adds `GroupName`, `GroupType`
- **Version 4**: Adds `DASSerialNumber`, `DASChannelIndex`, `StreamProfile`, `UDPAddress`, `TimeChannelId`, `DataChannelId`, `TmNSConfig`, `IRIGTimeDataPacketIntervalMS`, `TMATSIntervalMS`, `BaudRate`, `DataBits`, `StopBits`, `Parity`, `DataFormat`, `TestUserCode`, `TestUserChannelName`, `TestIsoCode`, `TestIsoChannelName`
- **Version 5**: Adds `ClockMasterInputType`, `ClockMasterOutputType`, `ManageClocksOutsideDPMaster`, `ManageClocksOutsideDPSlave`, `ClockSlaveInputType`, `ClockSlaveOutputType`
- **Version 6**: Adds `DASSerial`, `DASSampleRate`, `PTPDomainId`, `ClockMaster`
> Note: `Tags.Unknown` is returned for unrecognized strings in `GetTagForString`.
## 3. Invariants
- **CSV Import Versions**: Valid import versions are `0`, `2`, `3`, `4` (per `_SensorTagsVersions`). Versions `1`, `5`, and `6` are *not* included in `IsSensorTag`, but are still valid for general import (as `GetVersionTags` supports them).
- **Zero Method Ordering**: `ZeroMethodType` enum values are ordered to preserve legacy compatibility (e.g., `AverageOverTime = 0`, `UsePreEventDiagnosticsZero = 1`, `None = 2`). Changing order may break CSV import/export.
- **Bridge Type Conversion**: `ConvertBridgeToInt` and `ConvertIntToBridgeType` use non-bitmask integer mappings (e.g., `FullBridge → 3`, `QuarterBridge → 1`). Do not assume bitmask semantics for storage.
- **Sensitivity Unit Parsing**: `SensUnitStringConverter.ConvertFromString` is case-insensitive and accepts multiple aliases (e.g., `"mvperv"``mVperV`). Throws `InvalidCastException` for unrecognized strings.
- **TSR AIR Channel Detection**: Channel type detection is based on serial number suffixes (`"-High g"`, `"-Low g"`, `"-ARS"`, `"-Atm"`). Case-sensitive.
- **Test-Specific Serial Number Prefixes**: Prefixes are exact string matches (e.g., `"TSQ_"`). No wildcard or partial matching.
- **Calibration Policy Defaults**: `CAL_SENSOR_POLICY_DEFAULT = DONT_ALLOW`, `CAL_SENSOR_POLICY_WARNING_DAYS_DEFAULT = 14`. Mutable statics (`SensorCalPolicyCurrent`, `SensorCalOutOfDateWarningPeriodDays`) may be updated at runtime.
## 4. Dependencies
### Internal Dependencies
- `DTS.Common.Converters.EnumDescriptionTypeConverter`
- `DTS.Common.Attributes.VersionAttribute`, `System.ComponentModel.DataAnnotations.DisplayAttribute`
- `System.IO.Ports` (for `StopBits`, `Parity`, `Handshake`)
- `System.IO` (for `InvalidCastException` in `SensUnitStringConverter`)
### External Dependencies
- `System` (core types: `string`, `int`, `double`, `bool`, `Enum`, `Dictionary`, `HashSet`, `Exception`)
- `System.ComponentModel.DataAnnotations` (for `DisplayAttribute`)
- `System.IO.Ports` (for `StopBits`, `Parity`, `Handshake`)
### Usage
- This module is referenced by modules handling sensor configuration, CSV import/export, channel filtering, diagnostics, and calibration enforcement.
## 5. Gotchas
- **`ZeroMethodType` vs `OriginalZeroMethodType`**: