--- source_files: - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/IServicePublic.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SerializedSettings.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/CustomChannel.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/TestGraph.cs generated_at: "2026-04-16T04:56:56.352649+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "8e151bb0bac120f4" --- # DatabaseExport ## Documentation: `DatabaseExport` Module (Version 57) --- ### 1. **Purpose** This module provides data structures and serialization utilities for exporting and managing test configuration data in **Version 57** of the database schema. It defines core channel types (`DASChannel`, `DASOutputChannel`, `DigitalOutputDASChannel`, `OutputSquibChannel`, `OutputTOMDigitalChannel`) used to represent hardware I/O configurations, along with supporting classes for custom channels (`CustomChannel`, `CustomChannelList`), serialized application settings (`SerializedSettings`), and graph configuration (`TestGraph`). The module enables persistence of user-defined test setups—including channel assignments, thresholds, and hardware-specific modes—by mapping them to database-compatible formats (e.g., SQL string encodings for thresholds and channel lists). It serves as a legacy compatibility layer for older database versions, preserving backward compatibility with prior schema definitions. --- ### 2. **Public Interface** #### `DASChannel` - **Type**: `class` - **Attributes**: `[Serializable]` - **Description**: Base class for all DAS (Data Acquisition System) channels. No public members defined. #### `OutputDASChannel : DASChannel` - **Type**: `class` - **Attributes**: `[Serializable]` - **Description**: Base class for output channels. #### `DigitalOutputDASChannel : OutputDASChannel` - **Type**: `class` - **Attributes**: `[Serializable]` - **Description**: Represents a digital output channel. #### `OutputTOMDigitalChannel : DigitalOutputDASChannel` - **Type**: `class` - **Attributes**: `[Serializable]` - **Description**: Base class for SQUIB digital output channels. - **Nested Enum**: `DigitalOutputMode` - `NONE = 0` - `FVLH = 1 << 0` (5V, low-to-high transition) - `FVHL = 1 << 1` (5V, high-to-low transition) - `CCNO = 1 << 2` (contact closure, normally open) - `CCNC = 1 << 3` (contact closure, normally closed) #### `OutputSquibChannel` - **Type**: `class` - **Attributes**: `[Serializable()]` - **Description**: Base class for SQUIB output channels. - **Nested Enums**: - `SquibFireMode` - `NONE = 1 << 0` - `CAP = 1 << 1` (capacitor discharge) - `CONSTANT = 1 << 2` (constant current discharge) - `AC = 1 << 3` (AC discharge) - `SquibMeasurementType` - `NONE = 0` - `CURRENT = 1 << 0` - `INIT_SIGNAL = 1 << 1` - `VOLTAGE = 1 << 2` #### `SerializedSettings` - **Type**: `sealed class` - **Nested Enum**: `Keys` Contains **120+** static string-based keys for global settings (e.g., `ExportINIFile`, `DefaultIsoChannelSensorCompatibilityLevel`, `RealtimeSampleRates`, `SLICE6_PowerSetting`, `SPSINDEX_0` through `SPSINDEX_23`, etc.). - **Public Properties** (selected examples): - `ExportINIFile`: `string` Gets/sets the path to the export INI file (default: `""`). Uses `SettingsDB.GetGlobalValue`/`SetGlobalValue`. - `IsoChannelSensorCompatibilityLevel`: `IsoChannelSensorCompatibilityLevels` Gets/sets the default compatibility level for ISO channels (default: `Warn`). Parses from string via `SettingsDB`. - `TestSetupAutomaticMode`: `bool` Gets/sets whether Test Setup defaults to automatic mode (default: `false`). - `TestSetupDefaultCommonStatusLine`: `bool` Gets/sets whether to show a common status line in Test Setup (default: `true`). - `TestSetupAutomaticProgressDelayMS`: `int` Gets/sets delay (ms) before automatic progress in Test Setup (default: `0`). - `ISOSupportLevel`: `ISOSupportLevels` Gets/sets ISO support mode (default: `ISO_ONLY`). Enum values: - `ISO_ONLY` - `TRANSITORY` - `NO_ISO` #### `CustomChannel : IComparable` - **Type**: `class` - **Description**: Wrapper for `MMEPossibleChannels` to support user-defined (non-ISO13499) channels. Mirrors database tables without modifying the core ISO schema. - **Properties**: - `Channel`: `MMEPossibleChannels` (read-only) - `TestObject`, `Position`, `MainLocation`, `FinLoc1`, `FinLoc2`, `FinLoc3`, `PhysicalDimension`, `Direction`, `FilterClass`: Getters/setters that propagate changes to `Channel` via `Set_*` methods (e.g., `Channel.Set_Test_Object(...)`). - `Text1`: `string` → `Channel.Text_L1` - `Remarks`: `string` → `Channel.Remarks` - **Methods**: - `CustomChannel(MMEPossibleChannels channel, bool newChannel = true)` Constructor initializes backing fields from `ISO13499FileDb.IsoDb`, catching `ExpiredISOFieldException` in `_expiredErrors`. - `CompareTo(CustomChannel other)`: `int` Compares by `Text1` (ordinal string comparison). - `GetValues()`: `Dictionary` Returns all channel fields as key-value pairs (keys: `DbOperations.MMETables.MMEPossibleChannelsFields.*` enum names; values: string representations). #### `CustomChannelList` - **Type**: `class` - **Description**: Singleton list of all custom channels loaded from `ISO13499FileDb.IsoDb`. - **Properties**: - `List`: `CustomChannelList` (static, thread-safe singleton) - `AllChannels`: `CustomChannel[]` Returns all channels (lazy-loaded via `PopulateChannelsIfNecessary()`). - **Methods**: - `PopulateChannelsIfNecessary()`: `void` Loads channels from `ISO13499FileDb.IsoDb.GetSQLPossibleChannels()`, wraps each in `CustomChannel`, sorts by `Text1`. #### `TestGraph` - **Type**: `class` - **Description**: Represents a test graph configuration, including channels, thresholds, and axis ranges. - **Constants**: - `SEPARATOR = "§"` - `CURRENT_SUFFIX = "_CU"` - **Properties**: - `GraphName`, `GraphDescription`: `string` - `UseDomainMin/Max`, `DomainMin/Max`, `UseRangeMin/Max`, `RangeMin/Max`: `bool`/`double` - `Thresholds`: `double[]` - `Channels`: `TestObjectChannel[]` Returns channels *currently assigned* to the graph (filtered by presence in `_groups`/`_addedGroups`). - `AvailableChannels`: `TestObjectChannel[]` Returns all channels *available* for assignment (from `_groups`/`_addedGroups`, including SQUIB Current/Voltage variants). - **Methods**: - `GetThresholdsSQL()`: `string` Encodes thresholds as `{(t1)§(t2)§...}`. - `SetThresholdsFromSQL(string sThresholds)`: `void` Parses `{(t1)§(t2)§...}` into `_thresholds`. - `GetChannelsForSQL()`: `string` Encodes channel IDs as `{(id1)§(id2)§...}` after resolving channel IDs (handles SQUIB Current suffix `_CU`). - `SetChannelsFromSQL(string sChannels)`: `void` Parses channel IDs and populates `_channels` via `AddChannel`. - `GetTestGraphKey(TestObjectChannel ch)`: `string` Generates key: `__`; appends `_CU` for SQUIB Current channels. --- ### 3. **Invariants** - **Channel Serialization**: - Thresholds and channel lists are encoded as SQL-compatible strings using `{...}` delimiters and `§` separators. - SQUIB Current channels are uniquely identified by appending `"_CU"` to their graph key (see `GetTestGraphKey`). - **CustomChannel Consistency**: - Setting any property (e.g., `TestObject`, `Position`) immediately propagates the value to the underlying `Channel` object via `Set_*` methods. - `CustomChannel` instances are compared *only* by `Text1` (ordinal comparison). - **Singleton Safety**: - `CustomChannelList.List` uses double-checked locking (`lock(MyLock)`) for thread-safe initialization. - **Settings Persistence**: - All `SerializedSettings` properties delegate to `SettingsDB.GetGlobalValue*`/`SetGlobalValue*` methods (e.g., `GetGlobalValueBool`, `SetGlobalValueInt`). - Enum properties fall back to defaults on parse failure. --- ### 4. **Dependencies** #### **Internal Dependencies** - `ISO13499FileDb.IsoDb`: Used by `CustomChannel` to resolve ISO fields (e.g., `GetMainLocationByIso`, `GetFilterClassByIso`). - `DbOperations.MMETables.*`: Enumerations for field names (e.g., `MMEPossibleChannelsFields.ID`). - `Test.Module.Channel.Sensor.BridgeType`: Used in `TestGraph.AddChannels` to detect SQUIB sensors (`BridgeType.SQUIB`). - `SensorsCollection.SensorsList`: Used in `TestGraph` to retrieve sensor metadata (e.g., `IsDigitalOutput()`, `Bridge` type). - `SettingsDB`: Static class for global settings persistence (used by `SerializedSettings`). - `TestTemplate`, `TestTestObject`, `TestObjectChannel`: Referenced but not defined in these files (assumed to be in other modules). #### **External Dependencies** - `System` (core types: `SerializableAttribute`, `Enum`, `string`, `List`, `Dictionary`, `CultureInfo`, `StringBuilder`, `Linq`). #### **Dependents** - Likely consumed by: - Database export/import logic (e.g., saving/loading test setups). - Test Setup UI (for channel assignment, graph configuration). - Settings persistence layer (e.g., `SerializedSettings` usage). --- ### 5. **Gotchas** - **SQUIB Channel Handling**: - `TestGraph` *dynamically* adds SQUIB Current and Voltage channels to `AvailableChannels` if not already present. The Current variant is uniquely keyed with `"_CU"` suffix. - `ContainsCurrentChannel` checks for `"_CU"` suffix, but `ContainsVoltageChannel` does not—this asymmetry may cause issues if Voltage channels are later renamed or re-keyed. - **Channel ID Resolution**: - `GetChannelsForSQL()` refreshes `_channels` by resolving against `AvailableChannels` (to handle ID changes post-creation). This may silently drop channels if their keys no longer resolve. - **`CustomChannel` Constructor**: - `MMEPossibleChannels` is *copied* if `newChannel == true` (via `new MMEPossibleChannels(channel)`), but *shared* otherwise. This could lead to unintended side effects if the original `channel` is mutated. - `ExpiredISOFieldException` is caught and stored in `_expiredErrors`, but this list is not exposed—consumers cannot detect or handle expired fields. - **Settings Parsing**: - `SerializedSettings` properties use `Enum.TryParse` with fallback to defaults. If the stored string is invalid (e.g., `"UNKNOWN"`), the default is used silently—no logging or error is raised. - **Hardcoded Delimiters**: - `TestGraph` uses `"§"` as a separator. If this character appears in channel IDs or threshold values, parsing will break. - **Missing Type Safety**: - Thresholds are hardcoded as `double` in `SetThresholdsFromSQL`, but the comment notes future extensibility. No validation ensures only doubles are stored. - **`CustomChannelList` Initialization**: - `_dictChannels` (commented out) suggests a previous attempt to cache by ISO code. Its removal may impact performance if lookups by ISO code are frequent. > **None identified from source alone.** > *(Note: The above "gotchas" are inferred from code structure and behavior—not external documentation.)*