Files
DP44/docs/ai/Common/DTS.Common.ISO.md

403 lines
19 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common.ISO/IsoMDBFile.cs
- Common/DTS.Common.ISO/ISerializableFile.cs
- Common/DTS.Common.ISO/AbstractOLEDbWrapper.cs
- Common/DTS.Common.ISO/HardwareChannel.cs
- Common/DTS.Common.ISO/IsoCode.cs
- Common/DTS.Common.ISO/TestObjectChannel.cs
- Common/DTS.Common.ISO/CalculatedValueClass.cs
- Common/DTS.Common.ISO/LevelTriggerChannel.cs
- Common/DTS.Common.ISO/TestSetting.cs
- Common/DTS.Common.ISO/TestObjectTemplate.cs
- Common/DTS.Common.ISO/MMEFilterClasses.cs
- Common/DTS.Common.ISO/MMEPositions.cs
- Common/DTS.Common.ISO/MMEFineLocations2.cs
generated_at: "2026-04-17T15:26:54.219712+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "02238b951afcf713"
---
# DTS.Common.ISO Module Documentation
## 1. Purpose
This module provides data structures and utilities for working with ISO 13499 (MME) crash test data standards. It includes classes for managing test object templates, channels, hardware configurations, calculated values, and ISO metadata (positions, filter classes, fine locations). The module serves as a bridge between the database layer and the application's domain model for test setup and data acquisition, handling serialization, database persistence, and ISO code generation for channel identification.
---
## 2. Public Interface
### IsoMDBFile
```csharp
public class IsoMDBFile
```
Empty placeholder class. No members defined in source.
---
### ISerializableFile
```csharp
public interface ISerializableFile
```
Interface for serializable file operations.
| Method | Return Type | Description |
|--------|-------------|-------------|
| `GetDirectory()` | `string` | Returns the directory path for the file |
| `GetExtension()` | `string` | Returns the file extension |
| `GetFilter()` | `string` | Returns the file filter string |
| `GetFileLocation()` | `string` | Returns the full file location |
---
### AbstractOLEDbWrapper
```csharp
public abstract class AbstractOLEDbWrapper
```
Base class providing helper methods for database reader operations.
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetLong` | `protected static long GetLong(IDataReader reader, string field)` | Returns `long.MinValue` if field is `DBNull`, otherwise converts to `Int64` |
| `GetDate` | `protected static DateTime GetDate(IDataReader reader, string field)` | Returns `DateTime.MinValue` if field is `DBNull`, otherwise casts to `DateTime` |
---
### HardwareChannel
```csharp
public class HardwareChannel : DASChannelDBRecord, INotifyPropertyChanged
```
Represents a hardware channel associated with a DAS (Data Acquisition System).
**Constructors:**
- `public HardwareChannel()`
- `public HardwareChannel(IDASChannelDBRecord record, Hardware h)`
- `public HardwareChannel(HardwareChannel copy, Hardware h)`
**Properties:**
| Property | Type | Description |
|----------|------|-------------|
| `ParentDAS` | `Hardware` | Parent hardware device, with `INotifyPropertyChanged` support |
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `PhysicalCompare` | `public static int PhysicalCompare(HardwareChannel left, HardwareChannel right)` | Compares two channels by `ChannelIdx`. Returns -1 if left is null, 1 if right is null, 0 if equal |
| `Insert` | `public void Insert()` | Inserts this channel into database via `DbOperations.DASChannelsInsert` |
| `IsSupported` | `public bool IsSupported(SensorConstants.BridgeType bridge)` | Checks if bridge type is supported using bitwise AND on `SupportedBridges` |
---
### IsoCodeStatics
```csharp
public class IsoCodeStatics
```
Static utility class for generating ISO code strings.
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetString` | `public static string GetString(MMEPossibleChannels channel, MMETestObjects container, MMEPositions position, MMEFilterClasses fc)` | Builds ISO code from channel, test object, position, and filter class |
| `GetString` | `public static string GetString(MMEPossibleChannels channel, bool careAboutTestTimeFields)` | Builds ISO code, optionally masking test object and filter class with "??"/"?" |
| `GetString` | `public static string GetString(string testObject, string position, string main, string floc1, string floc2, string floc3, string physdim, string dir, string fc)` | Concatenates all parts into ISO code string |
---
### TestObjectChannel
```csharp
public class TestObjectChannel : TestObjectTemplateChannel, IComparable<TestObjectChannel>, IGroupChannel
```
Represents a channel within a test object, extending template channel with metadata.
**Constants:**
- `public const int CHANNEL_IDX_UNKNOWN = -1`
- `private const char CHANNEL_SEPARATOR = 'x'`
**Enum:**
```csharp
public enum SquibChannelTypes { None, Voltage, Current }
```
**Properties:**
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `Disabled` | `bool` | - | Controls whether channel is used in data collection |
| `ChannelIdx` | `int` | `CHANNEL_IDX_UNKNOWN` | Channel index |
| `SensorSerialNumber` | `string` | `""` | Serial number of associated sensor |
| `HardwareId` | `string` | `""` | Physical hardware channel ID (setter parses and reformats) |
| `SquibChannelType` | `SquibChannelTypes` | - | Type of squib channel |
| `TestObject` | `TestObject` | - | Parent test object (read-only) |
**Constructors:**
- `public TestObjectChannel(TestObjectTemplateChannel copy, TestObject testObject, TestObjectTemplate template)`
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `CompareTo` | `public int CompareTo(TestObjectChannel right)` | Compares by: 1) `DisplayOrder`, 2) `Name`, 3) `TestObject.SerialNumberOrOriginalSerialNumber` |
| `CompareTo` | `public int CompareTo(IGroupChannel other)` | Delegates to `CompareTo(TestObjectChannel)` |
| `GetGraphId` | `public string GetGraphId()` | Returns ID with `Constants.CURRENT_SUFFIX` if `SquibChannelType.Current`, else `GetId()` |
| `GetId` | `public string GetId()` | Returns `{SerialNumber}_{MMEChannelType}_{Channel.Id}` |
| `GetIdWithSpecificChannelId` | `public string GetIdWithSpecificChannelId(long id)` | Returns `{SerialNumber}_{MMEChannelType}_{id}` |
| `GetDASId` | `public string GetDASId()` | Extracts DAS ID from `HardwareId` (substring before first '_') |
---
### CalculatedValueClass
```csharp
public class CalculatedValueClass : CalculatedChannelRecord
```
Represents a calculated/derived channel value.
**Constructors:**
- `public CalculatedValueClass()`
- `public CalculatedValueClass(CalculatedValueClass copy)`
- `public CalculatedValueClass(ICalculatedChannelRecord record)`
**Properties:**
| Property | Type | Description |
|----------|------|-------------|
| `SupportsRealtime` | `bool` | Returns `ViewInRealtime` |
| `Operation` | `Operations` | Newed property that raises `ViewInRealtime` and `CanChangeViewInRealtime` change notifications |
| `ViewInRealtime` | `bool` | Returns `false` for `IRTRACC3D`, `IRTRACC3D_ABDOMEN`, `IRTRACC3D_LOWERTHORAX`, `HIC` operations |
| `CanChangeViewInRealtime` | `bool` | Returns `false` for same operations as above |
| `InputChannelIds` | `string[]` | Lazily builds from `_channels` list if populated |
| `TestObjectChannels` | `List<TestObjectChannel>` | Associated test object channels |
| `InputChannelIdsBlob` | `byte[]` | UTF-8 encoded, list-separator joined channel IDs |
| `Attributes` | `CCAttributeBase[]` | Array of calculation attributes |
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `IsValid` | `public bool IsValid(Dictionary<string, bool> channelIdLookup)` | Validates: non-empty name, at least one input channel, all IDs exist in lookup |
| `SetChannels` | `public void SetChannels(IGroupChannel[] groupChannels)` | Sets internal `_channels` list |
| `SetTestObjectChannels` | `public void SetTestObjectChannels(TestObjectChannel[] testObjectChannels)` | Sets `TestObjectChannels` list |
| `ReplaceInputChannelIdAtIndex` | `public void ReplaceInputChannelIdAtIndex(int index, string newId)` | Replaces channel ID at specified index |
---
### CCAttributeBase
```csharp
public abstract class CCAttributeBase
```
Abstract base for calculated channel attributes.
| Property | Signature | Description |
|----------|-----------|-------------|
| `AttributeId` | `public int AttributeId` | Returns protected `_attributeId` |
| `_attributeValue` | `protected object` | Protected backing field |
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetSerializedValue` | `public abstract string GetSerializedValue()` | Abstract |
| `GetDefaultValue` | `public abstract string GetDefaultValue()` | Abstract |
| `GetNameResourceId` | `public abstract string GetNameResourceId { get; }` | Abstract property |
| `Copy` | `public abstract CCAttributeBase Copy()` | Abstract |
---
### LevelTriggerChannel
```csharp
public class LevelTriggerChannel
```
Stores level trigger configuration for a channel.
**Constructors:**
- `public LevelTriggerChannel(LevelTriggerChannel copy)`
- `public LevelTriggerChannel(string groupChannelId, string hardwareChannelId, string sensorSerialNumber, bool greaterThanEnabled, double greaterThanEU, bool lessThanEnabled, double lessThanEU, double insideLowerLevelEU, double insideUpperLevelEU, double outsideLowerLevelEU, double outsideUpperLevelEU, bool triggerOutsideBounds, bool triggerInsideBounds)`
- `public LevelTriggerChannel(System.Data.DataRow dr)` - Populates from database row using `DbOperations.LevelTriggers.Fields`
**Properties:**
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `GroupChannel` | `IGroupChannel` | `null` | Associated group channel |
| `GroupChannelId` | `string` | `"-1"` | Channel ID |
| `HardwareChannelId` | `string` | `""` | Hardware channel ID |
| `SensorSerialNumber` | `string` | `""` | Sensor serial |
| `GreaterThanEnabled` | `bool` | `true` | Greater-than trigger enabled |
| `GreaterThanThresholdEU` | `double` | - | Threshold in engineering units |
| `LessThanEnabled` | `bool` | `false` | Less-than trigger enabled |
| `LessThanThresholdEU` | `double` | - | Threshold in engineering units |
| `TriggerBetweenBounds` | `bool` | `false` | Inside bounds trigger |
| `TriggerOutsideBounds` | `bool` | `false` | Outside bounds trigger |
| `InsideUpperLevelEU` | `double` | - | Upper bound for inside trigger |
| `InsideLowerLevelEU` | `double` | - | Lower bound for inside trigger |
| `OutsideUpperLevelEU` | `double` | - | Upper bound for outside trigger |
| `OutsideLowerLevelEU` | `double` | - | Lower bound for outside trigger |
| `LevelTriggerText` | `string` | - | Human-readable trigger description |
---
### TestSetting
```csharp
public class TestSetting
```
Represents a single test setting with ID, value, and default.
**Constants:**
- `private const string SEPARATOR = "_x_"`
**Constructors:**
- `public TestSetting(TestSetting copy, string value)`
- `public TestSetting(TestSetting copy)`
- `public TestSetting(int id, string value, string defaultValue)`
- `public TestSetting(TestSettingsEnum id, string value, string defaultValue)`
**Properties:**
| Property | Type | Description |
|----------|------|-------------|
| `Id` | `int` | Setting identifier |
| `Value` | `string` | Current value |
| `DefaultValue` | `string` | Default value (read-only) |
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `ToSerializeString` | `public string ToSerializeString()` | Returns `{Id}={Value}` with '=' replaced by `SEPARATOR` |
| `TryParse` | `public static bool TryParse(string s, out TestSetting ts)` | Parses serialized string; tries `TestSettingsEnum` first, then `int` |
---
### TestSettingsEnum
```csharp
public enum TestSettingsEnum
```
Enumeration of test setting identifiers: `ArmCheckListStep`, `CheckListInputVoltageCheck`, `CheckListBatteryVoltageCheck`, `CheckListSquibResistanceCheck`, `CheckListSensorIDCheck`, `CheckListTriggerStartCheck`, `CheckListTiltSensorCheck`, `CheckListTemperatureCheck`, `CheckListClockSyncCheck`, `EW`, `CheckListMustPass`.
---
### TestSettingDictionary
```csharp
public class TestSettingDictionary
```
Dictionary container for test settings.
**Constructors:**
- `public TestSettingDictionary()`
- `public TestSettingDictionary(TestSettingDictionary copy)`
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetValue` | `public string GetValue(int id, string defaultValue)` | Returns value or default if not found |
| `GetValue` | `public string GetValue(TestSettingsEnum id, string defaultValue)` | Overload for enum |
| `SetValue` | `public void SetValue(TestSetting setting, string value)` | Creates new `TestSetting` with value |
| `SetValue` | `public void SetValue(TestSetting setting)` | Sets setting directly |
| `SetValue` | `public void SetValue(TestSettingsEnum id, string value)` | Overload for enum |
| `SetValue` | `public void SetValue(int id, string value)` | Creates or updates setting |
| `UnLoad` | `public void UnLoad()` | Clears internal dictionary |
| `ToSerializeString` | `public string ToSerializeString()` | Serializes all settings |
| `LoadSettings` | `public void LoadSettings(string s)` | Deserializes settings, preserving defaults |
---
### TestObjectTemplate
```csharp
public class TestObjectTemplate : ITestObjectTemplate
```
Lightweight wrapper for group templates from database.
**Constructors:**
- `public TestObjectTemplate(string templateName, bool bLocalOnly)`
- `public TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)`
**Properties:**
| Property | Type | Description |
|----------|------|-------------|
| `TemplateName` | `string` | Template name (GUID for embedded templates) |
| `TemplateNameOrOriginalTemplateName` | `string` | Human-readable name |
| `Icon` | `string` | Icon identifier |
| `Description` | `string` | Template description |
| `LocalOnly` | `bool` | Whether template is local-only |
| `Version` | `int` | Version number |
| `LastModifiedBy` | `string` | Last modifier |
| `LastModified` | `DateTime` | Last modification date |
| `CRC32` | `int` | Checksum (not currently used per comments) |
| `TestObject` | `string` | ISO meta field |
| `TestObjectType` | `string` | ISO meta field for channel type |
| `TemplateParent` | `string` | Parent template (for composite templates) |
| `SysBuilt` | `bool` | System-built flag |
| `Channels` | `TestObjectTemplateChannel[]` | All channels |
| `OriginalTemplateName` | `string` | Original name for embedded templates |
| `Embedded` | `bool` | Whether embedded in test setup |
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `IsISOMode` | `public bool IsISOMode()` | Returns `false` if `TestObjectType` contains non-ISO markers |
| `GetTemplate` | `public static TestObjectTemplate GetTemplate(ref ISO13499FileDb db, string name)` | Returns `null` (unimplemented) |
---
### MMEFilterClasses
```csharp
public class MMEFilterClasses : AbstractOLEDbWrapper
```
Represents ISO 13499 filter class metadata.
**Constructors:**
- `public MMEFilterClasses(string sGuid, string filterClass, string textL1, string textL2, long version, DateTime date, string remarks, bool bExpired, string sortKey, DateTime lastChange, string lastChangeText, string history, MMEPossibleChannels.MMEChannelTypes type)`
**Properties:** `S_GUID`, `Filter_Class`, `Text_L1`, `Text_L2`, `Version`, `Date`, `Remarks`, `Expired`, `SortKey`, `Last_Change`, `Last_Change_Text`, `History`, `RecordType` (default: `ISO13499_106`).
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetFilterClasses` | `public static MMEFilterClasses[] GetFilterClasses()` | Queries database for all filter classes |
| `ReadXML` | `public static MMEFilterClasses ReadXML(XmlElement node)` | Imports from XML using `CustomFilterFields` enum |
| `ToString` | `public override string ToString()` | Returns `Text_L1` |
---
### MMEPositions
```csharp
public class MMEPositions : AbstractOLEDbWrapper
```
Represents ISO 13499 position metadata.
**Constructors:**
- `public MMEPositions(string sGuid, string position, string textL1, string textL2, long version, DateTime date, string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history, MMEPossibleChannels.MMEChannelTypes type)`
**Properties:** `S_GUID`, `Position`, `Text_L1`, `Text_L2`, `Version`, `Date`, `Remarks`, `Expired`, `SortKey`, `Last_Change`, `Last_Change_Text`, `History`, `RecordType`.
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetPositions` | `public static MMEPositions[] GetPositions()` | Queries database for all positions |
| `ReadXML` | `public static MMEPositions ReadXML(XmlElement node)` | Imports from XML using `PositionFields` enum |
---
### MMEFineLocations2
```csharp
public class MMEFineLocations2 : AbstractOLEDbWrapper
```
Represents ISO 13499 fine location 2 metadata.
**Constructors:**
- `public MMEFineLocations2(string sGuid, string fineLoc2, string textL1, string textL2, long version, DateTime date, string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history, MMEPossibleChannels.MMEChannelTypes type)`
**Properties:** `S_GUID`, `FINE_LOC_2`, `Text_L1`, `Text_L2`, `Version`, `Date`, `Remarks`, `Expired`, `SortKey`, `Last_Change`, `Last_Change_Text`, `History`, `RecordType`.
**Methods:**
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetFineLocations2` | `public static MMEFineLocations2[] GetFineLocations2()` | Queries database for all fine locations 2 |
| `ReadXML` | `public static MMEFineLocations2 ReadXML(XmlElement node)` | Imports from XML using `CustomFinLoc2Fields` enum |
---
## 3. Invariants
- **HardwareChannel.IsSupported**: Uses bitwise AND comparison - the bridge type value must be exactly matchable within `SupportedBridges` flags.
- **TestObjectChannel.CompareTo**: Null right operand returns 1; null left operand (implicit in static compare) returns -1.
- **TestObjectChannel.ChannelIdx**: Initialized to `CHANNEL_IDX_UNKNOWN` (-1).
- **TestObjectChannel.HardwareId setter**: If value contains exactly 3 underscore-separated tokens, reformats to `{token0}_{token1}{suffix}` where suffix is everything after `CHANNEL_SEPARATOR` ('x') in token2.
- **CalculatedValueClass.ViewInRealtime**: Always returns `false` for operations `IRTRACC3D`, `IRTRACC3D_ABDOMEN`, `IRTRACC3D_LOWERTHORAX`, and `HIC`.
- **CalculatedValueClass.IsValid**: Requires non-whitespace `Name`, at least one `InputChannelId`, and all IDs present in lookup dictionary.
- **AbstractOLEDbWrapper.GetLong**: Returns `long.MinValue` for `DBNull` values.
- **AbstractOLEDbWrapper.GetDate**: Returns `DateTime.MinValue` for `DBNull` values.
- **TestSettingDictionary.LoadSettings**: Preserves existing default settings; only updates `Value` for existing keys.
- **TestObjectTemplate.GetTemplate**: Currently returns `null` (unimplemented).
- **MMEFilterClasses/MMEPositions/MMEFine