This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
---
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-16T11:55:23.145140+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "275c64f80988749d"
---
# Documentation: DTS.Common.Storage Schema Definitions
## 1. Purpose
This module provides a collection of abstract classes that serve as schema definitions for the DTS storage system. It centralizes database table names and column identifiers into static constants and enumerations. Its primary role is to provide type-safe, compile-time references for database entities—such as Users, Sensors, TestSetups, and various hardware configurations—decoupling the codebase from raw string literals used in SQL queries or data access layers.
## 2. Public Interface
The module consists of the following abstract classes, which cannot be instantiated but provide static members for schema reference.
### `MMEPossibleChannels`
* **`const string Table`**: Value `"tblMMEPossibleChannels"`.
### `DbVersions` (Namespace: `Storage.Classes.Abstract`)
* **`enum DbVersionFields`**: Members: `Version`, `Step`, `Date`, `Remarks`, `UserField`.
### `Settings`
* **`const string Table`**: Value `"tblSettings"`.
* **`enum UserFields`**: Members: `PropertyId`, `PropertyType`, `PropertyValue`, `UserId`.
### `VersionTable`
* **`const string TableName`**: Value `"tblDataPRODbVersion"`.
* **`enum Fields`**: Members: `Version`, `Step`, `Date`, `Remarks`, `UserField`.
### `TestObjectChannelSettings`
* **`const string TableName`**: Value `"tblTestObjectChannelSettings"`.
* **`enum Fields`**: Members: `TestObjectSerial`, `ChannelId`, `Setting`, `SensorSerial`.
### `Tags`
* **`const string Table`**: Value `"tblTags"`.
* **`enum TagFields`**: Members: `TagId`, `TagText`, `Obssolete`.
* **`const string TAGASSIGNMENTS_TABLE`**: Value `"TagAssignments"`.
* **`enum TagAssignmentFields`**: Members: `ObjectID`, `ObjectType`, `TagID`.
### `DigitalOutputSettings`
* **`const string Table`**: Value `"tblTOMDigitalChannels"`.
* **`enum Fields`**: Members: `ChannelDescription`, `DelayMS`, `DurationMS`, `OutputMode`, `LimitDuration`, `LastModified`, `LastModifiedBy`, `Version`, `LocalOnly`, `DurationMSFloat`, `UserTags`.
### `LabratoryDetails`
* **`const string Table`**: Value `"tblLabratoryDetails"`.
* **`enum LabratoryDetailsFields`**: Members: `Name`, `LabratoryName`, `LabratoryContactName`, `LabratoryContactPhone`, `LabratoryContactFax`, `LabratoryContactEmail`, `LabratoryTestRefNumber`, `LabratoryProjectRefNumber`, `LastModified`, `LastModifiedBy`, `LocalOnly`, `Version`.
### `Squib`
* **`const string Table`**: Value `"tblTOMSquibChannels"`.
* **`enum Fields`**: Members: `SquibDescription`, `BypassCurrentFilter`, `BypassVoltageFilter`, `DelayMS`, `DurationMS`, `FireMode`, `ISOCode`, `MeasurementType`, `SquibOutputCurrent`, `SquibToleranceLow`, `SquibToleranceHigh`, `LimitDuration`, `ArticleId`, `LocalOnly`, `Version`, `LastModified`, `LastModifiedBy`, `UserValue1`, `UserValue2`, `UserValue3`, `UserTags`.
### `CalculatedChannels`
* **`const string Table`**: Value `"tblCalculatedChannels"`.
* **`enum Fields`**: Members decorated with `DbTypeAttr`:
* `Id` (`INTEGER PRIMARY KEY NOT NULL`)
* `Operation` (`INTEGER`)
* `CalculatedChannelValueCode` (`NVARCHAR(255)`)
* `InputChannelIds` (`BLOB`)
* `CFCForInputChannels` (`NVARCHAR(255)`)
* `CFCForOutput` (`NVARCHAR(255)`)
* `TestSetupName` (`NVARCHAR(255)`)
* `CCName` (`NVARCHAR(255)`)
### `Users`
* **`const string USERS_TABLE`**: Value `"DataPROUsers"`.
* **`enum UserFields`**: Members: `ID`, `UserName`, `DisplayName`, `Password`, `Role`, `LastModified`, `LastModifiedBy`, `LocalOnly`.
* **`const string UIITEMS_TABLE`**: Value `"UIITEMS"`.
* **`enum UIItemFields`**: Members: `ID`, `Name`.
* **`const string USERUISETTINGS_TABLE`**: Value `"UserUIItemSettings"`.
* **`enum UserUIItemSettingFields`**: Members: `UserId`, `UIItemID`, `Permission`, `Visible`.
### `LevelTriggers`
* **`const string Table`**: Value `"tblLevelTriggers"`.
* **`enum Fields`**: Members decorated with `DbTypeAttr` (e.g., `TestSetupName`, `GroupSerialNumber`, `HardwareChannelId`, `GreaterThanEnabled`, `GreaterThanEU`, etc.).
### `SensorDB`
* **`const string SensorCalibrationTable`**: Value `"tblSensorCalibrations"`.
* **`const string SensorDataTable`**: Value `"tblSensors"`.
* **`const string SensorModelsTable`**: Value `"tblSensorModels"`.
* **`enum SensorDataFields`**: Members include `SerialNumber`, `UserSerialNumber`, `Model`, `Manufacturer`, `Status`, `MeasurementUnit`, `OffsetToleranceLow`, `OffsetToleranceHigh`, `Id`, etc.
* **`enum SensorModelFields`**: Members include `Model`, `Manufacturer`, `UserPartNumber`, `Capacity`, etc.
* **`enum SensorCalibrationFields`**: Members include `SerialNumber`, `CalibrationDate`, `Username`, `NonLinear`, etc.
* **`enum SensorCalibrationRecordFields`**: Members include `Sensitivity`, `Poly`, `AtCapacity`, etc.
### `TestSetups`
* **`const string HardwareTable`**: Value `"tblTestSetupHardware"`.
* **`enum HardwareFields`**: Members: `TestSetupName`, `HardwareId`, `AddOrRemove`.
* **`const string DASSettingsTable`**: Value `"tblTestSetupDASSettings"`.
* **`const string ChannelSettingsTable`**: Value `"tblTestChannelSettings"`.
* **`enum ChannelSettingFields`**: Members: `TestName`, `TestObjectName`, `ChannelId`, `Setting`, `SensorSerial`.
* **`const string TestSetupsTable`**: Value `"tblTestSetups"`.
* **`enum Fields`**: Extensive list including `SetupName`, `SetupDescription`, `AutomaticTestProgression`, `SamplesPerSecond`, `PreTriggerSeconds`, `PostTriggerSeconds`, `ExportFormat`, etc.
* **`const string TestSetupObjectsTable`**: Value `"tblTestSetupObjects"`.
* **`enum TestSetupObjectFields`**: Members: `TestObjectSerialNumber`, `TestSetupName`, `TargetSampleRate`, `ExcitationWarmupTimeMS`, `LocalOnly`, `TestObjectType`, `TestObjectPosition`.
* **`const string TestObjectMetaDataTable`**: Value `"tblTestSetupObjectMetaData"`.
* **`enum TestObjectMetaDataFields`**: Members: `TestObject`, `SetupName`, `PropName`, `PropValue`, `Optional`, `Version`.
* **`const string TestObjectTemplatesTable`**: Value `"tblTestObjectTemplates"`.
* **`enum TestObjectTemplatesFields`**: Members: `TemplateName`, `Icon`, `Description`, `LocalOnly`, `Version`, `LastModifiedBy`, `CRC32`, `TestObject`, `LastModified`, `ParentTemplate`, `SysBuilt`.
* **`const string TestObjectsTable`**: Value `"tblTestObjects"`.
* **`enum TestObjectsFields`**: Members: `SerialNumber`, `LastModifiedBy`, `LastModified`, `Template`, `LocalOnly`, `ParentObject`, `SysBuilt`, `Embedded`, `OriginalTemplate`, `OriginalSerialNumber`.
* **`const string TestGraphsTable`**: Value `"tblTestGraphs"`.
* **`enum GraphFields`**: Members: `GraphName`, `GraphDescription`, `TemplateName`, `Channels`, `UseDomainMin`, `DomainMin`, etc.
## 3. Invariants
* **Abstract Definition**: All schema classes (`MMEPossibleChannels`, `Settings`, `Users`, etc.) are declared `abstract`. They are intended to be used as static containers for constants and enums, not instantiated.
* **Enum Usage**: Nested enums are used to define field names. This implies the system likely casts these enum values to integers or strings (via `.ToString()`) when constructing queries, or uses them for array indexing.
* **Attribute Metadata**: Only `CalculatedChannels` and `LevelTriggers` utilize the `[DbTypeAttr]` attribute. The absence of this attribute on other classes implies that schema type inference (if used) relies on default mappings or a different mechanism for those classes.
## 4. Dependencies
* **Internal Dependencies**: The source files do not contain `using` statements for external libraries, indicating they are self-contained data structures.
* **External Consumers**: Any module handling database persistence (DAOs, Repositories, SQL builders) within the `DTS`

