Files
2026-04-17 14:55:32 -04:00

126 lines
15 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
source_files:
- Common/DTS.Common.Storage/Classes/Abstract/MMEPossibleChannels.cs
- Common/DTS.Common.Storage/Classes/Abstract/DbVersions.cs
- Common/DTS.Common.Storage/Classes/Abstract/Settings.cs
- Common/DTS.Common.Storage/Classes/Abstract/VersionTable.cs
- Common/DTS.Common.Storage/Classes/Abstract/TestObjectChannelSettings.cs
- Common/DTS.Common.Storage/Classes/Abstract/Tags.cs
- Common/DTS.Common.Storage/Classes/Abstract/DigitalOutputSettings.cs
- Common/DTS.Common.Storage/Classes/Abstract/LabratoryDetails.cs
- Common/DTS.Common.Storage/Classes/Abstract/Squib.cs
- Common/DTS.Common.Storage/Classes/Abstract/CalculatedChannels.cs
- Common/DTS.Common.Storage/Classes/Abstract/Users.cs
- Common/DTS.Common.Storage/Classes/Abstract/LevelTriggers.cs
- Common/DTS.Common.Storage/Classes/Abstract/SensorDB.cs
- Common/DTS.Common.Storage/Classes/Abstract/TestSetups.cs
generated_at: "2026-04-16T02:11:23.946439+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "275c64f80988749d"
---
# Abstract
## Documentation: Storage Abstraction Layer Table and Field Constants
---
### 1. Purpose
This module provides a centralized, strongly-typed abstraction layer for database schema metadata within the DTS Storage subsystem. It defines `abstract` classes containing `const string` table names and `enum` types for field names across multiple database tables (e.g., `tblSettings`, `tblSensors`, `tblTestSetups`). These constants are used throughout the codebase to avoid hard-coded string literals in SQL queries, ORM mappings, or data access logic—ensuring consistency, reducing typos, and enabling refactoring safety. The module does *not* contain business logic, data access implementations, or validation; it is purely a metadata definition layer.
---
### 2. Public Interface
All types are `abstract` classes with no instance members. Public members are `const` strings and `enum` declarations.
| Type | Member | Signature | Description |
|------|--------|-----------|-------------|
| `MMEPossibleChannels` | `Table` | `public const string Table = "tblMMEPossibleChannels";` | Table name for MME possible channel configurations. |
| `DbVersions` | `DbVersionFields` | `public enum DbVersionFields { Version, Step, Date, Remarks, UserField }` | Field names for the database version tracking table (unspecified table name in source). |
| `Settings` | `Table` | `public const string Table = "tblSettings";` | Table name for user/application settings. |
| `Settings` | `UserFields` | `public enum UserFields { PropertyId, PropertyType, PropertyValue, UserId }` | Field names for the `tblSettings` table. |
| `VersionTable` | `TableName` | `public const string TableName = "tblDataPRODbVersion";` | Table name for version tracking (distinct from `DbVersions` table reference). |
| `VersionTable` | `Fields` | `public enum Fields { Version, Step, Date, Remarks, UserField }` | Field names for `tblDataPRODbVersion`. |
| `TestObjectChannelSettings` | `TableName` | `public const string TableName = "tblTestObjectChannelSettings";` | Table name for per-test-object channel configuration. |
| `TestObjectChannelSettings` | `Fields` | `public enum Fields { TestObjectSerial, ChannelId, Setting, SensorSerial }` | Field names for `tblTestObjectChannelSettings`. |
| `Tags` | `Table` | `public const string Table = "tblTags";` | Table name for tag definitions. |
| `Tags` | `TagFields` | `public enum TagFields { TagId, TagText, Obsolete }` | Field names for `tblTags`. |
| `Tags` | `TAGASSIGNMENTS_TABLE` | `public const string TAGASSIGNMENTS_TABLE = "TagAssignments";` | Table name for tag assignments (note: no `tbl` prefix). |
| `Tags` | `TagAssignmentFields` | `public enum TagAssignmentFields { ObjectID, ObjectType, TagID }` | Field names for `TagAssignments`. |
| `DigitalOutputSettings` | `Table` | `public const string Table = "tblTOMDigitalChannels";` | Table name for digital output channel settings. |
| `DigitalOutputSettings` | `Fields` | `public enum Fields { ChannelDescription, DelayMS, DurationMS, OutputMode, LimitDuration, LastModified, LastModifiedBy, Version, LocalOnly, DurationMSFloat, UserTags }` | Field names for `tblTOMDigitalChannels`. |
| `LabratoryDetails` | `Table` | `public const string Table = "tblLabratoryDetails";` | Table name for laboratory metadata (note: typo in table name: *Labratory* vs *Laboratory*). |
| `LabratoryDetails` | `LabratoryDetailsFields` | `public enum LabratoryDetailsFields { Name, LabratoryName, LabratoryContactName, LabratoryContactPhone, LabratoryContactFax, LabratoryContactEmail, LabratoryTestRefNumber, LabratoryProjectRefNumber, LastModified, LastModifiedBy, LocalOnly, Version }` | Field names for `tblLabratoryDetails`. |
| `Squib` | `Table` | `public const string Table = "tblTOMSquibChannels";` | Table name for squib (explosive device) channel settings. |
| `Squib` | `Fields` | `public enum Fields { SquibDescription, BypassCurrentFilter, BypassVoltageFilter, DelayMS, DurationMS, FireMode, ISOCode, MeasurementType, SquibOutputCurrent, SquibToleranceLow, SquibToleranceHigh, LimitDuration, ArticleId, LocalOnly, Version, LastModified, LastModifiedBy, UserValue1, UserValue2, UserValue3, UserTags }` | Field names for `tblTOMSquibChannels`. |
| `CalculatedChannels` | `Table` | `public const string Table = "tblCalculatedChannels";` | Table name for calculated channel definitions. |
| `CalculatedChannels` | `Fields` | `public enum Fields { Id, Operation, CalculatedChannelValueCode, InputChannelIds, CFCForInputChannels, CFCForOutput, TestSetupName, CCName }` | Field names for `tblCalculatedChannels`. <br> **Note**: Fields use `[DbTypeAttr(...)]` attributes (e.g., `Id` is `INTEGER PRIMARY KEY NOT NULL`). |
| `Users` | `USERS_TABLE` | `public const string USERS_TABLE = "DataPROUsers";` | Table name for user accounts (no `tbl` prefix). |
| `Users` | `UserFields` | `public enum UserFields { ID, UserName, DisplayName, Password, Role, LastModified, LastModifiedBy, LocalOnly }` | Field names for `DataPROUsers`. |
| `Users` | `UIITEMS_TABLE` | `public const string UIITEMS_TABLE = "UIITEMS";` | Table name for UI item definitions (no `tbl` prefix). |
| `Users` | `UIItemFields` | `public enum UIItemFields { ID, Name }` | Field names for `UIITEMS`. |
| `Users` | `USERUISETTINGS_TABLE` | `public const string USERUISETTINGS_TABLE = "UserUIItemSettings";` | Table name for per-user UI settings (no `tbl` prefix). |
| `Users` | `UserUIItemSettingFields` | `public enum UserUIItemSettingFields { UserId, UIItemID, Permission, Visible }` | Field names for `UserUIItemSettings`. |
| `LevelTriggers` | `Table` | `public const string Table = "tblLevelTriggers";` | Table name for level-triggering conditions. |
| `LevelTriggers` | `Fields` | `public enum Fields { TestSetupName, GroupSerialNumber, TestObjectChannelId, HardwareChannelId, SensorSerialNumber, GreaterThanEnabled, GreaterThanEU, LessThanEnabled, LessThanEU, InsideUpperEU, InsideLowerEU, OutsideUpperEU, OutsideLowerEU, TriggerInside, TriggerOutside }` | Field names for `tblLevelTriggers`. <br> **Note**: Fields use `[DbTypeAttr(...)]` attributes (e.g., `GreaterThanEnabled` is `BIT NOT NULL`). |
| `SensorDB` | `SensorCalibrationTable` | `public const string SensorCalibrationTable = "tblSensorCalibrations";` | Table name for sensor calibration records. |
| `SensorDB` | `SensorDataTable` | `public const string SensorDataTable = "tblSensors";` | Table name for sensor definitions. |
| `SensorDB` | `SensorModelsTable` | `public const string SensorModelsTable = "tblSensorModels";` | Table name for sensor model templates. |
| `SensorDB` | `SensorDataFields` | `public enum SensorDataFields { SerialNumber, UserSerialNumber, Model, ... }` (48 fields) | Field names for `tblSensors`. Includes metadata (e.g., `Version`, `LocalOnly`, `UserTags`, `Broken`). |
| `SensorDB` | `SensorModelFields` | `public enum SensorModelFields { Model, Manufacturer, UserPartNumber, ... }` (32 fields) | Field names for `tblSensorModels`. |
| `SensorDB` | `SensorCalibrationFields` | `public enum SensorCalibrationFields { SerialNumber, CalibrationDate, Username, ... }` (10 fields) | Field names for `tblSensorCalibrations`. |
| `SensorDB` | `SensorCalibrationRecordFields` | `public enum SensorCalibrationRecordFields { Sensitivity, Poly, AtCapacity, ... }` (7 fields) | Field names for calibration records *within* `tblSensorCalibrations` (likely stored as serialized data, e.g., BLOB). |
| `TestSetups` | `HardwareTable` | `public const string HardwareTable = "tblTestSetupHardware";` | Table for test setuphardware associations. |
| `TestSetups` | `HardwareFields` | `public enum HardwareFields { TestSetupName, HardwareId, AddOrRemove }` | Field names for `tblTestSetupHardware`. `AddOrRemove` uses `0=remove, 1=add`. |
| `TestSetups` | `DASSettingsTable` | `public const string DASSettingsTable = "tblTestSetupDASSettings";` | Table name for DAQ settings (no fields enum provided). |
| `TestSetups` | `ChannelSettingsTable` | `public const string ChannelSettingsTable = "tblTestChannelSettings";` | Table name for test channel settings. |
| `TestSetups` | `ChannelSettingFields` | `public enum ChannelSettingFields { TestName, TestObjectName, ChannelId, Setting, SensorSerial }` | Field names for `tblTestChannelSettings`. |
| `TestSetups` | `TestSetupsTable` | `public const string TestSetupsTable = "tblTestSetups";` | Table name for test setup definitions. |
| `TestSetups` | `Fields` | `public enum Fields { SetupName, SetupDescription, AutomaticTestProgression, ... }` (64 fields) | Field names for `tblTestSetups`. Includes flags (`ROIDownload`, `ViewRealtime`), paths (`ExportFolder`), and behavior controls (`StrictDiagnostics`, `RequireConfirmationOnErrors`). |
| `TestSetups` | `TestSetupObjectsTable` | `public const string TestSetupObjectsTable = "tblTestSetupObjects";` | Table for test objects assigned to a test setup. |
| `TestSetups` | `TestSetupObjectFields` | `public enum TestSetupObjectFields { TestObjectSerialNumber, TestSetupName, TargetSampleRate, ... }` | Field names for `tblTestSetupObjects`. |
| `TestSetups` | `TestObjectMetaDataTable` | `public const string TestObjectMetaDataTable = "tblTestSetupObjectMetaData";` | Table for test object metadata key-value pairs. |
| `TestSetups` | `TestObjectMetaDataFields` | `public enum TestObjectMetaDataFields { TestObject, SetupName, PropName, PropValue, Optional, Version }` | Field names for `tblTestSetupObjectMetaData`. |
| `TestSetups` | `TestObjectTemplatesTable` | `public const string TestObjectTemplatesTable = "tblTestObjectTemplates";` | Table for test object templates. |
| `TestSetups` | `TestObjectTemplatesFields` | `public enum TestObjectTemplatesFields { TemplateName, Icon, Description, ... }` | Field names for `tblTestObjectTemplates`. Includes `CRC32`, `SysBuilt`, and `ParentTemplate`. |
| `TestSetups` | `TestObjectsTable` | `public const string TestObjectsTable = "tblTestObjects";` | Table for test object definitions. |
| `TestSetups` | `TestObjectsFields` | `public enum TestObjectsFields { SerialNumber, LastModifiedBy, LastModified, Template, ... }` | Field names for `tblTestObjects`. Tracks templates, embedding, and original serial numbers. |
| `TestSetups` | `TestGraphsTable` | `public const string TestGraphsTable = "tblTestGraphs";` | Table for test graph configurations. |
| `TestSetups` | `GraphFields` | `public enum GraphFields { GraphName, GraphDescription, TemplateName, Channels, UseDomainMin, DomainMin, ... }` | Field names for `tblTestGraphs`. Includes axis ranges and thresholds. |
---
### 3. Invariants
- **No instance state**: All classes are `abstract` and contain only `const` and `enum` members. No runtime behavior or state is defined.
- **Case sensitivity**: Table and field names are case-sensitive string literals (e.g., `tblSettings`, not `tblsettings`).
- **Naming consistency**:
- Table names use `tbl` prefix for most tables (e.g., `tblSensors`, `tblTestSetups`), but exceptions exist: `DataPROUsers`, `UIITEMS`, `UserUIItemSettings`, `TagAssignments`.
- Enum names follow `XxxFields` or `XxxFields` pattern (e.g., `SensorDataFields`, `UserFields`).
- **Field ordering**: Enum values are *not* explicitly assigned integer values (except `SensorDataFields.SerialNumber = 1`), so their underlying values are sequential starting from `0` (or `1` for `SerialNumber`).
- **Type annotations**: `[DbTypeAttr(...)]` attributes (e.g., on `CalculatedChannels.Id` and `LevelTriggers` fields) are present in source but are *not* part of the runtime type system—likely custom attributes for code generation or ORM mapping. Their presence does not affect the enum/const definitions themselves.
---
### 4. Dependencies
- **No external dependencies**: None of the files reference `using` directives or external types. All types are self-contained within the `DTS.Storage` or `Storage.Classes.Abstract` namespaces.
- **Consumers**: This module is intended to be referenced by data access layers, migration scripts, or ORM configurations elsewhere in the codebase (e.g., to build SQL queries like `SELECT {TestSetups.Fields.SetupName} FROM {TestSetups.TestSetupsTable}`).
- **Namespace overlap**: Two namespaces are used: `DTS.Storage` (most files) and `Storage.Classes.Abstract` (`DbVersions.cs`). This suggests possible namespace migration or legacy coexistence.
---
### 5. Gotchas
- **Typo in table name**: `LabratoryDetails` class references `"tblLabratoryDetails"` (misspelled *Labratory*). This is likely intentional to match an existing database schema.
- **Inconsistent table prefixes**: Most tables use `tbl` prefix, but `DataPROUsers`, `UIITEMS`, `UserUIItemSettings`, and `TagAssignments` do not.
- **Enum name collisions**: `UserFields` is defined in both `Settings` and `Users` classes, but with different fields (`PropertyId` vs `ID`, `UserName`, etc.). This implies separate contexts (settings vs. user accounts).
- **Missing table references**: `DbVersions` defines `DbVersionFields` but *no table name constant*; `VersionTable` defines `TableName` and `Fields`, but the fields are identical to `DbVersions.DbVersionFields`. This suggests potential redundancy or historical duplication.
- **`AddOrRemove` semantics**: In `HardwareFields`, `AddOrRemove = 0` means *remove*, `= 1` means *add*. This inverse naming may be counterintuitive.
- **`SensorCalibrationRecordFields`**: This enum is defined but no corresponding table name constant is provided. Given the context, calibration records are likely stored as a serialized blob in `tblSensorCalibrations.CalibrationRecords`, not as a separate table.
- **`CalculatedChannels.InputChannelIds`**: Typed as `BLOB` (likely storing a serialized list of channel IDs). Consumers must handle serialization/deserialization.
- **`CalculatedChannels.CFCForInputChannels` / `CFCForOutput`**: Field names suggest "Calculated Function Chain" (CFC) logic, but no documentation of the format or execution engine is provided here.
None identified beyond those listed.