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,48 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/Enums.cs
generated_at: "2026-04-17T16:30:29.461343+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "c71314298f20f2e2"
---
# Classes
### Purpose
This module defines core enumerations used throughout the DatabaseExport system for version 57 of the database schema. It provides standardized constants for test settings, recording modes, sensor compatibility levels, export format flags, test template metadata tags, and strictness levels. These enumerations serve as the type-safe vocabulary for configuring and controlling test operations and data export functionality.
### Public Interface
**`enum TestSettingsEnum`**
- Values: `ArmCheckListStep`, `CheckListInputVoltageCheck`, `CheckListBatteryVoltageCheck`, `CheckListSquibResistanceCheck`, `CheckListSensorIDCheck`, `CheckListTriggerStartCheck`, `EW` (ExcitationWarmup), `CheckListMustPass`
- Represents non-columned test settings, primarily checklist validation steps and excitation warmup configuration.
**`enum RecordingModes`**
- Values: `CircularBuffer`, `Recorder`, `HybridRecorder`
- Defines the data recording strategy for test acquisition.
**`enum IsoChannelSensorCompatibilityLevels`**
- Values: `DontWarn`, `Warn`, `DontAllow`
- Specifies the enforcement level for ISO channel sensor compatibility checks.
**`[Flags] enum SupportedExportFormatBitFlags`**
- Bitwise flags for export format capabilities. Values include:
- `none = 0x0`
- `csvunfiltered = 0x1`, `csvfiltered = 0x80`
- `diademadc = 0x2`
- `isounfiltered = 0x4`, `isofiltered = 0x200`
- `somatunfiltered = 0x8`, `somatfiltered = 0x400`
- `tdmsadc = 0x10`, `tdasadc = 0x800`
- `toyotaunfiltered = 0x20`, `toyotafiltered = 0x1000`
- `tsvunfiltered = 0x40`, `tsvfiltered = 0x2000`
- `rdfadc = 0x4000`
- `ChryslerDDAS = 0x8000`
- `HDFUnfiltered = 0x10000`, `HDFFiltered = 0x20000`, `HDFMV = 0x40000`, `HDFADC = 0x80000`
- `xlsxfiltered = 0x100000`, `xlsxunfiltered = 0x200000`
- Note: `diademfiltered = 0x100` is commented out and marked as unused.
**`enum TestTemplateTags`**
- Extensive enumeration (80+ values) for test template metadata and configuration keys. Includes categories for: upload settings (`UploadData`, `UploadFolder`), user references (`AllCustomers`, `AllTestEngineers`, `AllLabs`), test configuration (`SamplesPerSecond`, `PreTriggerSeconds`, `PostTriggerSeconds`, `RecordingMode`), diagnostic settings (`StrictDiagnostics`, `PostTestDiagnostics`), export settings (`ExportFormats`, `ExportFolder`, `DownloadFolder`), checklist items, and UI visibility controls.
**

View File

@@ -0,0 +1,58 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/Hardware/DASSettings.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/Hardware/HardwareChannel.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/Hardware/DASHardware.cs
generated_at: "2026-04-17T15:55:40.458986+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "1a7487e353ec1e28"
---
# Documentation: DatabaseExport Hardware Classes (Version 57)
## 1. Purpose
This module provides data structures for representing Data Acquisition System (DAS) hardware configuration and settings within the `DatabaseExport` namespace. It defines three primary classes: `DASSettings` for storing test-specific DAS configuration parameters (serialized to `tblTestSetupDASSettings`), `HardwareChannel` for representing individual hardware channels with their associated sensors and display ordering, and `DASHardware` for managing complete DAS device information including channels, connection details, and database persistence. The `DASHardwareList` singleton provides centralized hardware lookup and caching functionality.
---
## 2. Public Interface
### DASSettings
A POCO (Plain Old CLR Object) class for holding DAS-specific test settings.
**Properties:**
- `string DASSerialNumber { get; set; }` - Serial number of the DAS device.
- `double SampleRate { get; set; }` - Sample rate configuration.
- `int ExcitationWarmupTimeMS { get; set; }` - Excitation warmup time in milliseconds.
- `double HardwareAAF { get; set; }` - Hardware Anti-Aliasing Filter setting.
- `double PreTriggerSeconds { get; set; }` - Pre-trigger duration in seconds.
- `double PostTriggerSeconds { get; set; }` - Post-trigger duration in seconds.
- `bool StatusLineCheck { get; set; }` - Whether status line checking is enabled.
- `bool BatteryCheck { get; set; }` - Whether battery checking is enabled.
- `double InputVoltageMin { get; set; }` - Minimum input voltage threshold.
- `double InputVoltageMax { get; set; }` - Maximum input voltage threshold.
- `double BatteryVoltageMin { get; set; }` - Minimum battery voltage threshold.
- `double BatteryVoltageMax { get; set; }` - Maximum battery voltage threshold.
---
### HardwareChannel
Represents a single hardware channel on a DAS device. Implements `System.IComparable<HardwareChannel>`.
**Constructors:**
- `HardwareChannel(HardwareChannel copy)` - Copy constructor. Copies `ChannelNumber`, `Sensor` (deep copy), `TestObjectChannel`, `Hardware`, and `_isoChannel`.
- `HardwareChannel(ISOHardwareChannel channel, DASHardware hardware)` - Creates a channel from an `ISOHardwareChannel` and parent `DASHardware`.
**Properties:**
- `DASHardware Hardware { get; }` - Read-only reference to parent hardware.
- `int ChannelNumber { get; }` - Read-only channel index, initialized to 0.
- `SensorData Sensor { get; set; }` - Associated sensor data, may be null.
- `TestObjectChannel TestObjectChannel { get; set; }` - Associated test object channel.
**Methods:**
- `ISOHardwareChannel GetISOChannel()` - Returns the internal `_isoChannel` reference.
- `int CompareTo(HardwareChannel right)` - Compares channels first by `DASDisplayOrder`, then by `ChannelIdx`. Returns 0 if `right` is null or same

View File

@@ -0,0 +1,227 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/RegionsAndZones/Zone.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/RegionsAndZones/RegionAdorner.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/RegionsAndZones/Region.cs
generated_at: "2026-04-17T15:56:25.670027+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "e682348ce2b9320d"
---
# Documentation: RegionsAndZones Module
## 1. Purpose
This module provides the data structures and UI components for defining and managing geographic/physical zones and regions within test object templates, specifically for ISO 13499 database export functionality. The `Zone` class represents a named area with an associated image and collection of `Region` objects, while `RegionAdorner` provides WPF adorner-based visual selection and manipulation of rectangular regions on zone images. The `Region` class encapsulates ISO 13499 metadata (transducer locations, directions, filter classes, physical dimensions) and manages channel filtering based on these attributes.
---
## 2. Public Interface
### Zone Class
**Constructor:**
```csharp
public Zone(TemplateZone z, TestObjectTemplate template)
```
Initializes a Zone from a `TemplateZone` and associated `TestObjectTemplate`. Loads the zone image from the `ZonePictures` directory and instantiates child `Region` objects from `z.TemplateRegions`.
**Properties:**
- `string Name { get; set; }` — Zone name, populated from `z.ZoneName`.
- `string Description { get; set; }` — Zone description, defaults to empty string if null.
- `string Image { get; set; }` — Image filename reference.
- `TemplateZone ISODllZone { get; }` — Read-only reference to the source template zone.
- `string[] AllPictures { get; }` — Lazily loads and caches all image filenames from the `ZonePictures` directory, sorted by full path.
- `int PictureIndex { get; set; }` — Index into `AllPictures`; setting to negative value clears `PictureSource`, otherwise loads the image.
- `System.Windows.Media.ImageSource PictureSource { get; set; }` — The loaded bitmap image source.
- `Region[] Regions { get; set; }` — Array of regions belonging to this zone.
**Methods:**
```csharp
public string GetPictureName()
```
Returns the filename of the currently selected picture, or empty string if `PictureIndex < 0`.
**Nested Class:**
```csharp
public class FileInfoComparer : IComparer<System.IO.FileInfo>
```
Compares `FileInfo` objects by `FullName`. Nulls sort to the beginning.
---
### RegionAdorner Class
**Constructor:**
```csharp
public RegionAdorner(UIElement adornedElement, TestObjectTemplate template, Contexts context)
```
Creates an adorner for the specified element, initializes a new `Region`, and attaches mouse event handlers.
**Enum:**
```csharp
public enum Contexts { EditTestObject, EditTestObjectTemplate }
```
**Properties:**
- `Region MyRegion { get; set; }` — The region data object associated with this adorner.
- `bool IsNew { get; set; }` — When true, shows "add" visibility; when false, shows "delete" visibility on the region.
- `Point AnchorPoint { get; set; }` — Anchor point for drawing operations.
- `Rect SelectRect { get; set; }` — The selection rectangle; setting updates `RegionUpperLeft` and `RegionBottomRight` on `MyRegion`.
- `Contexts Context { get; set; }` — Editing context.
- `Size _MeasuredSize { get; set; }` — Measured size of the adorned element (private backing field exposed via property).
**Methods:**
```csharp
public Point GetUpperLeft()
public Point GetLowerRight()
```
Returns scaled coordinates accounting for difference between image source size and measured element size.
```csharp
public void DrawSelection(object sender, MouseEventArgs e, UIElement adornedElement)
```
Updates `SelectRect` based on mouse position relative to `AnchorPoint`.
```csharp
public void MoveSelection(object sender, MouseEventArgs e, UIElement adornedElement)
```
Moves the existing `SelectRect` by the mouse delta.
```csharp
public void EndSelection(object sender, MouseButtonEventArgs e)
```
Releases mouse capture and invokes `OnEndSelection` event.
**Events:**
```csharp
public delegate void RegionSelectedHandler(RegionAdorner r, MouseButtonEventArgs e);
public event RegionSelectedHandler OnRegionSelected;
public delegate void EndSelectionHandler(RegionAdorner r);
public event EndSelectionHandler OnEndSelection;
```
---
### Region Class
**Constructors:**
```csharp
public Region(RegionAdorner adorner, TestObjectTemplate template)
```
Creates a new region with default name "New region" and description "Describe region".
```csharp
public Region(TestObjectTemplate template, TemplateRegion r)
```
Creates a region from an existing `TemplateRegion`, loading all ISO metadata properties.
**Properties (ISO 13499 Metadata):**
- `TestObjectTemplate Template { get; set; }` — Parent template; setting triggers `DetermineAvailableISOSettings()`.
- `string RegionName { get; set; }` — Region name; setting invalidates adorner visual.
- `string RegionDescription { get; set; }` — Region description.
- `Point RegionUpperLeft { get; set; }` — Upper-left corner coordinates.
- `Point RegionBottomRight { get; set; }` — Bottom-right corner coordinates.
- `MMEDirections RegionDirection { get; set; }` — Direction setting.
- `MMEFilterClasses RegionFilterClass { get; set; }` — Filter class; setting updates `_filterClassIndex`.
- `MMEFineLocations1 RegionFineLocation1 { get; set; }`
- `MMEFineLocations2 RegionFineLocation2 { get; set; }`
- `MMEFineLocations3 RegionFineLocation3 { get; set; }`
- `MMETransducerMainLocation RegionMainLocation { get; set; }`
- `MMEPhysicalDimensions RegionPhysicalDimension { get; set; }`
- `MMEPositions RegionPosition { get; set; }`
- `MMETestObjects RegionTestObject { get; set; }`
- `string ISOCode { get; set; }` — Computed ISO code string, default `"????????????????"`.
**Properties (Channel Collections):**
- `TestObjectTemplateChannel[] RegionChannels { get; set; }` — Filtered channel list.
- `TemplateChannelUI[] RegionUIChannels { get; set; }` — Filtered UI channel list.
**Properties (Available Options Arrays):**
Each has a corresponding string array property for UI binding:
- `AllDirections[]` / `AllDirectionsStrings[]`
- `AllFilterClasses[]` / `AllFilterClassStrings[]`
- `AllFineLocations1[]` / `AllFineLocations1Strings[]`
- `AllFineLocations2[]` / `AllFineLocations2Strings[]`
- `AllFineLocations3[]` / `AllFineLocations3Strings[]`
- `AllMainLocations[]` / `AllMainLocationsStrings[]`
- `AllPhysicalDimensions[]` / `AllPhysicalDimensionStrings[]`
- `AllPositions[]` / `AllPositionStrings[]`
**Properties (Visibility):**
- `Visibility RegionAddVisibility { get; set; }` — Default `Visibility.Visible`.
- `Visibility RegionDeleteVisibility { get; set; }` — Default `Visibility.Hidden`.
**Methods:**
```csharp
public TemplateRegion ToISORegion(TestObjectTemplate template, Zone zone, int number)
```
Converts this region to a `TemplateRegion` object for serialization.
---
## 3. Invariants
1. **Zone Picture Path**: All zone pictures must be located in `{AppDomain.CurrentDomain.BaseDirectory}\ZonePictures`. If the file does not exist, `PictureIndex` is set to `-1`.
2. **Region Coordinate Scaling**: `RegionAdorner.GetUpperLeft()` and `GetLowerRight()` apply scaling transformations based on the ratio between `Image.Source` dimensions and the adorned element's `_MeasuredSize`. This assumes the adorned element is an `Image` with a valid `Source`.
3. **ISO Code Format**: The `ISOCode` property follows a specific format constructed via `ISO.IsoCode.GetString()` with 9 parameters (testObject, position, main, floc1, floc2, floc3, physdim, dir, fc). Default placeholder is `"????????????????"`.
4. **Channel Filtering Consistency**: When any ISO metadata property (Direction, FilterClass, FineLocation1/2/3, MainLocation, PhysicalDimension, Position) is set, `SetISOCode()` is called. When `Template` is set, `DetermineAvailableISOSettings()` is called.
5. **RegionAdorner-Region Coupling**: The `Region` constructor that takes a `RegionAdorner` stores a reference to the adorner, and property setters call `_adorner?.InvalidateVisual()`.
---
## 4. Dependencies
### External Dependencies (from imports):
- `System.Windows` — WPF UI framework.
- `System.Windows.Controls` — For `Image` control.
- `System.Windows.Documents` — For `Adorner` base class.
- `System.Windows.Input` — For mouse event args.
- `System.Windows.Media` — For `ImageSource`, `Brushes`.
- `System.Windows.Media.Imaging` — For `BitmapImage`.
- `System.Windows.Shapes` — For `Path`, `RectangleGeometry`.
- `System.IO` — File and directory operations.
- `System.Linq` — LINQ queries.
### Internal Dependencies (inferred from code):
- `TemplateZone` — Source data for Zone construction.
- `TestObjectTemplate` — Parent template object.
- `TemplateRegion` — Serialization target for Region.
- `Region` — Referenced by Zone and RegionAdorner.
- `ISO13499FileDb.IsoDb` — Static service for ISO metadata lookups (e.g., `GetDirectionByIso`, `GetFilterClassByIso`, etc.).
- `ISO.IsoCode.GetString()` — Static method for ISO code construction.
- `MMEDirections`, `MMEFilterClasses`, `MMEFineLocations1/2/3`, `MMETransducerMainLocation`, `MMEPhysicalDimensions`, `MMEPositions`, `MMETestObjects` — ISO metadata entity classes.
- `TestObjectTemplateChannel`, `TemplateChannelUI` — Channel data classes.
### Consumers:
- Unknown from source alone; likely consumed by Zone editing UI, template editors, and database export workflows.
---
## 5. Gotchas
1. **Null Reference Risk in Zone Constructor**: The constructor accesses `z.Picture` and `z.ZoneName` without null-checking `z` after the initial null-coalescing for `Description`. If `z` is null, `Image = z.Picture` will throw `NullReferenceException`.
2. **Silent Image Load Failures**: In `Zone` constructor, if `BitmapImage.EndInit()` throws, the exception is caught silently and `PictureIndex` is set to `-1`. No logging or error propagation occurs.
3. **Scaling Division by Zero**: `RegionAdorner.GetUpperLeft()` and `GetLowerRight()` calculate `scaleX = difX / _MeasuredSize.Width` and `scaleY = difY / _MeasuredSize.Height`. If `_MeasuredSize.Width` or `_MeasuredSize.Height` is 0, this will throw `DivideByZeroException` or result in NaN/Infinity.
4. **GetLowerRight Early Return**: `GetLowerRight()` returns `new Point(0, 0)` if `i.Source` is null, but `GetUpperLeft()` has no such guard. This asymmetry could lead to inconsistent coordinate handling.
5. **Commented-Out Code**:
- `Zone` class has commented-out base class `Common.BindableBase`.
- `Zone.PictureIndex` setter has commented-out change notification.
- `RegionAdorner` constructor has commented-out `PropertyChanged` subscription.
These suggest incomplete refactoring or migration from a different architecture.
6. **Magic Strings for Wildcards**: The code uses `"?"`, `"??"`, `"???"`, `"????"` as wildcard/placeholder values for ISO fields of different lengths. These are hardcoded in multiple places in `Region.FilterRegionChannels()` and `SetISOCode()`.
7. **AllPictures Lazy Loading Side Effect**: The `AllPictures` property both caches the file list in `_fileNames` and returns the names. If the directory contents change during runtime, the cache will be stale.
8. **MoveSelection Logic**: The line `r.X -= /*p1.X -*/ (p1.X - mousePosition.X)` contains commented-out code that suggests the formula may have been modified for debugging purposes. The intent is unclear.