View File

@@ -0,0 +1,73 @@
---
source_files:
- Common/DTS.Common.Storage/Classes/Static/CustomChannelFieldSizeAttribute.cs
generated_at: "2026-04-16T11:54:41.555458+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "96c94c51da2a1b2d"
---
# Documentation: CustomChannelFieldSizeAttribute.cs
## 1. Purpose
This module provides a mechanism for associating fixed size metadata with enum values (specifically `MMETables.MMEPossibleChannelsFields`), enabling retrieval of custom field sizes via reflection. It exists to decouple size configuration from business logic, allowing channel field sizes to be defined declaratively as attributes on enum members rather than hard-coded elsewhere.
---
## 2. Public Interface
### `CustomChannelFieldSizeAttribute` (Class)
A custom attribute that stores an integer size value.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `internal CustomChannelFieldSizeAttribute(int size)` | Creates an instance with the specified size. **Note: Internal access only.** |
| Property | `public int Size { get; private set; }` | Gets the size value. Read-only after construction. |
### `CustomChannelFieldSizeExtensions` (Static Class)
Provides helper methods for retrieving field sizes.
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetFieldSize` | `public static int GetFieldSize(MMETables.MMEPossibleChannelsFields field)` | Retrieves the `Size` value from the `CustomChannelFieldSizeAttribute` applied to the given enum value. **Not an extension method**—must be called statically. |
### `EnumExtensions` (Static Class)
Provides generic reflection-based attribute retrieval for enum values.
| Method | Signature | Description |
|--------|-----------|-------------|
| `GetAttribute<TAttribute>` | `public static TAttribute GetAttribute<TAttribute>(this Enum value) where TAttribute : Attribute` | Extension method that retrieves a single custom attribute of type `TAttribute` from the given enum value. Returns `null` if not found; throws `InvalidOperationException` if multiple matching attributes exist. |
---
## 3. Invariants
- **Attribute Application**: `GetFieldSize` assumes that `CustomChannelFieldSizeAttribute` is always applied to the passed `MMEPossibleChannelsFields` enum value. If the attribute is missing, a `NullReferenceException` will occur.
- **Single Attribute Constraint**: `GetAttribute<TAttribute>` uses `SingleOrDefault()`, enforcing that at most one attribute of a given type may be present on any enum value. Multiple attributes of the same type will cause an `InvalidOperationException`.
- **Immutability**: The `Size` property is set only at construction and cannot be modified thereafter (private setter).
- **Construction Restriction**: The attribute constructor is `internal`, meaning attributes can only be defined within the same assembly.
---
## 4. Dependencies
### This module depends on:
- `System` (for `Attribute`, `Enum`, `Type` reflection APIs)
- `System.Linq` (for `OfType<T>()`, `SingleOrDefault()`)
- `MMETables.MMEPossibleChannelsFields` — an external enum type that this module is designed to annotate. **Location/assembly not visible in source.**
### What depends on this module:
- Cannot be determined from source alone. Consumers would be any code that needs to retrieve field sizes for `MMEPossibleChannelsFields` enum values.
---
## 5. Gotchas
1. **`GetFieldSize` is NOT an extension method** — Despite being defined in a class named `CustomChannelFieldSizeExtensions`, the method lacks the `this` keyword on its parameter. It must be called as `CustomChannelFieldSizeExtensions.GetFieldSize(field)`, not `field.GetFieldSize()`.
2. **Potential `NullReferenceException`**`GetFieldSize` directly accesses `.Size` on the result of `GetAttribute<CustomChannelFieldSizeAttribute>()` without null-checking. If the enum value lacks this attribute, the method will throw.
3. **Internal constructor limits extensibility** — The `internal` constructor means consumers outside this assembly cannot create new instances of `CustomChannelFieldSizeAttribute`. This is likely intentional to control where/how the attribute is applied, but could be restrictive for testing or extension scenarios.
4. **Tight coupling to specific enum type**`GetFieldSize` is hardcoded to `MMETables.MMEPossibleChannelsFields`, making this utility non-reusable for other enums even though `GetAttribute<T>` is generic.