init
This commit is contained in:
@@ -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
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
|
||||
---
|
||||
|
||||
@@ -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 |
|
||||
|--------|-----------|-------------|
|
||||
|
|
||||
@@ -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
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user