Files
DP44/docs/ai/Common/DTS.Common/Enums/Sensors.md

307 lines
13 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common/Enums/Sensors/SensorChangeTypes.cs
- Common/DTS.Common/Enums/Sensors/SensorStatus.cs
- Common/DTS.Common/Enums/Sensors/PossibleFilters.cs
- Common/DTS.Common/Enums/Sensors/LinearizationFormula.cs
- Common/DTS.Common/Enums/Sensors/CalibrationEnforcement.cs
- Common/DTS.Common/Enums/Sensors/SensitivityInspection.cs
- Common/DTS.Common/Enums/Sensors/CalibrationBehaviors.cs
- Common/DTS.Common/Enums/Sensors/InitialOffsetTypes.cs
- Common/DTS.Common/Enums/Sensors/FilterClassType.cs
- Common/DTS.Common/Enums/Sensors/ZeroMethodType.cs
- Common/DTS.Common/Enums/Sensors/CSVImportTags.cs
- Common/DTS.Common/Enums/Sensors/SensorConstants.cs
generated_at: "2026-04-17T15:31:44.880303+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "ef8fc2aacbeebadc"
---
# DTS.Common.Enums.Sensors Module Documentation
## 1. Purpose
This module provides the core enumerations, constants, and utility methods for sensor management within the DTS data acquisition system. It defines sensor lifecycle states, calibration behaviors, filter configurations, zero methods, CSV import/export field mappings, and various sensor-related constants. The module serves as a foundational layer for sensor configuration, validation, and data interchange across the application.
---
## 2. Public Interface
### Enumerations
#### `SensorChangeTypes`
```csharp
public enum SensorChangeTypes { OffsetTolerance }
```
Defines types of sensor changes. Currently only `OffsetTolerance` is defined.
#### `SensorStatus`
```csharp
public enum SensorStatus { Available, InUse, OutForService, OutForCalibration, Retired }
```
Defines the lifecycle states of a sensor.
#### `PossibleFilters`
```csharp
public enum PossibleFilters { All, Analog, Squib, DigitalIn, DigitalOut, UART, StreamOut, StreamIn, CAN }
```
Describes different ways of filtering channels and sensors by type.
#### `NonLinearStyles`
```csharp
public enum NonLinearStyles { IRTraccManual, IRTraccDiagnosticsZero, IRTraccZeroMMmV, IRTraccAverageOverTime, Polynomial, IRTraccCalFactor }
```
Defines linearization formula styles for non-linear sensor processing.
#### `NonLinearSLICEWareStyles`
```csharp
public enum NonLinearSLICEWareStyles { Manual, DiagnosticZeroMMmV, ZeroMMmV, AverageOverTime, Polynomial }
```
SLICEWare-specific linearization styles.
#### `CalibrationEnforcement`
```csharp
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum CalibrationEnforcement { None, NonLinear, Linear }
```
Defines calibration enforcement modes. Uses `EnumDescriptionTypeConverter` for display string conversion.
#### `SensitivityInspectionType`
```csharp
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum SensitivityInspectionType { NotSet = 0, Required = 1, Cleared = 2 }
```
Defines sensitivity inspection states with explicit integer values.
#### `CalibrationBehaviors`
```csharp
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum CalibrationBehaviors { LinearIfAvailable, NonLinearIfAvailable, UseBothIfAvailable }
```
Defines how calibration data should be selected when available.
#### `InitialOffsetTypes`
```csharp
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum InitialOffsetTypes { None = 0, EU = 1, EUAtMV = 2, LHS = 3, RHS = 4, FRONTAL = 5 }
```
Defines the format of initial offset values with explicit integer values.
#### `FilterClassType`
```csharp
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum FilterClassType { None = 0, AdHoc = -1, Unfiltered = -2, CFC10 = 17, CFC60 = 100, CFC180 = 300, CFC600 = 1000, CFC1000 = 1650 }
```
Defines SAE filter class types. Values represent cutoff frequencies in Hz. Uses `DescriptionResourceAttribute` for localized display strings.
#### `ZeroMethodType`
```csharp
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum ZeroMethodType { AverageOverTime = 0, UsePreEventDiagnosticsZero = 1, None = 2 }
```
Defines methods for calculating electrical zero. **Order and values are critical for legacy compatibility.**
#### `OriginalZeroMethodType`
```csharp
public enum OriginalZeroMethodType { AverageOverTime, UsePreCalZero, None }
```
Original version of zero method types for backward compatibility.
---
### CSVImportTags Class
```csharp
public abstract class CSVImportTags
```
#### Constants
```csharp
public const int MIN_VALID_VERSION = 0;
public const int MAX_VALID_VERSION = 6;
```
#### Static Methods
```csharp
public static bool IsSensorTag(int version)
```
Returns `true` if the version is in the sensor tags set (versions 0, 2, 3, or 4).
```csharp
public static Tags[] GetVersionTags(int version)
```
Returns all tags applicable to a given CSV import version. Returns empty array if version not found.
```csharp
public static string GetStringForTag(Tags tag)
```
Returns the display string for a given tag using `DisplayAttribute`.
```csharp
public static Tags GetTagForString(string s)
```
Returns the tag enum value for a display string. Returns `Tags.Unknown` if not found.
```csharp
public static int GetVersionForTag(Tags t)
```
Returns the version number in which a tag was introduced. Returns `int.MaxValue` if not found.
#### Nested `Tags` Enum
Contains 100+ tag values for CSV import/export fields, each decorated with `[Display(Name = "...")]` and `[Version(int)]` attributes indicating the field name and the version in which it was introduced.
---
### SensorConstants Class
```csharp
public abstract class SensorConstants
```
#### Static Properties (Cached Configuration Values)
| Property | Type | Default/Initial Value |
|----------|------|----------------------|
| `UseInitSignalTOM` | `bool` | `false` |
| `δThorax`, `δAbdomen`, `D0Thorax`, `D0Abdomen`, `δThoraxLower`, `D0ThoraxLower` | `double` | Various IR-TRACC 3D values |
| `UseSensorFirstUseDate` | `bool` | `false` |
| `DontAllowDataCollectionIfOverused` | `bool` | `false` |
| `AllowInspectBeforeUse` | `bool` | `false` |
| `UsageRemainingForWarning` | `int` | (uninitialized) |
| `DefaultMaxUsageAllowed` | `int` | (uninitialized) |
| `UseISOCodeFilterMapping` | `bool` | `true` |
| `DefaultZeroMethodType` | `ZeroMethodType` | `AverageOverTime` |
| `DefaultZeroMethodStart` | `double` | `-0.05D` |
| `DefaultZeroMethodEnd` | `double` | `-0.02D` |
| `DefaultRangeHiG` | `double` | `400D` |
| `DefaultRangeLowG` | `double` | `64D` |
| `DefaultRangeLowGDisplay` | `double` | `50D` |
| `DefaultRangeARS` | `double` | `2000D` |
| `DefaultRangeTemperature` | `double` | `85D` |
| `DefaultRangeHumidity` | `double` | `100D` |
| `DefaultRangePressure` | `double` | `16D` |
| `DisableAutoSense` | `bool` | (uninitialized) |
| `DefaultBridgeOffsetMVTolLow` | `double` | `-100` |
| `DefaultBridgeOffsetMVTolHigh` | `double` | `100` |
| `DefaultIEPEOffsetMVTolLow` | `double` | `-2000` |
| `DefaultIEPEOffsetMVTolHigh` | `double` | `2000` |
| `SensorCalOutOfDateWarningPeriodDays` | `int` | `14` |
| `SensorCalPolicyCurrent` | `SensorCalPolicy` | `DONT_ALLOW` |
#### Static Methods
```csharp
public static bool IsTestSpecificDigitalOut(string sn)
public static bool IsTestSpecificSquib(string sn)
public static bool IsTestSpecificDigitalIn(string sn)
public static bool IsTestSpecificEmbedded(string sn)
public static bool IsTestSpecificThermoCouple(string sn)
public static bool IsTestSpecificEmbeddedClock(string sn)
public static bool IsTestSpecificStreamOut(string sn)
public static bool IsTestSpecificStreamIn(string sn)
public static bool IsTestSpecificUart(string sn)
public static bool IsTestSpecificThermocoupler(string sn)
public static bool IsTestSpecificCAN(string sn)
```
Each returns `true` if the serial number starts with the corresponding test-specific prefix.
```csharp
public static bool IsTSRAirHighGChannel(string moduleSerialNumber)
public static bool IsTSRAirLowGChannel(string moduleSerialNumber)
public static bool IsTSRAirARSChannel(string moduleSerialNumber)
public static bool IsTSRAirAtmChannel(string moduleSerialNumber)
public static bool IsTSRAirHumidityChannel(string moduleSerialNumber, int channelNumber)
```
Identify TSR AIR module channel types by suffix or channel number.
```csharp
public static BridgeType ConvertIntToBridgeType(int bridge)
```
Converts integer database values to `BridgeType` enum.
```csharp
public static int ConvertBridgeToInt(BridgeType bridge)
```
Converts `BridgeType` enum to integer for database storage (non-bitmask values).
#### Nested Types
```csharp
public enum SensorSettings { Range, CFC, Polarity, Position, LimitDuration, Duration, Delay, OutputMode, SQMode, DIMode, DefaultValue, ActiveValue, SquibLimitDuration, SquibDuration, SquibDelay, DigitalOutLimitDuration, DigitalOutDuration, DigitalOutDelay, SquibCurrent, ZeroMethod, ZeroMethodStart, ZeroMethodEnd, UserValue1, UserValue2, UserValue3, InitialOffset, FilterClass, UartBaudRate, UartDataBits, UartStopBits, UartParity, UartFlowControl, UartDataFormat, StreamOutUDPProfile, StreamOutUDPAddress, StreamOutUDPTimeChannelId, StreamOutUDPDataChannelId, StreamOutUDPTmNSConfig, StreamOutIRIGTimeDataPacketIntervalMs, StreamInUDPAddress, ACCouplingEnabled, BridgeType }
public enum SensorType { Analog, DigitalIn, DigitalOut, Squib, Clock, UART, StreamOut, StreamIn, Thermocoupler }
public enum SensUnits { NONE = 0, mV = 1, mVperV = 2, mVperVperEU = 3, mVperEU = 4 }
public enum BridgeType { IEPE = 1, QuarterBridge = 2, HalfBridge = 4, FullBridge = 8, DigitalInput = 16, SQUIB = 32, TOMDigital = 64, HalfBridge_SigPlus = 128, RTC = 256, UART = 512, StreamOut = 1024, StreamIn = 2048, Thermocoupler = 4096, CAN = 8192 }
public enum SensorCalPolicy { AllowAlways, DONT_ALLOW }
public enum CouplingModes { AC = 0, DC }
public enum AvailableRangesLowG { LowG64D = 64 }
public enum AvailableRangesARS { ARS2000D = 2000 }
public abstract class SensUnitStringConverter
{
public static SensUnits ConvertFromString(string s)
}
```
---
## 3. Invariants
1. **CSV Version Range**: Valid CSV import versions are between `MIN_VALID_VERSION` (0) and `MAX_VALID_VERSION` (6), inclusive.
2. **Sensor Tag Versions**: Only versions 0, 2, 3, and 4 are considered "sensor tag" versions as defined in `_SensorTagsVersions`.
3. **Bridge Resistance Limits**: Valid bridge resistance values must be between `MIN_BRIDGE_RESISTANCE_OHMS` (1) and `MAX_BRIDGE_RESISTANCE_OHMS` (32000).
4. **ZeroMethodType Enum Ordering**: The order and explicit values of `ZeroMethodType` enum members must not be changed due to legacy compatibility requirements (e.g., GM ISF import).
5. **BridgeType Bitmask vs. Storage**: `BridgeType` uses bitmask values (powers of 2), but database storage uses sequential integers (0-4, 8) via `ConvertBridgeToInt`.
6. **FilterClassType Values**: Filter class values represent actual cutoff frequencies in Hz (e.g., `CFC60 = 100` Hz, not 60).
7. **TSR AIR Channel Numbers**: Humidity channel is channel 10, Pressure is channel 11, Temperature is channel 9 within TSR AIR atmospheric modules.
---
## 4. Dependencies
### This module depends on:
- `System` - Core .NET types
- `System.ComponentModel` - `TypeConverter`, `DescriptionAttribute`
- `System.ComponentModel.DataAnnotations` - `DisplayAttribute`
- `System.IO.Ports` - `StopBits`, `Parity`, `Handshake` enums
- `System.Collections.Generic` - `Dictionary`, `HashSet`, `List`
- `System.Linq` - LINQ extension methods
- `DTS.Common.Converters` - `EnumDescriptionTypeConverter`
- `DTS.Common.Attributes` - `DisplayAttribute`, `VersionAttribute` (custom attributes)
- `DTS.Common.Base.Classes` - `DescriptionResourceAttribute`
### What depends on this module:
- Unknown from source alone. This is a foundational enums/constants module likely used throughout the DTS application for sensor configuration, data acquisition, and import/export functionality.
---
## 5. Gotchas
1. **Static Property State**: Many static properties in `SensorConstants` (e.g., `UseInitSignalTOM`, `UseSensorFirstUseDate`, `DisableAutoSense`) are described as "holding values between processes" and do not serialize/deserialize. They must be set by using applications on startup.
2. **ZeroMethodType Legacy Compatibility**: The comment explicitly warns: *"Lots of legacy compatibility (e.g. importing GM ISF) depends on the order/value of this enum."* Do not reorder or reassign values.
3. **BridgeType Integer Conversion**: The `ConvertBridgeToInt` method uses non-bitmask integer values for database storage, which is described as "needed for historical reasons." The mapping is not 1:1 with bitmask values (e.g., `HalfBridge_SigPlus = 128` in enum but stores as `4`).
4. **Deprecated SensorSettings**: `LimitDuration`, `Duration`, and `Delay` in `SensorSettings` enum are marked as "deprecated in 2.1" but remain in the enum.
5. **FilterClassType None Behavior**: Per comments, `None = 0` has special behavior: "Code = P unless UseZeroForUnfiltered is True, then Code = 0". This behavior is not defined in this source file.
6. **Uninitialized Static Properties**: `UsageRemainingForWarning` and `DefaultMaxUsageAllowed` are declared without initialization, implying they must be set before use.
7. **Test-Specific Serial Number Prefixes**: Multiple similar prefixes exist (`TEST_SPECIFIC_THERMO = "TST_"` vs `TEST_SPECIFIC_THERMOCOUPLER = "TST_TestSpecific"`). The relationship between short prefixes and full serial formats is not fully documented in source.
8. **CSVImportTags Thread Safety**: All public methods use `lock(MY_LOCK)` for thread-safe lazy initialization of lookup dictionaries.