View File

@@ -0,0 +1,66 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TabPage/TabPageCommon.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TabPage/TabPage.cs
generated_at: "2026-04-17T16:45:12.899450+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "b7338aac2198f306"
---
# Documentation: TabPage Module
## 1. Purpose
This module provides a hierarchical data structure for managing tabbed UI content in the DatabaseExport system. It defines a base class `TabPageCommon` for tab page items, with two concrete implementations: `TabPageItem` (representing individual tab pages with WPF `UserControl` content) and `TabPageItemGroup` (representing groups of tab pages). A singleton `TabPageSource` class provides centralized access to all tab page groups via a static query method. The module is part of the Version 57 legacy codebase.
---
## 2. Public Interface
### `TabPageCommon` (abstract class)
**Inherits:** `IUIItems`
| Member | Signature | Description |
|--------|-----------|-------------|
| `UniqueId` | `string UniqueId { get; set; }` | A string identifier, default-initialized to `string.Empty`. |
| `GetName` | `virtual string GetName()` | Returns the value of `UniqueId`. Virtual, allowing derived classes to override. |
---
### `TabPageItem` (class)
**Inherits:** `TabPageCommon`
| Member | Signature | Description |
|--------|-----------|-------------|
| `Content` | `UserControl Content { get; set; }` | WPF `UserControl` instance for the tab page content. Default is `null`. |
---
### `TabPageItemGroup` (class)
**Inherits:** `TabPageCommon`
| Member | Signature | Description |
|--------|-----------|-------------|
| `Items` | `ObservableCollection<TabPageItem> Items { get; }` | Read-only property returning a collection of `TabPageItem` instances. The collection is initialized to an empty `ObservableCollection<TabPageItem>`. |
---
### `TabPageSource` (class)
| Member | Signature | Description |
|--------|-----------|-------------|
| `AllGroups` | `ObservableCollection<TabPageItemGroup> AllGroups { get; }` | Read-only property returning a collection of all `TabPageItemGroup` instances. Initialized to an empty `ObservableCollection<TabPageItemGroup>`. |
| `GetGroups` | `static IEnumerable<TabPageItemGroup> GetGroups(string uniqueid)` | Static method that returns the `AllGroups` collection. **Only accepts the literal string `"AllGroups"`** as the `uniqueid` parameter; throws `ArgumentException` for any other value. |
---
## 3. Invariants
1. **Singleton Pattern:** `TabPageSource` maintains a single private static instance `_source` that backs all `GetGroups` calls.
2. **Hardcoded Query Constraint:** The `GetGroups` method only accepts the exact string `"AllGroups"` (case-sensitive). Any other value results in an `ArgumentException`.
3. **Collection Initialization:** Both `TabPageItemGroup.Items` and `TabPageSource.AllGroups` are always non-null; they are initialized at construction time and cannot be replaced (read-only properties).
4. **Nullable Content:** `TabPageItem.Content` is explicitly initialized to `null` and may remain null.
---

View File

@@ -0,0 +1,27 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestMetaData/CustomerDetails.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestMetaData/LabratoryDetails.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestMetaData/TestEngineerDetails.cs
generated_at: "2026-04-17T15:56:04.045355+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "09bdfb2c0eec51fb"
---
# Documentation: Test Metadata Classes (Version 57)
## 1. Purpose
This module provides wrapper classes and singleton-based collection managers for test metadata entities—customers, laboratories, and test engineers—within the `DatabaseExport` namespace. Each wrapper encapsulates an underlying ISO namespace type, exposing a simplified `Name` property and providing conversion back to the ISO type. The accompanying list classes implement thread-safe, lazily-initialized dictionaries that aggregate data from ISO static methods, always include a default "(none)" entry, and return sorted arrays for UI consumption.
---
## 2. Public Interface
### `CustomerDetails` (class)
Wrapper for `ISO.CustomerDetails`.
| Member | Signature | Description |
|--------|-----------|-------------|
|

View File

