init
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
---
|
||||
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-16T04:59:11.131587+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "45f7e783788f3070"
|
||||
---
|
||||
|
||||
# Hardware
|
||||
|
||||
## Documentation: DAS Hardware Abstraction Layer (Version 57)
|
||||
|
||||
### 1. Purpose
|
||||
This module provides a version-specific abstraction layer for DAS (Data Acquisition System) hardware configuration and metadata within the `DatabaseExport` subsystem of the DataPRO system. It enables serialization of DAS settings (e.g., sample rate, AAF, trigger timing) into the legacy database schema (`tblTestSetupDASSettings`, `tblDAS`, `tblDASChannel`) and supports hardware discovery, comparison, and channel management. The classes (`DASSettings`, `HardwareChannel`, `DASHardware`, `DASHardwareList`) serve as DTOs and adapters for interacting with historical database structures, preserving compatibility with Version 57 schema while abstracting underlying `Hardware` and `ISOHardwareChannel` objects.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `DASSettings`
|
||||
- **Properties**
|
||||
- `string DASSerialNumber { get; set; }` — Serial number of the DAS device associated with the test settings.
|
||||
- `double SampleRate { get; set; }` — Sampling rate (Hz) configured for the test.
|
||||
- `int ExcitationWarmupTimeMS { get; set; }` — Warm-up time (milliseconds) for excitation voltage before data acquisition.
|
||||
- `double HardwareAAF { get; set; }` — Hardware anti-aliasing filter cutoff frequency (Hz).
|
||||
- `double PreTriggerSeconds { get; set; }` — Duration (seconds) of data captured *before* a trigger event.
|
||||
- `double PostTriggerSeconds { get; set; }` — Duration (seconds) of data captured *after* a trigger event.
|
||||
- `bool StatusLineCheck { get; set; }` — Flag indicating whether status line monitoring is enabled.
|
||||
- `bool BatteryCheck { get; set; }` — Flag indicating whether battery voltage monitoring is enabled.
|
||||
- `double InputVoltageMin { get; set; }` — Minimum acceptable input voltage (volts).
|
||||
- `double InputVoltageMax { get; set; }` — Maximum acceptable input voltage (volts).
|
||||
- `double BatteryVoltageMin { get; set; }` — Minimum acceptable battery voltage (volts).
|
||||
- `double BatteryVoltageMax { get; set; }` — Maximum acceptable battery voltage (volts).
|
||||
|
||||
#### `HardwareChannel`
|
||||
- **Constructors**
|
||||
- `HardwareChannel(HardwareChannel copy)` — Deep-copies channel data (including `Sensor`).
|
||||
- `HardwareChannel(ISOHardwareChannel channel, DASHardware hardware)` — Initializes from an `ISOHardwareChannel` and its parent `DASHardware`.
|
||||
- **Properties**
|
||||
- `DASHardware Hardware { get; }` — Parent DAS hardware instance.
|
||||
- `int ChannelNumber { get; }` — Zero-based channel index (`ChannelIdx` from `ISOHardwareChannel`).
|
||||
- `SensorData Sensor { get; set; }` — Sensor configuration for this channel (nullable).
|
||||
- `TestObjectChannel TestObjectChannel { get; set; }` — Logical test object channel mapped to this hardware channel.
|
||||
- **Methods**
|
||||
- `ISOHardwareChannel GetISOChannel()` — Returns the underlying `ISOHardwareChannel` instance.
|
||||
- `int CompareTo(HardwareChannel right)` — Compares channels first by `DASDisplayOrder`, then by `ChannelIdx`.
|
||||
- `string GetId()` — Returns a unique ID in the format `{HardwareId}x{1-based ChannelNumber}`.
|
||||
- `bool IsSupportedBridgeType(Test.Module.Channel.Sensor.BridgeType bridgeType)` — Checks if `bridgeType` is supported by this channel (via bitwise AND with `SupportedBridges`).
|
||||
|
||||
#### `DASHardware`
|
||||
- **Properties**
|
||||
- `string SerialNumber { get; set; }` — DAS serial number (from `_hardware.SerialNumber`).
|
||||
- `string Connection { get; set; }` — Network address (e.g., IP) for the DAS (from `_hardware.IPAddress`).
|
||||
- `DateTime CalDate { get; }` — Calibration date (read-only, from `_hardware.CalDate`).
|
||||
- `HardwareChannel[] Channels { get; set; }` — Sorted array of channels (sorted by `CompareTo` in setter).
|
||||
- `bool LocalOnly { get; set; }` — Flag indicating local-only operation (from `_hardware.LocalOnly`).
|
||||
- **Methods**
|
||||
- `Hardware GetHardware()` — Returns the underlying `Hardware` instance.
|
||||
- `int GetHardwareTypeInt()` — Returns `_hardware.DASType` as an integer.
|
||||
- `HardwareTypes GetHardwareTypeEnum()` — Casts `DASType` to `Hardware.HardwareTypes` enum.
|
||||
- `long GetMaxMemoryLong()` — Returns `_hardware.MaxMemory`.
|
||||
- `Dictionary<string, string> GetValues()` — Serializes DAS metadata (e.g., serial, type, firmware, sample rates, channel types) into a dictionary keyed by `DbOperations.DAS.Fields` enum values.
|
||||
- `Dictionary<string, string> GetChannelValues(HardwareChannel channel)` — Serializes channel metadata (e.g., `ChannelIdx`, `SupportedBridges`, `DASDisplayOrder`) into a dictionary keyed by `DbOperations.DAS.DASChannelFields` enum values.
|
||||
- `bool IsDummy()` — Returns `true` if `SerialNumber` contains `"Dummy"`.
|
||||
- **Inherited from `DbTimeStampBase`**
|
||||
- `override string LookupTable => "tblDAS"` — Database table name for persistence.
|
||||
- `override ConstraintHelper[] GetConstraints()` — Returns a constraint for `SerialNumber` (used for DB lookups).
|
||||
|
||||
#### `DASHardwareList` (Singleton)
|
||||
- **Methods**
|
||||
- `static DASHardwareList GetList()` — Returns the singleton instance (lazy-initialized via `PopulateHardware`).
|
||||
- `DASHardware GetHardware(string id)` — Retrieves DAS by ID (hardware ID or serial number).
|
||||
- `DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed)` — Retrieves DAS; if ID format includes a type suffix (e.g., `SN_123`) and the hardware type has changed, throws `HardwareTypeChangedException` (if `bThrowExceptionIfChanged=true`) or sets `changed=true`.
|
||||
- `DASHardware[] Hardware { get; }` — Returns all non-prototype DAS instances.
|
||||
- **Nested Exception**
|
||||
- `HardwareTypeChangedException : Exception` — Thrown when hardware type mismatch is detected during lookup.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
- **Channel Ordering**: `HardwareChannel.CompareTo` enforces ordering by `DASDisplayOrder` first, then `ChannelIdx`.
|
||||
- **Channel Array Consistency**: Setting `DASHardware.Channels` sorts the array internally and raises `OnPropertyChanged` for both `Channels` and `ChannelCount`.
|
||||
- **Hardware ID Format**: `HardwareChannel.GetId()` uses `1 + ChannelNumber` (1-based indexing in ID, 0-based in `ChannelNumber`).
|
||||
- **Prototype Exclusion**: `DASHardwareList.GetAllHardware()` filters out hardware with `Position == "Prototype"`.
|
||||
- **Serial Number Uniqueness**: `DASHardwareList` uses `_hardware.ContainsKey(h.GetHardware().GetId())` for deduplication during population.
|
||||
- **Dummy Detection**: `IsDummy()` checks for substring `"Dummy"` in `SerialNumber` (case-sensitive).
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
- **Internal Dependencies**
|
||||
- `Hardware` (from `DatabaseExport.Hardware` namespace) — Core data model for DAS hardware metadata.
|
||||
- `ISOHardwareChannel` — Encapsulates channel-level metadata (e.g., `ChannelIdx`, `SupportedBridges`).
|
||||
- `DbOperations.DAS.Fields` / `DbOperations.DAS.DASChannelFields` — Enumerations defining database column names (used in `GetValues`/`GetChannelValues`).
|
||||
- `DbTimeStampBase` — Base class for time-stamped database entities (provides `LookupTable`, `GetConstraints`, `DbTimeStamp`).
|
||||
- `SensorData` — Sensor configuration (used in `HardwareChannel`).
|
||||
- `Test.Module.Channel.Sensor.BridgeType` — Bridge type enum (used in `IsSupportedBridgeType`).
|
||||
- **External Dependencies**
|
||||
- `System.Collections.Generic`, `System.Linq`, `System.Data.SqlDbType` — Standard .NET libraries.
|
||||
- `System.IComparable<T>` — Implemented by `HardwareChannel` and `DASHardware`.
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
- **`CompareTo` Null Handling**: `HardwareChannel.CompareTo` returns `0` for `null` input (non-standard behavior; typically `null` comparisons should return `1`).
|
||||
- **`GetHardware(string id)` Ambiguity**: Lookup prioritizes hardware ID (e.g., `"DAS_123"`) over serial number, but falls back to serial if ID fails. If the ID contains `_` (e.g., `"SN_123"`), it truncates to `"SN"` for serial matching, risking incorrect matches.
|
||||
- **`Channels` Setter Sorts In-Place**: The setter sorts the input list and replaces `_channels`, but does not validate channel uniqueness or consistency with `_hardware.ISOChannels`.
|
||||
- **`IsDummy()` Substring Match**: `IsDummy()` uses `Contains("Dummy")`, which may yield false positives (e.g., `"MyDummyDAS"`).
|
||||
- **`DASHardwareList` Singleton Initialization**: Thread-safety is not guaranteed (no locking in `GetList()`).
|
||||
- **Hardcoded Prototype Filter**: Prototype exclusion uses a magic string `"Prototype"` (comment notes `/*DbOperations.DAS.PROTOTYPE_POSITION*/` suggests a constant should be used).
|
||||
- **`GetChannelValues` Field Names**: Uses `DbOperations.DAS.DASChannelFields` enum values directly as keys; mismatches here would cause DB schema errors.
|
||||
- **No Validation in `DASSettings`**: Properties lack validation (e.g., negative `SampleRate` or `PreTriggerSeconds` allowed).
|
||||
|
||||
None identified beyond these source-observable quirks.
|
||||
@@ -0,0 +1,197 @@
|
||||
---
|
||||
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-16T04:59:50.772455+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "086bec3733d0d7e4"
|
||||
---
|
||||
|
||||
# Documentation: `Region` and `Zone` Classes (DatabaseExport Module, Version 57)
|
||||
|
||||
---
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides data structures and UI adorning logic for representing and manipulating *regions* and *zones* within medical imaging test object templates, conforming to ISO 13499 standards. The `Zone` class encapsulates a named area of an image (with optional picture, description, and associated regions), while the `Region` class defines a rectangular sub-region with associated MME (Medical Monitoring Equipment) metadata (e.g., direction, filter class, transducer location). The `RegionAdorner` class enables interactive drawing and manipulation of regions on WPF `Image` elements. Together, they support editing, serialization, and ISO-compliant code generation for test object configurations.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `Zone` Class (`Zone.cs`)
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| **Constructor** | `Zone(TemplateZone z, TestObjectTemplate template)` | Initializes a `Zone` from a `TemplateZone` and `TestObjectTemplate`. Loads picture, sets description, and constructs `Region` objects from `z.TemplateRegions`. |
|
||||
| `Name` | `string Name { get; set; }` | Gets or sets the zone name (from `z.ZoneName`). |
|
||||
| `Description` | `string Description { get; set; }` | Gets or sets the zone description (from `z.Description`; defaults to `""` if null). |
|
||||
| `Image` | `string Image { get; set; }` | Gets or sets the picture filename (from `z.Picture`). |
|
||||
| `ISODllZone` | `TemplateZone ISODllZone { get; }` | Immutable reference to the underlying `TemplateZone` object. |
|
||||
| `AllPictures` | `string[] AllPictures { get; }` | Returns an alphabetically sorted array of all picture filenames (by `FileInfo.FullName`) in the `"ZonePictures"` subdirectory of `AppDomain.CurrentDomain.BaseDirectory`. |
|
||||
| `PictureIndex` | `int PictureIndex { get; set; }` | Gets or sets the index of the currently selected picture in `AllPictures`. Setting to `< 0` clears `PictureSource`; otherwise, loads and sets `BitmapImage` from `_fileNames[value].FullName`. |
|
||||
| `GetPictureName()` | `string GetPictureName()` | Returns the filename of the picture at `_pictureIndex`, or `""` if `_pictureIndex < 0`. |
|
||||
| `PictureSource` | `System.Windows.Media.ImageSource PictureSource { get; set; }` | Gets or sets the WPF `ImageSource` for the currently selected picture. Initialized to `null`. |
|
||||
| `Regions` | `Region[] Regions { get; set; }` | Gets or sets the array of `Region` objects associated with this zone. Internally stored as `List<Region>`. |
|
||||
|
||||
#### Nested Type: `FileInfoComparer`
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `Compare` | `int IComparer<FileInfo>.Compare(FileInfo left, FileInfo right)` | Compares two `FileInfo` objects by `FullName`. Handles `null` inputs (`null < non-null`). |
|
||||
|
||||
---
|
||||
|
||||
### `Region` Class (`Region.cs`)
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| **Constructors** | `Region(RegionAdorner adorner, TestObjectTemplate template)`<br>`Region(TestObjectTemplate template, TemplateRegion r)` | First: Creates a *new* region (e.g., for drawing), initializes defaults (`"New region"`, `"Describe region"`), and populates ISO settings from `template`.<br>Second: Loads region from persisted `TemplateRegion` (e.g., deserialization), including coordinates, ISO codes, and filters channels. |
|
||||
| `RegionName` | `string RegionName { get; set; }` | Gets or sets the region name. Triggers `InvalidateVisual()` on change. |
|
||||
| `RegionDescription` | `string RegionDescription { get; set; }` | Gets or sets the region description. Triggers `InvalidateVisual()` on change. |
|
||||
| `RegionUpperLeft` | `Point RegionUpperLeft { get; set; }` | Gets or sets the upper-left coordinate of the region (WPF `Point`, in pixel space). |
|
||||
| `RegionBottomRight` | `Point RegionBottomRight { get; set; }` | Gets or sets the bottom-right coordinate of the region (WPF `Point`, in pixel space). |
|
||||
| `RegionDirection` | `MMEDirections RegionDirection { get; set; }` | Gets or sets the direction (e.g., `"A"`, `"S"`, `"?"`). Triggers `SetISOCode()`. |
|
||||
| `RegionFilterClass` | `MMEFilterClasses RegionFilterClass { get; set; }` | Gets or sets the filter class. Updates `_filterClassIndex` and triggers `SetISOCode()`. |
|
||||
| `RegionFineLocation1/2/3` | `MMEFineLocations1/2/3 RegionFineLocation1/2/3 { get; set; }` | Gets or sets fine location properties. Each triggers `SetISOCode()`. |
|
||||
| `RegionMainLocation` | `MMETransducerMainLocation RegionMainLocation { get; set; }` | Gets or sets the main transducer location. Triggers `SetISOCode()`. |
|
||||
| `RegionPhysicalDimension` | `MMEPhysicalDimensions RegionPhysicalDimension { get; set; }` | Gets or sets the physical dimension (e.g., `"mm"`, `"??"`). Triggers `SetISOCode()`. |
|
||||
| `RegionPosition` | `MMEPositions RegionPosition { get; set; }` | Gets or sets the position (e.g., `"P1"`, `"?"`). Triggers `SetISOCode()`. |
|
||||
| `RegionTestObject` | `MMETestObjects RegionTestObject { get; set; }` | Gets or sets the associated test object (from ISO code or template). |
|
||||
| `RegionChannels` | `TestObjectTemplateChannel[] RegionChannels { get; set; }` | Gets or sets the list of channels *filtered* by current region settings. Setting triggers `DetermineAvailableISOSettings()`. |
|
||||
| `RegionUIChannels` | `TemplateChannelUI[] RegionUIChannels { get; set; }` | Gets or sets the UI channel list corresponding to `RegionChannels`. |
|
||||
| `ISOCode` | `string ISOCode { get; set; }` | Gets or sets the 16-character ISO code (e.g., `"A1B2C3D4E5F6G7H8"`). Computed from `SetISOCode()` using all region properties. |
|
||||
| `AllDirections`, `AllFilterClasses`, `AllFineLocations1/2/3`, `AllMainLocations`, `AllPhysicalDimensions`, `AllPositions` | `T[] AllX { get; set; }` | Arrays of available ISO enum values (e.g., `MMEDirections[]`). Each has a corresponding `AllXStrings` property (e.g., `string[] AllDirectionsStrings`). Setting populates the string array from `Text_L1` (or `"?"`, `"??"`, `"????"` for nulls). |
|
||||
| `AllDirectionsStrings`, `AllFilterClassStrings`, `AllFineLocations1Strings`, `AllFineLocations2Strings`, `AllFineLocations3Strings`, `AllMainLocationsStrings`, `AllPhysicalDimensionStrings`, `AllPositionStrings` | `string[] AllXStrings { get; set; }` | String representations of the corresponding enum arrays. |
|
||||
| `RegionAddVisibility` | `Visibility RegionAddVisibility { get; set; }` | Gets or sets UI visibility for "add region" controls. Default: `Visible`. |
|
||||
| `RegionDeleteVisibility` | `Visibility RegionDeleteVisibility { get; set; }` | Gets or sets UI visibility for "delete region" controls. Default: `Hidden`. |
|
||||
| `Template` | `TestObjectTemplate Template { get; set; }` | Gets or sets the parent template. Setting triggers `DetermineAvailableISOSettings()`. |
|
||||
| `ToISORegion(TestObjectTemplate, Zone, int)` | `TemplateRegion ToISORegion(TestObjectTemplate template, Zone zone, int number)` | Serializes this `Region` to a `TemplateRegion` object, converting `Point` coordinates to `System.Drawing.Point` and handling nulls with ISO defaults (`"?"`, `"??"`, etc.). |
|
||||
|
||||
---
|
||||
|
||||
### `RegionAdorner` Class (`RegionAdorner.cs`)
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| **Constructor** | `RegionAdorner(UIElement adornedElement, TestObjectTemplate template, Contexts context)` | Creates a new adorner for an `Image`. Initializes `_region`, `SelectRect`, `_geometry`, and `_path` (blue, semi-transparent stroke). Attaches mouse event handlers. |
|
||||
| `GetUpperLeft()` | `Point GetUpperLeft()` | Returns the *upper-left* point of `SelectRect`, adjusted for image scaling (difference between `RenderSize` and `Source` dimensions). |
|
||||
| `GetLowerRight()` | `Point GetLowerRight()` | Returns the *lower-right* point of `SelectRect`, similarly scaled. Returns `(0,0)` if `AdornedElement.Source` is `null`. |
|
||||
| `IsNew` | `bool IsNew { get; set; }` | Gets or sets whether this adorner represents a *new* region being drawn. Updates `RegionAddVisibility`/`RegionDeleteVisibility` accordingly. |
|
||||
| `AnchorPoint` | `Point AnchorPoint { get; set; }` | Gets or sets the starting point for drawing (set on `MouseDown`). |
|
||||
| `SelectRect` | `Rect SelectRect { get; set; }` | Gets or sets the current selection rectangle. Updates `MyRegion.RegionUpperLeft`/`RegionBottomRight` via `GetUpperLeft()`/`GetLowerRight()`. |
|
||||
| `MyRegion` | `Region MyRegion { get; set; }` | Gets or sets the associated `Region` instance. |
|
||||
| `Context` | `Contexts Context { get; set; }` | Gets or sets the editing context (`EditTestObject` or `EditTestObjectTemplate`). |
|
||||
| `OnRegionSelected` | `event RegionSelectedHandler OnRegionSelected` | Event raised on `MouseLeftButtonDown`. |
|
||||
| `OnEndSelection` | `event EndSelectionHandler OnEndSelection` | Event raised on `MouseLeftButtonUp` (after `EndSelection()`). |
|
||||
| `Region_MouseMove` | `void Region_MouseMove(...)` | Handles mouse drag: calls `DrawSelection()` (if `IsNew`) or `MoveSelection()` (if editing). Invalidates visuals. |
|
||||
| `DrawSelection` | `void DrawSelection(...)` | Updates `SelectRect` to a rectangle between `AnchorPoint` and current mouse position. |
|
||||
| `MoveSelection` | `void MoveSelection(...)` | Moves `SelectRect` by the delta from the previous mouse position (`p1`). |
|
||||
| `EndSelection` | `void EndSelection(...)` | Releases mouse capture and raises `OnEndSelection`. |
|
||||
|
||||
#### Nested Type: `Contexts`
|
||||
| Value | Description |
|
||||
|-------|-------------|
|
||||
| `EditTestObject` | Context for editing a specific test object instance. |
|
||||
| `EditTestObjectTemplate` | Context for editing a reusable template. |
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **`Zone`**:
|
||||
- `Description` is never `null`; defaults to `""` if `z.Description` is `null`.
|
||||
- `Image` is set from `z.Picture`; if non-empty, the code attempts to load the image from `"ZonePictures/{Image}"`.
|
||||
- `PictureIndex` is `-1` if the image file does not exist or fails to load (e.g., invalid format).
|
||||
- `Regions` is always initialized as a `List<Region>`; populated from `z.TemplateRegions` in the constructor.
|
||||
|
||||
- **`Region`**:
|
||||
- `ISOCode` is always 16 characters (uses `"?"`, `"??"`, `"????"` for null/missing values).
|
||||
- `RegionChannels` and `RegionUIChannels` are filtered based on current ISO settings (direction, filter class, fine locations, etc.) via `FilterRegionChannels()`.
|
||||
- `DetermineAvailableISOSettings()` ensures that each enum property (e.g., `RegionDirection`) includes a wildcard option (`"?"`, `"??"`) in its `AllX` array.
|
||||
- `RegionTestObject` is set from the first distinct test object in `RegionChannels` during `DetermineAvailableISOSettings()`.
|
||||
|
||||
- **`RegionAdorner`**:
|
||||
- `SelectRect` is always synchronized with `MyRegion.RegionUpperLeft`/`RegionBottomRight`.
|
||||
- Scaling adjustments in `GetUpperLeft()`/`GetLowerRight()` assume the `AdornedElement` is an `Image` with a `Source` of known dimensions.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Imports/References (from source):
|
||||
- **WPF namespaces**: `System.Windows.*` (`Adorner`, `Image`, `MouseEventArgs`, `Point`, `Rect`, `Visibility`, `Brushes`, `Path`, `RectangleGeometry`, `ImageSource`, `BitmapImage`).
|
||||
- **System.IO**: `AppDomain`, `Directory`, `Path`, `FileInfo`.
|
||||
- **Custom types** (inferred from usage):
|
||||
- `TestObjectTemplate`, `TemplateRegion`, `TemplateZone`, `TestObjectTemplateChannel`, `TemplateChannelUI`
|
||||
- ISO enums: `MMEDirections`, `MMEFilterClasses`, `MMEFineLocations1/2/3`, `MMETransducerMainLocation`, `MMEPhysicalDimensions`, `MMEPositions`, `MMETestObjects`
|
||||
- `ISO13499FileDb.IsoDb` (static singleton with methods like `GetDirectionByIso`, `GetFilterClassByIso`, etc.)
|
||||
- `ISO.IsoCode.GetString(...)` (static method for code generation)
|
||||
- `Common.BindableBase` (commented out in `Zone` class definition; not used)
|
||||
|
||||
### Inferred Consumers:
|
||||
- UI layers (WPF) that use `RegionAdorner` to draw/edit regions on images.
|
||||
- Serialization/deserialization logic (via `ToISORegion` and `Region(TemplateRegion)` constructor).
|
||||
- Code that accesses `Zone.Regions` and `Region.RegionChannels` for analysis or export.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`PictureIndex` and `AllPictures`**:
|
||||
`AllPictures` is lazily initialized on first access and sorted by `FileInfo.FullName`. If the `"ZonePictures"` directory is missing or inaccessible, `_fileNames` remains `null`, and `PictureIndex` will always be `-1`.
|
||||
|
||||
- **Scaling in `GetUpperLeft()`/`GetLowerRight()`**:
|
||||
The scaling logic assumes the `AdornedElement` is an `Image` with a `Source` whose dimensions differ from `RenderSize`. If `Source` is `null`, `GetLowerRight()` returns `(0,0)`; `GetUpperLeft()` may throw if `Source` is `null` (though not explicitly guarded).
|
||||
|
||||
- **Null Handling in ISO Enums**:
|
||||
Enum properties (e.g., `RegionDirection`) may be `null`, and their string representations use `"?"` (or `"??"`, `"????"`). This is critical for ISO code generation.
|
||||
|
||||
- **Channel Filtering**:
|
||||
`FilterRegionChannels()` mutates `_regionChannels`/`_regionUIChannels` in-place. If `RegionChannels` is set externally, `DetermineAvailableISOSettings()` is triggered, which may overwrite user selections if no channels match.
|
||||
|
||||
- **`FileInfoComparer`**:
|
||||
Compares by `FullName`, not `Name`. This may cause unexpected ordering if paths differ (e.g., `"ZonePictures/a.png"` vs `"ZonePictures/sub/a.png"`).
|
||||
|
||||
- **No `INotifyPropertyChanged`**:
|
||||
The `Zone` class has `Common.BindableBase` commented out. Changes to properties (e.g., `PictureIndex`, `Regions`) do not raise change notifications (unless handled elsewhere).
|
||||
|
||||
- **`IsNew` Side Effects**:
|
||||
Setting `IsNew = true` hides delete controls and shows add controls, but does *not* reset `SelectRect` or `MyRegion` coordinates.
|
||||
|
||||
- **`ToISORegion` Coordinate Conversion**:
|
||||
Converts `Point` (WPF, `double`) to `System.Drawing.Point` (WinForms, `int`) via `Convert.ToInt32(...)`, which truncates (not rounds). May cause precision loss.
|
||||
|
||||
- **No Thread Safety**:
|
||||
`AllPictures` uses non-thread-safe lazy initialization (`_fileNames`). Concurrent access may cause race conditions.
|
||||
|
||||
- **`_pictureIndex` Field**:
|
||||
`_pictureIndex` is private and used only in `PictureIndex`. It is not synchronized with `PictureSource` if set directly (though the property setter handles this).
|
||||
|
||||
- **`RegionAdorner` Mouse Capture**:
|
||||
`EndSelection` calls `ReleaseMouseCapture()`, but there is no explicit `CaptureMouse()` call in `DrawSelection`/`MoveSelection`. Mouse events may fire even after drag ends if capture was not held.
|
||||
|
||||
- **Hardcoded Paths**:
|
||||
`"ZonePictures"` is hardcoded as the picture directory. No configuration or fallback is provided.
|
||||
|
||||
- **`TemplateRegion` Constructor**:
|
||||
`ToISORegion` passes `template.IsLocalOnly` to `TemplateRegion` constructor, but `IsLocalOnly` is not used elsewhere in the provided code.
|
||||
|
||||
- **`Region` Constructor Overload**:
|
||||
The `Region(TestObjectTemplate, TemplateRegion)` constructor does *not* call `FilterRegionChannels()` until after setting all properties, but `SetISOCode()` is called at the end. This is safe, but the intermediate state may be inconsistent.
|
||||
|
||||
- **`AllX` Properties**:
|
||||
Setting `AllX` (e.g., `AllDirections`) populates `AllXStrings` from `Text_L1`, but setting `AllXStrings` does *not* update `AllX`. This breaks two-way binding if used.
|
||||
|
||||
- **`RegionAdorner` Mouse Events**:
|
||||
`Region_MouseLeftButtonDown` raises `OnRegionSelected`, but does *not* set `AnchorPoint` or begin selection. This must be handled externally (e.g., by the adorner layer).
|
||||
|
||||
- **`RegionAdorner` `_MeasuredSize`**:
|
||||
`_MeasuredSize` is set from `adornedElement.RenderSize` in the constructor. If the element resizes later, scaling calculations become incorrect.
|
||||
|
||||
- **`RegionAdorner` `IsNew` Default**:
|
||||
`IsNew` defaults to `true`, meaning the adorner starts in "drawing" mode unless explicitly set to `false`.
|
||||
|
||||
- **`RegionAdorner` `AnchorPoint` Initialization**:
|
||||
`AnchorPoint` is not initialized in the constructor. If `DrawSelection` is called before `AnchorPoint` is set, it will be `
|
||||
@@ -0,0 +1,55 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TabPage/TabPageCommon.cs
|
||||
- DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TabPage/TabPage.cs
|
||||
generated_at: "2026-04-16T04:59:00.585426+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "2bb1e521c729f483"
|
||||
---
|
||||
|
||||
# TabPage
|
||||
|
||||
## Documentation: `TabPageCommon` and Related Types
|
||||
|
||||
### 1. Purpose
|
||||
This module defines a lightweight, hierarchical data model for representing UI tab structures during database export operations in legacy (Version 57) contexts. It provides base abstractions (`TabPageCommon`, `TabPageItem`, `TabPageItemGroup`) to encapsulate tab content and grouping, and a singleton `TabPageSource` to expose a global collection of tab groups. The model is intended for *data export* (e.g., serialization, reporting), not runtime UI rendering—though it references `UserControl`, suggesting it may originate from or interface with WPF UI components.
|
||||
|
||||
### 2. Public Interface
|
||||
- **`TabPageCommon`** (abstract class)
|
||||
- `public virtual string GetName()` → Returns the value of `UniqueId`.
|
||||
- `public string UniqueId { get; set; }` → A string identifier; defaults to `string.Empty`. Used as the logical name via `GetName()`.
|
||||
|
||||
- **`TabPageItem`** (class, inherits `TabPageCommon`)
|
||||
- `public UserControl Content { get; set; }` → Holds the WPF UI content for the tab (nullable). Represents a single tab page.
|
||||
|
||||
- **`TabPageItemGroup`** (class, inherits `TabPageCommon`)
|
||||
- `public ObservableCollection<TabPageItem> Items { get; }` → A mutable collection of `TabPageItem` instances belonging to this group. Initialized lazily (non-null).
|
||||
|
||||
- **`TabPageSource`** (static singleton class)
|
||||
- `public ObservableCollection<TabPageItemGroup> AllGroups { get; }` → Global collection of tab groups.
|
||||
- `public static IEnumerable<TabPageItemGroup> GetGroups(string uniqueid)` → Returns `_source.AllGroups` *only if* `uniqueid == "AllGroups"`; otherwise throws `ArgumentException`.
|
||||
- *Note:* The method name and parameter suggest extensibility (e.g., filtering by ID), but only one value is currently supported.
|
||||
|
||||
### 3. Invariants
|
||||
- `TabPageCommon.UniqueId` must be set to a non-null, non-whitespace string for meaningful identification (though not enforced by code).
|
||||
- `TabPageItem.Content` may be `null`, but no validation prevents this.
|
||||
- `TabPageItemGroup.Items` is never `null` (initialized inline) and uses `ObservableCollection<T>`, implying change notifications are expected.
|
||||
- `TabPageSource.GetGroups()` enforces a strict invariant: **only** `"AllGroups"` is accepted as `uniqueid`; any other value throws `ArgumentException`.
|
||||
- `TabPageSource` is a singleton: `_source` is initialized once and reused.
|
||||
|
||||
### 4. Dependencies
|
||||
- **Depends on**:
|
||||
- `System` (core types: `ArgumentException`, `IEnumerable<T>`, `ObservableCollection<T>`)
|
||||
- `System.Collections.Generic` (`IEnumerable<T>`)
|
||||
- `System.Collections.ObjectModel` (`ObservableCollection<T>`)
|
||||
- `System.Windows.Controls` (`UserControl`)
|
||||
- **Depended on by**:
|
||||
- Unknown from source alone. Given the namespace `DatabaseExport`, this module is likely consumed by export-specific logic (e.g., serialization to XML/JSON, reporting tools). No explicit references to consumers are present.
|
||||
|
||||
### 5. Gotchas
|
||||
- **Misleading `GetGroups` signature**: Despite accepting a `uniqueid` parameter, it only supports `"AllGroups"`. This suggests incomplete implementation or legacy design—future extensions may break callers if they assume filtering capability.
|
||||
- **`GetName()` is trivial**: It directly returns `UniqueId` without normalization or fallback logic. Callers must ensure `UniqueId` is set meaningfully.
|
||||
- **`UserControl` coupling**: Using `System.Windows.Controls.UserControl` ties this module to WPF, despite being in a *database export* context. This may cause issues if reused in non-UI or cross-platform scenarios.
|
||||
- **No immutability guarantees**: `AllGroups` and `Items` are mutable collections. External code can modify them (add/remove groups/items), which may lead to race conditions if accessed concurrently (though no threading model is specified).
|
||||
- **No documentation on lifecycle**: It is unclear how `TabPageSource.AllGroups` is populated—no initialization methods or event hooks are visible.
|
||||
@@ -0,0 +1,124 @@
|
||||
---
|
||||
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-16T04:59:22.874172+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "283afdf9f6a03436"
|
||||
---
|
||||
|
||||
# Documentation: Test Metadata Wrappers (Version 57)
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides managed wrapper classes for low-level `ISO.*Details` types (`CustomerDetails`, `LabratoryDetails`, `TestEngineerDetails`) used in database export operations for Version 57 of the database schema. Its primary role is to encapsulate and standardize access to these domain entities—offering lazy-loaded, sorted, and deduplicated collections via singleton list managers (`CustomerDetailsList`, `LabratoryDetailsList`, `TestEngineerDetailsList`). It ensures consistent handling of a special "(none)" placeholder entry and provides thread-safe access to metadata used in test reporting and export workflows.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `CustomerDetails`
|
||||
- **`CustomerDetails()`**
|
||||
Default constructor. Initializes internal `_customerDetails` with a new `ISO.CustomerDetails`, setting its `Name` to `"(none)"`.
|
||||
- **`CustomerDetails(ISO.CustomerDetails customerDetails)`**
|
||||
Copy constructor. Creates a new `ISO.CustomerDetails` instance from the provided `customerDetails`.
|
||||
- **`string Name { get; set; }`**
|
||||
Gets or sets the `Name` property of the underlying `ISO.CustomerDetails`.
|
||||
- **`ISO.CustomerDetails GetISOCustomer()`**
|
||||
Returns the internal `ISO.CustomerDetails` instance.
|
||||
- **`override string ToString()`**
|
||||
Returns the `Name` property.
|
||||
|
||||
### `CustomerDetailsList`
|
||||
- **`static CustomerDetailsList CustomerList { get; }`**
|
||||
Singleton accessor.
|
||||
- **`CustomerDetails[] Customers { get; }`**
|
||||
Returns a sorted (by `Name`, ordinal) array of all `CustomerDetails`, including the "(none)" entry. Thread-safe via `lock` and lazy initialization.
|
||||
- **`CustomerDetails[] GetAllCustomers()`**
|
||||
Returns a fresh array containing a new "(none)" `CustomerDetails` followed by all `CustomerDetails` created from `ISO.CustomerDetails.GetAllCustomerDetails()`.
|
||||
- **`CustomerDetails GetCustomerDetail(string name)`**
|
||||
Returns the first `CustomerDetails` in `Customers` (parallel query) matching `name`, or `null` if none found.
|
||||
|
||||
---
|
||||
|
||||
### `LabratoryDetails`
|
||||
- **`LabratoryDetails()`**
|
||||
Default constructor. Initializes `_lab` with a new `ISO.LabratoryDetails`, setting `Name` to `"(none)"`.
|
||||
- **`LabratoryDetails(ISO.LabratoryDetails lab)`**
|
||||
Copy constructor. Creates a new `ISO.LabratoryDetails` instance from `lab`.
|
||||
- **`string Name { get; set; }`**
|
||||
Gets or sets the `Name` property of `_lab`.
|
||||
- **`ISO.LabratoryDetails GetIsoLab()`**
|
||||
Returns the internal `_lab` instance.
|
||||
- **`override string ToString()`**
|
||||
Returns the `Name` property.
|
||||
|
||||
### `LabratoryDetailsList`
|
||||
- **`protected LabratoryDetailsList()`**
|
||||
Protected constructor (enforces singleton via private instantiation).
|
||||
- **`static LabratoryDetailsList LabratoryList { get; }`**
|
||||
Singleton accessor.
|
||||
- **`LabratoryDetails[] Labs { get; }`**
|
||||
Returns a sorted (by `Name`, ordinal) array of all `LabratoryDetails`, including "(none)". Thread-safe via `lock` and lazy initialization.
|
||||
- **`LabratoryDetails GetLab(string name)`**
|
||||
Returns the `LabratoryDetails` for `name` from the internal `_labs` dictionary (if populated), or `null`. Includes exception handling (logs via `APILogger` on failure).
|
||||
- **`private LabratoryDetails[] GetAllLabs()`**
|
||||
Returns a fresh array containing a new "(none)" `LabratoryDetails` followed by all `LabratoryDetails` created from `ISO.LabratoryDetails.GetAllLabratoryDetails()`. Includes exception handling.
|
||||
|
||||
---
|
||||
|
||||
### `TestEngineerDetails`
|
||||
- **`TestEngineerDetails()`**
|
||||
Default constructor. Initializes `_testEngineerDetails` with a new `ISO.TestEngineerDetails`, setting `Name` to `"(none)"`.
|
||||
- **`TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)`**
|
||||
Copy constructor. Creates a new `ISO.TestEngineerDetails` instance from `testEngineerDetails`.
|
||||
- **`string Name { get; set; }`**
|
||||
Gets or sets the `Name` property of `_testEngineerDetails`.
|
||||
- **`ISO.TestEngineerDetails GetISOTestEngineer()`**
|
||||
Returns the internal `_testEngineerDetails` instance.
|
||||
- **`override string ToString()`**
|
||||
Returns the `Name` property.
|
||||
|
||||
### `TestEngineerDetailsList`
|
||||
- **`static TestEngineerDetailsList TestEngineerList { get; }`**
|
||||
Singleton accessor.
|
||||
- **`TestEngineerDetails[] TestEngineers { get; }`**
|
||||
Returns a sorted (by `Name`, using `CompareTo`) array of all `TestEngineerDetails`, including "(none)". Thread-safe via `lock` and lazy initialization.
|
||||
- **`TestEngineerDetails[] GetAllTestEngineers()`**
|
||||
Returns a fresh array containing a new "(none)" `TestEngineerDetails` followed by all `TestEngineerDetails` created from `ISO.TestEngineerDetails.GetAllTestEngineerDetails()`.
|
||||
- **`TestEngineerDetails GetTestEngineerDetail(string name)`**
|
||||
Returns the first `TestEngineerDetails` in `TestEngineers` (parallel LINQ query) matching `name`, or `null`.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **"(none)" Placeholder**: Each list (`CustomerDetails`, `LabratoryDetails`, `TestEngineerDetails`) *always* includes a special entry with `Name == "(none)"` as the first element returned by `GetAll*()` methods.
|
||||
- **Deduplication**: The internal `_customers`, `_labs`, and `_testEngineers` dictionaries use `Name` as the key, ensuring only one entry per unique name (last one wins in case of duplicates in `GetAll*()`).
|
||||
- **Sorted Output**: The `Customers`, `Labs`, and `TestEngineers` properties return arrays sorted by `Name` using ordinal string comparison (`String.Compare(..., StringComparison.Ordinal)` or `CompareTo`).
|
||||
- **Thread Safety**: All list properties (`Customers`, `Labs`, `TestEngineers`) and their underlying population methods (`PopulateCustomers`, `PopulateList`, `PopulateEngineers`) are guarded by dedicated static `lock` objects. However, `GetCustomerDetail` and `GetTestEngineerDetail` use `AsParallel()` on the *already-computed* `Customers`/`TestEngineers` array, which is safe but not optimized.
|
||||
- **Null Handling**: `Compare*` methods explicitly handle `null` inputs (returning `-1`, `0`, or `1` as appropriate). `Get*Detail` methods return `null` if no match is found.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
- **Internal Dependencies**:
|
||||
- `ISO.CustomerDetails`, `ISO.LabratoryDetails`, `ISO.TestEngineerDetails` (from the `ISO` namespace) — core data types being wrapped.
|
||||
- `ISO.CustomerDetails.GetAllCustomerDetails()`, `ISO.LabratoryDetails.GetAllLabratoryDetails()`, `ISO.TestEngineerDetails.GetAllTestEngineerDetails()` — static methods to fetch raw data.
|
||||
- **External Dependencies**:
|
||||
- `DTS.Utilities.Logging.APILogger` (used in `LabratoryDetailsList` only) — for logging exceptions during lab retrieval.
|
||||
- Standard .NET: `System`, `System.Collections.Generic`, `System.Linq`.
|
||||
- **Depended Upon**: This module is part of `DatabaseExport` namespace and is likely consumed by higher-level export/reporting logic in the `DataPRO` system (not visible in source).
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **Inconsistent Naming**: Class is named `LabratoryDetails` (misspelled) instead of `LaboratoryDetails`. This typo is propagated in both class and list names.
|
||||
- **Exception Swallowing**: `LabratoryDetailsList` silently swallows exceptions in `GetLab` and `GetAllLabs` (logs only via `APILogger`), which may hide failures during lab data loading.
|
||||
- **Race Condition in `Populate*`**: While `Populate*` methods are called under lock, they are not idempotent-safe in all cases:
|
||||
- `CustomerDetailsList.PopulateCustomers()` checks `if (null != _customers) return;` — safe.
|
||||
- `TestEngineerDetailsList.PopulateEngineers()` does *not* check `_testEngineers != null` before reassigning — safe only because it’s called under lock *and* only once.
|
||||
- `LabratoryDetailsList.PopulateList()` has the same safe guard (`if (null != _labs) return;`).
|
||||
→ All are safe *in practice* due to locking, but the pattern is fragile.
|
||||
- **Redundant Copying**: Both constructors (`CustomerDetails(ISO.CustomerDetails)`, etc.) create a *new* instance of the underlying `ISO.*Details` (via copy constructor), not a reference wrapper. This is intentional but may be surprising if mutation of the returned `ISO.*Details` is expected to affect the wrapper’s internal state.
|
||||
- **Inconsistent `Get*Detail` Implementations**:
|
||||
- `CustomerDetailsList.GetCustomerDetail` and `TestEngineerDetailsList.GetTestEngineerDetail` use `AsParallel()` on the *already-computed* array — unnecessary overhead for small lists.
|
||||
- `LabratoryDetailsList.GetLab` uses direct dictionary lookup (`_labs.ContainsKey`) — more efficient, but only works *after* `Labs` property has been accessed (since `_labs` is populated in `Labs` getter, not eagerly).
|
||||
- **No Validation**: No validation on `Name` values (e.g., empty strings, duplicates in raw data) — relies on underlying `ISO.*` types or data source to prevent invalid names.
|
||||
- **Hardcoded Placeholder**: The `"(none)"` string is hardcoded in constructors. No constant or resource reference (despite commented-out `Strings.StringResources.TestTemplate_EmptyListName` in `TestEngineerDetails`).
|
||||
@@ -0,0 +1,201 @@
|
||||
---
|
||||
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-16T05:00:11.636548+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "5a4f5e976b551f99"
|
||||
---
|
||||
|
||||
# Documentation: `DatabaseExport.TestObject` Module
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides a legacy (Version57) abstraction layer over ISO 13499 test object and template data for database export operations. It encapsulates domain entities—such as `TestObject`, `TestObjectTemplate`, and `TestTestObject`—and their relationships, enabling retrieval, manipulation, and serialization of test configuration data (including channel definitions, zones, and metadata) from a database-backed ISO 13499 file structure. It serves as an intermediate layer between raw database access (`DbOperations`, `ISO13499FileDb`) and higher-level UI or export logic, specifically supporting legacy workflows where templates and test objects must be exported or migrated.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `TemplateChannelUI`
|
||||
- **Constructor**: `public TemplateChannelUI(TestObjectTemplateChannel channel)`
|
||||
- Wraps a `TestObjectTemplateChannel` instance for UI binding purposes. No additional behavior beyond storage.
|
||||
|
||||
### `GroupTemplateTableInfo`
|
||||
- **Constructor**: `public GroupTemplateTableInfo(string templateName, SerializedSettings.ISOSupportLevels isoSupportLevel, bool sysBuilt, string templateDescription, DateTime lastModified, string lastModifiedBy, bool embedded)`
|
||||
- Immutable data transfer object (DTO) representing metadata for a test object template.
|
||||
- **Properties**:
|
||||
- `TemplateName` (`string`)
|
||||
- `ISOSupportLevel` (`SerializedSettings.ISOSupportLevels`)
|
||||
- `SysBuilt` (`bool`)
|
||||
- `TemplateDescription` (`string`)
|
||||
- `LastModified` (`DateTime`)
|
||||
- `LastModifiedBy` (`string`)
|
||||
- `Embedded` (`bool`)
|
||||
- **Overrides**: `ToString()` returns `TemplateName`.
|
||||
|
||||
### `TestObjectList`
|
||||
- **Static Property**: `public static TestObjectList TestObjectsList { get; }`
|
||||
- Implements lazy-initialized singleton pattern (thread-safe via `lock`). Returns the single instance of `TestObjectList`.
|
||||
- **Instance Method**: `public List<string> GetAllGroupSerialNumbers()`
|
||||
- Queries `tblTestObjects` for all `SerialNumber` values, deduplicates, and returns them as a `List<string>`.
|
||||
- **Instance Method**: `public TestObject GetTestObject(string serialNumber)`
|
||||
- Retrieves a `TestObject` by `serialNumber` using `ISO.TestObject.GetTestObject`, wrapping the result in a new `TestObject` instance with `SysBuilt` flag preserved. Returns `null` if not found.
|
||||
- **Instance Method**: `public TestObject GetAddedGroup(string serialNumber)`
|
||||
- Alias for `GetTestObject`. Delegates directly to it.
|
||||
|
||||
### `TestObjectTemplateCollection`
|
||||
- **Static Property**: `public static TestObjectTemplateCollection TemplateCollection { get; }`
|
||||
- Thread-safe lazy singleton via double-checked locking (`volatile` + null-coalescing assignment).
|
||||
- **Instance Method**: `public GroupTemplateTableInfo[] GetAllTemplates(bool bIncludeEmbeddedAndSysBuilt = true)`
|
||||
- Queries `tblTestObjectTemplates`. If `bIncludeEmbeddedAndSysBuilt` is `false`, filters rows where `Embedded = 0 OR NULL` and `SysBuilt = 0`.
|
||||
- For each row, constructs a `GroupTemplateTableInfo`:
|
||||
- `ISOSupportLevel` is inferred: `NO_ISO` if `TestObjectType` contains `NON_ISO_TESTOBJECT_CHANNEL_TYPE` or `NONISOCHANNELTYPE`; otherwise `ISO_ONLY`.
|
||||
- `Embedded` is safely parsed (treats `DBNull` as `false`).
|
||||
- Returns array of `GroupTemplateTableInfo`.
|
||||
- **Instance Property**: `public TestObjectTemplate SysBuiltTestObjectTemplate { get; }`
|
||||
- Returns the static `_sysBuiltTestObjectTemplate` field (currently unassigned in source; always `null`).
|
||||
- **Instance Method**: `public TestObjectTemplate GetTemplate(string templateId)`
|
||||
- Retrieves a template by `templateId` via `ISO.TestObjectTemplate.GetTemplate`.
|
||||
- If not found, returns a default-constructed `TestObjectTemplate()`; otherwise wraps the ISO template in a new `TestObjectTemplate`.
|
||||
|
||||
### `TestTestObject`
|
||||
- **Constructor**: `public TestTestObject(TestObject obj)`
|
||||
- Base constructor; delegates to `TestObject` base class.
|
||||
- **Properties**:
|
||||
- `Position` (`MMEPositions`)
|
||||
- Gets/sets position key (`#` = channel defaults, `@` = user-set/multiple).
|
||||
- On set: updates `_position`, toggles `GroupPositionComboBoxVisible`/`GroupPositionButtonVisible`, and if not `UserSetKey`, propagates position to all required sensors with valid serial numbers.
|
||||
- `GroupPositionComboBoxVisible`, `GroupPositionButtonVisible` (`System.Windows.Visibility`)
|
||||
- Visibility depends on `ISOSupportLevel`: always `Collapsed` if `NO_ISO`; otherwise reflects internal `_groupPosition*` fields.
|
||||
- `TestObject` (`MMETestObjects`)
|
||||
- Gets/sets the test object. On set, propagates `TestObject.Test_Object` to all required sensors with valid serial numbers.
|
||||
- `AvailablePositions` (`MMEPositions[]`)
|
||||
- Returns all positions from `ISO13499FileDb.IsoDb.GetPositions()`.
|
||||
- `AvailableGroupPositions` (`MMEPositions[]`)
|
||||
- Returns `AvailablePositions` + a special `ChannelDefaultsKey` (`#`) entry and a `UserSetKey` (`@`) entry.
|
||||
- `ExcitationWarmupTimeMS` (`int`)
|
||||
- Gets/sets warmup time (ms), default from `Properties.Settings.Default.DefaultTestExcitationWarmupMS`.
|
||||
- `TargetSampleRate` (`double`)
|
||||
- Gets/sets target sample rate.
|
||||
- **Constants**:
|
||||
- `ChannelDefaultsKey = "#"`
|
||||
- `UserSetKey = "@"`
|
||||
- **Methods**:
|
||||
- `SetTestObject(string s)`, `SetPosition(string s)`
|
||||
- Setters that bypass property change propagation logic (e.g., no sensor propagation); only update backing field and raise `OnPropertyChanged`.
|
||||
|
||||
### `TestObjectTemplate`
|
||||
- **Constants**:
|
||||
- `NON_ISO_TESTOBJECT_CHANNEL_TYPE = "x_NonISOTestObjectType_x"`
|
||||
- `NON_ISO_TESTOBJECT_NAME = "x_NonISOTestObjectName_x"`
|
||||
- **Properties**:
|
||||
- `LastModifiedBy` (`string`, default `"N/A"`)
|
||||
- `LastModified` (`DateTime`, default `SqlDateTime.MinValue`)
|
||||
- `CurrentZoneIndex` (`int`)
|
||||
- Setter updates `CurrentZone` and `AreZoneControlsEnabled`.
|
||||
- `CurrentZone` (`Zone`)
|
||||
- Setter toggles `AreZoneControlsEnabled` based on nullability.
|
||||
- `AreZoneControlsEnabled` (`bool`)
|
||||
- `RequiredChannels` (`List<TestObjectTemplateChannel>`)
|
||||
- `TemplateParent` (`string`)
|
||||
- `SysBuilt` (`bool`)
|
||||
- `Embedded` (`bool`)
|
||||
- `OriginalTemplateName` (`string`)
|
||||
- `TemplateName` (`string`)
|
||||
- `TemplateDescription` (`string`)
|
||||
- `IsLocalOnly` (`bool`)
|
||||
- `TestObject` (`MMETestObjects`)
|
||||
- Setter initializes `AvailableTestObjectTypes` and `TestObjectTypeIndex`.
|
||||
- `TestObjectType` (`string`)
|
||||
- Setter populates `_channels` and `TemplateAllChannels`.
|
||||
- `TemplateAllChannels` (`TestObjectTemplateChannel[]`)
|
||||
- Getter sorts by `DisplayOrder`; setter builds `TemplateAllUIChannels`.
|
||||
- `TemplateAllUIChannels` (`TemplateChannelUI[]`)
|
||||
- `TemplateZones` (`Zone[]`)
|
||||
- `AvailableTestObjectTypes` (`string[]`)
|
||||
- Lazy-initialized from `ISO13499FileDb.IsoDb.GetTestObjectTypeForTestObject`.
|
||||
- `TestObjectTypeIndex` (`int`)
|
||||
- Getter: index in `AvailableTestObjectTypes`; setter: updates `TestObjectType` and rebuilds channels.
|
||||
- **Static Methods**:
|
||||
- `GetNonISOTestObject()`
|
||||
- Finds or creates a system test object with code `NON_ISO_TESTOBJECT_NAME`. Returns first unused alpha (`A`–`Z`) or numeric (`0`–`9`) code. Throws `NotSupportedException` if none available.
|
||||
- **Instance Methods**:
|
||||
- `ToISOTestObjectTemplate()`
|
||||
- Converts this instance to an `ISO.TestObjectTemplate`, including zones, regions, channels, and metadata. Includes extensive logging via `EventLog`.
|
||||
- `GetValues()`
|
||||
- Returns a dictionary mapping `GroupTemplateFields` enum names to string values (from the ISO template).
|
||||
- `GetTemplateChannelValues(TestObjectTemplateChannel channel)`
|
||||
- Returns a dictionary mapping `GroupTemplateChannelFields` enum names to string values (from the channel).
|
||||
- **Constructors**:
|
||||
- `TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)`
|
||||
- Deep copy constructor.
|
||||
- `TestObjectTemplate(ISO.TestObjectTemplate template, ref ISO13499FileDb db)`
|
||||
- Wraps an ISO template.
|
||||
- `TestObjectTemplate()`
|
||||
- Default constructor: initializes `TestObject` based on `SerializedSettings.ISOSupportLevel`. For `NO_ISO`, calls `InitializeNonISO()`.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Singleton Consistency**:
|
||||
- `TestObjectList.TestObjectsList` and `TestObjectTemplateCollection.TemplateCollection` are lazily initialized singletons. Once created, the same instance persists for the application lifetime.
|
||||
- **Template Channel Sorting**:
|
||||
- `TestObjectTemplate.TemplateAllChannels` getter always returns channels sorted by `DisplayOrder`.
|
||||
- **ISO Support Level Inference**:
|
||||
- `TestObjectTemplateCollection.GetAllTemplates` infers `ISOSupportLevel` strictly based on `TestObjectType` string content (`NON_ISO_TESTOBJECT_CHANNEL_TYPE` or `NONISOCHANNELTYPE` → `NO_ISO`; else → `ISO_ONLY`).
|
||||
- **Embedded Field Handling**:
|
||||
- `GroupTemplateTableInfo.Embedded` and `TestObjectTemplate.Embedded` safely handle `DBNull` in database queries (treated as `false`).
|
||||
- **Non-ISO Template Initialization**:
|
||||
- When `TestObjectTemplate()` is constructed with `NO_ISO` support level, `TestObject` is set to a system-created object with code `NON_ISO_TESTOBJECT_NAME`, and `TestObjectType` is set to `NON_ISO_TESTOBJECT_CHANNEL_TYPE`.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Imports/Usings
|
||||
- `System`, `System.Collections.Generic`, `System.Data` (via `DataRow`, `DataSet`)
|
||||
- `DatabaseExport` namespace (same module)
|
||||
- `ISO` namespace (e.g., `ISO.TestObject`, `ISO.TestObjectTemplate`, `ISO13499FileDb`)
|
||||
- `SerializedSettings` (for `ISOSupportLevels`)
|
||||
- `Properties.Settings` (for `DefaultTestExcitationWarmupMS`)
|
||||
- `System.Diagnostics` (for `EventLog`)
|
||||
|
||||
### External Dependencies
|
||||
- **Database**:
|
||||
- `tblTestObjects` (used by `TestObjectList.GetAllGroupSerialNumbers`)
|
||||
- `tblTestObjectTemplates` (used by `TestObjectTemplateCollection.GetAllTemplates`)
|
||||
- **ISO Layer**:
|
||||
- `ISO13499FileDb.IsoDb` (static property) for database access and metadata lookups.
|
||||
- `DbOperations.GetCommand()` and `DbOperations.Connection.QueryDataSet()` for SQL execution.
|
||||
- **UI Framework**:
|
||||
- `System.Windows.Visibility` (used in `TestTestObject` for WPF visibility properties).
|
||||
- **Other Modules**:
|
||||
- `MMEPositions`, `MMETestObjects`, `MMEPossibleChannels` (from `ISO` or related modules).
|
||||
- `Zone`, `TemplateZone`, `TemplateRegion` (referenced but not defined here; assumed external).
|
||||
|
||||
### Dependents
|
||||
- **Inferred**:
|
||||
- UI layers (e.g., WPF) consuming `TemplateChannelUI`, `TestTestObject`, `GroupTemplateTableInfo`.
|
||||
- Export/migration workflows relying on `TestObjectTemplateCollection.GetAllTemplates()` and `TestObjectList.TestObjectsList`.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`SysBuiltTestObjectTemplate` is always `null`**:
|
||||
- The static field `_sysBuiltTestObjectTemplate` in `TestObjectTemplateCollection` is declared but never assigned. Accessing `SysBuiltTestObjectTemplate` will always return `null`.
|
||||
- **`TestObjectTemplateCollection.GetAllTemplates()` filters `Embedded` permissive**:
|
||||
- `DBNull` values in `Embedded` column are treated as `false`, which may differ from database semantics if `NULL` has special meaning.
|
||||
- **`TestObjectTemplate.GetTemplate()` returns default instance on failure**:
|
||||
- Returns a new `TestObjectTemplate()` (with default properties) instead of `null` when template is not found, potentially masking errors.
|
||||
- **`TestTestObject.Position` propagation is conditional**:
|
||||
- Sensor position updates only occur for required channels with non-whitespace `SensorSerialNumber`. Channels missing these are silently skipped.
|
||||
- **`TestObjectTemplate()` constructor behavior depends on global settings**:
|
||||
- Default constructor behavior changes based on `SerializedSettings.ISOSupportLevel`, which may not be obvious to callers expecting consistent initialization.
|
||||
- **`GetNonISOTestObject()` may throw**:
|
||||
- If no unused single-character test object codes (`A`–`Z`, `0`–`9`) are available, it throws `NotSupportedException` instead of returning `null` or retrying.
|
||||
- **`TemplateAllChannels` setter rebuilds `TemplateAllUIChannels`**:
|
||||
- Assigning directly to `TemplateAllChannels` triggers construction of new `TemplateChannelUI` wrappers. This side effect is not obvious from the property name.
|
||||
- **`CurrentZoneIndex` setter has side effects**:
|
||||
- Setting `CurrentZoneIndex` updates `CurrentZone` and toggles `AreZoneControlsEnabled`, which may affect UI state unexpectedly if not coordinated.
|
||||
- **`TestObjectTemplate.ToISOTestObjectTemplate()` logs heavily**:
|
||||
- Uses `EventLog.Source = "DataPROInstaller"` and writes many entries. May impact performance or cause issues in non-installer contexts (e.g., unit tests).
|
||||
@@ -0,0 +1,153 @@
|
||||
---
|
||||
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-16T04:59:45.231634+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "45cdf642e27469a5"
|
||||
---
|
||||
|
||||
# TestTemplate
|
||||
|
||||
## Documentation: `DatabaseExport.TestTemplate` Module (Version 57)
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides lightweight, read-only representations of test templates stored in the database (`tblTestSetups`) and supporting infrastructure for template management, primarily for export or migration workflows in legacy database versions (v57). It includes classes to load essential metadata from the database without instantiating the full `TestTemplate` object (which may trigger expensive side effects), and utilities to serialize/deserialize sensor settings and manage tag metadata. The module supports operations like retrieving templates by name, listing all templates in a simplified form, and handling special cases like the "Quick checkout" temporary template.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `HardwareInclusionInstruction`
|
||||
- **`HardwareInclusionInstruction(string hardwareId, Actions action)`**
|
||||
Constructor. Initializes a rule to explicitly include or exclude a specific hardware item from a test, overriding group-based inclusion logic (e.g., to support "DAS-less" groups).
|
||||
- **`HardwareId { get; }`**
|
||||
The identifier of the hardware item to which the rule applies.
|
||||
- **`Action { get; }`**
|
||||
The action to take: `Actions.Remove` (exclude despite group membership) or `Actions.Add` (include despite absence from groups).
|
||||
|
||||
#### `TestTemplateLite`
|
||||
- **`Name { get; set; }`**
|
||||
Template name.
|
||||
- **`Description { get; set; }`**
|
||||
Template description (defaults to `""`).
|
||||
- **`RecordingMode { get; set; }`**
|
||||
Recording mode (e.g., `Recorder`, `CircularBuffer`).
|
||||
- **`PreTriggerSeconds { get; set; }`**
|
||||
Pre-trigger duration in seconds. *Behavior*: Returns `0.0` for `Recorder` or `HybridRecorder` modes; otherwise returns the stored value.
|
||||
- **`PostTriggerSeconds { get; set; }`**
|
||||
Post-trigger duration in seconds.
|
||||
- **`LastModified { get; set; }`**
|
||||
Timestamp of last modification.
|
||||
- **`LastModifiedBy { get; set; }`**
|
||||
User who last modified the template.
|
||||
- **`IsComplete { get; set; }`**
|
||||
Whether the template is marked as complete.
|
||||
|
||||
#### `TestTemplateTableObject`
|
||||
- **`TestTemplateTableObject(string name, string description, RecordingModes recordingMode, DateTime lastModified, string lastModifiedBy, bool isComplete, string completionErrorMessage, bool useCustomerDetails, string customerDetails, int[] tagIds)`**
|
||||
Constructor. Initializes a simplified row-like object representing a `tblTestSetups` entry.
|
||||
- **`Name { get; private set; }`**
|
||||
Template name.
|
||||
- **`Description { get; private set; }`**
|
||||
Template description.
|
||||
- **`RecordingMode { get; private set; }`**
|
||||
Recording mode enum value.
|
||||
- **`LastModified { get; private set; }`**
|
||||
Last modification timestamp.
|
||||
- **`LastModifiedBy { get; private set; }`**
|
||||
Last modifier user ID.
|
||||
- **`IsComplete { get; private set; }`**
|
||||
Completion status.
|
||||
- **`CompletionErrorMessage { get; private set; }`**
|
||||
Error message if template is incomplete.
|
||||
- **`UseCustomerDetails { get; private set; }`**
|
||||
Whether customer details are enabled.
|
||||
- **`CustomerDetails { get; private set; }`**
|
||||
Customer details string (likely an ID or reference).
|
||||
- **`TagIds { get; private set; }`**
|
||||
Array of tag IDs associated with the template.
|
||||
|
||||
#### `TestTemplateList`
|
||||
- **`TemporaryTemplate { get; set; }`**
|
||||
Holds a temporary `TestTemplate` instance (e.g., for "Quick checkout") without persisting to DB.
|
||||
- **`GetTemplate(string name) → TestTemplate`**
|
||||
Retrieves a `TestTemplate` instance from `tblTestSetups` by name. Only loads fields defined in `DbOperations.TestSetups.Fields`. Sets `tt._bIsLoaded = false` to indicate incomplete loading. Returns `null` if not found or on error. Special case: Returns `TemporaryTemplate` if `name == "Quick checkout"`.
|
||||
- **`GetSensorFromSettings(string settings, string serial, Dictionary<string, SensorData> lookup) → SensorData`**
|
||||
Parses a comma-separated settings string (e.g., `"3=100,5=+"`) into a `SensorData` object. Uses `lookup` if provided and contains `serial`; otherwise queries `SensorsCollection.SensorsList`. Returns `null` if sensor not found. Supports settings: `CFC`, `Position`, `Polarity`, `Range`, `Delay`, `Duration`, `OutputMode`, `SQMode`, `DIMode`, `LimitDuration`, `ActiveValue`, `DefaultValue`.
|
||||
- **`GetSensorFromSettings(string settings, string serial) → SensorData`**
|
||||
Overload without `lookup` (passes `null`).
|
||||
- **`GetSensorSettings(SensorData sd) → string`**
|
||||
Serializes `SensorData` into the same comma-separated format used by `GetSensorFromSettings`. Only includes settings with non-default/empty values.
|
||||
- **`TestTemplatesList { get; }`**
|
||||
Singleton accessor for `TestTemplateList`.
|
||||
- **`SysBuiltObject(string serialNumber) → bool`**
|
||||
Queries `tblTestObjects` for `SysBuilt` flag of a given serial number. Returns `false` if not found.
|
||||
- **`ConvertToDictionary(DataTable dt, ref Dictionary<string, List<Dictionary<string, object>>> lookup, string key)`**
|
||||
Populates `lookup` by grouping rows in `dt` by `key` column. Each row becomes a `Dictionary<string, object>` of column values.
|
||||
- **`GetAllTemplates() → TestTemplateTableObject[]`**
|
||||
Queries `tblTestSetups` for all templates and returns an array of `TestTemplateTableObject`. Handles `UserTags` blob → `int[]` conversion via `GetTagIds`. If `Dirty` flag is true, re-fetches the full `TestTemplate` to update `IsComplete` status.
|
||||
- **`GetTagIds(byte[] bytes) → int[]`**
|
||||
Converts a byte array (from `UserTags` column) into an `int[]` using `Buffer.BlockCopy`. Returns empty array on failure.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **`TestTemplateLite.PreTriggerSeconds`**:
|
||||
For `RecordingModes.Recorder` and `RecordingModes.HybridRecorder`, `PreTriggerSeconds` is *always* `0.0`, regardless of the stored `_preTriggerSeconds` value.
|
||||
- **`TestTemplateTableObject` immutability**:
|
||||
All properties are `private set`, meaning instances are immutable after construction.
|
||||
- **`TestTemplateList.GetTemplate` behavior**:
|
||||
Templates loaded via `GetTemplate` are explicitly marked as *not fully loaded* (`_bIsLoaded = false`), indicating that only `tblTestSetups` fields were populated. Consumers must avoid relying on lazily-loaded data (e.g., channels, groups).
|
||||
- **`TemporaryTemplate` special case**:
|
||||
Only returned when `name == "Quick checkout"` (exact string match). Empty/whitespace names return `null`.
|
||||
- **`TagIds` blob format**:
|
||||
`UserTags` is stored as a `byte[]` and converted to `int[]` assuming 4-byte `int` elements (via `sizeof(int)`). Failure to parse yields an empty array.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### Internal Dependencies (from source):
|
||||
- **`DbOperations`**: Used for database access (`GetCommand`, `CreateParam`, `QueryDataSet`, `TestSetups` table/field enums).
|
||||
- **`Properties.Settings.Default.DownloadFolder`**: Used as fallback for `ExportFolder` and `DownloadFolder` in `GetTemplate`.
|
||||
- **`CustomerDetailsList.CustomerList`**, **`TestEngineerDetailsList.TestEngineerList`**, **`LabratoryDetailsList.LabratoryList`**: Used to resolve customer/test engineer/lab details from stored IDs.
|
||||
- **`SensorsCollection.SensorsList`**: Used by `GetSensorFromSettings` to look up sensors by serial number.
|
||||
- **`ISO.TestObject.SensorSettings`**: Enum defining sensor setting types (e.g., `CFC`, `Range`, `Delay`).
|
||||
- **`OutputTOMDigitalChannel.DigitalOutputMode`**, **`OutputSquibChannel.SquibFireMode`**, **`DigitalInputScaleMultiplier.InputModes`**: Enums used in sensor settings parsing.
|
||||
|
||||
#### External Dependencies:
|
||||
- **`System.Data`**: `SqlDbType`, `DataRow`, `DataTable`, `DataSet`.
|
||||
- **`System.Globalization`**: `CultureInfo.InvariantCulture` for numeric parsing.
|
||||
|
||||
#### Inferred Consumers:
|
||||
- Modules performing template export/migration (e.g., `DatabaseExport` namespace usage implies integration with export pipelines).
|
||||
- Code needing lightweight template metadata (e.g., UI lists, version comparison, migration scripts).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **`PreTriggerSeconds` logic is mode-dependent**:
|
||||
The property setter stores the value in `_preTriggerSeconds`, but the getter *ignores* it for `Recorder`/`HybridRecorder` modes. This may cause confusion if consumers expect the stored value to be returned.
|
||||
- **`GetTemplate` does *not* load full template data**:
|
||||
Despite returning a `TestTemplate`, only `tblTestSetups` fields are populated. Consumers must not assume groups, channels, or other related data are available.
|
||||
- **`Dirty` flag triggers redundant full load**:
|
||||
In `GetAllTemplates`, if `Dirty` is true, `GetTemplate` is called to re-fetch `IsComplete`. This may be inefficient and could fail silently (exceptions are caught and ignored).
|
||||
- **`GetTagIds` assumes fixed `int` size**:
|
||||
Uses `sizeof(int)` (4 bytes) for conversion. May fail on platforms with non-standard `int` sizes or malformed blobs.
|
||||
- **`TemporaryTemplate` is mutable and global**:
|
||||
As a singleton property, `TemporaryTemplate` can be overwritten by any caller. No thread-safety is implied beyond the singleton initialization.
|
||||
- **`GetSensorFromSettings` silently handles missing sensors**:
|
||||
Returns `null` if sensor not found, but only after creating a placeholder `SensorData` with empty `SerialNumber` if `serial` is null/whitespace.
|
||||
- **`GetSensorSettings` omits default/empty values**:
|
||||
Only includes settings with non-default values. This may cause round-trip mismatches if consumers expect all settings to be serialized.
|
||||
|
||||
None identified beyond the above.
|
||||
Reference in New Issue
Block a user