--- source_files: - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SensorRange.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SensorDB.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/DigitalInputSetting.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/ZeroMethod.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/DigitalOutputSetting.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/FilterClass.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SquibSetting.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/IsoCode.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/CalibrationRecords.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SensorsCollection.cs generated_at: "2026-04-16T04:58:51.573580+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "56b13794f7fbf4fa" --- # Documentation: `DatabaseExport` Sensor Data Types (Version 57) --- ## 1. Purpose This module defines data structures and types used to represent sensor configurations, calibration metadata, and related settings for legacy database version 57 in the DataPRO system. It provides strongly-typed classes to deserialize sensor and channel configuration data from database rows (`System.Data.DataRow`) and serialize them for persistence or exchange. These types serve as an abstraction layer between the raw database schema and higher-level application logic, enabling consistent handling of sensor metadata, digital I/O settings, calibration records, and ISO location codes across the system. --- ## 2. Public Interface ### `SensorRange` - **Namespace**: `DatabaseExport` - **Fields**: - `double Low { get; set; }` - `double Medium { get; set; }` - `double High { get; set; }` - **Constructor**: `SensorRange(double _low, double _medium, double _high)` Initializes all three range values. ### `LowHigh` - **Namespace**: `DatabaseExport` - **Fields**: - `double Low { get; set; }` - `double High { get; set; }` - **Constructor**: `LowHigh(double _low, double _high)` Initializes low and high bounds. ### `SensorStatus` - **Namespace**: `DatabaseExport` - **Enum Values**: - `Available` - `InUse` - `OutForService` - `OutForCalibration` - `Retired` ### `ShuntMode` - **Namespace**: `DatabaseExport` - **Enum Values**: - `None` - `Emulation` - `Internal` - `External` ### `BridgeLeg` - **Namespace**: `DatabaseExport` - **Enum Values**: - `First` - `Second` - `Third` - `Fourth` ### `CouplingModes` - **Namespace**: `DatabaseExport` - **Enum Values**: - `AC = 0` - `DC` ### `DigitalInputSetting` - **Namespace**: `DatabaseExport` - **Inherits**: `SensorData` - **Constructors**: - `DigitalInputSetting()` Initializes with defaults via `SetDefaults`. - `DigitalInputSetting(DigitalInputSetting copy)` Copy constructor; initializes with defaults after copying. - **Static Method**: - `static void SetDefaults(SensorData sd)` Sets default values for a `SensorData` instance: - `AxisNumber = 0` - `NumberOfAxes = 1` - `Capacity = 1` (overwrites earlier `2400`) - `Bridge = Test.Module.Channel.Sensor.BridgeType.DigitalInput` - `DisplayUnit = "V"` - `BridgeResistance = double.NaN` - `CheckOffset = false` - `Manufacturer = "Generic"` - `OffsetToleranceHigh = 2500` - `OffsetToleranceLow = 2500` - `Model = "Digital Input Setting"` - `Shunt = ShuntMode.None` - `MeasureExcitation = false` - `MeasureNoise = false` ### `ZeroMethod` - **Namespace**: `DatabaseExport` - **Fields**: - `Test.Module.Channel.Sensor.ZeroMethodType Method { get; set; }` - `double Start { get; set; }` - `double End { get; set; }` - **Constructors**: - `ZeroMethod(Test.Module.Channel.Sensor.ZeroMethodType zm, double _start, double _end)` - `ZeroMethod(string zm)` Parses a comma-separated string: `"MethodName,start,end"`; throws no exception on failure—silently returns uninitialized if tokens < 3. - `ZeroMethod(ZeroMethod copy)` Deep copy. - **Methods**: - `string ToDbString()` Returns `"Method,start,end"` using default formatting. - `string ToSerializeString()` Returns `"Method,start,end"` using `InvariantCulture` for numbers. ### `DigitalOutputSetting` - **Namespace**: `DatabaseExport` - **Inherits**: `SensorData` - **Properties**: - `string ChannelDescription { get; set; }` Getter returns `SerialNumber`; setter updates `SerialNumber` and raises `OnPropertyChanged("ChannelDescription")`. - **Constructors**: - `DigitalOutputSetting()` Initializes with defaults via `SetDefaults`. - `DigitalOutputSetting(System.Data.DataRow dr)` Populates instance from database row. Supports fields from `DbOperations.DigitalOutputSettings.Fields`: - `Version`, `OutputMode`, `LocalOnly`, `LimitDuration`, `LastModifiedBy`, `LastModified`, `DurationMSFloat`, `DelayMS`, `ChannelDescription`, `UserTags` - `DurationMS` is ignored (marked obsolete). - **Static Method**: - `static void SetDefaults(SensorData sd)` Sets defaults: - `SupportedExcitation = [Volt5]` - `Bridge = Test.Module.Channel.Sensor.BridgeType.TOMDigital` - `AxisNumber = 0`, `NumberOfAxes = 1` - `Capacity = 1` - `DisplayUnit = "V"` - `BridgeResistance = double.NaN` - `CheckOffset = false` - `Manufacturer = "Generic"` - `OffsetToleranceHigh = 2500` - `OffsetToleranceLow = 2500` - `Model = "Digital Output Setting"` - `Shunt = ShuntMode.None` - `MeasureExcitation = false` - `MeasureNoise = false` ### `FilterClass` - **Namespace**: `DatabaseExport` - **Nested Enum**: `FilterClassType` - `None = 0` - `AdHoc = -1` - `CFC10 = 17` - `CFC60 = 100` - `CFC180 = 300` - `CFC600 = 1000` - `CFC1000 = 1650` - **Fields**: - `FilterClassType FClass { get; set; }` - `double Frequency { get; set; }` - **Constructors**: - `FilterClass(FilterClassType fc)` Initializes `FClass` and `Frequency` (e.g., `CFC60` → `Frequency = 100.0`). Throws on unknown type. - `FilterClass(string fclass)` Parses string (e.g., `"100"`, `"CFC60"`, `"123.45"`). Maps known numeric codes to enum values; falls back to `AdHoc` with parsed frequency. - **Methods**: - `override string ToString()` Returns `"None"`, `"17 (CFC10)"`, etc., or numeric string for `AdHoc`. ### `SquibSetting` - **Namespace**: `DatabaseExport` - **Inherits**: `SensorData` - **Properties**: - `string SquibDescription { get; set; }` Getter returns `SerialNumber`; setter updates `SerialNumber` and raises `OnPropertyChanged("SquibDescription")`. - `bool BypassCurrentFilter { get; set; }` - `bool BypassVoltageFilter { get; set; }` - `string ArticleId { get; set; }` Getter returns `Id`; setter updates `Id` and raises `OnPropertyChanged("ArticleId")`. - **Constructors**: - `SquibSetting(System.Data.DataRow dr)` Populates from `tblTOMSquibChannels`. Supports fields from `DbOperations.Squib.Fields`: - `Version`, `SquibToleranceLow`, `SquibToleranceHigh`, `SquibOutputCurrent`, `SquibDescription`, `MeasurementType`, `LocalOnly`, `LimitDuration`, `LastModifiedBy`, `LastModified`, `ISOCode`, `FireMode`, `DurationMS`, `DelayMS`, `BypassVoltageFilter`, `BypassCurrentFilter`, `ArticleId`, `UserValue1`, `UserValue2`, `UserValue3`, `UserTags` - **Static Method**: - `static void SetDefaults(SensorData sd)` Sets defaults: - `AxisNumber = 0`, `Capacity = 5`, `NumberOfAxes = 1` - `Manufacturer = "Generic"`, `Model = "Squib Setting"` - `Shunt = ShuntMode.None` - `CheckOffset = false` - `BridgeResistance = -1` - `MeasureNoise = false`, `MeasureExcitation = false` - `Bridge = Test.Module.Channel.Sensor.BridgeType.SQUIB` - `SupportedExcitation = [Volt5]` - `DisplayUnit = "V"` - `Comment = SerialNumber` (if `UserValue1` is empty/whitespace) ### `IsoCode` - **Namespace**: `DatabaseExport` - **Fields**: - `string TestObject { get; set; }` (1 char, index 0) - `string Position { get; set; }` (1 char, index 1) - `string MainLocation { get; set; }` (4 chars, indices 2–5) - `string FineLocation1 { get; set; }` (2 chars, indices 6–7) - `string FineLocation2 { get; set; }` (2 chars, indices 8–9) - `string FineLocation3 { get; set; }` (2 chars, indices 10–11) - `string PhysicalDimension { get; set; }` (2 chars, indices 12–13) - `string Direction { get; set; }` (1 char, index 14) - `string FilterClass { get; set; }` (1 char, index 15) - **Constructors**: - `IsoCode(string isoCode)` Normalizes input to 16 chars: truncates if >16, pads with `'?'` if <16. - **Properties**: - `string StringRepresentation { get; set; }` Getter returns full 16-char string; setter normalizes to 16 chars (truncates/pads with `'0'` if shorter). ### `CalibrationRecords` - **Namespace**: `DatabaseExport` - **Fields**: - `CalibrationRecord[] Records { get; set; }` - **Constructors**: - `CalibrationRecords()` Initializes with one default `CalibrationRecord`. - `CalibrationRecords(CalibrationRecords copy)` Deep copy of `Records`. - `CalibrationRecords(string records)` Parses serialized string via `FromSerializedString`. - **Methods**: - `void FromSerializedString(string s)` Splits on `"__x__"` (with fallback `"___xx___"`), constructs `CalibrationRecord`s. - `string ToSerializedString(SensorCalibration sc)` Serializes each `CalibrationRecord`, escapes `"__x__"` → `"___xx___"`. ### `CalibrationRecord` - **Namespace**: `DatabaseExport` - **Fields**: - `double Sensitivity { get; set; }` - `double ZeroPoint { get; set; }` Computed from `Poly.ZeroPositionIntercept / Poly.CalibrationFactor` if `Poly.CalibrationFactor ≠ 0`; else returns stored `_zeroPoint`. - `LinearizationFormula Poly { get; set; }` - `bool AtCapacity { get; set; } = false` - `string EngineeringUnits { get; set; } = "g"` - `Test.Module.Channel.Sensor.SensUnits SensitivityUnits { get; set; } = NONE` - `Test.Module.Channel.Sensor.ExcitationVoltageOption Excitation { get; set; } = Volt5` - `int CapacityOutputIsBasedOn { get; set; } = 1` - **Constructors**: - `CalibrationRecord()` Initializes `Poly = new LinearizationFormula()`. - `CalibrationRecord(string s)` Parses via `FromString`. - `CalibrationRecord(CalibrationRecord copy)` Deep copy. - **Methods**: - `string ToSerializedString(SensorCalibration parentCal)` Serializes fields (including `Poly`) with escaping of list separators. - `void FromString(string s)` Parses serialized string. --- ## 3. Invariants - **`SensorRange`**: No explicit validation; `Low`, `Medium`, `High` may be any `double`. - **`ZeroMethod`**: Parsing from string silently fails if fewer than 3 comma-separated tokens; no exception thrown. - **`FilterClass`**: Constructor from `FilterClassType` throws `System.Exception` for unknown types. Constructor from string may assign `AdHoc` with arbitrary frequency. - **`IsoCode`**: All 16 positions are always populated; missing/short inputs are padded with `'?'`, excess truncated. Setter for `StringRepresentation` pads with `'0'` (not `'?'`) if shorter than 16. - **`CalibrationRecord.ZeroPoint`**: Computed value takes precedence over stored `_zeroPoint` if `Poly.CalibrationFactor ≠ 0`. - **`SensorsCollection`**: - Singleton via `SensorsList` (thread-safe via `lock`). - `GetSensorBySerialNumber` excludes sensors with `Broken = true`, `DoNotUse = true`, or `NumberOfAxes > 1` or `AxisNumber > 0`. - `AllSensorsDb` excludes multi-axis sensors but *not* `Broken`/`DoNotUse`. - Sensors loaded from `tblSensors`, `tblDigitalInputSetting`, `tblTOMSquibChannels`, `tblTOMDigitalChannels` into a single `_sensorDictionary`. --- ## 4. Dependencies ### Internal Dependencies (Inferred from Source) - **`Test.Module.Channel.Sensor` namespace**: - Types used: `ZeroMethodType`, `BridgeType`, `ExcitationVoltageOption`, `SensUnits` - **`DbOperations` namespace**: - Nested types: `DigitalOutputSettings.Fields`, `Squib.Fields`, `DigitalInputSettings.Fields` - Methods: `GetCommand()`, `Connection.QueryDataSet(...)` - **`SensorData` base class**: Used by `DigitalInputSetting`, `DigitalOutputSetting`, `SquibSetting`. Not provided in source, but assumed to define common properties like `SerialNumber`, `Id`, `Version`, `LastModified`, `TagsBlobBytes`, `Broken`, `DoNotUse`, `UserValue1`, etc. - **`LinearizationFormula`**: Referenced by `CalibrationRecord`. Not provided in source. ### External Dependencies - `System` (core types: `Enum`, `Convert`, `StringBuilder`, `CultureInfo`) - `System.Data` (`DataRow`, `DataSet`, `DBNull`) - `System.Collections.Generic` ### What Depends on This Module? - `SensorsCollection.SensorsList` is used to load and cache all sensor configurations at runtime. - `DigitalInputSetting`, `DigitalOutputSetting`, `SquibSetting` are instantiated from database rows during initialization. - `CalibrationRecords` and `CalibrationRecord` are used to serialize/deserialize calibration metadata. --- ## 5. Gotchas - **`DigitalInputSetting.SetDefaults` sets `Capacity = 2400` then immediately overwrites to `1`** — likely a typo or legacy artifact. - **`ZeroMethod` constructor from string silently ignores malformed input** — no exception, no logging; returns partially initialized object. - **`IsoCode.StringRepresentation` setter pads with `'0'`, but constructor/partial setters pad with `'?'`** — inconsistent default padding. - **`CalibrationRecord.ZeroPoint` is computed only when `Poly.CalibrationFactor ≠ 0`** — stored `_zeroPoint` may be stale if `Poly` changes. - **`SensorsCollection.GetSensorBySerialNumber` returns `null` for multi-axis sensors** — even if valid — due to legacy restriction "Disable 6-axis sensor capability". - **`FilterClass` constructor from string may assign `AdHoc` for unrecognized values** — no validation that frequency is positive or meaningful. - **`DigitalOutputSetting` copy constructor is commented out** — no deep copy support for this type. - **`CalibrationRecords` uses custom separators (`"__x__"` and `"___xx___"`)** — risk of collision if data contains these strings; escaping is manual and error-prone. - **`SensorData` is not defined in provided sources** — behavior of inherited properties (e.g., `Id`, `SerialNumber`, `TagsBlobBytes`) must be inferred from usage. - **`SquibSetting.Comment` defaults to `SerialNumber` if `UserValue1` is empty**, but `UserValue1` is set from DB row — potential for unintended override.