@@ -0,0 +1,149 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TemplateChannelUI.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/GroupTemplateTableInfo.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestObjectList.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestObjectTemplateCollection.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestTestObject.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestObjectTemplate.cs
generated_at: "2026-04-17T15:51:30.898539+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "80bd767974a55def"
---
# Documentation: DatabaseExport TestObject Module (Version 57)
## 1. Purpose
This module provides the data structures and access layer for managing test object templates and test objects within the Version 57 database export system. It handles template definitions, channel configurations, ISO 13499 compliance support, and provides both singleton-based collection access and individual entity management. The module serves as a bridge between the database layer (`DbOperations`, `ISO13499FileDb`) and the application layer, supporting both ISO-compliant and non-ISO test object configurations.
---
## 2. Public Interface
### TemplateChannelUI
A GUI wrapper class for template channels.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `TemplateChannelUI(TestObjectTemplateChannel channel)` | Initializes the wrapper with the provided channel. |
**Note:** No public members expose the wrapped `_channel` field.
---
### GroupTemplateTableInfo
An immutable data transfer object representing template metadata.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `GroupTemplateTableInfo(string templateName, SerializedSettings.ISOSupportLevels isoSupportLevel, bool sysBuilt, string templateDescription, DateTime lastModified, string lastModifiedBy, bool embedded)` | Initializes all properties. |
| `TemplateName` | `string { get; private set; }` | Name of the template. |
| `ISOSupportLevel` | `SerializedSettings.ISOSupportLevels { get; private set; }` | ISO support classification. |
| `SysBuilt` | `bool { get; private set; }` | Whether this is a system-built template. |
| `TemplateDescription` | `string { get; private set; }` | Human-readable description. |
| `LastModified` | `DateTime { get; private set; }` | Timestamp of last modification. |
| `LastModifiedBy` | `string { get; private set; }` | User who last modified the template. |
| `Embedded` | `bool { get; private set; }` | Whether the template is embedded. |
| `ToString()` | `override string ToString()` | Returns `TemplateName`. |
---
### TestObjectList
A thread-safe singleton that provides access to test objects.
| Member | Signature | Description |
|--------|-----------|-------------|
| `TestObjectsList` | `static TestObjectList { get; }` | Singleton instance accessor with lock-based lazy initialization. |
| `GetAllGroupSerialNumbers` | `List<string> GetAllGroupSerialNumbers()` | Queries `tblTestObjects` for all unique serial numbers. |
| `GetTestObject` | `TestObject GetTestObject(string serialNumber)` | Retrieves a test object by serial number; returns `null` if not found. |
| `GetAddedGroup` | `TestObject GetAddedGroup(string serialNumber)` | Delegates to `GetTestObject(serialNumber)`. |
---
### TestObjectTemplateCollection
A singleton providing template collection access.
| Member | Signature | Description |
|--------|-----------|-------------|
| `TemplateCollection` | `static TestObjectTemplateCollection =>` | Lazy-initialized singleton accessor. |
| `GetAllTemplates` | `GroupTemplateTableInfo[] GetAllTemplates(bool bIncludeEmbeddedAndSysBuilt = true)` | Queries `tblTestObjectTemplates`; excludes embedded/sys-built when `false`. |
| `SysBuiltTestObjectTemplate` | `TestObjectTemplate =>` | Returns cached `_sysBuiltTestObjectTemplate` (may be `null`). |
| `GetTemplate` | `TestObjectTemplate GetTemplate(string templateId)` | Returns a new empty `TestObjectTemplate` if not found, otherwise constructs from ISO database. |
---
### TestTestObject
Extends `TestObject` with test-specific settings and position management.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `TestTestObject(TestObject obj)` | Initializes from an existing `TestObject`. |
| `ChannelDefaultsKey` | `const string = "#"` | Constant for channel defaults position key. |
| `UserSetKey` | `const string = "@"` | Constant for user-defined position key. |
| `Position` | `MMEPositions { get; set; }` | Gets/sets position; propagates to all required sensors with serial numbers. |
| `TestObject` | `MMETestObjects { get; set; }` | Gets/sets test object; propagates to all required sensors. |
| `ExcitationWarmupTimeMS` | `int { get; set; }` | Defaults to `Properties.Settings.Default.DefaultTestExcitationWarmupMS`. |
| `TargetSampleRate` | `double { get; set; }` | Target sample rate for the test. |
| `AvailablePositions` | `MMEPositions[] =>` | From `ISO13499FileDb.IsoDb.GetPositions()`. |
| `AvailableGroupPositions` | `MMEPositions[] { get; }` | Combines `_channelDefaultsGUID` with `AvailablePositions`. |
| `GroupPositionComboBoxVisible` | `System.Windows.Visibility { get; set; }` | Collapsed when `ISOSupportLevel == NO_ISO`. |
| `GroupPositionButtonVisible` | `System.Windows.Visibility { get; set; }` | Collapsed when `ISOSupportLevel == NO_ISO`. |
| `SetTestObject` | `void SetTestObject(string s)` | Sets `_testObject` field and raises `OnPropertyChanged("TestObject")`. |
| `SetPosition` | `void SetPosition(string s)` | Sets `_position` field and updates visibility properties. |
---
### TestObjectTemplate
Manages test object template definitions with ISO 13499 integration.
| Member | Signature | Description |
|--------|-----------|-------------|
| `NON_ISO_TESTOBJECT_CHANNEL_TYPE` | `const string = "x_NonISOTestObjectType_x"` | Marker for non-ISO channel types. |
| `NON_ISO_TESTOBJECT_NAME` | `const string = "x_NonISOTestObjectName_x"` | Marker for non-ISO test object names. |
| Constructor | `TestObjectTemplate()` | Default constructor; behavior varies by `ISOSupportLevel`. |
| Constructor | `TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)` | Copy constructor. |
| Constructor | `TestObjectTemplate(ISO.TestObjectTemplate template, ref ISO13499FileDb db)` | Constructs from ISO template. |
| `TemplateName` | `string { get; set; }` | Template identifier. |
| `TemplateDescription` | `string { get; set; }` | Human-readable description. |
| `TestObject` | `MMETestObjects { get; set; }` | Associated test object; updates `AvailableTestObjectTypes` on set. |
| `TestObjectType` | `string { get; set; }` | Type identifier; rebuilds `TemplateAllChannels` on set. |
| `TestObjectTypeIndex` | `int { get; set; }` | Index into `AvailableTestObjectTypes`. |
| `TemplateAllChannels` | `TestObjectTemplateChannel[] { get; set; }` | Sorted by `DisplayOrder` on get. |
| `TemplateAllUIChannels` | `TemplateChannelUI[] { get; set; }` | UI wrappers for all channels. |
| `TemplateZones` | `Zone[] { get; set; }` | Zones defined in the template. |
| `RequiredChannels` | `List<TestObjectTemplateChannel> { get; set; }` | Channels marked as required. |
| `CurrentZone` | `Zone { get; set; }` | Currently selected zone; affects `AreZoneControlsEnabled`. |
| `CurrentZoneIndex` | `int { get; set; }` | Index of current zone; -1 for none. |
| `Embedded` | `bool { get; set; }` | Syncs with underlying `_template.Embedded`. |
| `SysBuilt` | `bool { get; set; }` | System-built flag. |
| `OriginalTemplateName` | `string { get; set; }` | Original name if renamed; syncs with `_template`. |
| `LastModifiedBy` | `string { get; set; }` | Default: `"N/A"`. |
| `LastModified` | `DateTime { get; set; }` | Default: `SqlDateTime.MinValue`. |
| `AvailableTestObjectTypes` | `string[] { get; set; }` | Lazy-loaded from database. |
| `AreZoneControlsEnabled` | `bool { get; set; }` | Set by `CurrentZone` changes. |
| `GetValues` | `Dictionary<string, string> GetValues()` | Serializes template to field dictionary using `GroupTemplateFields` enum. |
| `GetTemplateChannelValues` | `Dictionary<string, string> GetTemplateChannelValues(TestObjectTemplateChannel channel)` | Serializes channel to field dictionary using `GroupTemplateChannelFields` enum. |
| `ToISOTestObjectTemplate` | `ISO.TestObjectTemplate ToISOTestObjectTemplate()` | Converts to ISO template; writes to EventLog. |
| `GetNonISOTestObject` | `static MMETestObjects GetNonISOTestObject()` | Finds or creates a non-ISO test object. |
---
## 3. Invariants
- **Singleton patterns:** `TestObjectList` uses lock-based initialization; `TestObjectTemplateCollection` uses volatile field with null-coalescing.
- **Channel ordering:** `TemplateAllChannels` getter always returns channels sorted by `DisplayOrder`.
- **Zone index bounds:** `CurrentZoneIndex` of -1 sets `CurrentZone` to `null`; values ≥ 0 index into `TemplateZones`.
- **ISO support level effects:** When `SerializedSettings.ISOSupportLevel == NO_ISO`, `GroupPositionComboBoxVisible` and `GroupPositionButtonVisible` return `Collapsed` regardless of underlying value.
- **Embedded null handling:** In `GetAllTemplates()`, the `Embedded` column is checked for `DBNull.Value` before conversion.
- **Position propagation:** Setting `Position` or `TestObject` on `TestTestObject` propagates the value to all required channels with non-empty `SensorSerialNumber`.
---
## 4. Dependencies
### External Dependencies (Inferred)
- **DbOperations** - `GetCommand()`, `Connection.QueryDataSet()`
- **ISO13499FileDb** - `IsoDb` property, `GetTestObjectByIso()`, `GetTestObjects()`, `GetPositions()`, `GetPossibleChannelsForType()`, `GetUniquePossibleChannelTypes()`, `GetTestObjectTypeForTestObject()`
- **ISO namespace** - `TestObject

View File

@@ -0,0 +1,139 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestTemplate/HardwareInclusionInstruction.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestTemplate/TestTemplateLite.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestTemplate/TestTemplateTableObject.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestTemplate/TestTemplateList.cs
generated_at: "2026-04-17T15:53:21.543921+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "5681c42d0a4c2fa0"
---
# Documentation: DatabaseExport TestTemplate Module (Version 57)
## 1. Purpose
This module provides data structures and database access logic for managing test templates within the DataPRO application's database export functionality. It exists to support Version 57 of the database schema, offering classes for test template representation (`TestTemplateLite`, `TestTemplateTableObject`), hardware inclusion overrides (`HardwareInclusionInstruction`), and a singleton list manager (`TestTemplateList`) for retrieving and mapping test templates from the database. The module bridges raw database records to domain objects used in test configuration.
---
## 2. Public Interface
### `HardwareInclusionInstruction`
A class representing an instruction to add or remove hardware from a test configuration, overriding group-based defaults.
**Constructor:**
- `HardwareInclusionInstruction(string hardwareId, Actions action)`
**Properties:**
- `string HardwareId { get; }` — Read-only identifier for the hardware.
- `Actions Action { get; }` — The action to perform (Add or Remove).
**Nested Enum:**
- `Actions` — Values: `Remove` (exclude hardware even if included by group), `Add` (include hardware even if not in group).
---
### `TestTemplateLite`
A lightweight representation of a test template holding essential information.
**Properties:**
- `string Name { get; set; }`
- `string Description { get; set; }` — Default: empty string.
- `RecordingModes RecordingMode { get; set; }`
- `double PreTriggerSeconds { get; set; }` — Returns `0D` when `RecordingMode` is `Recorder` or `HybridRecorder`; otherwise returns the stored value.
- `double PostTriggerSeconds { get; set; }`
- `DateTime LastModified { get; set; }`
- `string LastModifiedBy { get; set; }`
- `bool IsComplete { get; set; }`
---
### `TestTemplateTableObject`
An immutable representation of a row in `tblTestTemplates` table.
**Constructor:**
- `TestTemplateTableObject(string name, string description, RecordingModes recordingMode, DateTime lastModified, string lastModifiedBy, bool isComplete, string completionErrorMessage, bool useCustomerDetails, string customerDetails, int[] tagIds)`
**Properties (all read-only):**
- `string Name { get; private set; }`
- `string Description { get; private set; }`
- `RecordingModes RecordingMode { get; private set; }`
- `DateTime LastModified { get; private set; }`
- `string LastModifiedBy { get; private set; }`
- `bool IsComplete { get; private set; }`
- `string CompletionErrorMessage { get; private set; }`
- `bool UseCustomerDetails { get; private set; }`
- `string CustomerDetails { get; private set; }`
- `int[] TagIds { get; private set; }`
---
### `TestTemplateList`
A singleton class for retrieving and managing test templates from the database.
**Static Property:**
- `TestTemplateList TestTemplatesList { get; }` — Thread-safe singleton accessor using lock synchronization.
**Instance Properties:**
- `TestTemplate TemporaryTemplate { get; set; }` — Holds a template in memory without committing to the database.
**Instance Methods:**
- `TestTemplate GetTemplate(string name)` — Retrieves a template by name from `tblTestSetups`. Returns `TemporaryTemplate` if name is `"Quick checkout"`. Returns `null` if not found or on error. The returned `TestTemplate` has `_bIsLoaded` set to `false`.
- `TestTemplateTableObject[] GetAllTemplates()` — Retrieves all templates from `tblTestSetups` as an array of `TestTemplateTableObject`. Re-evaluates `IsComplete` for templates marked as dirty.
**Static Methods:**
- `SensorData GetSensorFromSettings(string settings, string serial, Dictionary<string, SensorData> lookup)` — Parses a comma-separated settings string into a `SensorData` object, optionally using a lookup dictionary.
- `SensorData GetSensorFromSettings(string settings, string serial)` — Overload without lookup dictionary.
- `string GetSensorSettings(SensorData sd)` — Serializes a `SensorData` object to a settings string.
- `bool SysBuiltObject(string serialNumber)` — Queries `tblTestObjects` to check if an object is system-built.
- `void ConvertToDictionary(DataTable dt, ref Dictionary<string, List<Dictionary<string, object>>> lookup, string key)` — Converts a `DataTable` to a dictionary grouped by the specified key column.
---
## 3. Invariants
- **Singleton Thread Safety:** `TestTemplateList.TestTemplatesList` uses a lock (`ObjectLock`) to ensure thread-safe singleton instantiation.
- **PreTriggerSeconds Behavior:** `TestTemplateLite.PreTriggerSeconds` always returns `0D` for `RecordingModes.Recorder` and `RecordingModes.HybridRecorder`, regardless of the stored `_preTriggerSeconds` value.
- **Immutable Table Object:** `TestTemplateTableObject` properties are set only via constructor and have private setters.
- **HardwareInclusionInstruction Immutability:** `HardwareId` and `Action` are read-only after construction.
- **Template Name Handling:** `GetTemplate(string name)` returns `null` for null/whitespace names; special-cases `"Quick checkout"` to return `TemporaryTemplate`.
- **Tag Blob Format:** Tags are stored as byte arrays where each tag ID is a 4-byte integer (`sizeof(int)`).
---
## 4. Dependencies
### This Module Depends On:
- `DbOperations` — Database command creation and execution (`GetCommand()`, `CreateParam()`, `Connection.QueryDataSet()`).
- `DbOperations.TestSetups` — Table name and field enumeration for `tblTestSetups`.
- `TestTemplate` — Full test template class (referenced but not defined in these files).
- `SensorData`, `SensorsCollection.SensorsList` — Sensor data structures.
- `RecordingModes` — Enum for recording modes (referenced but not defined in these files).
- `CustomerDetailsList.CustomerList`, `TestEngineerDetailsList.TestEngineerList`, `LabratoryDetailsList.LabratoryList` — Detail list managers.
- `ISO.TestObject.SensorSettings` — Enum for sensor setting keys.
- `OutputTOMDigitalChannel.DigitalOutputMode`, `OutputSquibChannel.SquibFireMode`, `DigitalInputScaleMultiplier.InputModes` — Enums for sensor configuration.
- `SupportedExportFormatBitFlags` — Enum for export formats.
- `Properties.Settings.Default` — Application settings (e.g., `DownloadFolder`).
### What Depends On This Module:
- Unclear from source alone; this module is part of `DatabaseExport` namespace within Version 57 database migration support.
---
## 5. Gotchas
1. **Silent Failure on Database Errors:** Both `GetTemplate()` and `GetAllTemplates()` catch exceptions silently (commented-out logging) and return `null` or skip records. Callers cannot distinguish between "not found" and "database error."
2. **Hardcoded String Literal:** `GetTemplate()` compares against hardcoded `"Quick checkout"` string (a commented reference to `StringResources.QuickSensorCheck_DefaultTestName` suggests this should be localized).
3. **Internal Field Access:** `GetTemplate()` directly sets `tt._bIsLoaded = false` on the `TestTemplate` instance, accessing a non-public field (likely via `internal` access or `InternalsVisibleTo`).
4. **Redundant Class:** The comment in `TestTemplateLite` indicates this class may be redundant with the main `TestTemplate` class's lazy-loading mechanism (`IsLoaded` flag). It is preserved for potential future expansion.
5. **Tag Parsing Fragility:** `GetTagIds()` catches exceptions and returns an empty array, potentially hiding data corruption issues.
6. **Settings String Format:** Sensor settings are serialized as comma-separated `key=value` pairs where keys are integer casts of `ISO.TestObject.SensorSettings` enum values. Parsing uses `int.Parse` without error handling for malformed input.
7. **Dirty Template Re-evaluation:** `GetAllTemplates()` re-queries the full `TestTemplate` for records marked dirty to re-evaluate `IsComplete`, which could have performance implications for large datasets.

View File

@@ -0,0 +1,332 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/DASConcepts/Test.Module.Channel.Sensor.Bridge.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/DASConcepts/Test.Module.Channel.Sensor.SensorUnits.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/DASConcepts/Test.Module.Channel.Sensor.ZeroMethod.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/DASConcepts/DigitalInputScaleMultiplier.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/DASConcepts/Test.Module.Channel.Sensor.ExcitationVoltage.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/DASConcepts/InitialOffset.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/DASConcepts/LinearizationFormula.cs
generated_at: "2026-04-17T15:51:32.545999+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "9877a194e4f0eb7d"
---
# Documentation: DAS Concepts (DatabaseExport Namespace)
## 1. Purpose
This module provides data structures and enumerations defining sensor configuration concepts for a Data Acquisition System (DAS). It encapsulates properties for sensor bridge types, excitation voltage options, sensitivity units, zero calculation methods, digital input scaling, initial offsets, and linearization formulas. These types are used to serialize and deserialize sensor calibration and configuration data for database storage, supporting both modern and legacy data formats.
---
## 2. Public Interface
### Enum: `Test.Module.Channel.Sensor.BridgeType`
**Location:** `Test.Module.Channel.Sensor.Bridge.cs`
Defines available bridge/sensor types as bit-flagged values:
| Member | Value | Description |
|--------|-------|-------------|
| `IEPE` | `1 << 0` (1) | IEPE sensor setup |
| `QuarterBridge` | `1 << 1` (2) | Quarter bridge setup |
| `HalfBridge` | `1 << 2` (4) | Half bridge setup |
| `FullBridge` | `1 << 3` (8) | Full bridge setup |
| `DigitalInput` | `1 << 4` (16) | Digital input |
| `SQUIB` | `1 << 5` (32) | SQUIB sensor |
| `TOMDigital` | `1 << 6` (64) | TOM Digital |
---
### Enum: `Test.Module.Channel.Sensor.SensUnits`
**Location:** `Test.Module.Channel.Sensor.SensorUnits.cs`
Defines sensitivity unit types:
| Member | Value | Description |
|--------|-------|-------------|
| `NONE` | 0 | No sensitivity units (polynomial sensor) |
| `mV` | 1 | mV output at capacity EU |
| `mVperV` | 2 | mV/V output at capacity EU |
| `mVperVperEU` | 3 | mV/V/EU |
| `mVperEU` | 4 | mV/EU |
---
### Enum: `Test.Module.Channel.Sensor.ZeroMethodType`
**Location:** `Test.Module.Channel.Sensor.ZeroMethod.cs`
Defines zero calculation methods:
| Member | Value | Description |
|--------|-------|-------------|
| `AverageOverTime` | 0 | Calculate electrical zero using average over time |
| `UsePreEventDiagnosticsZero` | 1 | Calculate zero using pre-event diagnostics |
| `None` | 2 | Absolute zero (injected value) |
### Enum: `Test.Module.Channel.Sensor.OriginalZeroMethodType`
**Location:** `Test.Module.Channel.Sensor.ZeroMethod.cs`
Legacy version of zero method types (for backward compatibility):
| Member | Description |
|--------|-------------|
| `AverageOverTime` | Average over time |
| `UsePreCalZero` | Use pre-calibration zero |
| `None` | Absolute zero |
---
### Enum: `Test.Module.Channel.Sensor.ExcitationVoltageOption`
**Location:** `Test.Module.Channel.Sensor.ExcitationVoltage.cs`
Defines excitation voltage options with associated magnitude attributes:
| Member | Value | Magnitude |
|--------|-------|-----------|
| `Undefined` | 1 | 0.0V |
| `Volt1` | 64 | 1.0V |
| `Volt2` | 2 | 2.0V |
| `Volt2_5` | 4 | 2.5V |
| `Volt3` | 8 | 3.0V |
| `Volt5` | 16 | 5.0V |
| `Volt10` | 32 | 10.0V |
### Static Methods: `Test.Module.Channel.Sensor`
```csharp
public static double GetExcitationVoltageMagnitudeFromEnum(ExcitationVoltageOption target)
```
Converts an `ExcitationVoltageOption` enum value to its associated numeric magnitude (in volts). Throws `Exception` on failure.
```csharp
public static ExcitationVoltageOption GetExcitationVoltageEnumFromMagnitude(double magnitude)
```
Converts a voltage magnitude (in volts) to the corresponding `ExcitationVoltageOption`. Throws `NotSupportedException` if no matching enum exists.
### Nested Classes: `Test.Module.Channel.Sensor`
```csharp
public class VoltageMagnitudeAttribute : System.Attribute
```
Attribute for specifying voltage magnitude on enum fields. Constructor: `VoltageMagnitudeAttribute(double value)`. Property: `Value` (read-only).
```csharp
public class VoltageMagnitudeAttributeCoder : AttributeCoder<ExcitationVoltageOption, VoltageMagnitudeAttribute, double>
```
Helper class for encoding/decoding voltage magnitude attributes. Constructor: `VoltageMagnitudeAttributeCoder()`.
---
### Class: `DigitalInputScaleMultiplier`
**Location:** `DigitalInputScaleMultiplier.cs`
Transforms digital input data by defining 0/1 output values.
**Nested Enums:**
```csharp
public enum InputModes
```
| Member | Value |
|--------|-------|
| `TLH` | `1 << 1` (2) | Transition Low to High |
| `THL` | `1 << 2` (4) | Transition High to Low |
| `CCNO` | `1 << 3` (8) | Contact closure normally open |
| `CCNC` | `1 << 4` (16) | Contact closure normally closed |
```csharp
public enum Forms { ArbitraryLowAndHigh }
```
**Properties:**
- `Forms Form { get; set; }` — Default: `Forms.ArbitraryLowAndHigh`
- `double DefaultValue { get; set; }` — Value for "OFF" (0)
- `double ActiveValue { get; set; }` — Value for "ON" (1), default: `1.0`
**Constructors:**
```csharp
public DigitalInputScaleMultiplier()
public DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)
```
**Methods:**
```csharp
public string ToSerializeDbString()
```
Serializes the scaler to a database-safe string. Throws `NotSupportedException` for unsupported forms.
```csharp
public void FromDbSerializeString(string s)
```
Deserializes from a string. **Note:** Current implementation returns silently if input is null; parsing logic is commented out.
---
### Class: `InitialOffset`
**Location:** `InitialOffset.cs`
Represents initial offset for post-data-collection adjustment to engineering units.
**Nested Enum:**
```csharp
public enum Forms { None = 0, EU = 1, EUAtMV = 2 }
```
**Properties:**
- `Forms Form { get; set; }` — Format of the offset
- `double EU { get; set; }` — EU value (offset in EU, or EU@mV value)
- `double MV { get; set; }` — mV value (only for `EUAtMV` form)
**Constructors:**
```csharp
public InitialOffset()
public InitialOffset(InitialOffset copy)
```
**Methods:**
```csharp
public string ToDbSerializeString()
```
Serializes to a database-safe string using invariant culture list separator.
```csharp
public void FromDbSerializeString(string input)
```
Deserializes from string. Throws `System.IO.InvalidDataException` for invalid format or `FormatException` for parse errors.
---
### Class: `LinearizationFormula`
**Location:** `LinearizationFormula.cs`
Handles linearization formulas for converting sensor voltage to engineering units.
**Nested Enum:**
```csharp
public enum Styles
{
IRTraccManual,
IRTraccDiagnosticsZero,
IRTraccZeroMMmV,
IRTraccAverageOverTime,
Polynomial,
IRTraccCalFactor
}
```
**Properties:**
- `Styles Style { get; set; }` — Default: `Styles.IRTraccDiagnosticsZero`
- `double PolynomialSensitivity { get; set; }` — Default: `1.0`
- `double LinearizationExponent { get; set; }` — Default: `1.0`
- `double MMPerV { get; set; }` — Millimeters per volt
- `double MVAt0MM { get; set; }` — mV at 0mm
- `double Slope { get; set; }`
- `double Intercept { get; set; }`
- `double CalibrationFactor { get; set; }`
- `double ZeroPositionIntercept { get; set; }`
- `bool UsemVOverVForPolys { get; set; }` — Default: `true`
**Constructors:**
```csharp
public LinearizationFormula()
public LinearizationFormula(LinearizationFormula copy)
```
**Methods:**
```csharp
public bool IsValid()
public void MarkValid(bool bValid)
```
Validity state management.
```csharp
public string ToSerializeString()
```
Serializes formula to string format: `Style_data`. Throws `NotSupportedException` for unknown styles.
```csharp
public void FromSerializeString(string s)
public void FromSerializeString(string s, System.Globalization.CultureInfo culture)
```
Deserializes from string. Handles legacy formats `"1"`, `"0"`, `"1 "` as invalid.
**Style-specific serialization methods:**
```csharp
public string ToIRTraccDiagnosticZeroString()
public string ToIRTraccCalFactorString()
public string ToIRTraccManualString()
public string ToIRTraccZeroMMmVString()
public string ToIRTraccAverageOverTimeString()
public string ToPolynomialString()
```
**Style-specific deserialization methods:**
```csharp
public void FromIRTraccCalFactorString(string s, System.Globalization.CultureInfo culture)
public void FromIRTraccDiagnosticZeroString(string s, System.Globalization.CultureInfo culture)
public void FromIRTraccManualString(string s, System.Globalization.CultureInfo culture)
public void FromIRTraccZeroMMmVString(string s, System.Globalization.CultureInfo culture)
public void FromIRTraccAverageOverTimeString(string s, System.Globalization.CultureInfo culture)
public void FromPolynomialString(string s, System.Globalization.CultureInfo culture)
```
---
## 3. Invariants
1. **Bit-flag enum values:** `BridgeType` and `InputModes` use bit-shifted values (`1 << n`) to allow bitwise combination/flagging operations.
2. **ZeroMethodType ordering:** The comment explicitly states: *"Lots of legacy compatibility (e.g. importing GM ISF) depends on the order/value of this enum."* Values must remain `AverageOverTime = 0`, `UsePreEventDiagnosticsZero = 1`, `None = 2`.
3. **Invariant culture serialization:** All serialization methods use `System.Globalization.CultureInfo.InvariantCulture` for consistent cross-platform parsing.
4. **List separator format:** Serialization uses `CultureInfo.InvariantCulture.TextInfo.ListSeparator` as the delimiter.
5. **LinearizationFormula validity:** A formula is considered invalid if `ToSerializeString()` returns an empty string, or if the serialized string is `"1"`, `"0"`, or `"1 "`.
6. **ExcitationVoltageOption magnitude uniqueness:** Each enum value maps to exactly one voltage magnitude via the `VoltageMagnitudeAttribute`.
---
## 4. Dependencies
### This module depends on:
- `System` — Base types, exceptions, attributes
- `System.ComponentModel``DescriptionAttribute` for enum display names
- `System.Collections.Generic``List<T>` for coefficient/exponent storage
- `System.Linq` — LINQ operations (imported but usage unclear from visible code)
- `System.Text``StringBuilder` for string construction
- `System.Globalization` — Culture-specific parsing/formatting
### External dependencies (referenced but not defined in source):
- `AttributeCoder<ExcitationVoltageOption, VoltageMagnitudeAttribute, double>` — Base class for `VoltageMagnitudeAttributeCoder` (not included in source files)
### Partial class structure:
The `Test` class and its nested `Module`, `Channel`, `Sensor` classes are defined as `partial` across multiple files. The following files are referenced but not provided:
- `Test.cs`
- `Test.Module.Channel.cs`
- `Test.Module.Channel.Sensor.cs`
---
## 5. Gotchas
1. **DigitalInputScaleMultiplier deserialization is non-functional:** The `FromDbSerializeString` method has all parsing logic commented out. It only returns silently on null input and does nothing otherwise. This appears to be incomplete/broken functionality.
2. **Misleading class name:** The comment in `DigitalInputScaleMultiplier` states: *"the scaler is a bit different than an ordinary scaler, so the name here is inaccurate."*
3. **Misleading variable name:** In `LinearizationFormula`, the comment notes: *"THIS IS MM/V, (UI has already been updated, we need to update the variable name)"* referring to `MMPerV`.
4. **Extensive commented-out code:** Multiple files contain large blocks of commented-out code including:
- `DigitalInputScaleMultiplier`: `Equals`, `GetHashCode`, `SimpleEquals`, deserialization logic
- `InitialOffset`: `Equals`, display methods
- `LinearizationFormula`: `GetLinearizedValue`, polynomial calculation methods, SLICEWare serialization
5. **Legacy ZeroMethodType enum:** The existence of `OriginalZeroMethodType` with `UsePreCalZero` (vs. `UsePreEventDiagnosticsZero`) suggests a migration path for legacy data. The naming difference (`UsePreCalZero` vs `UsePreEventDiagnosticsZero`) may cause confusion.
6. **ExcitationVoltageOption non-sequential values:** Enum values are not sequential (1, 2, 4, 8, 16, 32, 64) suggesting they may have been designed as flags or for specific hardware register mapping.
7. **Polynomial serialization format:** The polynomial format uses `x` as a coefficient/exponent separator (e.g., `"c0xe0,c1xe1"`) and includes special tokens `S=` for sensitivity and `mV=` for the `UsemVOverVForPolys` flag.

View File

@@ -0,0 +1,122 @@
---
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-17T15:45:10.285441+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "82e99bbb3ec2255d"
---
# Documentation: DatabaseExport (Version 57 - ISO Module)
## 1. Purpose
This module provides a data access and entity modeling layer for a crash test data acquisition system, specifically handling "Version 57" database schemas. It contains classes responsible for mapping database rows (`System.Data.DataRow`) to C# objects representing test configurations, hardware channels, templates, and metadata. The module supports exporting and managing ISO-compliant data structures, including test objects, calculated channels, and trigger configurations.
## 2. Public Interface
### AbstractOLEDbWrapper
Abstract class providing static helper methods for safe database value retrieval.
* `public static long GetLong(IDataReader reader, string field)`: Returns `long.MinValue` if the database field is `DBNull`, otherwise converts the value to `Int64`.
* `public static DateTime GetDate(IDataReader reader, string field)`: Returns `DateTime.MinValue` if the database field is `DBNull`, otherwise casts the value to `DateTime`.
### TemplateZone
Represents a zone within a test template.
* `public TemplateZone(string template, string name, string picture, string description)`: Constructor initializing properties directly.
* `public TemplateZone(System.Data.DataRow dr)`: Constructor populating fields from a database row. Sets `ZoneName` to "Default zone" if null. Automatically loads `TemplateRegions` via `TemplateRegion.GetAllRegions`.
* `public TemplateRegion[] TemplateRegions { get; set; }`: Array of regions belonging to this zone.
### TemplateRegion
Represents a specific region within a `TemplateZone`, including coordinate data.
* `public TemplateRegion(DataRow dr)`: Constructor mapping database columns (e.g., `UpperLeftX`, `RegionName`) to properties.
* `internal static TemplateRegion[] GetAllRegions(string templateName, string zoneName)`: Queries the database (`tblTemplateRegions`) to retrieve all regions for a specific template and zone. Silently catches exceptions and returns an empty array on failure.
### TestObjectChannel
Represents a specific data channel on a test object. Inherits from `TestObjectTemplateChannel` (not shown) and implements `IComparable<TestObjectChannel>`.
* `public enum SquibChannelTypes`: Defines channel types (`None`, `Voltage`, `Current`).
* `public string GetGraphID()`: Returns the channel ID, appending `"_CU"` if `SquibChannelType` is `Current`.
* `public string GetId()`: Returns a formatted ID string (`SerialNumber_MMEChannelType_Id`).
* `public string GetID()`: Functionally identical to `GetId()` but uses `string.Format` instead of interpolation.
* `public int CompareTo(TestObjectChannel right)`: Compares by `DisplayOrder`, then `Name`, then `TestObject.SerialNumberOrOriginalSerialNumber`.
* `public string HardwareId { set; }`: Setter parses the input string expecting an underscore-delimited format (3 tokens) and reconstructs the value based on specific token logic involving `ChannelSeparator`.
### CalculatedValueClass
Defines a calculated channel derived from other input channels.
* `public enum Operations`: Defines calculation types (`SUM`, `AVERAGE`, `IRTRACC3D`, etc.).
* `public CalculatedValueClass(System.Data.DataRow dr)`: Constructor mapping database fields to properties using `DbOperations.CalculatedChannels.Fields` enum.
* `public byte[] InputChannelIdsBlob { get; set; }`: Serializes/deserializes the `InputChannelIds` list to/from a UTF-8 encoded string separated by the system's list separator.
### ISOHardwareChannel
Represents a physical hardware channel configuration.
* `public ISOHardwareChannel(DataRow dr, Hardware hardware)`: Constructor mapping `DbOperations.DAS.DASChannelFields` to properties. Throws `NotSupportedException` for unknown fields.
* `public static int PhysicalCompare(ISOHardwareChannel left, ISOHardwareChannel right)`: Compares two channels by `ChannelIdx`.
### LevelTriggerChannel
Stores trigger configuration based on signal levels.
* `public LevelTriggerChannel(System.Data.DataRow dr)`: Constructor mapping `DbOperations.LevelTriggers.Fields` to properties.
* Properties include thresholds: `GreaterThanThresholdEU`, `LessThanThresholdEU`, `InsideUpperLevelEU`, etc.
### MMEFigures
Represents figure metadata, inheriting from `AbstractOLEDbWrapper`.
* `public static MMEFigures[] GetFigures()`: Static factory method querying the `MMEFIGURES` table via `DbOperations.GetISOCommand()`. Returns an array of populated `MMEFigures` objects.
### TestSetting & TestSettingDictionary
Classes for managing key-value test settings with serialization support.
* `public string TestSetting.ToSerializeString()`: Serializes the setting to "Key=Value" format, escaping internal equals signs with `"_x_"`.
* `public static bool TestSetting.TryParse(string s, out TestSetting ts)`: Parses a serialized string back into a `TestSetting` object.
* `public void TestSettingDictionary.LoadSettings(string s)`: Parses a serialized string (separated by system list separator) and populates the dictionary.
* `public string TestSettingDictionary.ToSerializeString()`: Serializes all settings in the dictionary.
### TestEngineerDetails & CustomerDetails
Serializable classes holding contact details.
* `public Dictionary<string, string> GetValues()`: Returns a dictionary of all fields and their values (used for serialization/database storage).
* `public static TestEngineerDetails[] GetAllTestEngineerDetails()`: Fetches all records from `tblTestEngineerDetails`.
* `public static CustomerDetails[] GetAllCustomerDetails()`: Fetches all records from `tblCustomerDetails`.
### TestObjectMetaData & TestSetupMetaData
Manage metadata properties using a dictionary backing field.
* `public void SetProperty(MetaData meta)`: Adds or updates a metadata property.
* `public MetaData[] Properties { get; }`: Returns all metadata properties as an array.
### IsoCode
Handles the construction and parsing of a 16-character ISO code string.
* `public IsoCode(string isoCode)`: Constructor. Pads or truncates input to exactly 16 characters.
* `public string StringRepresentation { get; set; }`: Gets or sets the 16-char code.
* `public static string GetString(...)`: Overloaded static methods to construct an ISO code from various components (`MMEPossibleChannels`, `MMETestObjects`, etc.).
## 3. Invariants
1. **IsoCode Length**: An `IsoCode` string representation is always exactly 16 characters. Inputs are padded with `'?'` or truncated to enforce this.
2. **ChannelIDX Default**: The default value for `TestObjectChannel._channelIDX` is `CHANNEL_IDX_UNKNOWN` (-1).
3. **DBNull Handling**: Database readers/constructors in this module consistently convert `DBNull.Value` to specific default values (e.g., `long.MinValue`, `DateTime.MinValue`, "NOVALUE", or "Default zone") rather than throwing exceptions or leaving values null.
4. **Comparison Logic**: `TestObjectChannel.CompareTo` guarantees a stable sort order based on `DisplayOrder` -> `Name` -> `SerialNumber`.
5. **HardwareId Parsing**: The `TestObjectChannel.HardwareId` setter expects an underscore-delimited string with exactly 3 tokens to perform its parsing logic; otherwise, it passes the value through (or null) to `SetProperty`.
## 4. Dependencies
**Internal Dependencies (Inferred from source)**:
* `DbOperations`: Used extensively for database connections, commands, and parameter creation (`GetCommand`, `GetISOCommand`, `CreateParam`, `Connection.QueryDataSet`).
* `DatabaseExport.ISO.TestObject`: Referenced in `TestObjectChannel`.
* `DatabaseExport.ISO.TestObjectTemplateChannel`: Base class for `TestObjectChannel`.
* `DatabaseExport.Hardware`: Referenced in `ISOHardwareChannel`.
* `MMEPossibleChannels`, `MMETestObjects`, `MMEPositions`, `MMEFilterClasses`: Referenced in `IsoCode.GetString` static methods.
**External Dependencies**:
* `System.Data` / `System.Data.OleDb`: Used for database interaction.
* `System.Drawing`: Used in `TemplateRegion` for `Point` objects.
* `System.Globalization`: Used for culture-invariant string parsing/serialization.
## 5. Gotchas
1. **Bug in MMEFigures.GetFigures**: In the `GetFigures()` method, when reading the `LAST_CHANGE` column, the code incorrectly assigns the value to the `datRevision` variable instead of `lastChange`. This means `Last_Change` in the resulting object will likely be `DateTime.MinValue`, and `DatRevision` may contain the

View File

@@ -0,0 +1,51 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Properties/AssemblyInfo.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Properties/Settings.Designer.cs
generated_at: "2026-04-17T15:58:52.458716+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "21a9c1485f486d12"
---
# Documentation: DatabaseExport (Version 57)
## 1. Purpose
This module provides configuration and assembly metadata for the `DatabaseExport` component within DataPRO's Version 57 database schema. It appears to be a legacy version of database export functionality, likely related to sensor data acquisition and crash test measurement systems (inferred from settings referencing sensors, squib resistance, triggers, ROI, and excitation warmup). The module centralizes application settings for test execution, data download, export formatting, and database connectivity.
## 2. Public Interface
### Assembly Information (`AssemblyInfo.cs`)
- **Assembly Title**: `DatabaseExport`
- **Assembly Version**: `1.0.0.0`
- **File Version**: `1.0.0.0`
- **COM GUID**: `0e52df76-b8a7-4c69-981c-cdc27b7ee5a9`
- **COM Visibility**: `false` (types not visible to COM components)
### Settings Class (`Settings.Designer.cs`)
**Namespace**: `DatabaseExport.Properties`
```csharp
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
```
#### Static Property
| Property | Type | Description |
|----------|------|-------------|
| `Default` | `Settings` | Singleton instance providing access to all settings via `Synchronized()` pattern |
#### Application-Scoped Settings (Read-Only)
| Property | Type | Default Value | Description |
|----------|------|---------------|-------------|
| `ISOMMEDbLocation` | `string` | `"ISO\\mme_code.mdb"` | Path to ISO MME database file |
| `AllowAutoArm` | `bool` | `false` | Controls automatic arming behavior |
| `DBType` | `int` | `1` | Database type identifier |
| `DownloadFolder` | `string` | `"..\\Data"` | Default download destination folder |
| `RequireXCrashCompatibilityForISOExports` | `bool` | `true` | Enforces XCrash compatibility for ISO exports |
**Test Configuration Settings (Application-Scoped, Read-Only):**
| Property | Type

View File

@@ -0,0 +1,255 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SensorRange.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SensorDB.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/DigitalInputSetting.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/ZeroMethod.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/DigitalOutputSetting.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/FilterClass.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SquibSetting.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/IsoCode.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/CalibrationRecords.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SensorDB/SensorsCollection.cs
generated_at: "2026-04-17T15:47:20.640909+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "c3b027ba34ded2f4"
---
# SensorDB Module Documentation
## 1. Purpose
This module provides the data structures and collection management for sensor configuration within the Version 57 database export system. It defines sensor-related enums, configuration classes (for digital inputs/outputs, squib settings), calibration records, ISO codes, and a singleton `SensorsCollection` that loads and caches sensor data from multiple database tables (`tblSensors`, `tblDigitalInputSetting`, `tblTOMSquibChannels`, `tblTOMDigitalChannels`). The module serves as the read model for sensor metadata used throughout the DataPRO application.
---
## 2. Public Interface
### Enums
#### `SensorStatus`
```csharp
public enum SensorStatus { Available, InUse, OutForService, OutForCalibration, Retired }
```
#### `ShuntMode`
```csharp
public enum ShuntMode { None, Emulation, Internal, External }
```
#### `BridgeLeg`
```csharp
public enum BridgeLeg { First, Second, Third, Fourth }
```
#### `CouplingModes`
```csharp
public enum CouplingModes { AC = 0, DC }
```
#### `FilterClass.FilterClassType`
```csharp
public enum FilterClassType {
None = 0,
AdHoc = -1,
CFC10 = 17, // 17 Hz
CFC60 = 100, // 100 Hz
CFC180 = 300, // 300 Hz
CFC600 = 1000, // 1000 Hz
CFC1000 = 1650 // 1650 Hz
}
```
---
### Classes
#### `SensorRange`
```csharp
public SensorRange(double _low, double _medium, double _high)
public double Low { get; set; }
public double Medium { get; set; }
public double High { get; set; }
```
Simple data container for low/medium/high range values.
#### `LowHigh`
```csharp
public LowHigh(double _low, double _high)
public double Low { get; set; }
public double High { get; set; }
```
Simple data container for low/high range pairs.
#### `ZeroMethod`
```csharp
public ZeroMethod(Test.Module.Channel.Sensor.ZeroMethodType zm, double _start, double _end)
public ZeroMethod(string zm)
public ZeroMethod(ZeroMethod copy)
public Test.Module.Channel.Sensor.ZeroMethodType Method { get; set; }
public double Start { get; set; }
public double End { get; set; }
public string ToDbString()
public string ToSerializeString()
```
Represents a zeroing method with start/end range. Parses from comma-separated string format: `"{Method},{Start},{End}"`. Uses invariant culture for serialization.
#### `FilterClass`
```csharp
public FilterClass(FilterClassType fc)
public FilterClass(string fclass)
public FilterClassType FClass { get; set; }
public double Frequency { get; set; }
public override string ToString()
```
Encapsulates CFC (Channel Frequency Class) filter definitions. Constructor throws `System.Exception` for unknown class types. String constructor parses both numeric frequency values and string representations like "CFC60".
#### `IsoCode`
```csharp
public IsoCode(string isoCode)
public string TestObject { get; set; } // 1 char
public string Position { get; set; } // 1 char
public string MainLocation { get; set; } // 4 chars
public string FineLocation1 { get; set; } // 2 chars
public string FineLocation2 { get; set; } // 2 chars
public string FineLocation3 { get; set; } // 2 chars
public string PhysicalDimension { get; set; } // 2 chars
public string Direction { get; set; } // 1 char
public string FilterClass { get; set; } // 1 char
public string StringRepresentation { get; set; }
```
Fixed 16-character ISO code representation with named field accessors. Pads with `'?'` for missing values.
#### `DigitalInputSetting` : `SensorData`
```csharp
public DigitalInputSetting()
public DigitalInputSetting(DigitalInputSetting copy)
public static void SetDefaults(SensorData sd)
```
Configuration for digital input channels. Sets `Bridge = BridgeType.DigitalInput`, `Capacity = 1`, `DisplayUnit = "V"`, and other defaults.
#### `DigitalOutputSetting` : `SensorData`
```csharp
public DigitalOutputSetting()
public DigitalOutputSetting(System.Data.DataRow dr)
public string ChannelDescription { get; set; } // Maps to SerialNumber
public static void SetDefaults(SensorData sd)
```
Configuration for digital output channels. Sets `Bridge = BridgeType.TOMDigital`. DataRow constructor populates from `DbOperations.DigitalOutputSettings.Fields`.
#### `SquibSetting` : `SensorData`
```csharp
public SquibSetting(System.Data.DataRow dr)
public string SquibDescription { get; set; } // Maps to SerialNumber
public bool BypassCurrentFilter { get; set; }
public bool BypassVoltageFilter { get; set; }
public string ArticleId { get; set; } // Maps to Id
public static void SetDefaults(SensorData sd)
```
Configuration for squib (pyrotechnic) output channels. Sets `Bridge = BridgeType.SQUIB`. DataRow constructor populates from `DbOperations.Squib.Fields`.
#### `CalibrationRecords`
```csharp
public CalibrationRecords()
public CalibrationRecords(CalibrationRecords copy)
public CalibrationRecords(string records)
public CalibrationRecord[] Records { get; set; }
public void FromSerializedString(string s)
public string ToSerializedString(SensorCalibration sc)
```
Collection of calibration records with serialization support using `"__x__"` separator.
#### `CalibrationRecord`
```csharp
public CalibrationRecord()
public CalibrationRecord(CalibrationRecord copy)
public CalibrationRecord(string s)
public double Sensitivity { get; set; }
public double ZeroPoint { get; set; }
public LinearizationFormula Poly { get; set; }
public bool AtCapacity { get; set; }
public string EngineeringUnits { get; set; }
public Test.Module.Channel.Sensor.SensUnits SensitivityUnits { get; set; }
public Test.Module.Channel.Sensor.ExcitationVoltageOption Excitation { get; set; }
public int CapacityOutputIsBasedOn { get; set; }
public string ToSerializedString(SensorCalibration parentCal)
public void FromString(string s)
```
Individual calibration record. `ZeroPoint` getter is calculated from `Poly.ZeroPositionIntercept / Poly.CalibrationFactor` when `Poly.CalibrationFactor != 0`.
#### `SensorsCollection`
```csharp
public static SensorsCollection SensorsList { get; } // Singleton accessor
public SensorData GetSensorBySerialNumber(string serialNumber, bool excludeBroken = true)
public SensorData[] AllSensorsDb { get; }
```
Singleton that loads and caches all sensors from database. Filters out multi-axis sensors (`NumberOfAxes > 1` or `AxisNumber > 0`).
---
## 3. Invariants
- **IsoCode**: Always represents exactly 16 characters. Shorter strings are padded with `'?'`; longer strings are truncated.
- **FilterClass**: `Frequency` is always set to the enum's underlying integer value for defined `FilterClassType` values (except `AdHoc`).
- **CalibrationRecord.ZeroPoint**: When `Poly.CalibrationFactor != 0`, the getter returns a calculated value (`Poly.ZeroPositionIntercept / Poly.CalibrationFactor`) rather than the stored `_zeroPoint`.
- **SensorsCollection**: Singleton instance is lazily initialized under lock. All public accessors acquire `_lock` before accessing internal dictionaries.
- **SensorsCollection filtering**: `GetSensorBySerialNumber` and `AllSensorsDb` always exclude multi-axis sensors (`NumberOfAxes > 1` or `AxisNumber > 0`).
- **Serialization format**: `ZeroMethod` uses format `"{Method},{Start},{End}"`. `CalibrationRecords` uses `"__x__"` as record separator with `"___xx___"` as escape sequence.
---
## 4. Dependencies
### This module depends on:
- `System.Data` - `DataRow`, `DataSet` for database operations
- `System.Globalization.CultureInfo.InvariantCulture` - for parsing/formatting
- `Test.Module.Channel.Sensor` namespace - `ZeroMethodType`, `BridgeType`, `ExcitationVoltageOption`, `SensUnits`
- `DbOperations` - `GetCommand()`, `Connection.QueryDataSet()`, enum types `DigitalOutputSettings.Fields`, `Squib.Fields`, `DigitalInputSettings.Fields`
- `OutputTOMDigitalChannel.DigitalOutputMode` - enum type
- `OutputSquibChannel.SquibMeasurementType`, `OutputSquibChannel.SquibFireMode` - enum types
- `SensorData` (base class, not provided in source)
- `SensorCalibration` (referenced in `CalibrationRecord.ToSerializedString()`, not provided in source)
- `LinearizationFormula` (referenced in `CalibrationRecord`, not provided in source)
- `DigitalInputScaleMultiplier` (referenced in `SensorsCollection.LoadAllSensors()`, not provided in source)
### What depends on this module:
- Cannot be determined from source alone; consumers would reference `SensorsCollection.SensorsList` and the various setting classes.
---
## 5. Gotchas
1. **Commented-out INotifyPropertyChanged**: Multiple classes (`SensorRange`, `LowHigh`, `ZeroMethod`, `FilterClass`, `SensorsCollection`) have commented-out `INotifyPropertyChanged` inheritance, suggesting a refactoring or abandoned feature.
2. **FilterClass.CFC naming mismatch**: `FilterClassType.CFC10` corresponds to 17 Hz, `CFC60` to 100 Hz, etc. The enum names do not directly match their frequency values.
3. **FilterClass constructor throws**: The `FilterClass(FilterClassType)` constructor throws a generic `System.Exception` for any `FilterClassType` not explicitly handled in the switch statement (including `AdHoc`).
4. **CalibrationRecord.ZeroPoint calculated vs stored**: The `ZeroPoint` property has non-obvious behavior—it returns a calculated value when `Poly.CalibrationFactor != 0`, otherwise returns the stored `_zeroPoint`. The setter always stores to `_zeroPoint`.
5. **SensorsCollection silently ignores duplicates**: When loading sensors, if a serial number already exists in `_sensorDictionary`, the new entry is ignored (for digital input/squib settings) or replaces the old entry (for main sensor table).
6. **Multi-axis sensors excluded**: Per comment referencing "6093 Disable 6-axis sensor capability", sensors with `NumberOfAxes > 1` or `AxisNumber > 0` are filtered out from `GetSensorBySerialNumber` and `AllSensorsDb`.
7. **FilterClassIso default fix**: In `GetSensorBySerialNumber`, if `FilterClassIso == "?"`, it is silently changed to `"P"`.
8. **Obsolete field handling**: `DigitalOutputSetting` constructor has a commented-out handling for `DurationMS` field marked as obsolete, with the new field being `DurationMSFloat`.
9. **Exception swallowing**: `SensorsCollection.LoadAllSensors()` catches and silently ignores all exceptions during database loading. Similarly, `SquibSetting` and `DigitalOutputSetting` DataRow constructors catch exceptions per-field without rethrowing.

View File

@@ -0,0 +1,49 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Serialization/Control/DAS/IFilterable.cs
generated_at: "2026-04-17T16:47:19.107954+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "ad767485b255164e"
---
# Documentation: IFilterable.cs
## 1. Purpose
This module defines `IFilterable`, a marker interface within the `DatabaseExport` namespace. It exists to provide a type identity for "filterable slice control event module channels," allowing other components to identify or filter objects that implement this interface. Based on the copyright header, this interface originates from DTS (Diversified Technical Systems) slice control architecture for DAS (Data Acquisition System) channels.
## 2. Public Interface
### `IFilterable` (interface)
**Signature:**
```csharp
namespace DatabaseExport
{
public interface IFilterable
{
}
}
```
**Behavior:** This is a marker interface with no members. It conveys no behavioral contract; classes implement it solely to indicate they support filtering operations or belong to a category of filterable components.
## 3. Invariants
- No behavioral invariants can be defined from the source, as the interface contains no members.
- Any class implementing `IFilterable` implicitly declares itself as participating in filtering semantics, but the specific contract is undefined in this file.
## 4. Dependencies
**This module depends on:**
- None visible from source (no `using` statements; relies only on core C# language features).
**What depends on this module:**
- Unknown from source alone. Consumers would be other classes within the `DatabaseExport` namespace or external modules that check for this interface type.
## 5. Gotchas
- **Empty marker interface:** The interface defines no methods or properties. Its utility depends entirely on external code performing type checks (e.g., `is IFilterable` or `as IFilterable`).
- **Typo in documentation:** The XML summary comment contains "channle" instead of "channel."
- **Filename mismatch:** The internal header comment references `DTS.Slice.Control.DAS.Channel.IFilterable.cs`, suggesting this file was migrated or refactored from a different project structure, but now resides under `DatabaseExport` namespace in a legacy versions directory (`Version57`).

View File

@@ -0,0 +1,39 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Serialization/Control/Event/Module/Channel/Channel.cs
generated_at: "2026-04-17T16:15:59.228854+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "6ca12734f06c65f6"
---
# Channel
### Purpose
This module defines an abstract partial class `Channel` that serves as a representation of a channel within the event/module hierarchy of the DTS.Slice control system. It provides a base abstraction for channel implementations that require filtering capabilities, exception handling behavior (via `Exceptional`), and resource cleanup (via `IDisposable`).
### Public Interface
- **`Event.Module.Channel`** (abstract partial class)
- Inherits from: `Exceptional`
- Implements: `IFilterable`, `IDisposable`
- `void Dispose()` - Implements IDisposable. Currently has an empty implementation in this partial class definition.
### Invariants
- The `Channel` class is defined as `abstract partial`, meaning it cannot be instantiated directly and must be inherited.
- This is a partial class split across multiple files; the complete implementation requires other partial definitions (referenced by comments pointing to `DTS.Slice.Control.Event.cs` and `DTS.Slice.Control.Event.Module.cs`).
- The class exists within a nested hierarchy: `Event.Module.Channel`.
### Dependencies
- **Implements/Inherits:**
- `Exceptional` (base class, location unclear from this source alone)
- `IFilterable` (interface, location unclear from this source alone)
- `IDisposable` (System interface)
- **Namespace:** `DatabaseExport`
### Gotchas
- The `Dispose()` method is empty in this partial definition; actual cleanup logic may exist in another partial class file not shown here.
- The comments reference other files (`DTS.Slice.Control.Event.cs` and `DTS.Slice.Control.Event.Module.cs`) that contain related partial definitions—these files are necessary to understand the complete class structure.
- The relationship between `DatabaseExport` namespace and `DTS.Slice.Control.Event` naming convention is unclear from this source alone.
---

View File

@@ -0,0 +1,25 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Serialization/SliceRaw/SliceRaw.File.PersistentChannel.cs
generated_at: "2026-04-17T16:52:46.566838+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "bf7c1ec84e1e42af"
---
# Documentation: SliceRaw.File.PersistentChannel.cs
## 1. Purpose
This source file defines the `PersistentChannel` nested class within the `File` partial class. It serves as a structural component of the `DatabaseExport` namespace, specifically for Version 57 of the database serialization logic. According to the XML documentation, this class represents a data channel where modifications to the object instance are immediately written to the associated file on disk, ensuring data persistence.
## 2. Public Interface
This file contains no executable methods or properties. It defines the following partial class structure:
* **`DatabaseExport.File`**
* A partial class acting as the container for the nested `PersistentChannel` class.
* **`DatabaseExport.File.PersistentChannel`**
* A partial class representing a persistent channel.
* *Note:* The class body is empty in this specific file. The implementation is expected to be defined in other partial class files.
## 3. Invariants
Based strictly on the XML documentation provided in the

View File

@@ -0,0 +1,56 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SettingsDB/Setting.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SettingsDB/GlobalSetting.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/SettingsDB/SettingsDB.cs
generated_at: "2026-04-17T15:55:29.267823+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "08773b944623c2c5"
---
# SettingsDB Module Documentation
## 1. Purpose
This module provides a singleton-based mechanism for storing and retrieving application settings from a database. It implements a cached settings layer where global configuration values are read from the database on first access and cached in memory. The module is part of a legacy database version (Version57) and supports string, integer, and boolean setting types. It assumes an existing database connection has been established via `DbOperations`.
---
## 2. Public Interface
### `Setting` (Abstract Base Class)
**Constructor:**
```csharp
public Setting(string id, PropertyTypes type, string defaultPropertyValue, string userId)
```
Initializes a new setting with the given ID, type, default value, and user ID. Calls `GetPropertyValue(defaultPropertyValue)` during construction.
**Properties:**
- `public string PropertyId` — Read-only accessor for the setting's string identifier.
- `public string PropertyValue` — Read-only accessor for the setting's string value.
**Enum:**
```csharp
public enum PropertyTypes
{
User = 1 << 0, // Value: 1
Global = 1 << 1 // Value: 2
}
```
**Methods:**
- `protected abstract void GetPropertyValue(string defaultValue)` — Abstract method that derived classes must implement to retrieve the property value (typically from database).
- `public void SetValue(string value)` — Sets `_propertyValue` to the provided string.
---
### `GlobalSetting` (Concrete Class)
Inherits from `Setting`.
**Constructor:**
```csharp
public GlobalSetting(string id, string defaultPropertyValue)
``

