Files

131 lines
8.7 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common.Storage/Classes/NoDBAccessException.cs
- Common/DTS.Common.Storage/Classes/DigitalInputSettings.cs
- Common/DTS.Common.Storage/Classes/DbTypeAttr.cs
- Common/DTS.Common.Storage/Classes/DAS.cs
- Common/DTS.Common.Storage/Classes/MMETables.cs
generated_at: "2026-04-16T02:10:51.158458+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "ad177a41b5582582"
---
# Classes
## Documentation: `DTS.Storage` Common Storage Types
---
### 1. Purpose
This module defines core data model types and metadata used for interacting with a proprietary database in the DTS (Data Acquisition and Test System) ecosystem. It provides strongly-typed constants for table and column names, custom exception types for access control, and reflection-based utilities for mapping .NET enum values to database-specific type strings. Its role is to decouple database schema knowledge from business logic, enabling type-safe, maintainable data access across the system.
---
### 2. Public Interface
#### `NoDBAccessException`
- **Signature**: `public class NoDBAccessException : Exception`
- **Behavior**: A custom exception class wrapping another exception (`ex`) to indicate a database access denial or failure. It preserves the original exceptions message and inner exception.
#### `DigitalInputSettings`
- **Fields**:
- `public const string Table = "tblDigitalInputSetting";`
- `public enum Fields { ... }`
Enumerates column names for the `tblDigitalInputSetting` table:
`SettingName`, `SettingMode`, `ScaleMultiplier`, `LastModified`, `LastModifiedBy`, `SensorId`, `UserValue1`, `UserValue2`, `UserValue3`, `UserTags`.
#### `DbTypeAttr`
- **Fields**:
- `public string DbType { get; }` Stores the database type string.
- **Methods**:
- `public static string GetDbType(object o)` Uses reflection to retrieve the `DbType` string associated with an enum *value* (via its `MemberInfo`). Returns `null` if no attribute is found.
#### `DAS`
- **Fields**:
- `public const string Table = "tblDAS";`
- `public enum Fields { ... }`
Enumerates columns for `tblDAS`:
`SerialNumber`, `Type`, `MaxModules`, `MaxMemory`, `MaxSampleRate`, `MinSampleRate`, `FirmwareVersion`, `CalDate`, `ProtocolVersion`, `LastModified`, `LastModifiedBy`, `Version`, `LocalOnly`, `LastUsed`, `LastUsedBy`, `Connection`, `Channels`, `Position`, `ChannelTypes`, `Reprogramable`, `Reconfigurable`, `IsModule`.
- `public const string TableDASChannels = "tblDASChannels";`
- `public enum DASChannelFields { ... }`
Enumerates columns for `tblDASChannels`:
`HardwareId`, `ChannelIdx`, `SupportedBridges`, `SupportedExcitations`, `DASDisplayOrder`, `LocalOnly`, `SupportedDigitalInputModes`, `SupportedSquibFireModes`, `SupportedDigitalOutputModes`, `ModuleSerialNumber`, `ModuleArrayIndex`.
- **Prototype Constants**:
A large set of `public const string` values representing known DAS hardware prototypes (e.g., `"SLICE1 Prototype"`, `"G5 VDS Prototype"`, `"SLICE PRO Lab TOM"`). Used for identifying device types.
#### `MMETables`
- **Fields**:
- `public const string MyType = "MyType";`
Legacy table name (used up to version 1.3.496), superseded by `CustomChannelType`.
- `public const string CustomChannelType = "CustomChannelType";`
Intermediate table name (versions 1.3.4981.3.515), superseded by `"TYPE"`.
- `public const string Id = "Id";`
Legacy column name (up to 1.3.515), superseded by `"ID"`.
- **Table Names & Field Enums**:
- `MMEPossibleChannelsTable = "tblMMEPossibleChannels"`
`MMEPossibleChannelsFields` enum with fields like `ID`, `TYPE`, `TEST_OBJECT`, `POSITION`, `PHYSICAL_DIMENSION`, `DIRECTION`, `DEFAULT_FILTER_CLASS`, `TEXT_L1`, `TEXT_L2`, `VERSION`, `DATE`, `REMARKS`, `EXPIRED`, `SORTKEY`, `PICTURE_SHORTNAME`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`.
Several fields are annotated with `[CustomChannelFieldSize(n)]` (not defined in this file—likely elsewhere).
- `MMEDirectionsTable = "tblMMEDirections"`
`MMEDirectionsFields` enum: `s_GUID`, `DIRECTION`, `TEXT_L1`, `TEXT_L2`, `DATE`, `VERSION`, `EXPIRED`, `REMARKS`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`, `SORTKEY`.
- `MMEFilterClassesTable = "tblMMEFilterClasses"`
`MMEFilterClassesFields` enum: `s_GUID`, `FILTER_CLASS`, `TEXT_L1`, `TEXT_L2`, `VERSION`, `DATE`, `REMARKS`, `EXPIRED`, `SORTKEY`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`.
- `MMEFineLocations1Table`, `MMEFineLocations2Table`, `MMEFineLocations3Table`
Corresponding enums with `s_GUID`, location field (`FINE_LOC_1`/`2`/`3`), `TEXT_L1`, `TEXT_L2`, `VERSION`, `DATE`, `REMARKS`, `EXPIRED`, `SORTKEY`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`.
- `MMEPhysicalDimensions = "tblMMEPhysicalDimensions"`
`MMEPhysicalDimensionFields` enum includes `s_GUID`, `PHYSICAL_DIMENSION`, `TEXT_L1`, `TEXT_L2`, `DEFAULT_UNIT`, dimensional exponents (`LENGTH_EXP`, `TIME_EXP`, etc.), `VERSION`, `DATE`, `REMARKS`, `EXPIRED`, `SORTKEY`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`.
- `MMEPositionsTable = "tblMMEPositions"`
`MMEPositionsFields` enum: `s_GUID`, `POSITION`, `TEXT_L1`, `TEXT_L2`, `VERSION`, `DATE`, `REMARKS`, `EXPIRED`, `SORTKEY`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`.
- `MMETestObjectsTable = "tblMMETestObjects"`
`MMETestObjectsFields` enum: `s_GUID`, `TEST_OBJECT`, `TEXT_L1`, `TEXT_L2`, `VERSION`, `DATE`, `REMARKS`, `EXPIRED`, `SORTKEY`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`.
- `MMEMainLocationTable = "tblMMEMainLocations"`
`MMEMainLocationsFields` enum: `s_GUID`, `TYPE`, `TRANS_MAIN_LOC`, `TEXT_L1`, `TEXT_L2`, `VERSION`, `DATE`, `REMARKS`, `EXPIRED`, `SORTKEY`, `PICTURE_SHORTNAME`, `LAST_CHANGE`, `LAST_CHANGE_TEXT`, `HISTORY`.
> **Note**: `[CustomChannelFieldSize(n)]` is referenced in `MMETables` but *not defined in the provided source files*. Its definition is unknown.
---
### 3. Invariants
- **`DbTypeAttr.GetDbType` behavior**:
- Only inspects the *first* member info (`mi[0]`) returned by `GetType().GetMember(o.ToString())`.
- Returns `null` if the object is `null`, no member is found, or no `DbTypeAttr` is applied to the enum value.
- Assumes the enum values name matches a member name on its type (standard for `enum.ToString()`).
- **Table/column naming**:
- Table names are hardcoded string constants (e.g., `"tblDAS"`, `"tblMMEPossibleChannels"`).
- Field names in enums map directly to database column names (e.g., `DAS.Fields.SerialNumber``"SerialNumber"`).
- **Versioning semantics**:
- `MyType`, `CustomChannelType`, and `Id` are explicitly marked as legacy. Their usage is version-gated in the system (not enforced in this module).
- **Prototype constants**:
- All prototype names are exact string literals; no normalization or canonicalization is performed in this module.
---
### 4. Dependencies
- **Dependencies *of* this module**:
- `System` (for `Exception`, `Attribute`, `MemberInfo`, `Reflection`).
- No external libraries beyond .NET Framework base types.
- **Dependencies *on* this module**:
- Any module performing database access using these schema constants (e.g., data access layers, configuration tools, migration scripts).
- Code that uses `DbTypeAttr` for dynamic SQL generation or type mapping.
- Modules handling DAS device metadata (e.g., device discovery, configuration, calibration).
- Modules managing MME (likely "Measurement Model Exchange") metadata (e.g., channel definition, test setup, reporting).
---
### 5. Gotchas
- **`[CustomChannelFieldSize]` is undefined here**:
The `MMETables` enum uses `[CustomChannelFieldSize(n)]` attributes, but this attribute type is *not defined* in the provided source. Its behavior and usage are unknown.
- **`DbTypeAttr.GetDbType` is fragile**:
Relies on `GetMember(o.ToString())`, which may fail or return unexpected results if enum values have custom names or if reflection is blocked (e.g., in some AOT or security contexts).
- **Legacy table/column names are *not* handled programmatically**:
`MyType`, `CustomChannelType`, and `Id` are documented as historical, but no runtime logic is present to select the correct name based on version. Consumers must manage version compatibility themselves.
- **Prototype strings are magic**:
All `PROTOTYPE` constants are raw strings. No validation or enum-based safety prevents typos or mismatches in device type identification.
- **No validation in `NoDBAccessException`**:
The constructor accepts any `Exception`, including `null` (though `ex.Message` would throw if `ex` is `null`). This may lead to `NullReferenceException` at construction time if misused.
- **Case sensitivity**:
Enum field names (e.g., `ID` vs `Id`) are used verbatim. Ensure database column names match *exactly* (case-sensitive in some DBMSs).