Files
DP44/enriched-qwen3-coder-next/DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO.md

294 lines
16 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/AbstractOLEDbWrapper.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/TemplateZone.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/TestObjectChannel.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/CalculatedValueClass.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/HardwareChannel.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/TemplateRegion.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/LevelTriggerChannel.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/MMEFigures.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/TestSetting.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/TestEngineerDetails.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/TestObjectMetaData.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/IsoCode.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/ISO/CustomerDetails.cs
generated_at: "2026-04-16T04:57:15.551651+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "8139d487746881b8"
---
# Documentation: DatabaseExport.ISO Module (Version 57)
## 1. Purpose
This module provides data models and utility classes for exporting test data to ISO-compliant formats, specifically targeting legacy database schema version 57. It serves as a bridge between internal data structures and standardized export formats by encapsulating database row mappings, ISO code construction logic, and metadata handling. The module supports template-based channel definitions, calculated values, level triggers, hardware configuration, and customer/test engineer metadata—enabling consistent serialization and deserialization of test setup information for interoperability with external systems.
## 2. Public Interface
### `AbstractOLEDbWrapper`
- **`GetLong(IDataReader reader, string field)`**
Safely extracts a `long` value from an `IDataReader`. Returns `long.MinValue` if the field value is `DBNull.Value`.
- **`GetDate(IDataReader reader, string field)`**
Safely extracts a `DateTime` value from an `IDataReader`. Returns `DateTime.MinValue` if the field value is `DBNull.Value`.
### `TemplateZone`
- **Constructor `TemplateZone(string template, string name, string picture, string description)`**
Initializes a new zone with explicit values.
- **Constructor `TemplateZone(DataRow dr)`**
Initializes from a database row. Sets `ZoneName` to `"Default zone"` if `ZoneName` is `DBNull.Value`; sets `Description` to `""` if `ZoneDescription` is `DBNull.Value`; populates `TemplateRegions` via `TemplateRegion.GetAllRegions()`.
- **Properties**
- `TemplateName` (read-only)
- `ZoneName` (read-only, defaults to `""`)
- `Picture` (read-write)
- `Description` (read-only, defaults to `""`)
- `TemplateRegions` (read-write array of `TemplateRegion`)
### `TestObjectChannel`
- **`GetGraphID()`**
Returns `GetId() + "_CU"` if `SquibChannelType == SquibChannelTypes.Current`; otherwise returns `GetId()`.
- **`GetId()`**
Returns `GetIdWithSpecificChannelId(Channel.Id)`.
- **`GetIdWithSpecificChannelId(long id)`**
Returns formatted string: `"{SerialNumber}_{MMEChannelType}_{id}"`.
- **`GetID()` / `GetIDWithSpecificChannelId(long id)`**
Alias methods identical to `GetId()` / `GetIdWithSpecificChannelId(long id)`.
- **`CompareTo(TestObjectChannel right)`**
Compares by `DisplayOrder`, then `Name`, then `TestObject.SerialNumberOrOriginalSerialNumber` (if both non-null). Returns `1` if `right == null`.
- **Properties**
- `SquibChannelType` (`SquibChannelTypes` enum: `None`, `Voltage`, `Current`)
- `SensorSerialNumber` (read-write string, default `""`)
- `HardwareId` (read-write string; setter normalizes format: splits on `'_'`, keeps first two tokens, and appends everything from first `'x'` in third token)
- `TestObject` (read-only `ISO.TestObject`)
- `ChannelIDX` (read-write `int`, initialized to `CHANNEL_IDX_UNKNOWN = -1`)
### `CalculatedValueClass`
- **Constructor `CalculatedValueClass(DataRow dr)`**
Populates properties from `DbOperations.CalculatedChannels.Fields` enum values. Skips `DBNull.Value` fields.
- **Properties**
- `Id` (`int`, default `-1`)
- `Operation` (`Operations` enum: `SUM`, `AVERAGE`, `IRTRACC3D`, `IRTRACC3D_ABDOMEN`, `IRTRACC3D_LOWERTHORAX`; default `SUM`)
- `CalculatedValueCode` (`string`, default `"???????????????X"`)
- `InputChannelIds` (`string[]`)
- `InputChannelIdsBlob` (`byte[]`):
- Getter joins `InputChannelIds` with `CultureInfo.InvariantCulture.TextInfo.ListSeparator`, encodes to UTF-8.
- Setter decodes UTF-8, splits by list separator, populates `_inputChannelIds`.
- `CFCForInputChannels` (`string`, default `""`)
- `ChannelFilterClassForOutput` (`string`, default `""`)
- `TestSetupName` (`string`)
- `Name` (`string`)
### `ISOHardwareChannel`
- **Constructor `ISOHardwareChannel(ISOHardwareChannel copy, Hardware h)`**
Deep-copies configuration from `copy`, assigns `ParentDAS = h`.
- **Constructor `ISOHardwareChannel(DataRow dr, Hardware hardware)`**
Populates from `DbOperations.DAS.DASChannelFields` enum values. Throws `NotSupportedException` for unknown fields.
- **Static Method `PhysicalCompare(ISOHardwareChannel left, ISOHardwareChannel right)`**
Compares by `ChannelIdx`. Returns `-1`/`0`/`1` for null checks.
- **Properties**
- `ParentDAS` (`Hardware`)
- `SupportedBridges`, `SupportedSquibFireModes`, `SupportedExcitations`, `SupportedDigitalInputModes`, `SupportedDigitalOutputModes` (`int`, defaults `12`, `16`, `16`, `16`, `16`)
- `ChannelIdx`, `DASDisplayOrder` (`int`)
- `ModuleSerialNumber` (`string`, default `""`)
- `ModuleArrayIndex` (`int`, default `0`)
- `LocalOnly` (`bool`, default `false`)
### `TemplateRegion`
- **Constructor `TemplateRegion(string templateName, string zoneName, bool bLocalOnly)`**
Initializes with explicit values.
- **Constructor `TemplateRegion(DataRow dr)`**
Populates all fields from database row, including coordinate points (`UpperLeft`, `LowerRight`).
- **Static Method `GetAllRegions(string templateName, string zoneName)`**
Queries `tblTemplateRegions` via `DbOperations`, returns array of `TemplateRegion`. Silently ignores exceptions.
- **Properties**
- `TemplateName`, `TemplateZone` (read-only)
- `RegionNumber`, `RegionName`, `RegionDescription`, `TestObject`, `Position`, `MainLocation`, `FineLocation1-3`, `PhysicalDimension`, `Direction`, `FilterClass` (`string`)
- `LocalOnly` (read-only `bool`)
- `UpperLeft`, `LowerRight` (`System.Drawing.Point`)
### `LevelTriggerChannel`
- **Constructor `LevelTriggerChannel(LevelTriggerChannel copy)`**
Deep-copies all properties.
- **Constructor `LevelTriggerChannel(DataRow dr)`**
Populates from `DbOperations.LevelTriggers.Fields` enum values. Silently ignores exceptions.
- **Properties**
- `TestSetupName`, `GroupSerialNumber`, `TestObjectChannelId`, `HardwareChannelId`, `SensorSerialNumber` (`string`, defaults `""`)
- `GreaterThanEnabled`, `LessThanEnabled` (`bool`, defaults `true`, `false`)
- `GreaterThanThresholdEU`, `LessThanThresholdEU` (`double`, defaults `0D`)
- `TriggerBetweenBounds`, `TriggerOutsideBounds` (`bool`, defaults `false`)
- `InsideUpperLevelEU`, `InsideLowerLevelEU`, `OutsideUpperLevelEU`, `OutsideLowerLevelEU` (`double`, defaults `0D`)
### `MMEFigures`
- **Constructor `MMEFigures(...)`**
Initializes all fields explicitly.
- **Static Method `GetFigures()`**
Queries `MMEFIGURES` table via `DbOperations.GetISOCommand()`, returns array of `MMEFigures`. Silently ignores exceptions during row processing.
- **Properties**
- `ID`, `IntAuthor`, `IntVersion` (`long`)
- `TxtShortName`, `TxtDescription`, `TxtRemarks`, `TxtImageFile`, `TxtSortKey`, `TxtPath`, `Last_Change_Text`, `History` (`string`)
- `DatRevision`, `Last_Change` (`DateTime`)
- `IntPage`, `IntPages` (`ushort`)
- `BolExpired` (`bool`)
- `BitStdPath` (`bool`)
- `IntIDStdPath` (`long`)
### `TestSetting` & `TestSettingDictionary`
- **`TestSetting`**
- **Constructor `TestSetting(string id, string value, string defaultValue)`**
- **`ToSerializeString()`**
Returns `"id=value"` with `=` replaced by `"_x_"` in both fields.
- **Static `TryParse(string s, out TestSetting ts)`**
Parses `"id=value"` format (reverses `"_x_"``"="`). Returns `false` if parsing fails.
- **`TestSettingDictionary`**
- **`GetValue(string ID, string defaultValue)`**
Returns `_lookup[ID].Value` if exists and non-null; otherwise `_lookup[ID].DefaultValue`; otherwise `defaultValue`.
- **`SetValue(TestSetting setting, string value)`**
Replaces entry for `setting.Id` with new `TestSetting` (preserves `Id`, `DefaultValue`, sets `Value = value`).
- **`SetValue(TestSetting setting)`**
Adds/updates entry with `setting`.
- **`SetValue(string id, string value)`**
Adds new entry or updates `Value` if key exists.
- **`ToSerializeString()` / `LoadSettings(string s)`**
Serializes/deserializes settings using `"id=value"` pairs separated by `CultureInfo.InvariantCulture.TextInfo.ListSeparator`, with internal `"_X_"` escaping.
### `TestEngineerDetails`
- **Constructor `TestEngineerDetails(DataRow dr)`**
Populates from `tblTestEngineerDetails` row.
- **Static Method `GetAllTestEngineerDetails()`**
Queries `tblTestEngineerDetails`, returns array. Silently ignores exceptions.
- **Properties**
- `Name`, `TestEngineerName`, `TestEngineerPhone`, `TestEngineerFax`, `TestEngineerEmail` (`string`; setters ignore empty strings for engineer fields)
- `LocalOnly` (`bool`)
- `LastModified` (`DateTime`)
- `LastModifiedBy` (`string`)
- `Version` (`int`, default `1`)
- **`GetValues()`**
Returns `Dictionary<string, string>` of all fields.
### `TestObjectMetaData` & `TestSetupMetaData`
- **`TestObjectMetaData`**
- **Constructor `TestObjectMetaData(char testobject)`**
Initializes properties from `Fields`, `CommentFields`, `OptionFields` enums. Sets `NOVALUE` defaults (except `VelocityOfTestObject`, `MassOfTestObject``""`).
- **Properties**
- `Version` (`double`, default `1.06`)
- `NOVALUE = "NOVALUE"`
- `TestObject` (`char`, default `'?'`)
- `Properties` (`MetaData[]`)
- **`TestSetupMetaData`**
- **Constructor `TestSetupMetaData(bool requireXCrashCompatibilityForISOExports)`**
Initializes properties from `Fields` enum. Sets `NOVALUE` or `""` based on `requireXCrashCompatibilityForISOExports`.
- **`SetProperty(MetaData meta, bool requireXCrashCompatibilityForISOExports)`**
Overrides `NOVALUE``""` for specific fields if `requireXCrashCompatibilityForISOExports` is `true`.
- **Properties**
- `Version` (`double`, default `1.06`)
- `NOVALUE = "NOVALUE"`, `MEDIADEFAULT = "1/1"`
- `TestObject = '_'`
- `Properties` (`MetaData[]`)
- **`MetaData`**
- **Constructor `MetaData(string name, bool optional, string value, double version)`**
- **Properties**
- `Name`, `Value` (`string`)
- `IsOptional`, `Version` (`bool`, `double`)
### `IsoCode`
- **Constructor `IsoCode(string isoCode)`**
Normalizes input to 16 characters (truncates or pads with `'?'`).
- **Static Methods**
- **`GetString(MMEPossibleChannels, MMETestObjects, MMEPositions, MMEFilterClasses)`**
Constructs 16-char ISO code from components. Uses `'?'` for null inputs.
- **`GetString(MMEPossibleChannels, bool careAboutTestTimeFields)`**
Same as above, but masks `TestObject` and `FilterClass` to `'?'` if `careAboutTestTimeFields == false`.
- **`GetString(string testObject, string position, string main, string floc1, string floc2, string floc3, string physdim, string dir, string fc)`**
Concatenates inputs into 16-char code (no padding/truncation).
- **Properties**
- `TestObject`, `Position`, `MainLocation`, `FineLocation1-3`, `PhysicalDimension`, `Direction`, `FilterClass` (read-write `string`; setters enforce 1-char/4-char/2-char constraints)
- `StringRepresentation` (`string`):
- Getter: returns full 16-char code.
- Setter: pads with `'0'` if shorter than 16.
### `CustomerDetails`
- **Constructor `CustomerDetails(DataRow dr)`**
Populates from `tblCustomerDetails` row.
- **Static Method `GetAllCustomerDetails()`**
Queries `tblCustomerDetails`, returns array. Silently ignores exceptions.
- **Properties**
- `Name`, `CustomerName`, `CustomerTestRefNumber` (`string`)
- `ProjectRefNumber`, `CustomerOrderNumber`, `CustomerCostUnit` (`string`; setters ignore empty strings)
- `LocalOnly` (`bool`)
- `LastModified` (`DateTime`)
- `LastModifiedBy` (`string`)
- `Version` (`int`, default `1`)
- **`GetValues()`**
Returns `Dictionary<string, string>` of all fields.
## 3. Invariants
- **`AbstractOLEDbWrapper`**:
- `GetLong` never throws on `DBNull`; returns `long.MinValue`.
- `GetDate` never throws on `DBNull`; returns `DateTime.MinValue`.
- **`TemplateZone`**:
- `ZoneName` defaults to `"Default zone"` only if `DBNull.Value` in DB row; otherwise preserved.
- `Description` defaults to `""` if `DBNull.Value` in DB row.
- **`TestObjectChannel`**:
- `HardwareId` setter enforces format: splits on `'_'`, expects 3 tokens, and reassembles first two tokens + suffix from third token after first `'x'`.
- `CompareTo` uses `DisplayOrder` as primary key; `Name` as secondary; `SerialNumberOrOriginalSerialNumber` as tertiary (if both non-null).
- **`CalculatedValueClass`**:
- `InputChannelIdsBlob` getter/setter uses `CultureInfo.InvariantCulture.TextInfo.ListSeparator` (typically `','`), not locale-specific.
- `CalculatedValueCode` defaults to `"???????????????X"` (15 chars + `'X'`).
- **`IsoCode`**:
- `StringRepresentation` setter pads with `'0'` if input < 16 chars.
- All individual properties enforce fixed widths:
- `TestObject`, `Position`, `Direction`, `FilterClass`: 1 char
- `MainLocation`: 4 chars
- `FineLocation1-3`: 2 chars each
- `PhysicalDimension`: 2 chars
- Total length always 16 characters.
- **`TestSettingDictionary`**:
- `ToSerializeString` escapes `ListSeparator``"_X_"` in serialized values.
- `LoadSettings` preserves existing default settings; only updates `Value` if key exists.
## 4. Dependencies
### Internal Dependencies
- **`DbOperations`** (referenced via `DbOperations.GetCommand()`, `DbOperations.GetISOCommand()`, `DbOperations.CreateParam()`, `DbOperations.Connection.QueryDataSet()`):
Provides database access utilities (SQL command creation, parameterization, query execution).
- **`ISO.TestObject`** (used in `TestObjectChannel.TestObject`):
Referenced but not defined in provided files.
- **`ISO.TestObjectTemplate`** (used in `TestObjectChannel` constructor):
Referenced but not defined in provided files.
- **`Hardware`** (used in `ISOHardwareChannel.ParentDAS`):
Referenced but not defined in provided files.
- **`MMEPossibleChannels`, `MMETestObjects`, `MMEPositions`, `MMEFilterClasses`** (used in `IsoCode.GetString`):
Referenced but not defined in provided files.
### External Dependencies
- **`System.Data`** (`System.Data.OleDb`, `System.Data.SqlClient`):
Used for `IDataReader`, `DataRow`, `SqlDbType`, `OleDbCommand`.
- **`System.Text`**:
Used for `StringBuilder`, `Encoding.UTF8`.
- **`System.Drawing`**:
Used for `System.Drawing.Point` in `TemplateRegion.UpperLeft/LowerRight`.
- **`System.Globalization`**:
Used for `CultureInfo.InvariantCulture.TextInfo.ListSeparator`.
### Inferred Usage
- `TemplateRegion.GetAllRegions()` and `TestEngineerDetails.GetAllTestEngineerDetails()`/`CustomerDetails.GetAllCustomerDetails()` imply database persistence layer.
- `TestSettingDictionary` serialization suggests configuration storage/retrieval (e.g., XML, DB).
- `CalculatedValueClass` and `LevelTriggerChannel` imply integration with channel processing logic.
## 5. Gotchas
- **`AbstractOLEDbWrapper.GetDate`**:
Returns `DateTime.MinValue` for `DBNull`, which may be ambiguous if `DateTime.MinValue` is a valid value in the domain. Consider using `DateTime?` or sentinel values.
- **`TestObjectChannel.HardwareId` setter**:
Mutates input by stripping characters after first `'x'` in the third token. This may cause data loss if `'x'` appears elsewhere in the hardware ID.
- **`CalculatedValueClass.InputChannelIdsBlob`**:
Uses `