View File

@@ -0,0 +1,264 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Storage/DbOperationsEnum.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Storage/DbVersion.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Storage/IDbTimeStampAware.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Storage/DbOperations.cs
generated_at: "2026-04-17T15:54:44.751987+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "504312ba24f92523"
---
# DatabaseExport Module Documentation
## 1. Purpose
This module provides the data access layer and schema definitions for the DataPRO system, supporting both Microsoft SQL Server and SQLite databases. It manages database connections, executes queries/commands, defines table structures for domain entities (sensors, test setups, users, calibration data, MME metadata), and implements timestamp-based concurrency checking to detect stale data. The module appears to be part of a versioned database schema system (Version 57) for backward compatibility.
---
## 2. Public Interface
### DbOperationsEnum.cs
**`DbOperationsEnum.StoredProcedure`** (enum)
- Nested enum containing stored procedure names.
- Member: `sp_DbVersionGet`
---
### DbVersion.cs
**`DbVersion`** (class)
- Entity class representing a database version record.
**Constructor:**
```csharp
public DbVersion(System.Data.DataRow dr)
```
- Populates instance from a `DataRow` with columns: `Version`, `Step`, `Date`, `Remarks`, `UserField`.
**Properties:**
| Property | Type | Access |
|----------|------|--------|
| `Version` | `int` | get/set |
| `Step` | `int` | get/set |
| `Date` | `DateTime` | get/set |
| `Remarks` | `string` | get/set |
| `UserField` | `string` | get/set |
---
### IDbTimeStampAware.cs
**`IDbTimeStampAware`** (interface)
```csharp
public interface IDbTimeStampAware
{
long GetTimeStampMemory();
void SetTimeStampMemory(long value);
long GetTimeStampDb();
bool IsOutOfDate();
}
```
**`DbTimeStampBase`** (abstract class)
- Implements `IDbTimeStampAware` and `INotifyPropertyChanged`.
- Provides base functionality for timestamp-based concurrency.
**Protected Members:**
- `protected long DbTimeStamp` - backing field for timestamp
- `protected bool SetProperty<T>(ref T storage, T value, String propertyName = null)` - property setter with change notification
- `protected void OnPropertyChanged(string propertyName = null)` - raises `PropertyChanged` event
**Public Methods:**
| Method | Return Type | Description |
|--------|-------------|-------------|
| `GetTimeStampMemory()` | `long` | Returns in-memory timestamp |
| `SetTimeStampMemory(long value)` | `void` | Sets in-memory timestamp |
| `SetTimeStampMemory(DataRow row)` | `void` | Sets timestamp from DataRow (currently sets to 0) |
| `SetTimeStampMemory(IDataReader reader)` | `void` | Sets timestamp from IDataReader (currently sets to 0) |
| `GetTimeStampDb(Dictionary<string, long> lookup)` | `long` | Gets DB timestamp from lookup (currently returns 0) |
| `GetAllTimeStampDb()` | `Dictionary<string, long>` | Returns empty dictionary (implementation commented out) |
| `GetTimeStampDb()` | `long` | Returns 0 (implementation commented out) |
| `IsNotInDb()` | `bool` | Returns `true` if `GetTimeStampDb() == 0` |
| `IsOutOfDate()` | `bool` | Compares memory vs DB timestamps |
**Abstract Members:**
```csharp
public abstract string LookupTable { get; }
public abstract ConstraintHelper[] GetConstraints();
```
**`DbTimeStampBase.ConstraintHelper`** (nested class)
| Property | Type |
|----------|------|
| `ColumnName` | `string` |
| `DbType` | `System.Data.SqlDbType` |
| `DbValue` | `object` |
**`DbItemOutOfDateException`** (class)
- Exception class deriving from `Exception`.
- Constructor: `public DbItemOutOfDateException(string msg)`
---
### DbOperations.cs
**`DbOperations`** (class)
- Main database operations class with singleton connection management.
**Static Fields:**
| Field | Type | Initial Value |
|-------|------|---------------|
| `_usingCentralizedDB` | `bool` | `true` |
| `_usingMSSQL` | `bool` | `true` |
| `_usingNTLMAuthentication` | `bool` | `false` |
| `_previousDir` | `string` | `string.Empty` |
**Static Properties:**
| Property | Type | Description |
|----------|------|-------------|
| `Connection` | `DbOperations` | Thread-safe singleton instance |
| `LastConnectionStatus` | `bool` | Last connection success/failure state |
| `ConnectionStatusChanged` | `ConnectionStatusChangedDelegate` | Event for connection status changes |
**Instance Properties:**
| Property | Type | Default |
|----------|------|---------|
| `Server` | `string` | `null` |
| `DBName` | `string` | `null` |
| `Username` | `string` | `""` |
| `Password` | `string` | (not initialized) |
**Static Methods:**
```csharp
public static SqlCommand GetSQLCommand()
public static SqlCommand GetSQLCommand(bool newCommand)
```
- Returns a `SqlCommand` with an open connection. Caches command in `_cmd` unless `newCommand` is `true`.
```csharp
public static IDbCommand GetISOCommand()
```
- Returns an `IDbCommand` connected to the ISO database.
```csharp
public static IDbCommand GetCommand()
```
- Returns `SqlCommand` if `_usingMSSQL` is true, otherwise `SQLiteCommand`.
```csharp
public static void CreateParam(IDbCommand icmd, string name, SqlDbType type, object value)
```
- Adds a parameter to the command. Handles `DateTime` normalization to SQL minimum values and special formatting.
**Instance Methods:**
```csharp
public DataSet QueryDataSet(IDbCommand icmd)
```
- Executes a query and returns a `DataSet`. Supports both MSSQL and SQLite.
```csharp
public int ExecuteCommand(IDbCommand icmd)
```
- Executes a non-query command and returns rows affected.
```csharp
public string GetLocalISOConnectionString()
```
- Returns connection string for ISO database, using NTLM or SQL authentication.
**Nested Schema Classes (all `abstract`):**
| Class | Table Constant | Key Fields |
|-------|----------------|------------|
| `Tags` | `tblTags`, `TagAssignments` | `TagId`, `TagText`, `ObjectID`, `ObjectType` |
| `DbVersions` | (none) | `Version`, `Step`, `Date`, `Remarks`, `UserField` |
| `Settings` | `tblSettings` | `PropertyId`, `PropertyType`, `PropertyValue`, `UserId` |
| `Users` | `DataPROUsers`, `UIITEMS`, `UserUIItemSettings` | `ID`, `UserName`, `DisplayName`, `Password`, `Role` |
| `SensorDB` | `tblSensors`, `tblSensorModels`, `tblSensorCalibrations` | `SerialNumber`, `Model`, `Manufacturer`, `CalibrationDate` |
| `CalculatedChannels` | `tblCalculatedChannels` | `Id`, `Operation`, `InputChannelIds` |
| `LevelTriggers` | `tblLevelTriggers` | `TestSetupName`, `HardwareChannelId`, `GreaterThanEU` |
| `TestSetups` | Multiple tables | `SetupName`, `TestObjectName`, `ChannelId` |
| `TestObjectChannelSettings` | `tblTestObjectChannelSettings` | `TestObjectSerial`, `ChannelId`, `SensorSerial` |
| `DigitalOutputSettings` | `tblTOMDigitalChannels` | `ChannelDescription`, `DelayMS`, `DurationMS` |
| `Squib` | `tblTOMSquibChannels` | `SquibDescription`, `FireMode`, `ISOCode` |
| `MMETables` | Multiple MME tables | `ID`, `TYPE`, `TEST_OBJECT`, `POSITION` |
| `DAS` | `tblDAS`, `tblDASChannels` | `SerialNumber`, `Type`, `MaxModules` |
| `DigitalInputSettings` | `tblDigitalInputSetting` | `SettingName`, `SettingMode`, `SensorId` |
**`DbTypeAttr`** (nested class, derives from `Attribute`)
- Used to annotate enum fields with SQL type information.
- Property: `DbType` (string)
- Static method: `GetDbType(object o)` - retrieves attribute value via reflection.
**`CustomChannelFieldSizeAttribute`** (nested class, derives from `Attribute`)
- Used to specify field sizes for MME channel fields.
- Property: `Size` (int)
---
## 3. Invariants
1. **Singleton Pattern**: `DbOperations.Connection` must always return the same instance; access is protected by `dbLock`.
2. **Connection State**: `GetSQLCommand()` ensures the returned command has an open connection; if the connection is null or closed, a new connection is created and opened.
3. **DateTime Normalization**: `CreateParam()` normalizes `DateTime` values to be at least `SqlDateTime.MinValue` to prevent SQL Server overflow errors.
4. **Timestamp Concurrency Model**:
- If `GetTimeStampDb() == 0`, the item is considered not in the database.
- `IsOutOfDate()` returns `false` if there's no record in the DB (allows creation).
- If memory timestamp is 0 but DB timestamp is non-zero, memory is synchronized to DB value.
5. **Database Mode**: The module operates in one of two modes determined by `_usingMSSQL`:
- `true`: Uses `System.Data.SqlClient` with connection string from `Server`/`DBName`.
- `false`: Uses `System.Data.SQLite` with database file at `_previousDir/datapro.db`.
---
## 4. Dependencies
**External Dependencies (from imports):**
- `System`
- `System.Collections.Generic`
- `System.ComponentModel`
- `System.Data`
- `System.Data.SqlClient`
- `System.Data.SqlTypes` (inferred from usage)
- `System.Data.SQLite` (referenced but not imported; conditional compilation)
- `System.IO` (used for path operations)
- `System.Linq`
- `System.Reflection` (used in `DbTypeAttr.GetDbType`)
- `System.Text`
**Internal Dependencies:**
- `Connection` class is referenced via `Connection.GetLocalConnectionString()` and `Connection.GetLocalISOConnectionString()` but not defined in provided sources.
**Consumers:**
- Unknown from provided sources; this module appears to be a foundational data access layer used by higher-level modules.
---
## 5. Gotchas
1. **Commented-Out Implementations**: `DbTimeStampBase` has substantial commented-out code in `GetTimeStampDb()`, `GetAllTimeStampDb()`, and `GetTimeStampDb(Dictionary<string, long>)`. These methods currently return 0 or empty dictionaries, making timestamp-based concurrency non-functional.
2. **Static Command Caching**: `GetSQLCommand()` caches the command in a static field `_cmd`. Calling without `newCommand=true` reuses the same command, which may retain parameters from previous operations (though `Parameters.Clear()` is called).
3. **Historical Field Naming in MMETables**: Comments indicate field names have changed over versions:
- `MyType``CustomChannelType``TYPE`
- `Id``ID`
This may cause compatibility issues with older database exports.
4. **Dual Database Support Complexity**: The code switches between MSSQL and SQLite based on `_usingMSSQL`. Some code paths (e.g., `CreateParam`) handle both, but the `GetSQLCommand()` method only returns `SqlCommand`, potentially causing issues in SQLite mode.
5. **Exception Re-throw Pattern**: `ExecuteCommand()` and `QueryDataSet()` use `throw ex;` which resets the stack trace. Should use `throw;` for proper exception propagation.
6. **Connection String Security**: Password is stored in a plain string property with no encryption.
7. **No Null Checks**: `DbVersion` constructor directly casts `dr["Remarks"]` and `dr["UserField"]` to string without null checking; will throw if database contains `DBNull`.

View File

@@ -0,0 +1,143 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/IUIItems.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/ITagAware.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/Tags.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/User.cs
generated_at: "2026-04-17T15:54:08.207380+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "3cdbf9b023e772e8"
---
# Documentation: DatabaseExport Users Module (Version 57)
## 1. Purpose
This module provides the user management subsystem for the `DatabaseExport` namespace, handling user identity, roles, permissions, visibility settings, and tag associations. It implements a tag caching system for efficient tag lookups, supports serialization of user data for XML storage, and manages per-user permissions on UI items. The module is part of a legacy database version (Version 57) and contains abstractions for database-backed user entities with timestamp and tagging capabilities.
---
## 2. Public Interface
### `IUIItems` (Interface)
**File:** `IUIItems.cs`
```csharp
string GetName();
```
- Returns the name of a UI item. Implementers provide a string identifier used for permission and visibility lookups in the `User` class.
---
### `TagAwareBase` (Abstract Class)
**File:** `ITagAware.cs`
**Inherits from:** `DbTimeStampBase`
**Properties:**
```csharp
byte[] TagsBlobBytes { get; set; }
int[] TagIDs { get; set; }
```
- `TagsBlobBytes`: Converts `TagIDs` to/from a byte array (4 bytes per int). The setter silently catches exceptions during conversion.
- `TagIDs`: Backed by `_tagIDs`, defaults to empty array. Setter null-coalesces to empty array.
**Methods:**
```csharp
string GetTagsCommaSeperatedString();
virtual string[] GetTagsArray();
```
- `GetTagsCommaSeperatedString()`: Returns comma-separated string of tag text by delegating to `GetTagsArray()`.
- `GetTagsArray()`: Returns string array of tag text by calling `Tags.GetTagTextFromIDs(TagIDs)`.
---
### `Tags` (Class)
**File:** `Tags.cs`
**Nested Class `Tag`:**
```csharp
public const int INVALID_ID = -1;
int ID { get; set; }
string Text { get; set; }
bool IsObsolete { get; set; }
```
- Implements `ICloneable`. Constructor from `DataRow` reads fields via `DbOperations.Tags.TagFields` enum. Copy constructor available.
**Static Properties:**
```csharp
static Tags TagsInstance { get; }
```
- Singleton accessor, lazily instantiated.
**Static Methods:**
```csharp
static string GetTagTextFromID(int tagID);
static string[] GetTagTextFromIDs(int[] tagID);
```
- `GetTagTextFromID(int)`: Returns tag text for a valid ID (> 0 and not `Tag.INVALID_ID`), or `null` if invalid/not found.
- `GetTagTextFromIDs(int[])`: Returns array of tag texts, skipping invalid IDs and null/whitespace results.
**Constructor:**
```csharp
Tags(); // Initializes _tagsLookup and calls UpdateList()
```
---
### `User` (Class)
**File:** `User.cs`
**Inherits from:** `TagAwareBase`
**Nested Enums:**
```csharp
public enum DefaultRoles { Administrator = 0, PowerUser = 1, User = 2, Guest = 3 }
public enum UserPermissionLevels { Deny = 0, Read = 1, ReadAndExecute = 2, Edit = 3, Admin = 4 }
public enum Tags { User, Role, Version, LastModified, LastModifiedBy, Name, UserName, Password, LocalOnly, Permissions, Visibility, Id }
public enum XmlFields { ID, UserName, DisplayName, Password, IUIItemPermissions, IUIItemVisibility, Role, LastModified, LastModifiedBy, Version, LocalOnly, UserTags }
```
**Constants:**
```csharp
private const string DEFAULT_LAST_MODIFIED_BY = "---";
private const string DEFAULT_ADMIN_USERNAME = "Admin";
private const string DEFAULT_GUEST_USERNAME = "Guest";
private const string DEFAULT_POWERUSER_USERNAME = "PowerUser";
private const string DEFAULT_USER_USERNAME = "User";
private const int INVALID_ID = -1;
```
**Properties:**
```csharp
bool IsADefaultUser { get; }
string Name { get; set; }
string UserName { get; set; }
int Id { get; set; }
DefaultRoles Role { get; set; }
int Version { get; set; }
DateTime LastModified { get; set; }
string LastModifiedBy { get; set; }
bool LocalOnly { get; set; }
```
- `Role` setter throws `NotSupportedException` if user is a default user and role changes.
- All setters use `SetProperty(ref field, value, Tags.EnumName.ToString())`.
**Constructor:**
```csharp
User(DataRow row);
```
- Populates user from `DbOperations.Users.UserFields` columns.
**Methods:**
```csharp
override ConstraintHelper[] GetConstraints();
override string LookupTable { get; }
string GetPermissionSerialized();
static string GetDefaultUserName(DefaultRoles role);
string GetVisibilitySerialized();
Dictionary<string, string> GetValues();
```
- `GetConstraints()`: Returns single constraint on `UserName` column.
- `LookupTable`: Returns `DbOperations.Users.USERS_TABLE`.
- `GetPermissionSerialized()`: Returns `"ItemName=PermissionValue,..."` string from `_tabPermissions` dictionary.
- `GetDefaultUserName(DefaultRoles)`: Maps role enum to default username string; throws `NotSupportedException` for unknown roles.
- `Get

View File

@@ -0,0 +1,91 @@
---
source_files:
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Utilities/DiskUtility.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Utilities/Exceptional.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Utilities/ExceptionalList.cs
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Utilities/AttributeCoder.cs
generated_at: "2026-04-17T15:53:59.285477+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "c2a6300146b5dc97"
---
# Documentation: DatabaseExport Utilities
## 1. Purpose
This module provides utility classes for the `DatabaseExport` subsystem within the DataPRO Version 57 codebase. It includes an exception-handling base class hierarchy (`Exceptional`, `ExceptionalList<T>`) designed to enable type-specific exception catching, a disk/file validation utility (`DiskUtility`), and a reflection-based attribute manipulation framework (`AttributeCoder<TargetType, AttributeType, AttributeValueType>`) for encoding/decoding attribute values attached to types—primarily intended for use with enumeration types.
---
## 2. Public Interface
### `Exceptional` (abstract class)
**Namespace:** `DatabaseExport`
**Inheritance:** `object``Exceptional`
**Attributes:** `[Serializable]`
An abstract marker/base class with no members. Intended as the "ultimate" base class for classes that expect to throw exceptions, allowing callers to catch exceptions by the throwing class's type.
---
### `ExceptionalList<T>` (generic class)
**Namespace:** `DatabaseExport`
**Inheritance:** `List<T>``ExceptionalList<T>`
**Attributes:** `[global::System.Serializable]`
A generic collection that inherits from `List<T>` and is intended to provide its own exception type. No additional members are defined beyond those inherited from `List<T>`.
---
### `DiskUtility` (static class)
**Namespace:** `DatabaseExport`
**Inheritance:** `Exceptional``DiskUtility`
A collection of disk-related utility methods.
#### Methods
| Signature | Description |
|-----------|-------------|
| `public static bool ValidateFileAndPathNameChars(string nameToValidate)` | Validates that the input string contains no illegal file or path characters. Returns `true` if valid, `false` otherwise. |
**Validation rules applied:**
- Rejects strings that are empty or whitespace-only after trimming
- Rejects strings containing any character from `Path.GetInvalidFileNameChars()`
- Rejects strings containing any character from `Path.GetInvalidPathChars()`
- Rejects strings containing the period character (`'.'`)
---
### `AttributeCoder<TargetType, AttributeType, AttributeValueType>` (generic class)
**Namespace:** `DatabaseExport`
**Inheritance:** `Exceptional``AttributeCoder<,,>`
A reflection-based utility for manipulating attributes attached to types, designed primarily for enum-to-attribute value mapping.
#### Delegates
| Delegate | Signature |
|----------|-----------|
| `AttributeValueExtractionMethod` | `AttributeValueType(AttributeType attribute)` |
| `AttributeValueEqualityComparisonMethod` | `bool(AttributeValueType value1, AttributeValueType value2)` |
#### Constructor
```csharp
public AttributeCoder(
AttributeValueExtractionMethod attributeValueExtractionMethod,
AttributeValueEqualityComparisonMethod attributeValueEqualityComparisonMethod)
```
Initializes the coder with a required extraction method and an optional equality comparison method. If `attributeValueEqualityComparisonMethod` is `null`, default equality comparison is used.
#### Methods
| Signature | Description |
|-----------|-------------|
| `public AttributeValueType DecodeAttributeValue(TargetType target)` | Returns the attribute value of `AttributeType` attached to the specified `TargetType`. Expects exactly one attribute; throws if none found. |
| `public List<AttributeValueType> DecodeAttributeValues(TargetType target)` | Returns a list of all `AttributeValueType` values from `AttributeType` attributes attached to the specified `TargetType`. |
| `public TargetType EncodeAttributeValue(AttributeValueType attributeValue)` | Returns the `TargetType` value that has an `AttributeType` attribute with the specified value. Expects exactly one match; throws otherwise. |
| `public List<TargetType> DehashAttributeValue(AttributeValueType attributeValue)` | Returns