init
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/App/WaitCursor.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/App/App.cs
|
||||
generated_at: "2026-04-16T04:29:09.171697+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "85d98116aaeec020"
|
||||
---
|
||||
|
||||
# App
|
||||
|
||||
## Documentation: `WaitCursor` and `App` Module (DatabaseImporter)
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides UI-level cursor and application state management during long-running operations in a WPF-based database import workflow. Specifically, the `WaitCursor` class offers a lightweight, `IDisposable` wrapper to temporarily override the mouse cursor to a wait state and restore it upon disposal. The `App` class (a partial class for `Application`) extends this functionality at the application level by coordinating global busy/idle states: it disables the main window and manages a singleton `WaitCursor` instance across thread boundaries using the WPF `Dispatcher`, ensuring safe, re-entrant, and exception-safe busy/idle transitions—typically used before/after data-intensive operations (e.g., database refreshes or imports).
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `WaitCursor` class (`DataImport.WaitCursor`)
|
||||
|
||||
- **`public WaitCursor()`**
|
||||
Constructor. Saves the current `Mouse.OverrideCursor`, sets `Mouse.OverrideCursor = Cursors.Wait`, and prepares for later restoration via `Dispose()`.
|
||||
|
||||
- **`public void Dispose()`**
|
||||
Restores the previously saved cursor (`_previousCursor`) to `Mouse.OverrideCursor`. Must be called exactly once per instance (per `using` or manual disposal pattern). No-op if called multiple times (but cursor may be incorrectly restored if disposed more than once).
|
||||
|
||||
#### `App` class (`DatabaseImport.App`, partial)
|
||||
|
||||
- **`public ISO13499FileDb IsoDb { get; }`**
|
||||
Lazy-initialized singleton accessor for the `ISO13499FileDb` database instance. On first access, instantiates `_isoDb`, calls `_isoDb.RefreshAllData()`, and returns it. Thread-safety is *not* guaranteed (no locking around initialization or `RefreshAllData()`).
|
||||
|
||||
- **`public void SetAppBusy()`**
|
||||
Sets the application into a *busy* state:
|
||||
- Marshals to the UI thread via `Dispatcher.BeginInvoke` if called from a non-UI thread.
|
||||
- Disposes any existing `_wc` (if not null).
|
||||
- Creates a new `WaitCursor` instance and assigns it to `_wc`.
|
||||
- Sets `MainWindow.IsEnabled = false`.
|
||||
- Uses `lock (WaitCursorLock)` to serialize concurrent calls.
|
||||
- *No-op* if `MainWindow` is null.
|
||||
|
||||
- **`public void SetAppAvailable()`**
|
||||
Sets the application into an *available* (idle) state:
|
||||
- Marshals to the UI thread via `Dispatcher.BeginInvoke` if called from a non-UI thread.
|
||||
- Disposes and nullifies `_wc` (if not null).
|
||||
- Sets `MainWindow.IsEnabled = true`.
|
||||
- Uses `lock (WaitCursorLock)` to serialize concurrent calls.
|
||||
- *No-op* if `MainWindow` is null.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **Cursor restoration guarantee**: After a `WaitCursor` instance is disposed, `Mouse.OverrideCursor` is restored to the value it held at the time of construction.
|
||||
- **Application busy/idle state consistency**:
|
||||
- `MainWindow.IsEnabled` is `false` *only* when `_wc` is non-null (i.e., during a `SetAppBusy()` call with no intervening `SetAppAvailable()`).
|
||||
- `_wc` is `null` *only* when the application is not busy (i.e., after `SetAppAvailable()` or before any `SetAppBusy()` call).
|
||||
- **Thread-safety of state transitions**:
|
||||
- `SetAppBusy()` and `SetAppAvailable()` are thread-safe *with respect to each other* via `lock (WaitCursorLock)`.
|
||||
- Both methods *always* marshal to the UI thread via `Dispatcher.BeginInvoke` if invoked off-thread, ensuring UI mutations occur on the correct thread.
|
||||
- **Singleton `IsoDb` initialization**: `_isoDb` is initialized at most once, and only upon first access to `IsoDb`. `RefreshAllData()` is called exactly once per instance creation.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### This module depends on:
|
||||
- `System.Windows.Input.Cursors` (for `Cursors.Wait`)
|
||||
- `System.Windows.Input.Mouse` (for `Mouse.OverrideCursor`)
|
||||
- `System.Windows.Threading.Dispatcher` (for `Dispatcher.CheckAccess`, `BeginInvoke`)
|
||||
- `System.Windows.Application` (base class `App : Application`)
|
||||
- `System.Windows.Window` (via `MainWindow`)
|
||||
- `DatabaseImport.ISO13499FileDb` (referenced in `App.IsoDb` property; defined elsewhere in the codebase)
|
||||
|
||||
#### This module is depended on by:
|
||||
- Any code that needs to wrap long-running operations in a wait cursor (e.g., `using (new WaitCursor()) { ... }`).
|
||||
- Code that triggers database refreshes or imports (uses `App.IsoDb`).
|
||||
- UI or service layers that call `App.SetAppBusy()` before and `App.SetAppAvailable()` in `finally` blocks (as recommended in comments).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **`IsoDb` initialization is not thread-safe**: Multiple concurrent first-time accesses to `IsoDb` may result in multiple `ISO13499FileDb` instances being created and `RefreshAllData()` being called multiple times. No locking or double-check pattern is used.
|
||||
- **`WaitCursor` is not re-entrant**: If `WaitCursor` is constructed multiple times without disposal (e.g., nested `using` blocks), only the *outermost* cursor state is preserved in `_previousCursor`. Inner disposals will overwrite the cursor prematurely.
|
||||
*Example*:
|
||||
```csharp
|
||||
using (new WaitCursor()) // Saves cursor A, sets Wait
|
||||
{
|
||||
using (new WaitCursor()) // Saves cursor Wait, sets Wait again
|
||||
{
|
||||
// ...
|
||||
} // Restores cursor Wait → incorrect!
|
||||
} // Restores cursor A
|
||||
```
|
||||
- **`SetAppBusy()` / `SetAppAvailable()` may silently no-op**: If `MainWindow` is `null` at the time of call (e.g., during early startup or after window close), the methods exit early with no side effects—no exception is thrown.
|
||||
- **`WaitCursorLock` is static and shared across all `App` instances**: Since `App` is a singleton in WPF, this is expected—but if multiple `App` instances were ever created (e.g., in tests), locking would be incorrectly shared.
|
||||
- **No exception handling in `SetAppBusy()`/`SetAppAvailable()`**: If `MainWindow.IsEnabled = false/true` or `WaitCursor.Dispose()` throws, the busy/idle state may be left inconsistent (e.g., `_wc` disposed but `MainWindow.IsEnabled` not updated).
|
||||
- **`_wc` is not thread-local**: Though marshaled to the UI thread, `_wc` is a *single instance field*—concurrent calls via `BeginInvoke` are serialized by `WaitCursorLock`, but the timing of disposal/creation may cause transient cursor flicker if not used carefully (e.g., overlapping busy periods).
|
||||
- **`WaitCursor` does not prevent user input beyond disabling `MainWindow`**: `Mouse.OverrideCursor` alone does not block input; the disabling of `MainWindow` is what prevents interaction. If `MainWindow` is hidden or replaced, the busy state may persist incorrectly.
|
||||
|
||||
None identified beyond the above.
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Constants.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Enums.cs
|
||||
generated_at: "2026-04-16T04:29:22.195029+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "7d0744f20dc3772b"
|
||||
---
|
||||
|
||||
# Classes
|
||||
|
||||
## Documentation: DatabaseImport Module – Constants and Enums
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
This module provides foundational type definitions and symbolic constants used throughout the `DatabaseImport` subsystem, primarily to support test configuration, channel handling, and recording behavior in the DataPRO test framework. It centralizes string literals for non-ISO test object metadata and defines strongly-typed enumerations for recording modes, ISO channel compatibility policies, and test template metadata tags—enabling consistent interpretation of test setup data imported from external databases or configuration sources.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### Constants (`DatabaseImport.Constants`)
|
||||
- **`NON_ISO_TESTOBJECT_CHANNEL_TYPE`** (`public const string`)
|
||||
String value: `"x_NonISOTestObjectType_x"`. Used as a channel type identifier for non-ISO test objects during import.
|
||||
- **`NON_ISO_TESTOBJECT_NAME`** (`public const string`)
|
||||
String value: `"x_NonISOTestObjectName_x"`. Used as a channel name identifier for non-ISO test objects during import.
|
||||
|
||||
#### Enumerations
|
||||
|
||||
- **`RecordingModes`** (`public enum`)
|
||||
Represents supported data acquisition recording strategies.
|
||||
- `CircularBuffer`: `"RecordingModes_CircularBuffer"`
|
||||
- `Recorder`: `"RecordingModes_Recorder"`
|
||||
- `HybridRecorder`: `"RecordingModes_HybridRecorder"`
|
||||
*Note:* Uses `[TypeConverter(typeof(EnumDescriptionTypeConverter))]` for localized description resolution.
|
||||
|
||||
- **`IsoChannelSensorCompatibilityLevels`** (`public enum`)
|
||||
Defines policy for handling non-ISO sensors attached to ISO channels:
|
||||
- `DontWarn`: No warning or restriction.
|
||||
- `Warn`: Issue warning but allow operation.
|
||||
- `DontAllow`: Block operation if non-ISO sensor detected.
|
||||
|
||||
- **`TestTemplateTags`** (`public enum`)
|
||||
Contains 103 named constants representing keys for test template metadata fields (e.g., `"UploadData"`, `"RecordingMode"`, `"PreTriggerSeconds"`). Used to serialize/deserialize test configuration properties from structured data (e.g., XML, JSON, or database rows).
|
||||
*Note:* Includes both high-level flags (`AllowMissingSensors`, `AutomaticProgression`) and granular settings (`AutomaticProgressionDelayMS`, `AutoVerifyDelaySeconds`).
|
||||
|
||||
- **`StrictLevel`** (`public enum`)
|
||||
Controls validation strictness during import:
|
||||
- `Strict`: Enforce strict schema/data validation.
|
||||
- `UpdateTable`: Allow schema updates or relaxed validation (e.g., for backward compatibility).
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
- All `TestTemplateTags` enum values are **string-identifiable keys**—their underlying integer values are irrelevant; only their symbolic names matter for lookup.
|
||||
- `RecordingModes` enum values are **exhaustive and mutually exclusive**—a test configuration must specify exactly one mode.
|
||||
- `IsoChannelSensorCompatibilityLevels` values define a **strict ordering of enforcement**: `DontWarn` ≤ `Warn` ≤ `DontAllow`.
|
||||
- `Constants` values are **fixed string literals**—no runtime modification or localization is performed within this module.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
- **Depends on**:
|
||||
- `System` (for `TypeConverter`, `DescriptionAttribute`)
|
||||
- `System.ComponentModel` (for `TypeConverter` and `DescriptionAttribute`)
|
||||
- **Used by**:
|
||||
- Other modules in `DatabaseImport` (e.g., importers, validators, test template processors) that parse test configurations or validate channel/sensor compatibility.
|
||||
- Likely consumed by UI layers (via `TypeConverter`) for localized enum descriptions.
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
- **Non-ISO identifiers are placeholder strings**: The values `"x_NonISOTestObjectType_x"` and `"x_NonISOTestObjectName_x"` are *not* standardized—they are internal markers. Do not assume they match external schema names.
|
||||
- **`TestTemplateTags` enum is exhaustive but not self-documenting**: The enum names map directly to string keys (e.g., `TestTemplateTags.RecordingMode` → `"RecordingMode"`), but the *meaning* of each key is defined elsewhere (e.g., in schema docs or template parsers).
|
||||
- **`RecordingModes` descriptions are resource keys**: The `[Description(...)]` attributes contain *resource keys* (e.g., `"RecordingModes_CircularBuffer"`), not literal descriptions. Actual display text requires resource resolution via `EnumDescriptionTypeConverter`.
|
||||
- **`StrictLevel.UpdateTable` implies leniency**: This may bypass validation that would otherwise fail imports (e.g., missing required fields), risking data inconsistency if misused.
|
||||
- **No validation logic in this module**: These types define *what* can be configured, not *how*—validation rules reside in other modules (e.g., importers, validators).
|
||||
|
||||
None identified beyond the above.
|
||||
@@ -0,0 +1,177 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Hardware/DASSettings.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Hardware/HardwareChannel.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Hardware/DASHardwareList.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Hardware/DASHardware.cs
|
||||
generated_at: "2026-04-16T04:31:49.040833+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "d546885c144cb09e"
|
||||
---
|
||||
|
||||
# Hardware
|
||||
|
||||
## Documentation: DAS Hardware Module (`DatabaseImport.Classes.Hardware`)
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides data structures and utilities for representing and managing Data Acquisition System (DAS) hardware configurations within the `DatabaseImporter` module. It encapsulates hardware metadata (e.g., serial number, type, channels, settings) and supports persistence into the database (specifically `tblTestSetupDASSettings` for `DASSettings`). It serves as a bridge between raw database records (via `ISO.Hardware` and `ISO.HardwareChannel`) and higher-level application logic, enabling consistent handling of DAS hardware during test import and processing.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `DASSettings`
|
||||
- **`public string DASSerialNumber { get; set; }`**
|
||||
Serial number of the DAS device associated with these settings.
|
||||
- **`public double SampleRate { get; set; }`**
|
||||
Sample rate (in Hz) configured for the DAS.
|
||||
- **`public int ExcitationWarmupTimeMS { get; set; }`**
|
||||
Excitation warm-up time in milliseconds.
|
||||
- **`public double HardwareAAF { get; set; }`**
|
||||
Hardware anti-aliasing filter (AAF) cutoff frequency (in Hz).
|
||||
- **`public double PreTriggerSeconds { get; set; }`**
|
||||
Duration (in seconds) of pre-trigger buffer.
|
||||
- **`public double PostTriggerSeconds { get; set; }`**
|
||||
Duration (in seconds) of post-trigger buffer.
|
||||
- **`public bool StatusLineCheck { get; set; }`**
|
||||
Flag indicating whether status line checking is enabled.
|
||||
- **`public bool BatteryCheck { get; set; }`**
|
||||
Flag indicating whether battery voltage checking is enabled.
|
||||
- **`public double InputVoltageMin { get; set; }`**
|
||||
Minimum acceptable input voltage (V).
|
||||
- **`public double InputVoltageMax { get; set; }`**
|
||||
Maximum acceptable input voltage (V).
|
||||
- **`public double BatteryVoltageMin { get; set; }`**
|
||||
Minimum acceptable battery voltage (V).
|
||||
- **`public double BatteryVoltageMax { get; set; }`**
|
||||
Maximum acceptable battery voltage (V).
|
||||
|
||||
> **Note**: This class is intended for serialization into `tblTestSetupDASSettings`. No custom logic or validation is present in the class itself.
|
||||
|
||||
---
|
||||
|
||||
#### `HardwareChannel`
|
||||
- **`public HardwareChannel(HardwareChannel copy)`**
|
||||
Copy constructor. Copies `ChannelNumber`, `Sensor`, `_testObjectChannel`, `Hardware`, and `_isoChannel` from `copy`.
|
||||
- **`public HardwareChannel(ISO.HardwareChannel channel, DASHardware hardware)`**
|
||||
Constructor initializing from an `ISO.HardwareChannel` and its parent `DASHardware`.
|
||||
- **`public int CompareTo(HardwareChannel right)`**
|
||||
Compares two `HardwareChannel` instances first by `DASDisplayOrder`, then by `ChannelIdx` (0-based index). Returns `0` if either operand is `null` or reference-equal.
|
||||
- **`public string GetId()`**
|
||||
Returns a unique identifier string in the format `{HardwareId}x{ChannelNumber+1}` (1-based channel index).
|
||||
- **`public bool IsSupportedBridgeType(Test.Module.Channel.Sensor.BridgeType bridgeType)`**
|
||||
Returns `true` if the underlying `ISO.HardwareChannel.SupportedBridges` bitmask includes the specified `bridgeType`.
|
||||
- **`public int ChannelNumber { get; }`**
|
||||
0-based channel index (`ISO.HardwareChannel.ChannelIdx`).
|
||||
- **`public DASHardware Hardware { get; }`**
|
||||
Parent `DASHardware` instance.
|
||||
- **`public SensorData Sensor { get; set; }`**
|
||||
Optional sensor configuration associated with this channel.
|
||||
- **`public ISO.HardwareChannel GetISOChannel()`**
|
||||
Returns the underlying `ISO.HardwareChannel` instance.
|
||||
|
||||
---
|
||||
|
||||
#### `DASHardware`
|
||||
- **`public DASHardware(Hardware hardware)`**
|
||||
Constructor initializing from a `Hardware` instance. Populates `Channels` by wrapping each `ISO.HardwareChannel` in a `HardwareChannel`.
|
||||
- **`public DASHardware(DASHardware copy, DASHardware parentDAS)`**
|
||||
Constructor for creating a child DAS from a `copy`, with `parentDAS` as its logical parent. Copies `Channels` (deep copy via `HardwareChannel` copy constructor) and `DbTimeStamp`.
|
||||
- **`public bool IsPseudoRack()`**
|
||||
Returns `true` if the hardware type is `SLICE_LabEthernet`, `SLICE_EthernetController`, or `SLICE6DB`, indicating it should be UI-rendered as a rack despite not physically being one.
|
||||
- **`public bool IsDummy()`**
|
||||
Returns `true` if `SerialNumber` contains the substring `"Dummy"`.
|
||||
- **`public int CompareTo(DASHardware right)`**
|
||||
Implements ordering logic:
|
||||
- `null` → `1`
|
||||
- Same reference or `SerialNumber` match → `0`
|
||||
- Parent/child relationship → child sorts after parent
|
||||
- Same parent and `PositionOnDistributor` → sort by `PositionOnDistributor`
|
||||
- Otherwise → lexicographic sort on `SerialNumber`.
|
||||
- **`public string SerialNumber { get; set; }`**
|
||||
Serial number of the DAS.
|
||||
- **`public string ParentDAS { get; set; }`**
|
||||
Serial number of the parent DAS (if any).
|
||||
- **`public int PositionOnDistributor { get; set; }`**
|
||||
Position index on a distributor rack (used for ordering).
|
||||
- **`public HardwareChannel[] Channels { get; set; }`**
|
||||
Array of channels. Setter sorts the list using `HardwareChannel.CompareTo()` before assignment.
|
||||
- **`public int GetHardwareTypeInt()`**
|
||||
Returns the raw integer type (`_hardware.DASType`).
|
||||
- **`public HardwareTypes GetHardwareTypeEnum()`**
|
||||
Casts `GetHardwareTypeInt()` to `HardwareTypes` enum.
|
||||
- **`public long GetMaxMemoryLong()`**
|
||||
Returns `_hardware.MaxMemory`.
|
||||
- **`public Hardware GetHardware()`**
|
||||
Returns the underlying `Hardware` instance.
|
||||
|
||||
---
|
||||
|
||||
#### `DASHardwareList`
|
||||
- **`public static DASHardwareList GetList()`**
|
||||
Singleton accessor. Returns the cached instance if present; otherwise instantiates and caches a new one. (Note: `PopulateHardware()` is commented out in both constructor and `GetList()`.)
|
||||
- **`public void ReloadAll()`**
|
||||
Intended to reload hardware definitions, but current implementation is commented out.
|
||||
- **`public DASHardware GetHardware(string id, bool bUseCache = true)`**
|
||||
Convenience overload of the 4-parameter version with `bThrowExceptionIfChanged = true`, `changed = out bool` ignored.
|
||||
- **`public DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache = true)`**
|
||||
Retrieves a `DASHardware` by `id`. Uses `_cachedHardware` if available and `bUseCache` is `true`. Falls back to `Hardware.GetAllDAS(id, null)`. Returns `null` if not found.
|
||||
**Note**: Legacy logic for detecting hardware type changes (including `HardwareTypeChangedException`) is commented out and not active.
|
||||
- **`public class HardwareTypeChangedException : Exception`**
|
||||
Placeholder exception type for hardware type mismatch, but **not used** in current implementation.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **`HardwareChannel.ChannelNumber`** is always non-negative and corresponds to `ISO.HardwareChannel.ChannelIdx`.
|
||||
- **`HardwareChannel.GetId()`** produces a 1-based channel index (i.e., `ChannelNumber + 1`).
|
||||
- **`DASHardware.Channels`** is always sorted by `HardwareChannel.CompareTo()` after assignment (via setter).
|
||||
- **`DASHardware.CompareTo()`** enforces a partial order where:
|
||||
- Parent DAS sorts before its children.
|
||||
- Siblings under the same parent sort by `PositionOnDistributor`.
|
||||
- Otherwise, lexicographic by `SerialNumber`.
|
||||
- **`DASSettings`** is a pure data container with no runtime validation or normalization. Values are assumed valid per database schema.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### Internal Dependencies
|
||||
- **`ISO.Hardware`** and **`ISO.HardwareChannel`**
|
||||
Core data models representing raw database records. Used in `HardwareChannel` and `DASHardware` constructors.
|
||||
- **`SensorData`**
|
||||
Referenced in `HardwareChannel.Sensor`. Must be defined elsewhere in the codebase.
|
||||
- **`Test.Module.Channel.Sensor.BridgeType`**
|
||||
Referenced in `HardwareChannel.IsSupportedBridgeType()`.
|
||||
- **`HardwareTypes`**
|
||||
Enum used in `DASHardware.GetHardwareTypeEnum()`. Must be defined externally.
|
||||
- **`DbTimeStampBase`**
|
||||
Base class for `DASHardware`. Provides timestamping functionality.
|
||||
|
||||
#### External Dependencies
|
||||
- **`System`** (core .NET types)
|
||||
- **`DatabaseImport.Hardware`** (static class)
|
||||
Used in `DASHardwareList.GetHardware()` via `Hardware.GetAllDAS(id, null)`. Must be defined elsewhere.
|
||||
|
||||
#### Dependencies on This Module
|
||||
- Likely consumed by higher-level modules handling test setup, import, or configuration (e.g., `DatabaseImporter` entry points, UI layers).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **Singleton caching is non-functional**: `GetList()` instantiates `_list`, but `_list.PopulateHardware()` is commented out. Similarly, `ReloadAll()` and caching logic in `GetHardware()` are commented out. As written, `DASHardwareList` does not cache hardware data beyond the initial instantiation.
|
||||
- **`HardwareTypeChangedException` is unused**: The exception class exists but is never thrown—legacy logic for detecting hardware type changes is disabled.
|
||||
- **`CompareTo()` returns `0` for `null`**: In `HardwareChannel.CompareTo()`, passing `null` returns `0`, which violates the `IComparable<T>` contract (should throw `ArgumentException` or return non-zero). This may cause unexpected behavior in sorting or collections.
|
||||
- **`GetHardware()` in `DASHardwareList` silently returns `null`**: No exception or warning is raised if hardware is not found or if type changes occur (legacy checks are commented out).
|
||||
- **Channel ID is 1-based in string but 0-based internally**: `HardwareChannel.GetId()` uses `ChannelNumber + 1`, which may cause off-by-one confusion if `ChannelNumber` is assumed to be 1-based elsewhere.
|
||||
- **No validation in `DASSettings`**: All properties are auto-implemented with no guards. Invalid values (e.g., negative sample rate) are permitted.
|
||||
- **`DASHardware.IsDummy()` is substring-based**: Relies on `"Dummy"` appearing anywhere in `SerialNumber`, which may yield false positives (e.g., `"Dummy123"` vs `"MyDummyDAS"`).
|
||||
- **`DASHardwareList.GetHardware()` does not handle duplicate IDs**: If `Hardware.GetAllDAS()` returns multiple records, only the first is used—no conflict resolution or logging.
|
||||
|
||||
> **None identified from source alone** for additional gotchas beyond those explicitly visible in the code.
|
||||
@@ -0,0 +1,187 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/RegionsAndZones/Zone.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/RegionsAndZones/RegionAdorner.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/RegionsAndZones/Region.cs
|
||||
generated_at: "2026-04-16T04:32:32.660920+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "cd00dc5bfe396de9"
|
||||
---
|
||||
|
||||
# RegionsAndZones
|
||||
|
||||
## Documentation: Regions and Zones Module
|
||||
|
||||
### 1. Purpose
|
||||
This module provides data structures and UI adorning capabilities for defining and managing spatial regions and zones within test object templates, primarily for ISO-compliant test configuration. It enables users to define named zones (e.g., anatomical or functional areas) containing one or more rectangular regions, each associated with metadata (e.g., direction, filter class, transducer location) used to generate ISO codes and filter available channels. The module bridges raw template data (`TemplateZone`, `TemplateRegion`) with WPF-based UI interaction (via `RegionAdorner`) and supports bidirectional conversion between in-memory objects and ISO database representations.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `Zone` class
|
||||
- **`Zone(Zone copy, TestObjectTemplate template)`**
|
||||
Copy constructor. Initializes a new `Zone` by copying properties (`Description`, `Image`, `Regions`) from an existing `Zone`, preserving `ISODllZone`, and preloading picture filenames.
|
||||
- **`Zone(TemplateZone z, TestObjectTemplate template)`**
|
||||
Constructor from ISO `TemplateZone`. Loads `Description`, `Image`, and `Regions` (converted to `Region` objects). Attempts to load and cache the zone picture as a `BitmapImage` if the file exists.
|
||||
- **`string Name { get; set; }`**
|
||||
Zone name, sourced from `ISODllZone.ZoneName`.
|
||||
- **`string Description { get; set; }`**
|
||||
Zone description, sourced from `ISODllZone.Description` (defaults to `""`).
|
||||
- **`string Image { get; set; }`**
|
||||
Filename of the zone picture, sourced from `ISODllZone.Picture`.
|
||||
- **`TemplateZone ISODllZone { get; }`**
|
||||
Read-only reference to the underlying ISO `TemplateZone` object.
|
||||
- **`string[] AllPictures { get; }`**
|
||||
Thread-safe array of filenames (not full paths) in the `ZonePictures` subdirectory of the app base directory. Populates on first access.
|
||||
- **`void PopulateFilenamesIfNeeded()`**
|
||||
Ensures `_fileNames` is populated (only if empty), using a lock to prevent concurrent population.
|
||||
- **`int PictureIndex { get; set; }`**
|
||||
Index into `AllPictures` for the currently selected picture. Setting triggers loading of the corresponding image into `PictureSource`. Index `-1` sets `PictureSource` to `null`.
|
||||
- **`string GetPictureName()`**
|
||||
Returns the filename of the currently selected picture (empty string if `PictureIndex < 0`).
|
||||
- **`System.Windows.Media.ImageSource PictureSource { get; set; }`**
|
||||
The WPF `ImageSource` for the currently selected picture.
|
||||
- **`Region[] Regions { get; set; }`**
|
||||
Array of `Region` objects in this zone. `get` returns a copy; `set` replaces the internal list.
|
||||
|
||||
#### `RegionAdorner` class
|
||||
- **`RegionAdorner(UIElement adornedElement, TestObjectTemplate template, Contexts context)`**
|
||||
Constructor. Creates a new adorner for an `Image` (or other `UIElement`). Initializes `_region`, sets up mouse event handlers, and configures visual path (AliceBlue stroke, 60% opacity, initially hidden).
|
||||
- **`Point GetUpperLeft()`**
|
||||
Returns the upper-left corner of `SelectRect`, adjusted for scaling between the adorned element’s `RenderSize` and its `Source` dimensions.
|
||||
- **`Point GetLowerRight()`**
|
||||
Returns the lower-right corner of `SelectRect`, similarly scaled.
|
||||
- **`bool IsNew { get; set; }`**
|
||||
Controls visibility of region add/delete UI: `true` → `RegionAddVisibility=Visible`, `RegionDeleteVisibility=Hidden`; `false` → vice versa.
|
||||
- **`Rect SelectRect { get; set; }`**
|
||||
Bounding rectangle of the region in adorner coordinates. Setting it updates `MyRegion.RegionUpperLeft`/`RegionBottomRight` via `GetUpperLeft()`/`GetLowerRight()`.
|
||||
- **`Region MyRegion { get; set; }`**
|
||||
Reference to the associated `Region` object.
|
||||
- **`Contexts Context { get; set; }`**
|
||||
Context enum (`EditTestObject` or `EditTestObjectTemplate`) indicating usage mode.
|
||||
- **`event RegionSelectedHandler OnRegionSelected`**
|
||||
Raised on `MouseLeftButtonDown`.
|
||||
- **`event EndSelectionHandler OnEndSelection`**
|
||||
Raised on `MouseLeftButtonUp` (via `EndSelection()`).
|
||||
- **`void DrawSelection(...)`**
|
||||
Updates `SelectRect` to a rectangle defined by `AnchorPoint` and current mouse position (used during region creation).
|
||||
- **`void MoveSelection(...)`**
|
||||
Updates `SelectRect` by translating it by the mouse delta (used during region movement).
|
||||
|
||||
#### `Region` class
|
||||
- **`Region(RegionAdorner adorner, TestObjectTemplate template)`**
|
||||
Constructor for a *new* region. Sets default name/description, assigns `Template`, initializes `RegionChannels`/`RegionUIChannels` from template, and calls `DetermineAvailableISOSettings()`.
|
||||
- **`Region(TestObjectTemplate template, TemplateRegion r)`**
|
||||
Constructor from ISO `TemplateRegion`. Populates all properties from `r` (e.g., `RegionUpperLeft`, `RegionDirection`, `ISOCode`) and calls `FilterRegionChannels()` and `SetISOCode()`.
|
||||
- **`string RegionName { get; set; }`**
|
||||
User-facing region name.
|
||||
- **`string RegionDescription { get; set; }`**
|
||||
User-facing region description.
|
||||
- **`Point RegionUpperLeft { get; set; }`**
|
||||
Upper-left coordinate (WPF `Point`) of the region.
|
||||
- **`Point RegionBottomRight { get; set; }`**
|
||||
Lower-right coordinate (WPF `Point`) of the region.
|
||||
- **`MMEDirections RegionDirection { get; set; }`**
|
||||
Direction metadata (e.g., "Anterior", "Posterior"). Setting updates `_directionIndex` and calls `SetISOCode()`.
|
||||
- **`MMEFilterClasses RegionFilterClass { get; set; }`**
|
||||
Filter class metadata. Setting updates `_filterClassIndex` and calls `SetISOCode()`.
|
||||
- **`MMEFineLocations1 RegionFineLocation1 { get; set; }`**
|
||||
Fine location 1 metadata. Setting updates `_fineLocation1Index` and calls `SetISOCode()`.
|
||||
- **`MMEFineLocations2 RegionFineLocation2 { get; set; }`**
|
||||
Fine location 2 metadata. Setting updates `_fineLocation2Index` and calls `SetISOCode()`.
|
||||
- **`MMEFineLocations3 RegionFineLocation3 { get; set; }`**
|
||||
Fine location 3 metadata. Setting calls `SetISOCode()`.
|
||||
- **`MMETransducerMainLocation RegionMainLocation { get; set; }`**
|
||||
Main transducer location metadata. Setting updates `_mainLocationIndex` and calls `SetISOCode()`.
|
||||
- **`MMEPhysicalDimensions RegionPhysicalDimension { get; set; }`**
|
||||
Physical dimension metadata. Setting updates `_physicalDimensionIndex` and calls `SetISOCode()`.
|
||||
- **`MMEPositions RegionPosition { get; set; }`**
|
||||
Position metadata. Setting updates `_positionIndex` and calls `SetISOCode()`.
|
||||
- **`MMETestObjects RegionTestObject { get; set; }`**
|
||||
Test object type (e.g., "Breast", "Brain").
|
||||
- **`TestObjectTemplate Template { get; set; }`**
|
||||
Reference to the parent template. Setting triggers `DetermineAvailableISOSettings()`.
|
||||
- **`string[] AllDirections { get; set; }`**
|
||||
Available direction options (from template). `set` also populates `AllDirectionsStrings`.
|
||||
- **`string[] AllDirectionsStrings { get; }`**
|
||||
Human-readable direction names (e.g., `"Anterior"`).
|
||||
- **`MMEFilterClasses[] AllFilterClasses { get; set; }`**
|
||||
Available filter classes. `set` populates `AllFilterClassStrings`.
|
||||
- **`string[] AllFilterClassStrings { get; }`**
|
||||
Human-readable filter class names.
|
||||
- **`MMEFineLocations1[] AllFineLocations1 { get; set; }`**
|
||||
Available fine location 1 options. `set` populates `AllFineLocations1Strings`.
|
||||
- **`string[] AllFineLocations1Strings { get; }`**
|
||||
Human-readable fine location 1 names (`"??"` for null).
|
||||
- **`MMEFineLocations2[] AllFineLocations2 { get; set; }`**
|
||||
Available fine location 2 options. `set` populates `AllFineLocations2Strings`.
|
||||
- **`string[] AllFineLocations2Strings { get; }`**
|
||||
Human-readable fine location 2 names.
|
||||
- **`int FineLocation2Index { get; set; }`**
|
||||
Index into `AllFineLocations2`. Setting updates `RegionFineLocation2` and calls `FilterRegionChannels()`.
|
||||
- **`MMEFineLocations3[] AllFineLocations3 { get; set; }`**
|
||||
Available fine location 3 options. `set` populates `AllFineLocations3Strings`.
|
||||
- **`string[] AllFineLocations3Strings { get; }`**
|
||||
Human-readable fine location 3 names.
|
||||
- **`MMETransducerMainLocation[] AllMainLocations { get; set; }`**
|
||||
Available main location options. `set` populates `AllMainLocationsStrings`.
|
||||
- **`string[] AllMainLocationsStrings { get; }`**
|
||||
Human-readable main location names (`"????"` for null).
|
||||
- **`MMEPhysicalDimensions[] AllPhysicalDimensions { get; set; }`**
|
||||
Available physical dimension options. `set` populates `AllPhysicalDimensionStrings`.
|
||||
- **`string[] AllPhysicalDimensionStrings { get; }`**
|
||||
Human-readable physical dimension names (`"??"` for null).
|
||||
- **`MMEPositions[] AllPositions { get; set; }`**
|
||||
Available position options. `set` populates `AllPositionStrings`.
|
||||
- **`string[] AllPositionStrings { get; }`**
|
||||
Human-readable position names.
|
||||
- **`string ISOCode { get; set; }`**
|
||||
16-character ISO code string (e.g., `"BREAST?ANTERIOR???????"`). Generated by `SetISOCode()` from metadata fields.
|
||||
- **`TestObjectTemplateChannel[] RegionChannels { get; set; }`**
|
||||
List of channels *available* for this region (filtered by `RegionMainLocation`, `RegionDirection`, etc.). `set` triggers `DetermineAvailableISOSettings()`.
|
||||
- **`TemplateChannelUI[] RegionUIChannels { get; set; }`**
|
||||
UI-friendly channel list (mirrors `RegionChannels`).
|
||||
- **`Visibility RegionAddVisibility { get; set; }`**
|
||||
UI visibility flag for "add region" controls.
|
||||
- **`Visibility RegionDeleteVisibility { get; set; }`**
|
||||
UI visibility flag for "delete region" controls.
|
||||
- **`TemplateRegion ToISORegion(TestObjectTemplate template, Zone zone, int number)`**
|
||||
Converts this `Region` to a `TemplateRegion` for ISO export. Uses `RegionUpperLeft`/`RegionBottomRight` (converted to `System.Drawing.Point`), and maps null metadata to ISO defaults (`"?"`, `"??"`, `"????"`).
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
- **Picture filename consistency**: `PictureIndex` must be in `[0, AllPictures.Length-1]` or `-1`. Setting `PictureIndex` to `-1` sets `PictureSource` to `null`.
|
||||
- **ISO code format**: `ISOCode` is always 16 characters, with `"?"`, `"??"`, or `"????"` used for missing metadata fields.
|
||||
- **Channel filtering**: `RegionChannels` is always a subset of `Template.TemplateAllChannels`, filtered by `RegionMainLocation`, `RegionDirection`, `RegionFilterClass`, `RegionFineLocation1/2/3`, `RegionPhysicalDimension`, and `RegionPosition`.
|
||||
- **Metadata consistency**: `RegionDirection`, `RegionFilterClass`, etc., are always `null` or a valid object from their respective `All*` arrays.
|
||||
- **Thread safety**: `_fileNames` population is guarded by a static lock (`MyLock`), and `AllPictures` always accesses `_fileNames` under this lock.
|
||||
- **Region bounds**: `RegionUpperLeft` and `RegionBottomRight` are WPF `Point` coordinates relative to the adorned image.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
- **Imports/References**:
|
||||
- `System`, `System.Collections.Generic`, `System.Linq` (core .NET)
|
||||
- `System.Windows`, `System.Windows.Controls`, `System.Windows.Documents`, `System.Windows.Input`, `System.Windows.Media`, `System.Windows.Shapes` (WPF)
|
||||
- `System.ComponentModel` (`INotifyPropertyChanged`)
|
||||
- `App` (from `Application.Current`), `IsoDb`, `TestObjectTemplate`, `TemplateZone`, `TemplateRegion`, `MMEDirections`, `MMEFilterClasses`, `MMEFineLocations1/2/3`, `MMETransducerMainLocation`, `MMEPhysicalDimensions`, `MMEPositions`, `MMETestObjects`, `TestObjectTemplateChannel`, `TemplateChannelUI` (all inferred from usage).
|
||||
- **External resources**:
|
||||
- `ZonePictures` subdirectory in `AppDomain.CurrentDomain.BaseDirectory` (for zone images).
|
||||
- **Depended on by**:
|
||||
- UI layers (e.g., WPF adorner layers using `RegionAdorner`).
|
||||
- Database import/export logic (via `ToISORegion` and `Zone` constructors).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
- **Picture loading failure**: If `Image` is set but the file does not exist at `ZonePictures/<Image>`, `PictureIndex` is set to `-1` silently (no exception thrown).
|
||||
- **Scaling assumptions**: `GetUpperLeft()`/`GetLowerRight()` assume the adorned element is an `Image` with a `BitmapImage` source. Scaling logic may be incorrect if `Source` dimensions are unavailable or non-integer.
|
||||
- **`FineLocation2Index` setter**: Only updates `RegionFineLocation2` and calls `FilterRegionChannels()`; does *not* update `_fineLocation2Index` directly (relies on `RegionFineLocation2` setter).
|
||||
- **`RegionFineLocation3` setter**: Does not update `_fineLocation3Index` (empty `else` block), unlike other fine location properties.
|
||||
- **`AllPictures` thread safety**: While `_fileNames` population is thread-safe, `AllPictures` returns a *snapshot* array. Concurrent modifications to `_fileNames` (e.g., via `PopulateFilenames()`) during enumeration could cause `IndexOutOfRangeException` if not for the lock (but `AllPictures` itself is safe).
|
||||
- **`Region` constructor from `TemplateRegion`**: Uses `((App)Application.Current).IsoDb` for lookups. If `IsoDb` is not initialized, this will throw a `NullReferenceException`.
|
||||
- **`RegionChannels`/`RegionUIChannels`**: The `set` accessor for `RegionChannels` calls `DetermineAvailableISOSettings()`, which may overwrite previously set values (e.g., `RegionDirection`, `RegionFilterClass`).
|
||||
- **ISO code generation**: `SetISOCode()` uses `"?"` for null `RegionTestObject`, but `"???"` for null `RegionMainLocation` (inconsistent padding).
|
||||
@@ -0,0 +1,132 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Sensors/ZeroMethod.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Sensors/InitialOffset.cs
|
||||
generated_at: "2026-04-16T04:31:39.106411+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f3a6aea6102ad03a"
|
||||
---
|
||||
|
||||
# Sensors
|
||||
|
||||
## Documentation: Sensor Calibration Offset Classes
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module defines two core data structures—`ZeroMethod` and `InitialOffset`—used to represent sensor calibration parameters within the database import pipeline. `ZeroMethod` encodes the *zeroing procedure* applied to a sensor (e.g., how and over what range the zero offset was determined), while `InitialOffset` encodes the *initial offset correction* applied to raw sensor data, supporting legacy single-value EU offsets as well as modern calibrated offsets specified in engineering units (EU) at a known millivolt (mV) input. Together, they enable accurate reconstruction of calibrated sensor readings from raw data during import.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `ZeroMethod` class
|
||||
|
||||
- **`public event PropertyChangedEventHandler PropertyChanged;`**
|
||||
Implements `INotifyPropertyChanged`—raised when any property (`Method`, `Start`, `End`) is modified.
|
||||
|
||||
- **`protected bool SetProperty<T>(ref T storage, T value, string propertyName = null) → bool`**
|
||||
Updates the backing field if the new value differs, raises `PropertyChanged`, and returns `true`; otherwise returns `false`. Used internally by property setters (not shown in source but implied by usage pattern).
|
||||
|
||||
- **`protected void OnPropertyChanged(string propertyName = null)`**
|
||||
Raises the `PropertyChanged` event for the specified property name (or `null` for all properties).
|
||||
|
||||
- **`public ZeroMethodType Method { get; set; }`**
|
||||
The zeroing method used (e.g., `ZeroMethodType.Average`, `ZeroMethodType.LinearFit`). *Type is referenced but not defined in this source file.*
|
||||
|
||||
- **`public double Start { get; set; }`**
|
||||
Start index or time of the zeroing window/range.
|
||||
|
||||
- **`public double End { get; set; }`**
|
||||
End index or time of the zeroing window/range.
|
||||
|
||||
- **`public ZeroMethod(ZeroMethodType zm, double start, double end)`**
|
||||
Primary constructor: initializes `Method`, `Start`, and `End` directly.
|
||||
|
||||
- **`public ZeroMethod(string zm)`**
|
||||
Deserialization constructor: parses a comma-separated string `zm` of the form `"Method,Start,End"` (e.g., `"Average,100.0,200.0"`), using `InvariantCulture`. Throws no exception on failure—invalid input silently leaves properties at default values.
|
||||
|
||||
- **`public ZeroMethod(ZeroMethod copy)`**
|
||||
Copy constructor: performs deep copy of all fields (`Method`, `Start`, `End`).
|
||||
|
||||
#### `InitialOffset` class
|
||||
|
||||
- **`public enum Forms { None = 0, EU = 1, EUAtMV = 2 }`**
|
||||
Indicates the format of the offset:
|
||||
- `None`: No offset applied.
|
||||
- `EU`: Single offset value in engineering units.
|
||||
- `EUAtMV`: Offset specified as EU value measured at a known mV input (requires additional context to compute full offset).
|
||||
|
||||
- **`public Forms Form { get; set; }`**
|
||||
Current format of this offset instance.
|
||||
|
||||
- **`public double EU { get; set; } = 0;`**
|
||||
Engineering unit value. Interpretation depends on `Form`:
|
||||
- `EU`: Direct offset to add to raw data.
|
||||
- `EUAtMV`: EU value observed at `MV`.
|
||||
- `None`: Unused.
|
||||
|
||||
- **`public double MV { get; set; } = 0;`**
|
||||
Millivolt input at which `EU` was measured. Only meaningful when `Form == EUAtMV`.
|
||||
|
||||
- **`public InitialOffset(InitialOffset copy)`**
|
||||
Copy constructor: copies `EU`, `MV`, and `Form`. Safely handles `null` input (no-op).
|
||||
|
||||
- **`public InitialOffset()`**
|
||||
Default constructor: sets `Form = Forms.None`, `EU = 0`, `MV = 0`.
|
||||
|
||||
- **`public InitialOffset(double d)`**
|
||||
Legacy constructor: creates an `EU`-form offset with `EU = d`, `MV = 0`, `Form = Forms.EU`.
|
||||
|
||||
- **`public void FromDbSerializeString(string input)`**
|
||||
Deserializes from a database string (e.g., `"EUAtMV,12.5,45.3"` using `InvariantCulture` list separator).
|
||||
- Throws `InvalidDataException` if fewer than 3 tokens or invalid `Forms` enum value.
|
||||
- Throws `FormatException` if `EU` or `MV` token is not parseable as `double`.
|
||||
- Sets `Form = Forms.None`, `EU = 0`, `MV = 0` on empty/whitespace input.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **`ZeroMethod`**
|
||||
- `Start` and `End` may be in any order (no guarantee `Start ≤ End` is enforced).
|
||||
- `Method` must be a valid `ZeroMethodType` enum value (enforced only if constructed via `ZeroMethodType` constructor; string constructor does not validate enum parsing).
|
||||
- After deserialization via string constructor, if parsing fails (e.g., fewer than 3 tokens), properties retain their default values (`Method = default(ZeroMethodType)`, `Start = End = 0.0`).
|
||||
|
||||
- **`InitialOffset`**
|
||||
- `Form == Forms.None` ⇔ `EU = 0` and `MV = 0` (enforced by constructors and `FromDbSerializeString` on empty input).
|
||||
- `Form == Forms.EU` ⇒ `MV` is irrelevant (but not reset); `EU` holds the offset in EU.
|
||||
- `Form == Forms.EUAtMV` ⇒ `EU` is the observed EU at `MV` (both must be non-zero in practice, though not enforced).
|
||||
- `FromDbSerializeString` requires exactly 3 tokens; otherwise throws.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
- **`ZeroMethod`**
|
||||
- **Depends on**: `System.ComponentModel` (for `INotifyPropertyChanged`), `System` (for `Equals`, `Convert`, `Enum.Parse`, `PropertyChangedEventArgs`).
|
||||
- **References**: `ZeroMethodType` (enum, not defined in this file—must be defined elsewhere in `DatabaseImport` namespace).
|
||||
- **Used by**: Likely sensor configuration/import logic (inferred from namespace `DatabaseImport.Sensors`).
|
||||
|
||||
- **`InitialOffset`**
|
||||
- **Depends on**: `System` (for `Enum.TryParse`, `double.TryParse`, `InvalidDataException`, `FormatException`).
|
||||
- **References**: `Forms` nested enum (defined in this file).
|
||||
- **Used by**: Sensor calibration/offset application logic during data import.
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **`ZeroMethod` string constructor is non-throwing on failure**: If the input string has fewer than 3 comma-separated tokens, the constructor silently leaves properties uninitialized (default values). Callers must validate or assume success only for well-formed inputs.
|
||||
|
||||
- **`ZeroMethodType` is undefined here**: Its possible values and semantics (e.g., `Average`, `LinearFit`) are not documented in this source—must be referenced externally.
|
||||
|
||||
- **`InitialOffset.EU` meaning is context-dependent**: In `EUAtMV` mode, `EU` is *not* the final offset—it is the EU value *at* `MV`. The actual offset calculation requires additional calibration data (e.g., sensor sensitivity), which is not provided in this class.
|
||||
|
||||
- **`FromDbSerializeString` uses list separator from `InvariantCulture`**: While `InvariantCulture` is used for number parsing, the list separator (`TextInfo.ListSeparator`) is *not* guaranteed to be a comma—it is culture-specific (though `InvariantCulture`’s is `,`). This may cause issues if the DB string uses a different delimiter.
|
||||
|
||||
- **No validation of `Start`/`End` ranges**: `ZeroMethod` allows `Start > End` or negative values without error.
|
||||
|
||||
- **`InitialOffset` copy constructor does not throw on `null`**: It silently returns with default values if `copy == null`.
|
||||
@@ -0,0 +1,97 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestMetaData/LabratoryDetails.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestMetaData/CustomerDetails.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestMetaData/TestEngineerDetails.cs
|
||||
generated_at: "2026-04-16T04:31:55.181756+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "6aa688c6b66d13f9"
|
||||
---
|
||||
|
||||
# TestMetaData
|
||||
|
||||
## Documentation: Test Metadata Wrappers Module
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
This module provides thin managed wrappers around low-level `ISO.*` data entities (`LabratoryDetails`, `CustomerDetails`, `TestEngineerDetails`) to support database import operations within the DataPRO system. It exposes simplified, namespaced access to metadata entities used during test configuration and reporting, including CRUD-like operations (e.g., `DeleteAll`) and instance management (e.g., singleton list for engineers). The module exists to decouple the import pipeline from direct dependencies on the `ISO` layer, enabling testability and future flexibility in metadata handling.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `LabratoryDetails`
|
||||
- **`public string Name { get; set; }`**
|
||||
Gets or sets the laboratory name by delegating to the underlying `_lab.Name` field.
|
||||
|
||||
#### `LabratoryDetailsList`
|
||||
- **`public static void DeleteAll()`**
|
||||
Invokes `ISO.LabratoryDetails.DeleteLabratoryDetails()` to remove all laboratory detail records from persistent storage.
|
||||
|
||||
#### `CustomerDetails`
|
||||
- **`public string Name { get; set; }`**
|
||||
Gets or sets the customer name by delegating to `_customerDetails.Name`.
|
||||
|
||||
#### `CustomerDetailsList`
|
||||
- **`public static void DeleteAll()`**
|
||||
Invokes `ISO.CustomerDetails.DeleteCustomerDetails()` to delete all customer detail records.
|
||||
|
||||
#### `TestEngineerDetails`
|
||||
- **`public TestEngineerDetails()`**
|
||||
Default constructor initializes `_testEngineerDetails` to a new `ISO.TestEngineerDetails` instance with `Name` set to `"(none)"`.
|
||||
- **`public TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)`**
|
||||
Copy constructor: initializes `_testEngineerDetails` by constructing a new `ISO.TestEngineerDetails` from the provided instance.
|
||||
- **`public string Name { get; set; }`**
|
||||
Gets or sets the engineer’s name via `_testEngineerDetails.Name`.
|
||||
|
||||
#### `TestEngineerDetailsList`
|
||||
- **`public static TestEngineerDetailsList TestEngineerList { get; }`**
|
||||
Static singleton accessor for the single `TestEngineerDetailsList` instance.
|
||||
- **`public void ReloadAll()`**
|
||||
Thread-safely repopulates the internal `_testEngineers` dictionary by calling `GetAllTestEngineers()` and caching entries keyed by `Name`.
|
||||
- **`public static void DeleteAll()`**
|
||||
Clears the in-memory `_testEngineers` dictionary and invokes `ISO.TestEngineerDetails.DeleteAllTestEngineerDetails()` to purge persisted records.
|
||||
- **`private TestEngineerDetails[] GetAllTestEngineers()`**
|
||||
Returns an array of `TestEngineerDetails` objects: first a sentinel `"(none)"` entry (via default constructor), then one entry per record returned by `ISO.TestEngineerDetails.GetAllTestEngineerDetails()`.
|
||||
|
||||
> **Note**: `GetAllTestEngineers()` is `private`, but used internally by `ReloadAll()` and implicitly by the `PopulateEngineers()` method.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
- **`Name` is the only mutable property** exposed via the public interface for all three detail classes (`LabratoryDetails`, `CustomerDetails`, `TestEngineerDetails`).
|
||||
- **`TestEngineerDetailsList` is a singleton** — only one instance exists (`_testEngineerList`), accessed via `TestEngineerList`.
|
||||
- **Thread safety for `ReloadAll()`** is enforced via `lock (_testEngineerLock)` around `PopulateEngineers()`.
|
||||
- **`"(none)"` sentinel entry** is always the first element in the list returned by `GetAllTestEngineers()`.
|
||||
- **Duplicate names are prevented** in `_testEngineers` dictionary: `PopulateEngineers()` only adds an entry if `!_testEngineers.ContainsKey(t.Name)`.
|
||||
- **`_testEngineers` is nullified on `DeleteAll()`**, forcing a full reload on next access.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### Dependencies *of* this module:
|
||||
- `ISO.LabratoryDetails` (type with static methods `DeleteLabratoryDetails()`)
|
||||
- `ISO.CustomerDetails` (type with static method `DeleteCustomerDetails()`)
|
||||
- `ISO.TestEngineerDetails` (type with static methods `GetAllTestEngineerDetails()`, `DeleteAllTestEngineerDetails()`, and constructors)
|
||||
- `System.Collections.Generic.Dictionary<string, TestEngineerDetails>` (used in `TestEngineerDetailsList`)
|
||||
|
||||
#### Dependencies *on* this module:
|
||||
- Not explicitly stated in source, but given the naming and structure, this module is likely consumed by:
|
||||
- `DatabaseImport` pipeline components (e.g., importers that populate or validate test metadata).
|
||||
- UI or service layers that require test metadata (e.g., selecting engineer or lab for a test run).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
- **Typo in class names**: All classes use `Labratory` (misspelled) instead of `Laboratory`. This is preserved from the underlying `ISO` layer and must be maintained for compatibility.
|
||||
- **`TestEngineerDetails` is *not* thread-safe for concurrent mutation** — while `ReloadAll()` is synchronized, direct access to `_testEngineerDetails.Name` (via `Name` property) is not guarded.
|
||||
- **`_testEngineerDetails` field in `TestEngineerDetails` is *not* `readonly`**, unlike the others — implying potential reassignment (though not observed in current code).
|
||||
- **`GetAllTestEngineers()` silently ignores duplicate names** — only the first occurrence is retained in `_testEngineers`.
|
||||
- **No validation on `Name` values** — empty strings or duplicates are allowed at the wrapper level (though duplicates are deduped in `TestEngineerDetailsList`).
|
||||
- **`CustomerDetailsList` and `LabratoryDetailsList` have no instance members beyond `DeleteAll()`** — they are effectively static namespaces.
|
||||
- **`TestEngineerDetailsList` caches in-memory state** — changes made directly to `ISO.*` entities outside this module may not be reflected until `ReloadAll()` is called.
|
||||
|
||||
None identified beyond those above.
|
||||
@@ -0,0 +1,263 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestObject/TemplateChannelUI.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestObject/TestObjectTemplateCollection.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestObject/TestObjectList.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestObject/TestTestObject.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestObject/TestObjectTemplate.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestObject/TestObject.cs
|
||||
generated_at: "2026-04-16T04:33:08.085586+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "d8ddaddf5f4cb968"
|
||||
---
|
||||
|
||||
# TestObject
|
||||
|
||||
**Documentation Page: Test Object & Template Management Module**
|
||||
|
||||
---
|
||||
|
||||
### 1. **Purpose**
|
||||
|
||||
This module provides in-memory wrappers and management abstractions for test object and template data originating from the `ISO.TestObject` and `ISO.TestObjectTemplate` types in the underlying `ISO` namespace. It serves as the data-access and UI-binding layer for test object configurations, templates, and associated channel/sensor metadata within the `DatabaseImporter` module. Its primary role is to decouple UI and business logic from raw database structures (`ISO13499FileDb`) while supporting both ISO-compliant and non-ISO (custom) test object types, and enabling template reuse, inheritance, and zone-based channel organization.
|
||||
|
||||
---
|
||||
|
||||
### 2. **Public Interface**
|
||||
|
||||
#### `TemplateChannelUI`
|
||||
- **`TemplateChannelUI(TestObjectTemplateChannel channel)`**
|
||||
Constructor wrapping a `TestObjectTemplateChannel`. No public properties or methods exposed beyond the internal `_channel` field.
|
||||
|
||||
#### `TestObjectTemplateCollection`
|
||||
- **`static TestObjectTemplateCollection TemplateCollection { get; }`**
|
||||
Singleton accessor for the global collection of test object templates.
|
||||
- **`TestObjectTemplate GetTemplate(string templateId)`**
|
||||
Retrieves a `TestObjectTemplate` by ID from the database (`IsoDb`) and wraps it in a `TestObjectTemplate` instance. Returns `null` if not found.
|
||||
- **`TestObjectTemplate SysBuiltTestObjectTemplate { get; }`**
|
||||
Returns the system-built template (currently uninitialized in source; `_sysBuiltTestObjectTemplate` is `null`).
|
||||
- **`void ReloadAll(bool loadSubComponents)`**
|
||||
Stubbed out (all logic commented out). Intended to refresh templates and subcomponents.
|
||||
- **`static void DeleteAll()`**
|
||||
Deletes all templates in the database via `ISO.TestObjectTemplate.DeleteAllTemplates()`, then resets the singleton collection.
|
||||
|
||||
#### `TestObjectList`
|
||||
- **`static TestObjectList TestObjectsList { get; }`**
|
||||
Singleton accessor for the main list of test objects (non-system-built).
|
||||
- **`static TestObjectList AddedGroupsList { get; }`**
|
||||
Singleton accessor for a separate list used for user-added groups (system-built).
|
||||
- **`void ReloadAll(bool bLoadSubComponents)`**
|
||||
Stubbed out (empty body). Intended to reload all test objects and subcomponents.
|
||||
- **`TestObject GetTestObject(string serialNumber, bool bSysBuilt)`**
|
||||
Retrieves a test object by serial number and `bSysBuilt` flag. Returns `null` if not found.
|
||||
- **`TestObject GetTestObject(string serialNumber)`**
|
||||
Convenience overload: tries non-system-built first, then system-built.
|
||||
- **`TestObject GetAddedGroup(string serialNumber)`**
|
||||
Alias for `GetTestObject(serialNumber, true)`.
|
||||
- **`void DeleteAll()`**
|
||||
Deletes all test objects in the database via `ISO.TestObject.DeleteAllTestObjects()`.
|
||||
|
||||
#### `TestTestObject`
|
||||
- **`TestTestObject(TestObject obj)`**
|
||||
Constructor wrapping a `TestObject`.
|
||||
- **`MMEPositions Position { get; set; }`**
|
||||
Gets/sets the group position. Setting to `UserSetKey` (`"@"`) hides the combo box and shows the position button; otherwise, vice versa. Also propagates position to all required sensors.
|
||||
- **`string ChannelDefaultsKey { get; }`**
|
||||
Constant `"#"` representing the default channel position.
|
||||
- **`string UserSetKey { get; }`**
|
||||
Constant `"@"` representing a user-defined position.
|
||||
- **`Visibility GroupPositionComboBoxVisible { get; set; }`**
|
||||
Controls visibility of the position combo box. Collapsed if `ISO13499` support is disabled (`NO_ISO`).
|
||||
- **`Visibility GroupPositionButtonVisible { get; set; }`**
|
||||
Controls visibility of the position button. Collapsed if `ISO13499` support is disabled.
|
||||
- **`MMETestObjects TestObject { get; set; }`**
|
||||
Gets/sets the test object for the group. Setting it propagates the change to all required sensors.
|
||||
- **`int ChannelTypesIndex { get; set; }`**
|
||||
Index into a list of channel types (used for UI binding).
|
||||
- **`int ExcitationWarmupTimeMS { get; set; }`**
|
||||
Excitation warm-up time in milliseconds.
|
||||
- **`double TargetSampleRate { get; set; }`**
|
||||
Target sample rate.
|
||||
- **`double PreTriggerSeconds { get; set; }`**
|
||||
Pre-trigger duration in seconds.
|
||||
- **`double PostTriggerSeconds { get; set; }`**
|
||||
Post-trigger duration in seconds.
|
||||
- **`MMEPositions[] AvailablePositions { get; }`**
|
||||
Returns available positions from `IsoDb`.
|
||||
- **`MMEPositions[] AvailableGroupPositions { get; }`**
|
||||
Returns combined list: `ChannelDefaultsKey` position first, then `AvailablePositions`.
|
||||
- **`void SetTestObject(string s)`**
|
||||
Sets `_testObject` and raises `TestObject` property change.
|
||||
- **`void SetPosition(string s)`**
|
||||
Sets `_position` and raises `Position` change; updates UI visibility flags.
|
||||
|
||||
#### `TestObjectTemplate`
|
||||
- **`TestObjectTemplate()`**
|
||||
Default constructor. Initializes `TestObject` based on `SerializedSettings.ISOSupportLevel`. For `NO_ISO`, creates a non-ISO test object and sets channel type to `Constants.NON_ISO_TESTOBJECT_CHANNEL_TYPE`.
|
||||
- **`TestObjectTemplate(ISO.TestObjectTemplate template, ref ISO13499FileDb db)`**
|
||||
Wraps an `ISO.TestObjectTemplate` instance.
|
||||
- **`TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)`**
|
||||
Copy constructor.
|
||||
- **`string TemplateName { get; set; }`**
|
||||
Template name.
|
||||
- **`string TemplateDescription { get; set; }`**
|
||||
Template description.
|
||||
- **`string TemplateParent { get; set; }`**
|
||||
Parent template name (for inheritance).
|
||||
- **`bool SysBuilt { get; set; }`**
|
||||
Whether the template is system-built.
|
||||
- **`bool Embedded { get; set; }`**
|
||||
Whether the template is embedded.
|
||||
- **`string OriginalTemplateName { get; set; }`**
|
||||
Original template name (preserved for tracking).
|
||||
- **`MMETestObjects TestObject { get; set; }`**
|
||||
Test object associated with the template.
|
||||
- **`string TestObjectType { get; set; }`**
|
||||
Test object type (e.g., channel type).
|
||||
- **`int TestObjectTypeIndex { get; set; }`**
|
||||
Index into `AvailableTestObjectTypes`.
|
||||
- **`string[] AvailableTestObjectTypes { get; set; }`**
|
||||
List of test object types compatible with current `TestObject`.
|
||||
- **`TestObjectTemplateChannel[] RequiredChannels { get; }`**
|
||||
List of required channels for the template.
|
||||
- **`TestObjectTemplateChannel[] TemplateAllChannels { get; set; }`**
|
||||
All channels (required + optional), sorted by `DisplayOrder`.
|
||||
- **`TemplateChannelUI[] TemplateAllUIChannels { get; set; }`**
|
||||
UI wrapper list for `TemplateAllChannels`.
|
||||
- **`Zone[] TemplateZones { get; set; }`**
|
||||
List of zones defined in the template.
|
||||
- **`int CurrentZoneIndex { get; set; }`**
|
||||
Index of the currently selected zone. Updates `CurrentZone`.
|
||||
- **`Zone CurrentZone { get; set; }`**
|
||||
Currently selected zone. Controls `AreZoneControlsEnabled`.
|
||||
- **`bool AreZoneControlsEnabled { get; }`**
|
||||
`true` if `CurrentZone` is non-null.
|
||||
- **`DateTime LastModified { get; set; }`**
|
||||
Last modification timestamp.
|
||||
- **`string LastModifiedBy { get; set; }`**
|
||||
User who last modified the template.
|
||||
- **`static MMETestObjects GetNonISOTestObject()`**
|
||||
Retrieves or creates a non-ISO test object (name: `Constants.NON_ISO_TESTOBJECT_NAME`). Tries letters A–Z, then digits 0–9.
|
||||
- **`ISO.TestObjectTemplate ToISOTestObjectTemplate()`**
|
||||
Converts the wrapper to an `ISO.TestObjectTemplate` instance for persistence.
|
||||
|
||||
#### `TestObject`
|
||||
- **`TestObject()`**
|
||||
Default constructor. Initializes empty `_isoTestObject` and `Template`.
|
||||
- **`TestObject(ISO.TestObject to, bool sysBuilt)`**
|
||||
Wraps an `ISO.TestObject`. Initializes `Template` and hardware.
|
||||
- **`TestObject(TestObject copy)`**
|
||||
Copy constructor.
|
||||
- **`string SerialNumber { get; set; }`**
|
||||
Unique serial number.
|
||||
- **`string SerialNumberConverted { get; set; }`**
|
||||
Human-readable serial number (e.g., stripped prefix for system-built).
|
||||
- **`string DisplaySerialNumber { get; set; }`**
|
||||
Serial number used for display. Setting it updates `SerialNumber`, `OriginalSerialNumber`, and template name.
|
||||
- **`string TestSetupName { get; set; }`**
|
||||
Name prefix for user-added groups.
|
||||
- **`string TestObjectType { get; set; }`**
|
||||
Type of the test object (from template).
|
||||
- **`string ParentObject { get; set; }`**
|
||||
Parent test object (for hierarchy).
|
||||
- **`bool SysBuilt { get; set; }`**
|
||||
Whether the test object is system-built.
|
||||
- **`TestObjectTemplate Template { get; set; }`**
|
||||
Template associated with the test object.
|
||||
- **`void SetTemplateDontResetISOObject(TestObjectTemplate value)`**
|
||||
Sets template without resetting underlying `ISO.TestObject.Template`.
|
||||
- **`string[] ZoneNames { get; set; }`**
|
||||
Names of zones in the current template.
|
||||
- **`string TemplateType { get; }`**
|
||||
`Template.TestObjectType`, or `""` if no template.
|
||||
- **`DASHardware[] Hardware { get; }`**
|
||||
List of attached hardware devices, sorted.
|
||||
- **`void SetHardwareFromISO()`**
|
||||
Refreshes `_hardware` from `ISO.TestObject.HardwareIds`.
|
||||
- **`void SetHardware(DASHardware[] hardware)`**
|
||||
Sets hardware list in memory and updates `ISO.TestObject.HardwareIds`.
|
||||
- **`void AddHardware(DASHardware hardware)`**
|
||||
Adds hardware, handling dummy hardware naming collisions.
|
||||
- **`bool ContainsHardware(DASHardware h)`**
|
||||
Checks if hardware is attached.
|
||||
- **`SensorData GetSensor(string channelId, string serialNumber, string alternateChannelId = null)`**
|
||||
Retrieves sensor settings for a given channel and serial number. Applies ISO channel defaults and overrides from `ISO.TestObject.SensorSettings`.
|
||||
- **`void SetSensor(string channelName, SensorData sensor)`**
|
||||
Persists sensor settings to the underlying `ISO.TestObject`.
|
||||
- **`ISO.TestObject GetISOTestObject()`**
|
||||
Returns the underlying `ISO.TestObject` instance.
|
||||
- **`void RefreshHardware()`**
|
||||
Alias for `SetHardwareFromISO()`.
|
||||
- **`string SerialNumberOrOriginalSerialNumber { get; }`**
|
||||
Returns `OriginalSerialNumber` if embedded, else `SerialNumberConverted` or `SerialNumber`.
|
||||
- **`SerializedSettings.ISOSupportLevels GetObjectISOLevel()`**
|
||||
Returns `NO_ISO` if template type contains `NON_ISO_TESTOBJECT_CHANNEL_TYPE` or `NONISOCHANNELTYPE`, else `ISO_ONLY`.
|
||||
|
||||
---
|
||||
|
||||
### 3. **Invariants**
|
||||
|
||||
- **Singleton consistency**:
|
||||
`TestObjectTemplateCollection.TemplateCollection` and `TestObjectList.TestObjectsList`/`AddedGroupsList` are lazily initialized singletons. Thread-safety is ensured via `volatile` and `lock(MyLock)` (in `TestObjectList`).
|
||||
- **Template ↔ ISO mapping**:
|
||||
Every `TestObjectTemplate` wraps exactly one `ISO.TestObjectTemplate`, and vice versa. The `ToISOTestObjectTemplate()` method must produce a valid `ISO.TestObjectTemplate` with all fields populated.
|
||||
- **Sensor settings precedence**:
|
||||
`TestObject.GetSensor()` applies ISO channel defaults *first*, then overlays `SensorSettings` from `ISO.TestObject`. If `FilterClassIso` is `"?"`, it is normalized to `"P"`.
|
||||
- **Channel ordering**:
|
||||
`TemplateAllChannels` is sorted by `DisplayOrder` (via `CompareChannels`).
|
||||
- **Non-ISO test object uniqueness**:
|
||||
`GetNonISOTestObject()` ensures a single non-ISO test object exists, using letters A–Z first, then digits 0–9 if needed.
|
||||
- **Template type consistency**:
|
||||
`TestObject.TemplateType` is derived from `Template.TestObjectType`. If `Template` is `null`, it returns `""`.
|
||||
|
||||
---
|
||||
|
||||
### 4. **Dependencies**
|
||||
|
||||
#### **Internal Dependencies**
|
||||
- `ISO.TestObject`, `ISO.TestObjectTemplate`, `ISO13499FileDb` (from `ISO` namespace).
|
||||
- `App.IsoDb` (accessed via `Application.Current as App`).
|
||||
- `DASHardware`, `DASHardwareList`, `SensorData`, `SensorsCollection.SensorsList`.
|
||||
- `MMEPositions`, `MMETestObjects`, `MMEPossibleChannels`.
|
||||
- `SerializedSettings`, `Constants` (e.g., `NON_ISO_TESTOBJECT_NAME`, `NON_ISO_TESTOBJECT_CHANNEL_TYPE`).
|
||||
- `Zone`, `TemplateZone`, `TestObjectTemplateChannel`.
|
||||
- `DbTimeStampBase` (base class for `TestObject`).
|
||||
- `Tags` enum (used for property change notifications).
|
||||
|
||||
#### **External Dependencies**
|
||||
- `System.Windows` (for `Visibility`, `Application`, `Guid.NewGuid()`).
|
||||
- `System.Globalization` (for `CultureInfo.InvariantCulture` parsing).
|
||||
- `System.Linq` (for LINQ queries in `GetNonISOTestObject()` and `TestObjectTemplate` initialization).
|
||||
|
||||
#### **Dependents**
|
||||
- UI layers (e.g., WPF views binding to `TemplateChannelUI`, `TestObject`, `TestTestObject`).
|
||||
- Import/export logic (e.g., TDM imports calling `DeleteAll()` on `TestObjectList` or `TestObjectTemplateCollection`).
|
||||
- Template management UI (e.g., zone editing, channel assignment).
|
||||
|
||||
---
|
||||
|
||||
### 5. **Gotchas**
|
||||
|
||||
- **`SysBuiltTestObjectTemplate` is uninitialized**:
|
||||
`_sysBuiltTestObjectTemplate` is declared but never assigned. `SysBuiltTestObjectTemplate` will always return `null`.
|
||||
- **`ReloadAll` stubbed out**:
|
||||
Both `TestObjectTemplateCollection.ReloadAll()` and `TestObjectList.ReloadAll()` have no implementation (all logic commented out). This may cause stale data if callers assume reload occurs.
|
||||
- **`TemplateAllChannels` setter triggers side effects**:
|
||||
Setting `TemplateAllChannels` in `TestObjectTemplate` instantiates `TemplateAllUIChannels` and updates `_channels` and `_availableTestObjectTypes`. This may cause unexpected behavior if called multiple times.
|
||||
- **`TestObject.GetSensor()` uses ambiguous channel lookup**:
|
||||
The method tries `channelId` first, then `alternateChannelId` (often `channelId` again). The comment notes historical inconsistency between channel name vs. ID usage.
|
||||
- **`DisplaySerialNumber` setter mutates multiple fields**:
|
||||
Setting `DisplaySerialNumber` on a user-added group updates `SerialNumber`, `SerialNumberConverted`, `OriginalSerialNumber`, and template names. This may cause unintended side effects if used on system-built objects.
|
||||
- **`TestTestObject.Position` setter propagates to sensors**:
|
||||
Changing `Position` updates *all* required sensors’ positions, but only if `Position != UserSetKey`. This may be unexpected if the UI allows switching to `UserSetKey` mid-edit.
|
||||
- **`GetNonISOTestObject()` may throw**:
|
||||
If no available letters/digits remain, `GetNonISOTestObject()` throws `NotSupportedException`. No fallback or logging is present.
|
||||
- **`TemplateType` may be `"?"`**:
|
||||
`TestObject.TestObjectType` defaults to `"?"`, and `TemplateType` inherits this. Consumers must handle this sentinel value.
|
||||
- **No explicit `INotifyPropertyChanged` implementation visible**:
|
||||
Classes reference `SetProperty` and `OnPropertyChanged`, but no base class (`BasePropertyChanged`) is included in the source. Behavior assumes a working implementation elsewhere.
|
||||
|
||||
---
|
||||
|
||||
*End of Documentation.*
|
||||
@@ -0,0 +1,124 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestTemplate/ICachedContainer.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestTemplate/HardwareInclusionInstruction.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestTemplate/TestTemplateLite.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestTemplate/RegionOfInterest.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestTemplate/TestTemplateList.cs
|
||||
generated_at: "2026-04-16T04:32:24.918567+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "d58cccdbb5baf57a"
|
||||
---
|
||||
|
||||
# Documentation: TestTemplate Module
|
||||
|
||||
## 1. Purpose
|
||||
This module provides foundational data structures and utilities for representing and manipulating test templates within the DatabaseImporter subsystem. It defines lightweight and extensible models for test configurations (e.g., `TestTemplateLite`), hardware inclusion/exclusion rules (`HardwareInclusionInstruction`), time-domain regions of interest (`RegionOfInterest`), and a caching interface (`ICachedContainer`) for hardware lookups. It also includes helper methods in `TestTemplateList` for serializing/deserializing sensor settings and managing system-wide test template state. The module exists to decouple test template representation from full database persistence, enabling in-memory manipulation, validation, and deferred commit—particularly useful during test import workflows where DAS hardware may be excluded via group-based rules (e.g., for "DASless" tests).
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `ICachedContainer` (Interface)
|
||||
- **`DASHardware GetCachedHardware(string serialNumber)`**
|
||||
Retrieves a cached `DASHardware` instance by serial number. Returns `null` if not found (behavior inferred from usage context).
|
||||
- **`IISOHardware[] GetAllCachedHardware()`**
|
||||
Returns all cached hardware items as an array of `IISOHardware`.
|
||||
|
||||
### `HardwareInclusionInstruction` (Class)
|
||||
- **Constructor `HardwareInclusionInstruction(string hardwareId, Actions action)`**
|
||||
Initializes a new instruction to add or remove hardware from a test, overriding group-derived inclusion.
|
||||
- `hardwareId`: Identifier for the hardware item (e.g., serial number).
|
||||
- `action`: Either `Actions.Remove` (exclude despite group membership) or `Actions.Add` (include despite absence from groups).
|
||||
- **Properties**
|
||||
- `HardwareId`: Read-only string identifier.
|
||||
- `Action`: Read-only `Actions` enum value (`Remove` or `Add`).
|
||||
|
||||
### `TestTemplateLite` (Class)
|
||||
- **Properties**
|
||||
- `Name`: `string` — Name of the test template.
|
||||
- `Description`: `string` — Optional description (defaults to `""`).
|
||||
- `RecordingMode`: `RecordingModes` — Determines pre-trigger behavior.
|
||||
- `PreTriggerSeconds`: `double` —
|
||||
- Returns `0` for `Recorder` or `HybridRecorder` modes.
|
||||
- Returns stored `_preTriggerSeconds` for `CircularBuffer` or other modes.
|
||||
- Setter updates `_preTriggerSeconds` unconditionally.
|
||||
- `ErrorMessage`: `string` — Raw error message (defaults to `string.Empty`).
|
||||
- `CompletionErrorMessage`: `string` — Truncated error message (max 250 chars).
|
||||
- `PostTriggerSeconds`: `double` — Post-trigger duration.
|
||||
- `LastModified`: `DateTime` — Timestamp of last modification.
|
||||
- `LastModifiedBy`: `string` — User who last modified the template.
|
||||
- `IsComplete`: `bool` — Indicates if the template is fully configured.
|
||||
|
||||
### `RegionOfInterest` (Class)
|
||||
- **Constructors**
|
||||
- `RegionOfInterest()` — Default: `Suffix=""`, `Start=-1`, `End=1`, `IsEnabled=true`, `IsDefault=true`.
|
||||
- `RegionOfInterest(bool isDefault)` — Sets `IsDefault`.
|
||||
- `RegionOfInterest(string suffix, bool isDefault, double start, double end)` — Full initialization.
|
||||
- **Properties**
|
||||
- `Suffix`: `string` — Auto-normalized to start with `_` (e.g., `"foo"` → `"_foo"`; `""` remains `""`).
|
||||
- `Start`: `double` — Clamped to `[PreTrigger, End - 0.01]`.
|
||||
- `End`: `double` — Clamped to `[Start + 0.01, PostTrigger]`.
|
||||
- `PreTrigger`: `double` — Setter updates `Start` if `Start < PreTrigger`.
|
||||
- `PostTrigger`: `double` — Setter updates `End` if `End > PostTrigger`.
|
||||
- `IsEnabled`: `bool` — Default `true`.
|
||||
- `IsDefault`: `bool` — Read-only; set only via constructor.
|
||||
- **Events**
|
||||
- `PropertyChanged`: Implements `INotifyPropertyChanged` for UI binding.
|
||||
|
||||
### `TestTemplateList` (Class)
|
||||
- **Static Properties**
|
||||
- `TestTemplatesList`: Singleton instance (thread-safe via `lock`).
|
||||
- **Instance Properties**
|
||||
- `TemporaryTemplate`: `TestTemplate` — Holds a template in memory without DB persistence.
|
||||
- **Static Methods**
|
||||
- `GetSensorFromSettings(string settings, string serial, Dictionary<string, SensorData> lookup)`:
|
||||
Parses `settings` (comma-separated `key=value` pairs) to populate a `SensorData` object. Falls back to `SensorsCollection.SensorsList.GetSensorBySerialNumber(serial)` if `lookup` is `null` or missing `serial`. Returns `null` if `serial` is null/empty or no `SensorData` found.
|
||||
- `GetSensorFromSettings(string settings, string serial)`: Overload with `lookup=null`.
|
||||
- `GetSensorSettings(SensorData sd)`: Serializes `sd` into a comma-separated `key=value` string. Only includes settings with non-default values (e.g., omits `Delay` if `DelayMS` is `0`).
|
||||
- `SysBuiltObject(string serialNumber)`: Calls stored procedure `sp_TestObjectsGet` to determine if `serialNumber` corresponds to a system-built test object. Returns `bool`.
|
||||
- `ConvertToDictionary(DataTable dt, ref Dictionary<string, List<Dictionary<string, object>>> lookup, string key)`: Populates `lookup` by grouping `dt` rows on `key`. Each row becomes a `Dictionary<string, object>` of column values.
|
||||
- **Instance Methods**
|
||||
- `Reload()`: Refreshes all related data collections (ISO DB, sensors, DAS hardware, etc.) and calls `Load()` (currently a no-op).
|
||||
- `DeleteAll()`: Executes stored procedure `sp_TestSetupsDeleteAll` to clear all test setups. Handles output parameters for error info (logging suppressed in source).
|
||||
|
||||
## 3. Invariants
|
||||
- **`RegionOfInterest`**:
|
||||
- `Start < End` always holds (enforced via setter clamping).
|
||||
- `Start ≥ PreTrigger` and `End ≤ PostTrigger` always hold (enforced via setter clamping and `PreTrigger`/`PostTrigger` setters).
|
||||
- `Suffix` is normalized to start with `_` if non-empty and non-whitespace.
|
||||
- **`TestTemplateLite`**:
|
||||
- `PreTriggerSeconds` is `0` for `Recorder`/`HybridRecorder` modes regardless of stored `_preTriggerSeconds`.
|
||||
- `CompletionErrorMessage` truncates `ErrorMessage` to 250 characters if longer.
|
||||
- **`HardwareInclusionInstruction`**:
|
||||
- `HardwareId` is never `null` or empty (enforced by constructor).
|
||||
- **`TestTemplateList`**:
|
||||
- `TestTemplatesList` is a singleton (lazy-initialized under lock).
|
||||
- `GetSensorFromSettings` returns `null` if `serial` is null/empty or no matching sensor exists.
|
||||
|
||||
## 4. Dependencies
|
||||
### Internal Dependencies
|
||||
- **`DatabaseImport` namespace**: All types are internal to this module.
|
||||
- **`ISO.TestObject.SensorSettings`**: Used in `GetSensorFromSettings`/`GetSensorSettings` (enum values drive parsing/serialization).
|
||||
- **`SensorData`**: Core data type for sensor configuration (used in `GetSensorFromSettings`, `GetSensorSettings`).
|
||||
- **`DASHardware`, `IISOHardware`**: Referenced in `ICachedContainer` (concrete types not defined in provided sources).
|
||||
- **`RecordingModes`**: Enum used in `TestTemplateLite.PreTriggerSeconds` (concrete definition not provided).
|
||||
- **`DigitalOutputModes`, `SquibFireMode`, `DigitalInputModes`**: Referenced in `GetSensorFromSettings` (enum definitions not provided).
|
||||
- **Database Abstraction**:
|
||||
- `DbOperations`, `DbOperationsEnum.StoredProcedure`, `SqlDbType`, `CommandType`, `SqlParameter`, `DataRow`, `DataTable` (from `System.Data`).
|
||||
- Stored procedures: `sp_TestObjectsGet`, `sp_TestSetupsDeleteAll`.
|
||||
- **UI Framework**: `Application.Current` (WPF `App` type) in `Reload()`.
|
||||
- **Singleton Collections**: `SensorsCollection.SensorsList`, `CustomChannelList.List`, `SensorCalibrationList`, `DASHardwareList`, `TestEngineerDetailsList.TestEngineerList`, `TestObjectTemplateCollection.TemplateCollection`, `TestObjectList.TestObjectsList` (referenced in `Reload()`).
|
||||
|
||||
### External Dependencies
|
||||
- `System`, `System.ComponentModel`, `System.Data`, `System.Data.SqlClient`, `System.Linq`, `System.Text`, `System.Windows` (WPF).
|
||||
|
||||
## 5. Gotchas
|
||||
- **`PreTriggerSeconds` behavior**: For `Recorder`/`HybridRecorder` modes, `PreTriggerSeconds` always returns `0`, ignoring the stored `_preTriggerSeconds` value. This may cause confusion if persisted/serialized values are expected to be preserved.
|
||||
- **`Suffix` normalization**: Non-empty suffixes are auto-prefixed with `_` (e.g., `"foo"` → `"_foo"`). Empty/whitespace suffixes remain unchanged.
|
||||
- **`GetSensorFromSettings` fallback**: If `lookup` is provided but lacks `serial`, it falls back to `SensorsCollection.SensorsList.GetSensorBySerialNumber(serial)`. This dual-source lookup may mask missing data in `lookup`.
|
||||
- **`GetSensorSettings` omits default values**: Settings with default/zero values (e.g., `DelayMS=0`) are excluded from the serialized string. This may cause deserialization to use defaults instead of explicit values if the caller expects all settings to be present.
|
||||
- **`SysBuiltObject` return value**: Returns `false` if the stored procedure returns no rows, but does not distinguish between "not found" and "error occurred" (error handling logs are suppressed).
|
||||
- **`DeleteAll` error handling**: Output parameters (`@ErrorSeverity`, `@ErrorState`, `@ErrorMessage`) are captured but not logged or propagated (commented-out logging suggests intentional suppression).
|
||||
- **`TestTemplateLite` is incomplete**: The class is explicitly labeled a "lightweight" version and omits many fields of a full `TestTemplate`. Its `IsComplete` flag may not reflect full validation state.
|
||||
- **`RegionOfInterest` clamping is cascading**: Setting `PreTrigger` may trigger `Start` updates (via `Start = PreTrigger`), and setting `Start` may trigger `End` updates (via `End = Start + 0.01`). This can cause unexpected side effects in UI bindings.
|
||||
- **No documentation for `TestTemplate`**: `TemporaryTemplate` is typed as `TestTemplate`, but this class is not defined in the provided sources. Its structure and relationship to `TestTemplateLite` are unclear.
|
||||
@@ -0,0 +1,115 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Controls/SensorsAndModels/ImportSensorsImportControl.cs
|
||||
generated_at: "2026-04-16T04:33:13.762411+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f5ef3c2722125dc9"
|
||||
---
|
||||
|
||||
# SensorsAndModels
|
||||
|
||||
## Documentation: `ImportSensorsImportControl` Module
|
||||
|
||||
---
|
||||
|
||||
### 1. **Purpose**
|
||||
|
||||
This module provides utility functions for resetting or clearing large swaths of persistent application state—both in-memory collections and database records—prior to importing sensor and model data from an external source (e.g., a TDM export or database import). Its primary role is to ensure a clean state before data ingestion by deleting all non-essential data, including test templates, test objects, sensors, calibrations, users, UI items, tags, and legacy database versions. It is used exclusively during import workflows and is tightly coupled with database operations and legacy data structures.
|
||||
|
||||
---
|
||||
|
||||
### 2. **Public Interface**
|
||||
|
||||
#### `public static void ClearAllTables(bool clearForDbImport)`
|
||||
|
||||
- **Behavior**: Clears all in-memory collections (via `DeleteAll()` calls on static list/collection types) and, if `clearForDbImport` is `true`, also clears corresponding database tables and related entities.
|
||||
- **In-memory deletions include**:
|
||||
- `TestTemplateList.TestTemplatesList`
|
||||
- `TestObjectList.AddedGroupsList`
|
||||
- `TestObjectList.TestObjectsList` *(deleted twice per comment)*
|
||||
- `CustomChannelList.List`
|
||||
- `SensorsCollection.SensorsList`
|
||||
- `SensorModelCollection.SensorModelList`
|
||||
- `SensorCalibrationList`
|
||||
- `CustomerDetailsList`
|
||||
- `LabratoryDetailsList`
|
||||
- `TestEngineerDetailsList`
|
||||
- **Database deletions (only if `clearForDbImport == true`)**:
|
||||
- Non-prototype DAS tables via `DTS.Common.Storage.DbOperations.ClearNonPrototypeDas()`
|
||||
- `LockedItems` table
|
||||
- All users (via stored procedure `sp_UserDelete`)
|
||||
- All UI items (via `sp_UIItemsDelete`)
|
||||
- All tags (via `sp_TagsDelete`)
|
||||
- All database versions older than `DbOperations.CURRENT_DB_VERSION` (via `sp_DbVersionDelete`)
|
||||
|
||||
---
|
||||
|
||||
### 3. **Invariants**
|
||||
|
||||
- **Ordering**: The in-memory `DeleteAll()` calls must precede database operations to avoid stale references or orphaned data in memory.
|
||||
- **Dependency on `clearForDbImport`**: If `false`, *no database operations* are performed. All database-clearing logic is guarded by this flag.
|
||||
- **Assumption about prior state**:
|
||||
- `ClearAllUsers()` must be called before `ClearAllUIItems()` because UI items depend on user metadata (per comment: *"We're assuming that all of the UIItemSettings and Users are already deleted"*).
|
||||
- Similarly, `ClearAllUsers()` is assumed to delete `TagAssignments` before `ClearAllTags()` runs.
|
||||
- **Versioning invariant**: Only database versions `< DbOperations.CURRENT_DB_VERSION` are deleted; the current version and newer versions are preserved.
|
||||
|
||||
---
|
||||
|
||||
### 4. **Dependencies**
|
||||
|
||||
#### **Internal Dependencies**
|
||||
- Static collections:
|
||||
- `TestTemplateList.TestTemplatesList`
|
||||
- `TestObjectList.AddedGroupsList`, `TestObjectList.TestObjectsList`
|
||||
- `CustomChannelList.List`
|
||||
- `SensorsCollection.SensorsList`
|
||||
- `SensorModelCollection.SensorModelList`
|
||||
- `SensorCalibrationList`
|
||||
- `CustomerDetailsList`, `LabratoryDetailsList`, `TestEngineerDetailsList`
|
||||
- `DTS.Common.Storage.DbOperations` (for `ClearNonPrototypeDas()`)
|
||||
- `DbOperations` class (for SQL command generation, connection handling, and stored procedure names)
|
||||
- `DbOperationsEnum.StoredProcedure` enum (used to resolve stored procedure names like `sp_UserDelete`, `sp_UIItemsGet`, etc.)
|
||||
- `Tags.Tag` class (used to parse rows from `sp_TagsGet`)
|
||||
- `DbOperations.Users`, `DbOperations.Users.UserFields`, `DbOperations.Users.UIItemFields`, `DbOperations.DbVersions`, `DbOperations.DbVersions.DbVersionFields` (static field/enum types for column access)
|
||||
|
||||
#### **External Dependencies**
|
||||
- `System.Data.SqlClient` (for `SqlCommand`, `SqlParameter`, `SqlDbType`, etc.)
|
||||
- `System.Data` (for `DataSet`, `DataRow`, `CommandType`)
|
||||
- WPF `UserControl` base class (though `ImportSensorsImportControl` is a UI control, this module’s public method is static and does not rely on UI state)
|
||||
|
||||
#### **Dependents**
|
||||
- Likely invoked by higher-level import logic (e.g., `DatabaseImporter` or `DataImportViewModel`) before populating the cleared state with new data.
|
||||
|
||||
---
|
||||
|
||||
### 5. **Gotchas**
|
||||
|
||||
- **Double deletion of `TestObjectsList`**:
|
||||
`TestObjectList.TestObjectsList.DeleteAll()` is called twice with a comment indicating “we keep two copies of the list around”—a strong signal of legacy duplication or refactoring debt.
|
||||
|
||||
- **Stored procedure usage is environment-specific**:
|
||||
Comments explicitly state that `sp_UserDelete` and `sp_UserGet` are *only used in `DataPROPre20.mdf`*, not `DataPRO.mdf`. This implies the module may behave incorrectly or throw if run against newer database schemas.
|
||||
|
||||
- **Error handling is silent**:
|
||||
In `ClearAllUsers()`, `ClearAllUIItems()`, `ClearAllTags()`, and `ClearAllExceptCurrentDbVersion()`, errors returned via `@errorNumber` are *not logged or propagated*—only commented out (`//errorMessageParam.Value`). This could mask failures during deletion.
|
||||
|
||||
- **Assumption of deletion order**:
|
||||
`ClearAllUsers()` must run before `ClearAllUIItems()` and `ClearAllTags()` due to foreign key or logical dependencies, but this ordering is *not enforced programmatically*—it relies on caller discipline.
|
||||
|
||||
- **`GetAllUIItemIds()` uses `DbOperations.Users.UIItemFields.ID`**:
|
||||
This suggests a possible naming inconsistency or reuse of user-related field enums for UI items, which could be confusing.
|
||||
|
||||
- **`GetAllUsers()` returns all columns as `string[]`**:
|
||||
The method returns raw string arrays with fixed column order (id, username, etc.), making it fragile to schema changes. No type safety or schema validation is applied.
|
||||
|
||||
- **Resource disposal pattern is manual**:
|
||||
All `SqlCommand` objects use `try/finally` to dispose connections manually. While correct, this is error-prone and could be replaced with `using` blocks for clarity and safety.
|
||||
|
||||
- **No transactional safety**:
|
||||
Database deletions are executed in separate commands without an explicit transaction. A failure mid-way (e.g., after deleting users but before deleting tags) could leave the database in a partially cleared state.
|
||||
|
||||
- **`ClearAllExceptCurrentDbVersion()` deletes *older* versions only**:
|
||||
The logic skips versions `>= CURRENT_DB_VERSION`, but does *not* delete newer versions (e.g., if `CURRENT_DB_VERSION` is updated post-deployment). This may be intentional for forward compatibility, but could lead to stale schema data if not managed carefully.
|
||||
|
||||
---
|
||||
@@ -0,0 +1,129 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Controls/TestSetups/ImportTestSetup.cs
|
||||
generated_at: "2026-04-16T04:33:34.717126+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "c54de3e2daf5d6b9"
|
||||
---
|
||||
|
||||
# TestSetups
|
||||
|
||||
### **Purpose**
|
||||
The `ImportTestSetup` class is a WPF `UserControl` responsible for parsing and importing structured XML data representing test setup configurations (including sensors, calibrations, hardware, groups, and custom MME metadata) into the system’s database via stored procedures. It acts as the core ingestion layer for legacy or exported test setup files, supporting versioned import logic (v1.0 and v2.0) and maintaining in-memory collections of imported entities prior to database persistence. Its role is to translate XML fragments into domain objects and orchestrate their bulk insertion into the database while preserving data integrity and handling version-specific transformations.
|
||||
|
||||
---
|
||||
|
||||
### **Public Interface**
|
||||
|
||||
#### **Static Fields (Publicly Exposed Collections)**
|
||||
These collections hold imported data *before* it is persisted to the database. They are populated during XML processing and cleared by `Cleanup()`.
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `Directions` | `List<MMEDirections>` | Custom MME direction definitions imported from XML. |
|
||||
| `FilterClasses` | `List<MMEFilterClasses>` | Custom MME filter class definitions. |
|
||||
| `FineLoc1s` | `List<MMEFineLocations1>` | First-level fine location definitions. |
|
||||
| `FineLoc2s` | `List<MMEFineLocations2>` | Second-level fine location definitions. |
|
||||
| `FineLoc3s` | `List<MMEFineLocations3>` | Third-level fine location definitions. |
|
||||
| `MainLocs` | `List<MMETransducerMainLocation>` | Transducer main location definitions. |
|
||||
| `TestObjects` | `List<MMETestObjects>` | Custom test object definitions. |
|
||||
| `PhysicalDimensions` | `List<MMEPhysicalDimensions>` | Physical dimension definitions. |
|
||||
| `Positions` | `List<MMEPositions>` | Position definitions. |
|
||||
| `Calibrations` | `List<SensorCalibration>` | Sensor calibration history records. |
|
||||
| `CustomerDetails` | `List<ISO.CustomerDetails>` | Customer metadata imported from XML. |
|
||||
| `LabDetails` | `List<ISO.LabratoryDetails>` | Laboratory metadata imported from XML. |
|
||||
| `Sensors` | `List<SensorData>` | Sensor definitions (note: declared `public static readonly`, but no direct population logic visible in this file—likely populated via `ImportElement` → stored procedure). |
|
||||
| `_testSetups` | `List<TestTemplate>` | Test setup templates (note: declared `public static`, not `readonly`). |
|
||||
| `_sensorsWithDuplicateIds` | `List<SensorData>` | Internal tracking for sensors with duplicate IDs (not exposed publicly). |
|
||||
|
||||
#### **Static Methods**
|
||||
|
||||
| Method | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `ProcessRootNode` | `public static void ProcessRootNode(string name, string outerXML, DbImporter.SetStatusDelegate SetStatus)` | Dispatches XML fragment processing based on `name` (e.g., `"SensorData"`, `"TestSetup"`). Maps element names to corresponding stored procedures and invokes `ImportElement`. Does *not* handle `DbVersion` or `SensorCalibration` directly—those have dedicated logic elsewhere (see `ImportCalibrations`). |
|
||||
| `ImportElement` | `private static void ImportElement(string storedProcedure, string storedProcedureParameter, string outerElementName, string outerXML)` | Wraps `outerXML` in `<outerElementName>...</outerElementName>`, executes the specified stored procedure with the XML as an `@parameter`, and captures output error info. Throws on failure. Does *not* log or handle errors beyond re-throwing. |
|
||||
| `GetTestSetupName` | `private static string GetTestSetupName(string outerXML)` | Extracts `SetupName` from `<TestSetup/Fields/SetupName>` in `outerXML` using `XmlDocument`. Returns `null` if not found. |
|
||||
| `Cleanup` | `private static void Cleanup()` | Clears *all* static collections listed above (including `_sensorsWithDuplicateIds`, `_globalSettings`, `_customChannels`, etc.). Resets state for a new import session. |
|
||||
|
||||
#### **Nested Types (Referenced)**
|
||||
- `PossibleStatus` enum: Defines UI states (`Waiting`, `Working`, `Done`, `Failed`).
|
||||
- `DbOperationsEnum.StoredProcedure`: Used to resolve stored procedure names (e.g., `sp_DBImportSensors`).
|
||||
- `SensorCalibration`, `SensorData`, `TestTemplate`, `DASHardware`, `User`, `TestObject`, etc.: Domain types imported via XML or stored procedures.
|
||||
|
||||
> **Note**: `ProcessRootNode` does *not* handle `SensorCalibration` or `DbVersion`—those are processed separately (implied by `ImportCalibrations` method and `_importedVersion` usage). `DbVersion` is imported via `ImportElement`, but `_importedVersion` is set elsewhere (not shown here).
|
||||
|
||||
---
|
||||
|
||||
### **Invariants**
|
||||
|
||||
1. **XML Structure**:
|
||||
- `outerXML` passed to `ProcessRootNode` must be a well-formed XML fragment corresponding to the expected schema for the given `name` (e.g., `<SensorData>...</SensorData>`).
|
||||
- `GetTestSetupName` assumes `outerXML` contains a `<TestSetup>` root with a `<Fields>` child containing `<SetupName>`.
|
||||
|
||||
2. **Version Handling**:
|
||||
- `_importedVersion` (private) must be set *before* `ImportCalibrations` is called (not shown in this file).
|
||||
- Calibration import logic diverges based on `_importedVersion == 1.0D` or `2.0D`. Version 1.0 applies transformations (e.g., setting `SensitivityUnits`, `AtCapacity = false`).
|
||||
|
||||
3. **Database Interaction**:
|
||||
- All `ImportElement` calls use stored procedures with XML parameters.
|
||||
- Stored procedure output parameters `@errorNumber` and `@errorMessage` are captured but only checked for non-zero `@errorNumber`; error messages are *not* propagated or logged in this method.
|
||||
- Command timeout is fixed at 60 seconds.
|
||||
|
||||
4. **State Management**:
|
||||
- `Cleanup()` must be called before a new import to reset all static collections.
|
||||
- `_sensorsWithDuplicateIds` is populated elsewhere (not visible here) but is cleared on `Cleanup()`.
|
||||
|
||||
---
|
||||
|
||||
### **Dependencies**
|
||||
|
||||
#### **Internal Dependencies**
|
||||
- **Types**:
|
||||
- `DbOperations` (provides `GetSQLCommand` and `SetStatusDelegate`).
|
||||
- `DbOperationsEnum.StoredProcedure` (for stored procedure names).
|
||||
- `ISO.CustomerDetails`, `ISO.LabratoryDetails`, `SensorCalibration`, `SensorData`, `TestTemplate`, `DASHardware`, `User`, `TestObject`, `MME*` types (e.g., `MMEDirections`, `MMEPossibleChannels`).
|
||||
- `Test.Module.Channel.Sensor.SensUnits` (used in `ImportCalibrations` for v1.0 transformations).
|
||||
- **XAML**: `ImportTestSetup.xaml` (interaction logic partial class).
|
||||
|
||||
#### **External Dependencies**
|
||||
- **.NET Framework**: `System.Data`, `System.Data.SqlClient`, `System.Xml`, `System.Windows.Controls`.
|
||||
- **Database**: SQL Server (via stored procedures named `sp_DBImport*`).
|
||||
- **Calling Code**: `DbImporter.SetStatusDelegate` (likely from `DbImporter` class) for status reporting.
|
||||
|
||||
#### **Depended Upon**
|
||||
- Likely invoked by `DbImporter` (or similar orchestrator) during XML parsing of an import file.
|
||||
- Public static fields are consumed by downstream logic (e.g., UI binding, final commit to DB).
|
||||
|
||||
---
|
||||
|
||||
### **Gotchas**
|
||||
|
||||
1. **Static State Management**:
|
||||
- All data is held in *static* collections. This makes the class **not thread-safe** and unsuitable for concurrent imports without external synchronization.
|
||||
- `Cleanup()` must be called explicitly before each import; otherwise, stale data persists across sessions.
|
||||
|
||||
2. **Incomplete Error Handling**:
|
||||
- `ImportElement` captures `@errorNumber` and `@errorMessage` but *does nothing* with them (commented-out error handling block). Errors are silently ignored unless an exception is thrown.
|
||||
- `ProcessRootNode` does *not* handle `SensorCalibration` or `DbVersion`—these require separate processing logic (implied by `ImportCalibrations` and `_importedVersion` usage), which is not visible here.
|
||||
|
||||
3. **Version-Specific Logic Fragility**:
|
||||
- Calibration import for v1.0 assumes exactly one calibration record (`sc.Records.Records[0]`). If the schema changes, this will throw `IndexOutOfRangeException`.
|
||||
- `_importedVersion` is set elsewhere (not in this file), creating a hidden dependency.
|
||||
|
||||
4. **XML Parsing Assumptions**:
|
||||
- `GetTestSetupName` uses `SelectSingleNode` without null-checking beyond the null-conditional operator. If `SetupName` is missing, it returns `null`—callers must handle this.
|
||||
- `outerXML` is naively wrapped in `<outerElementName>...</outerElementName>`. If `outerXML` already contains a root element, this produces invalid XML.
|
||||
|
||||
5. **Naming Inconsistencies**:
|
||||
- `LabDetails` uses `LabratoryDetails` (misspelled) in the type name (`ISO.LabratoryDetails`).
|
||||
- `_testSetups` is `public static List<TestTemplate>`, while other collections (e.g., `Calibrations`) are `readonly`. This suggests `_testSetups` may be reassigned elsewhere.
|
||||
|
||||
6. **No Version Validation**:
|
||||
- No explicit check ensures `_importedVersion` matches `CurrentVersion` (2.0). Mismatched versions may cause silent data loss or corruption.
|
||||
|
||||
7. **Unused/Commented Code**:
|
||||
- `ProcessRootNode` contains commented-out `CancelCheck` calls and `page` parameters, suggesting legacy cancellation UI support that is no longer active.
|
||||
- The `//Store the compressed binary copy...` comment in the `"TestSetup"` case indicates incomplete or deprecated functionality.
|
||||
|
||||
> **None identified from source alone** for thread-safety, serialization, or external API contracts—these require examining `DbImporter` and related types.
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Converters/EnumDescriptionTypeConverter.cs
|
||||
generated_at: "2026-04-16T04:29:54.553980+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "60faab8710c59a2c"
|
||||
---
|
||||
|
||||
# Converters
|
||||
|
||||
## Documentation: `EnumDescriptionTypeConverter`
|
||||
|
||||
### 1. Purpose
|
||||
This module provides a custom type converter for .NET enums that enables WPF data binding to display human-readable descriptions (via `DescriptionAttribute`) instead of the raw enum names or underlying values. It extends `System.ComponentModel.EnumConverter` to support scenarios where enum members are decorated with `[Description("...")]`, allowing UI frameworks like WPF to render meaningful labels (e.g., "Active User" instead of `ActiveUser`) during data binding operations. Its role is to bridge the gap between enum definitions and user-facing text in UI contexts.
|
||||
|
||||
### 2. Public Interface
|
||||
- **`EnumDescriptionTypeConverter(Type type)`**
|
||||
*Constructor.* Initializes a new instance of `EnumDescriptionTypeConverter` for the specified `enum` type.
|
||||
- **Parameters:**
|
||||
- `type`: The `Type` of the enum to convert (must be an enum type).
|
||||
- **Behavior:** Delegates to the base `EnumConverter` constructor. No additional logic is implemented in this class beyond inheritance.
|
||||
|
||||
### 3. Invariants
|
||||
- The `type` parameter passed to the constructor **must** be an enum type (i.e., `Type.IsEnum == true`); otherwise, the base `EnumConverter` constructor will throw an `ArgumentException`.
|
||||
- The converter does **not** validate or modify the enum type itself—it relies on the base `EnumConverter`’s behavior for parsing and formatting.
|
||||
- No runtime validation of `[DescriptionAttribute]` presence is performed; missing attributes fall back to the enum member’s name (handled by the base class).
|
||||
|
||||
### 4. Dependencies
|
||||
- **Depends on:**
|
||||
- `System.ComponentModel.EnumConverter` (base class).
|
||||
- `System.DescriptionAttribute` (implicitly, via the base class’s expected usage pattern—though not explicitly referenced in this file).
|
||||
- **Used by:**
|
||||
- WPF data binding infrastructure (e.g., via `TypeConverterAttribute` applied to enum types or properties).
|
||||
- Likely referenced by other modules in `DatabaseImport` namespace that bind enums to UI controls (e.g., comboboxes, labels).
|
||||
|
||||
### 5. Gotchas
|
||||
- **No custom logic implemented:** Despite the class name and summary comment, this implementation **does not override** `ConvertTo`/`ConvertFrom` methods. As written, it behaves identically to `EnumConverter` and will **not** automatically use `[DescriptionAttribute]` values. To achieve the described behavior, overrides for `ConvertTo` (and possibly `ConvertFrom`) are required but absent in the source.
|
||||
- **Documentation mismatch:** The referenced blog post (`http://brianlagunas.com/...`) likely contains the intended implementation pattern, but the current code is incomplete.
|
||||
- **Common mistake:** Developers may assume this converter enables `DescriptionAttribute` support out-of-the-box, leading to incorrect expectations about UI rendering.
|
||||
- **None identified from source alone** regarding other behaviors, but the lack of overrides is a critical gap.
|
||||
@@ -0,0 +1,130 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/DASConcepts/Test.Module.Channel.Sensor.SensorUnits.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/DASConcepts/Test.Module.Channel.Sensor.Bridge.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/DASConcepts/DigitalInputScaleMultiplier.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/DASConcepts/LinearizationFormula.cs
|
||||
generated_at: "2026-04-16T04:29:46.893362+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "50ada406a17a3727"
|
||||
---
|
||||
|
||||
# Documentation: Sensor & Linearization Concepts Module
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module defines core data structures and enumerations used to represent sensor configuration and signal linearization behavior within the DatabaseImporter subsystem of the DTS DataPRO system. It provides strongly-typed representations of sensor sensitivity units (`SensUnits`), bridge configurations (`BridgeType`), digital input scaling (`DigitalInputScaleMultiplier`), and various linearization formulae (`LinearizationFormula`)—all derived from legacy database serialization formats. These constructs enable consistent interpretation and persistence of sensor metadata during database import operations, bridging historical DTS-specific formats with modern .NET type safety.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `Test.Module.Channel.Sensor.SensUnits` (enum)
|
||||
|
||||
- **Definition**: `public enum SensUnits`
|
||||
- **Values**:
|
||||
- `NONE = 0` → Polynomial sensor with no sensitivity units.
|
||||
- `mV = 1` → Sensitivity in millivolts at full-scale (Capacity EU).
|
||||
- `mVperV = 2` → Excitation-proportional sensitivity in mV/V at full-scale.
|
||||
- `mVperVperEU = 3` → Excitation-proportional sensitivity per engineering unit (mV/V/EU).
|
||||
- `mVperEU = 4` → Sensitivity in mV per engineering unit.
|
||||
- **Behavior**: Encodes the unit type for sensor sensitivity; used to interpret sensitivity values in configuration.
|
||||
|
||||
### `Test.Module.Channel.Sensor.BridgeType` (enum)
|
||||
|
||||
- **Definition**: `public enum BridgeType`
|
||||
- **Values** (bitmask flags):
|
||||
- `IEPE = 1 << 0` → IEPE (Integrated Electronics Piezo Electric) sensor setup.
|
||||
- `QuarterBridge = 1 << 1` → Quarter-bridge configuration.
|
||||
- `HalfBridge = 1 << 2` → Half-bridge configuration.
|
||||
- `FullBridge = 1 << 3` → Full-bridge configuration.
|
||||
- `DigitalInput = 1 << 4` → Digital input mode.
|
||||
- `SQUIB = 1 << 5` → Squib (pyrotechnic) output setup.
|
||||
- `TOMDigital = 1 << 6` → TOM (Test Output Module) digital output.
|
||||
- `HalfBridge_SigPlus = 1 << 7` → G5 half-bridge with signal-plus wiring.
|
||||
- **Behavior**: Represents physical bridge/wiring topology; supports bitwise combinations.
|
||||
|
||||
### `DigitalInputScaleMultiplier` (class)
|
||||
|
||||
- **Definition**: `public class DigitalInputScaleMultiplier`
|
||||
- **Properties**:
|
||||
- `Form`: `Forms` enum; currently only `ArbitraryLowAndHigh` supported.
|
||||
- `DefaultValue`: `double`; value displayed when digital input = 0 (OFF).
|
||||
- `ActiveValue`: `double`; value displayed when digital input = 1 (ON); defaults to `1.0`.
|
||||
- **Constructors**:
|
||||
- `DigitalInputScaleMultiplier()` → Initializes `DefaultValue = 0.0`.
|
||||
- `DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)` → Copy constructor.
|
||||
- **Methods**:
|
||||
- `void FromDbSerializeString(string s)` → Parses serialized string (e.g., `"ArbitraryLowAndHigh,0.0,5.0"`) into object state.
|
||||
- Throws `NotSupportedException` on malformed input or unsupported format.
|
||||
- Uses `InvariantCulture` for numeric parsing.
|
||||
|
||||
### `LinearizationFormula` (class)
|
||||
|
||||
- **Definition**: `public class LinearizationFormula`
|
||||
- **Properties**:
|
||||
- `NonLinearStyle`: `NonLinearStyles` (not defined in provided files; inferred from usage).
|
||||
- `PolynomialSensitivity`: `double`; sensitivity for polynomial models.
|
||||
- `LinearizationExponent`: `double`; exponent in power-law models.
|
||||
- `MMPerV`: `double`; millimeters per volt (note: comment indicates variable name is inaccurate).
|
||||
- `MVAt0MM`: `double`; millivolts at zero millimeters.
|
||||
- `Slope`, `Intercept`: `double`; linear model parameters.
|
||||
- `CalibrationFactor`: `double`; calibration coefficient.
|
||||
- `ZeroPositionIntercept`: `double`; intercept at zero position.
|
||||
- `UsemVOverVForPolys`: `bool`; flag for polynomial unit preference (default `true`).
|
||||
- **Constructors**:
|
||||
- `LinearizationFormula()` → Initializes default state (e.g., `_coefficients = [0,0,0,0]`, `_exponents = [0,1,2,3]`).
|
||||
- `LinearizationFormula(LinearizationFormula copy)` → Copy constructor.
|
||||
- **Methods**:
|
||||
- `void MarkValid(bool bValid)` → Sets internal `_bIsValid` flag (no getter exposed).
|
||||
- `void FromSerializeString(string s, CultureInfo culture)` → Parses serialized format: `<Style>_<params>`.
|
||||
- Supports styles: `IRTraccDiagnosticsZero`, `IRTraccManual`, `IRTraccZeroMMmV`, `Polynomial`, `IRTraccAverageOverTime`, `IRTraccCalFactor`.
|
||||
- Throws `NotSupportedException` for unknown styles or malformed data.
|
||||
- `void FromSerializeString(string s)` → Overload using `InvariantCulture`.
|
||||
- Private helper methods (called by `FromSerializeString`):
|
||||
- `FromIRTraccCalFactorString`, `FromIRTraccDiagnosticZeroString`, `FromIRTraccManualString`, `FromIRTraccAverageOverTimeString`, `FromIRTraccZeroMMmVString`, `FromPolynomialString`
|
||||
→ Parse style-specific parameter strings (e.g., `"Slope x Exponent x Intercept"`).
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **`SensUnits`**:
|
||||
- Values are mutually exclusive and non-overlapping (no bitwise combinations).
|
||||
- `NONE` (0) is reserved for polynomial sensors lacking sensitivity units.
|
||||
|
||||
- **`BridgeType`**:
|
||||
- Values are bitmask flags; multiple types may be combined via bitwise OR.
|
||||
- Only one physical bridge type (e.g., `QuarterBridge`, `HalfBridge`, `FullBridge`) should be active per sensor, though combinations like `DigitalInput | TOMDigital` may be valid.
|
||||
|
||||
- **`DigitalInputScaleMultiplier`**:
|
||||
- `Form` must be `ArbitraryLowAndHigh`; no other forms are implemented.
|
||||
- `DefaultValue` and `ActiveValue` must be parseable as `double`; invalid values throw `NotSupportedException`.
|
||||
|
||||
- **`LinearizationFormula`**:
|
||||
- `_bIsValid` is set only by `FromSerializeString` (via `MarkValid` internally); no public validation method exists.
|
||||
- `FromSerializeString` expects format `<Style>_<param_string>`; parsing fails if tokens are missing or malformed.
|
||||
- Polynomial parsing (`FromPolynomialString`) has ambiguous behavior: if a token lacks `'x'`, it may be interpreted as a special key (`"S"` or `"mV"`) instead of coefficient/exponent.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
- **Internal Dependencies**:
|
||||
- Relies on `Test.Module.Channel.Sensor` being defined elsewhere (via `partial class` and `//*** see ... ***` comments).
|
||||
- `NonLinearStyles` enum is referenced but not defined in provided files; must be declared in another file (likely `DASConcepts/NonLinearStyles.cs`).
|
||||
- Uses `System.ComponentModel.DescriptionAttribute` for enum metadata (not used in logic, likely for UI).
|
||||
|
||||
- **External Dependencies**:
|
||||
- `System` (core types, `CultureInfo`, `double`, `List<T>`, `string`).
|
||||
- `System.Globalization` (`InvariantCulture`, `NumberStyles`).
|
||||
|
||||
- **Depended Upon By**:
|
||||
- Database import logic (e.g., parsing sensor configuration from legacy DB strings).
|
||||
- UI components (via `DescriptionAttribute` for display names).
|
||||
- Serialization/deserialization layers for sensor metadata.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`MMPerV` naming is misleading**: Comment explicitly states *"THIS IS MM/V, (UI has already been updated, we need to update the variable name)"*—the variable name does not match its meaning (millimeters per volt, not millivolts per volt).
|
||||
- **`_bIsValid` is internal-only**: No public `IsValid()` method is exposed despite the private `_bIsValid` field and commented-out `IsValid()` method.
|
||||
- **Polynomial parsing ambiguity**: In `FromPolynomialString`, tokens without `'x'` are treated as special keys (`"S"`/`"mV"`), but tokens with `'x'` but only one part (e.g., `"2"`) fall through to `PolynomialSensitivity` assignment—this may cause silent misinterpretation.
|
||||
- **`DigitalInputScaleMultiplier` ignores null/empty input**: `FromDbSerializeString(null)` returns silently (with comment `//FIXME is this the right thing to do?`), potentially masking errors.
|
||||
- **`BridgeType` values use bit shifts**: While designed for bitwise combination, the enum is not marked `[Flags]`, so tools may not display combined values intuitively.
|
||||
- **Culture sensitivity**: All numeric parsing uses `InvariantCulture`, but `FromDbSerializeString` in `DigitalInputScaleMultiplier` splits on `CultureInfo.InvariantCulture.TextInfo.ListSeparator` (typically `','`), which may conflict with decimal separators in some locales if not handled consistently upstream.
|
||||
- **No validation of polynomial coefficients/exponents**: `FromPolynomialString` does not enforce non-empty lists or valid exponents (e.g., negative exponents may be allowed).
|
||||
@@ -0,0 +1,188 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/DigitalInputs.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/DigitalOutputs.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/SupportedExportFormatBitFlags.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/Squibs.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/ExcitationVoltageOptions.cs
|
||||
generated_at: "2026-04-16T04:30:02.337162+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "004a8160296448d2"
|
||||
---
|
||||
|
||||
# Documentation: DatabaseImport Enumerations
|
||||
|
||||
## 1. Purpose
|
||||
This module defines core enumerations used throughout the `DatabaseImport` subsystem to represent configuration states and capabilities related to digital I/O, squib (pyrotechnic initiator) measurement/fire modes, and data export formats. These enums provide strongly-typed, self-documenting representations of hardware and software configuration parameters, enabling consistent interpretation of digital channel behavior, squib operation, and export target formats across the codebase.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `DigitalInputModes`
|
||||
*Defined in:* `DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/DigitalInputs.cs`
|
||||
*Attributes:* `[TypeConverter(typeof(EnumDescriptionTypeConverter))]`
|
||||
*Purpose:* Represents supported input modes for digital channels.
|
||||
|
||||
| Member | Value | Description |
|
||||
|--------|-------|-------------|
|
||||
| `TLH` | `1 << 1` (2) | Transition low to high |
|
||||
| `THL` | `1 << 2` (4) | Transition high to low |
|
||||
| `CCNO` | `1 << 3` (8) | Contact closure normally open |
|
||||
| `CCNC` | `1 << 4` (16) | Contact closure normally closed |
|
||||
|
||||
> **Note:** Values are powers of two, enabling bitwise combination.
|
||||
|
||||
---
|
||||
|
||||
### `DigitalOutputModes`
|
||||
*Defined in:* `DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/DigitalOutputs.cs`
|
||||
*Attributes:* `[TypeConverter(typeof(EnumDescriptionTypeConverter))]`
|
||||
*Purpose:* Represents supported output modes for digital channels.
|
||||
|
||||
| Member | Value | Description |
|
||||
|--------|-------|-------------|
|
||||
| `NONE` | `0` | Digital channel mode not set |
|
||||
| `FVLH` | `1 << 0` (1) | 5V, low-to-high transition |
|
||||
| `FVHL` | `1 << 1` (2) | 5V, high-to-low transition |
|
||||
| `CCNO` | `1 << 2` (4) | Contact closure normally open |
|
||||
| `CCNC` | `1 << 3` (8) | Contact closure normally closed |
|
||||
|
||||
> **Note:** Values are powers of two, enabling bitwise combination.
|
||||
|
||||
---
|
||||
|
||||
### `SupportedExportFormatBitFlags`
|
||||
*Defined in:* `DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/SupportedExportFormatBitFlags.cs`
|
||||
*Attributes:* `[Flags]`
|
||||
*Purpose:* Represents supported export file formats as bit flags.
|
||||
|
||||
| Member | Value | Description |
|
||||
|--------|-------|-------------|
|
||||
| `none` | `0x0` | No format selected |
|
||||
| `csvunfiltered` | `0x1` | Unfiltered CSV export |
|
||||
| `diademadc` | `0x2` | DIAdem ADC format |
|
||||
| `isounfiltered` | `0x4` | ISO unfiltered export |
|
||||
| `somatunfiltered` | `0x8` | Somat unfiltered export |
|
||||
| `tdmsadc` | `0x10` | TDMS ADC format |
|
||||
| `toyotaunfiltered` | `0x20` | Toyota unfiltered export |
|
||||
| `tsvunfiltered` | `0x40` | TSV unfiltered export |
|
||||
| `csvfiltered` | `0x80` | Filtered CSV export |
|
||||
| `isofiltered` | `0x200` | ISO filtered export |
|
||||
| `somatfiltered` | `0x400` | Somat filtered export |
|
||||
| `tdasadc` | `0x800` | TDAS ADC format |
|
||||
| `toyotafiltered` | `0x1000` | Toyota filtered export |
|
||||
| `tsvfiltered` | `0x2000` | TSV filtered export |
|
||||
| `rdfadc` | `0x4000` | RDF ADC format |
|
||||
| `ChryslerDDAS` | `0x8000` | Chrysler DDAS format |
|
||||
| `HDFUnfiltered` | `0x10000` | HDF unfiltered export |
|
||||
| `HDFFiltered` | `0x20000` | HDF filtered export |
|
||||
| `HDFMV` | `0x40000` | HDF MV format |
|
||||
| `HDFADC` | `0x80000` | HDF ADC format |
|
||||
| `xlsxfiltered` | `0x100000` | Excel (XLSX) filtered export |
|
||||
| `xlsxunfiltered` | `0x200000` | Excel (XLSX) unfiltered export |
|
||||
|
||||
> **Note:** One format (`diademfiltered = 0x100`) is commented out and currently unused.
|
||||
|
||||
---
|
||||
|
||||
### `SquibMeasurementType`
|
||||
*Defined in:* `DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/Squibs.cs`
|
||||
*Attributes:* `[TypeConverter(typeof(EnumDescriptionTypeConverter))]`
|
||||
*Purpose:* Specifies what squib-related signals are recorded during measurement.
|
||||
|
||||
| Member | Value | Description |
|
||||
|--------|-------|-------------|
|
||||
| `NONE` | `0` | Measurement mode not set |
|
||||
| `CURRENT` | `1 << 0` (1) | Squib current recorded |
|
||||
| `INIT_SIGNAL` | `1 << 1` (2) | Squib initiation indicator recorded |
|
||||
| `VOLTAGE` | `1 << 2` (4) | Squib voltage recorded |
|
||||
|
||||
> **Note:** Values are powers of two, enabling bitwise combination.
|
||||
|
||||
---
|
||||
|
||||
### `SquibFireMode`
|
||||
*Defined in:* `DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/Squibs.cs`
|
||||
*Attributes:* `[TypeConverter(typeof(EnumDescriptionTypeConverter))]`
|
||||
*Purpose:* Specifies the discharge method used to fire the squib.
|
||||
|
||||
| Member | Value | Description |
|
||||
|--------|-------|-------------|
|
||||
| `NONE` | `1 << 0` (1) | Fire mode not set |
|
||||
| `CAP` | `1 << 1` (2) | Capacitor discharge |
|
||||
| `CONSTANT` | `1 << 2` (4) | Constant current discharge |
|
||||
| `AC` | `1 << 3` (8) | AC discharge |
|
||||
|
||||
> **Note:** `NONE` is *not* zero-valued (value = 1), unlike typical patterns. This may be intentional to distinguish "unset" from "disabled".
|
||||
|
||||
---
|
||||
|
||||
### `ExcitationVoltageOptions`
|
||||
*Defined in:* `DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/ExcitationVoltageOptions.cs`
|
||||
*Purpose:* Defines available excitation voltage levels for sensors, with associated metadata.
|
||||
|
||||
#### Nested Type: `ExcitationVoltageOption`
|
||||
*Attributes:* `[TypeConverter(typeof(EnumDescriptionTypeConverter))]` (inferred from usage of `EnumDescriptionTypeConverter` elsewhere)
|
||||
|
||||
| Member | Value | Description | Voltage Magnitude |
|
||||
|--------|-------|-------------|-------------------|
|
||||
| `Undefined` | `1` | Undefined excitation voltage | `0.0` V |
|
||||
| `Volt2` | `2` | 2.0 V | `2.0` V |
|
||||
| `Volt2_5` | `4` | 2.5 V | `2.5` V |
|
||||
| `Volt3` | `8` | 3.0 V | `3.0` V |
|
||||
| `Volt5` | `16` | 5.0 V | `5.0` V |
|
||||
| `Volt10` | `32` | 10.0 V | `10.0` V |
|
||||
| `Volt1` | `64` | 1.0 V | `1.0` V |
|
||||
|
||||
#### Nested Type: `VoltageMagnitudeAttribute`
|
||||
*Purpose:* Custom attribute to associate a numeric voltage magnitude with enum members.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `Value` | `public double Value { get; }` | Returns the voltage magnitude (in volts) associated with the enum field. |
|
||||
| `VoltageMagnitudeAttribute(double value)` | `public VoltageMagnitudeAttribute(double value)` | Constructor. Stores the voltage magnitude. |
|
||||
|
||||
> **Note:** `VoltageMagnitudeAttribute` is defined *inside* `ExcitationVoltageOptions` class.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Bitwise Independence:** All enums except `SquibFireMode.NONE` and `ExcitationVoltageOption` use powers of two, enabling safe bitwise OR/AND operations for flag combinations.
|
||||
- **`DigitalInputModes` vs `DigitalOutputModes`:** Both share `CCNO` and `CCNC` names but have different underlying values (e.g., `CCNO` = 8 in inputs, 4 in outputs). They are *not* interchangeable.
|
||||
- **`SquibFireMode.NONE` ≠ 0:** Unlike `SquibMeasurementType.NONE`, `SquibFireMode.NONE` has value `1` (not `0`). This is likely intentional to distinguish "unset" from a valid fire mode.
|
||||
- **`VoltageMagnitudeAttribute.Value` is non-null:** Every `ExcitationVoltageOption` field decorated with `[VoltageMagnitude(...)]` has a corresponding `double` value.
|
||||
- **No overlapping values within an enum:** Each enum member has a unique underlying integer value (no duplicates within the same enum).
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This module depends on:
|
||||
- `System.ComponentModel` (for `[Description]` and `TypeConverter` infrastructure)
|
||||
- `System` (for `[Flags]`, `[AttributeUsage]`, `Attribute`, `double`)
|
||||
|
||||
### This module is depended upon by:
|
||||
- Other modules in `DatabaseImport` (inferred from namespace usage)
|
||||
- Likely used by:
|
||||
- Configuration parsers (e.g., reading from database or XML)
|
||||
- Export pipeline (to select output format via `SupportedExportFormatBitFlags`)
|
||||
- Hardware abstraction layer (to configure digital channels via `DigitalInputModes`/`DigitalOutputModes`)
|
||||
- Squib control logic (via `SquibMeasurementType`/`SquibFireMode`)
|
||||
- Sensor configuration (via `ExcitationVoltageOptions`)
|
||||
|
||||
> **Note:** `EnumDescriptionTypeConverter` is referenced but not defined in the provided files. Its implementation must exist elsewhere in the codebase.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`SquibFireMode.NONE` is non-zero (`1`)**: This breaks the common convention where "none" or "unset" is `0`. Code checking for unset mode must compare explicitly to `SquibFireMode.NONE`, not `0`.
|
||||
- **`DigitalInputModes` and `DigitalOutputModes` share names but not values**: `CCNO` and `CCNC` have different bit positions in each enum. Do not assume equivalence or reuse across input/output contexts.
|
||||
- **`diademfiltered` is commented out**: The value `0x100` is reserved but unused. Do not assume it is supported or safe to use.
|
||||
- **`ExcitationVoltageOption` values are powers of two, but not sequential**: Values are `1, 2, 4, 8, 16, 32, 64` — not contiguous. Avoid arithmetic assumptions (e.g., `Volt10` is not `Volt5 + 5`).
|
||||
- **`VoltageMagnitudeAttribute` is nested**: Its fully qualified name is `ExcitationVoltageOptions.VoltageMagnitudeAttribute`. Reflection or attribute lookup must account for nesting.
|
||||
- **No validation on enum combinations**: The enums support bitwise combination, but no runtime checks ensure logically invalid combinations (e.g., `TLH | THL` for a single digital input).
|
||||
- **Missing `diademfiltered` may cause confusion**: If legacy code references `0x100`, it may be unclear whether it was intended for `diademfiltered` or another format.
|
||||
|
||||
None identified beyond those above.
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/Hardware/HardwareTypes.cs
|
||||
generated_at: "2026-04-16T04:32:55.929056+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "38a6927cd83972ad"
|
||||
---
|
||||
|
||||
# Hardware
|
||||
|
||||
### 1. Purpose
|
||||
This module defines the `HardwareTypes` enumeration, which serves as a canonical type-safe identifier for supported hardware devices within the DatabaseImport subsystem. It enables unambiguous referencing and mapping of physical hardware units (e.g., SLICE variants, TOM, SIM, DIM, G5-series devices) during data import operations—likely when correlating raw sensor data or configuration files with specific hardware models in the database. Its role is foundational: it standardizes hardware type representation across the import pipeline, ensuring consistent interpretation of device metadata.
|
||||
|
||||
### 2. Public Interface
|
||||
The module exposes a single public type:
|
||||
|
||||
- **`HardwareTypes`** (`enum`)
|
||||
A strongly-typed enumeration of hardware device types used in the system. Each member is assigned an explicit integer value starting from `0`. The enum includes variants of SLICE hardware (e.g., `SLICE_Base`, `SLICE2_IEPE_Hi`, `SLICE6DB`), legacy/legacy-adjacent devices (`TDAS_Pro_Rack`, `TDAS_LabRack`), and specialized modules (`TOM`, `SIM`, `DIM`, `Ribeye`, `G5INDUMMY`, `SLICE_EthernetController`).
|
||||
*Note:* A commented-out entry `//G5IPORT=22` exists, indicating a planned or deprecated type.
|
||||
|
||||
### 3. Invariants
|
||||
- **Sequential integer values (mostly):** All explicitly defined enum members have unique, non-overlapping integer values. However, the sequence is *not strictly contiguous* due to the commented-out `G5IPORT=22`—the value `22` is unused, and the next entry (`G5INDUMMY`) is `23`.
|
||||
- **No negative values:** All enum values are ≥ 0.
|
||||
- **No runtime validation:** The enum itself enforces no semantic constraints (e.g., it does not prevent invalid combinations or enforce hardware-specific rules). Validation (if any) must occur elsewhere in the codebase.
|
||||
- **Stable identity:** The integer values are part of the public contract; changing them would break persistence (e.g., in database records or serialized configs).
|
||||
|
||||
### 4. Dependencies
|
||||
- **No external dependencies:** The file imports only the `System` namespace implicitly (via `namespace` declaration) and contains no `using` statements or external references.
|
||||
- **Consumers:** This enum is almost certainly referenced by other modules in the `DatabaseImport` namespace (e.g., classes handling hardware configuration parsing, database schema mapping, or device initialization). Based on naming conventions, consumers may include:
|
||||
- Hardware-specific importers (e.g., `SLICEImporter`, `TOMImporter`)
|
||||
- Database schema mappers (e.g., tables/columns storing `HardwareType` as an integer)
|
||||
- Configuration parsers (e.g., reading hardware type strings and mapping them to `HardwareTypes` enum values)
|
||||
*Exact consumers cannot be determined from this file alone.*
|
||||
|
||||
### 5. Gotchas
|
||||
- **Non-contiguous numbering:** The gap at value `22` (due to commented-out `G5IPORT`) may cause issues if downstream code assumes contiguous ranges (e.g., using `Enum.GetValues(typeof(HardwareTypes)).Length` for array sizing without filtering).
|
||||
- **Commented-out member:** `G5IPORT=22` is commented out but *not removed*, which could mislead developers into expecting support for this type. Its status (deprecated, planned, or obsolete) is unclear.
|
||||
- **No documentation on semantics:** The enum provides no XML comments or inline descriptions explaining what each hardware type *does* (e.g., "SLICE_Bridge" vs. "SLICE2_Bridge_Hi"). This forces reliance on external documentation or reverse engineering.
|
||||
- **Case sensitivity in string parsing:** If string-to-enum conversion is used (e.g., from config files), the enum is case-sensitive (standard C# behavior), and mismatches (e.g., `"slice_base"` vs. `"SLICE_Base"`) will fail unless explicitly handled.
|
||||
- **No `Flags` attribute:** The enum is *not* marked with `[Flags]`, implying bitwise combinations are not intended—though this is not enforced by the compiler.
|
||||
|
||||
*None identified beyond these.*
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/Sensors/SensorStatus.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/Sensors/LinearizationFormula.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Enums/Sensors/ZeroMethodType.cs
|
||||
generated_at: "2026-04-16T04:32:45.162581+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "fee300d457ca6c5a"
|
||||
---
|
||||
|
||||
# Sensors
|
||||
|
||||
## 1. Purpose
|
||||
This module defines core enumeration types used for representing sensor metadata and calibration behavior within the `DatabaseImport` subsystem of the DataPRO system. Specifically, it standardizes how sensor operational status, nonlinear signal conversion methods, and zero-point calculation strategies are encoded—enabling consistent interpretation of imported sensor configuration data (e.g., from legacy databases like GM ISF). These enums serve as foundational building blocks for deserializing and validating sensor-related records during database import operations.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `SensorStatus`
|
||||
- **Namespace**: `DatabaseImport`
|
||||
- **Type**: `public enum`
|
||||
- **Members**:
|
||||
- `Available`: Sensor is ready for use.
|
||||
- `InUse`: Sensor is currently deployed or active.
|
||||
- `OutForService`: Sensor is offline for maintenance.
|
||||
- `OutForCalibration`: Sensor is offline for calibration.
|
||||
- `Retired`: Sensor is no longer in service.
|
||||
|
||||
### `NonLinearStyles`
|
||||
- **Namespace**: `DatabaseImport`
|
||||
- **Type**: `public enum`
|
||||
- **Members**:
|
||||
- `IRTraccManual`: Manual linearization method (likely user-defined or legacy).
|
||||
- `IRTraccDiagnosticsZero`: Linearization using diagnostic-based zero point.
|
||||
- `IRTraccZeroMMmV`: Linearization using zero point derived from millivolt-level diagnostics.
|
||||
- `IRTraccAverageOverTime`: Linearization using time-averaged zero point.
|
||||
- `Polynomial`: Polynomial-based nonlinearity correction (e.g., higher-order fit).
|
||||
- `IRTraccCalFactor`: Linearization using a calibration factor (likely multiplicative).
|
||||
|
||||
### `ZeroMethodType`
|
||||
- **Namespace**: `DatabaseImport`
|
||||
- **Type**: `public enum`
|
||||
- **Members**:
|
||||
- `AverageOverTime = 0`: Compute zero by averaging signal over time.
|
||||
- `UsePreEventDiagnosticsZero = 1`: Compute zero using diagnostics captured *before* an event.
|
||||
- `None = 2`: No zero calculation—use an absolute or pre-specified zero value.
|
||||
- **Note**: The comment explicitly warns that legacy compatibility (e.g., GM ISF imports) depends on the *ordinal values* of this enum; changing them would break data import correctness.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Ordinal stability for `ZeroMethodType`**: The underlying integer values (`0`, `1`, `2`) are part of the contract with legacy data sources (e.g., GM ISF). Reordering, inserting, or modifying values would corrupt imports.
|
||||
- **Exhaustive status coverage**: `SensorStatus` must account for all known sensor lifecycle states in the system; no new statuses should be added without updating downstream import logic.
|
||||
- **Nonlinearity method alignment**: `NonLinearStyles` values correspond to specific calibration workflows; each implies a particular data structure or processing pipeline (e.g., `Polynomial` likely requires coefficient arrays, while `IRTraccCalFactor` expects a scalar factor).
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
- **Depends on**: None (pure enum definitions; no external references).
|
||||
- **Depended on by**:
|
||||
- Other types in the `DatabaseImport` module (e.g., sensor record classes, import parsers) that consume these enums to interpret database fields.
|
||||
- Likely used in serialization/deserialization layers (e.g., JSON/XML converters, database mappers) that handle sensor configuration data.
|
||||
- Legacy import adapters (e.g., GM ISF importer) rely on `ZeroMethodType`’s fixed ordinals for backward compatibility.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`ZeroMethodType.None` does *not* mean "no zero calculation" in the intuitive sense**: Its value (`2`) and comment clarify it means "use an absolute/external zero value," not "skip zeroing." Misinterpreting this could lead to incorrect signal offsets.
|
||||
- **`NonLinearStyles` enum name mismatch**: The file is named `LinearizationFormula.cs`, but the enum is `NonLinearStyles`. This may cause confusion—ensure consumers use the *actual* type name.
|
||||
- **Missing `Description` attributes**: Though `ZeroMethodType` members have XML summaries, they lack `[Description]` attributes (commented out). If the system relies on reflection-based description resolution (e.g., for UI or logging), this could cause runtime issues.
|
||||
- **No validation of enum values in source**: The enums themselves do not enforce constraints (e.g., "only one status may be active at a time"). Validation logic, if any, resides elsewhere.
|
||||
- **No guidance on fallback behavior**: If an unknown `NonLinearStyles` or `SensorStatus` value is encountered during import (e.g., from a newer database), the source provides no indication of how it should be handled (throw? default? warn?).
|
||||
@@ -0,0 +1,217 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/TemplateZone.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/CalculatedValueClass.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/LevelTriggerChannel.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/TestObjectChannel.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/TemplateRegion.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/IsoCode.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/TestEngineerDetails.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/TestSetting.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/HardwareChannel.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/TestObjectMetaData.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/CustomerDetails.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/ISO/LabratoryDetails.cs
|
||||
generated_at: "2026-04-16T04:29:31.413854+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "fd925eaa489a9345"
|
||||
---
|
||||
|
||||
# Documentation: ISO Database Import Module Classes
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides data transfer objects (DTOs) for importing and exporting ISO-compliant test data from a database. It encapsulates structured representations of test configurations—including templates, zones, regions, channels, triggers, calculated values, and metadata—enabling serialization/deserialization between database rows and in-memory objects. These classes serve as intermediaries between the database layer and higher-level application logic, supporting data migration, configuration management, and ISO standard compliance for crash testing systems.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `TemplateZone`
|
||||
- **`TemplateName`** (`string`, read-only)
|
||||
Name of the template this zone belongs to.
|
||||
- **`ZoneName`** (`string`)
|
||||
Name of the zone; defaults to `"Default zone"` if null in database.
|
||||
- **`Picture`** (`string`, read/write)
|
||||
Path or identifier for an associated picture.
|
||||
- **`Description`** (`string`)
|
||||
Zone description; defaults to empty string if null in database.
|
||||
- **`TemplateRegions`** (`TemplateRegion[]`, read/write)
|
||||
Array of regions associated with this zone; populated via `TemplateRegion.GetAllRegions()` in the `DataRow` constructor.
|
||||
|
||||
### `CalculatedValueClass`
|
||||
- **`Id`** (`int`)
|
||||
Unique identifier; defaults to `-1`.
|
||||
- **`Operation`** (`Operations` enum)
|
||||
Operation type: `SUM`, `AVERAGE`, `IRTRACC3D`, `IRTRACC3D_ABDOMEN`, `IRTRACC3D_LOWERTHORAX`. Defaults to `SUM`.
|
||||
- **`CalculatedValueCode`** (`string`)
|
||||
Code string; defaults to `"???????????????X"`.
|
||||
- **`InputChannelIds`** (`string[]`, read/write)
|
||||
Array of input channel IDs; backed by `InputChannelIdsBlob`.
|
||||
- **`InputChannelIdsBlob`** (`byte[]`, read/write)
|
||||
UTF-8 encoded blob of channel IDs joined by `CultureInfo.InvariantCulture.TextInfo.ListSeparator`.
|
||||
- **`CFCForInputChannels`** (`string`)
|
||||
Filter class for input channels; defaults to `""`.
|
||||
- **`ChannelFilterClassForOutput`** (`string`)
|
||||
Filter class for output; defaults to `""`.
|
||||
- **`TestSetupName`**, **`Name`** (`string`)
|
||||
Test setup and calculated channel names.
|
||||
|
||||
### `LevelTriggerChannel`
|
||||
- **`TestSetupName`**, **`GroupSerialNumber`**, **`TestObjectChannelId`**, **`HardwareChannelId`**, **`SensorSerialNumber`** (`string`)
|
||||
Identifiers for test context and hardware.
|
||||
- **`GreaterThanEnabled`** (`bool`)
|
||||
Whether high-threshold triggering is enabled; defaults to `true`.
|
||||
- **`GreaterThanThresholdEU`**, **`LessThanThresholdEU`** (`double`)
|
||||
High and low threshold values in engineering units.
|
||||
- **`LessThanEnabled`** (`bool`)
|
||||
Whether low-threshold triggering is enabled.
|
||||
- **`TriggerBetweenBounds`**, **`TriggerOutsideBounds`** (`bool`)
|
||||
Bounds-triggering modes.
|
||||
- **`InsideUpperLevelEU`**, **`InsideLowerLevelEU`**, **`OutsideUpperLevelEU`**, **`OutsideLowerLevelEU`** (`double`)
|
||||
Upper/lower bounds for inside/outside triggering.
|
||||
|
||||
### `TestObjectChannel`
|
||||
- **`Disabled`** (`bool`)
|
||||
Whether the channel is excluded from data collection.
|
||||
- **`ChannelIdx`** (`int`)
|
||||
Channel index; `CHANNEL_IDX_UNKNOWN = -1` if unset.
|
||||
- **`SensorSerialNumber`**, **`HardwareId`** (`string`)
|
||||
Sensor and hardware channel identifiers; `HardwareId` setter normalizes format (e.g., strips `x` separators).
|
||||
- **`SquibChannelType`** (`SquibChannelTypes` enum)
|
||||
Channel type: `None`, `Voltage`, or `Current`.
|
||||
- **`TestObject`** (`ISO.TestObject`)
|
||||
Parent test object instance.
|
||||
- **`CompareTo(TestObjectChannel)`** (`int`)
|
||||
Comparison for sorting: by `DisplayOrder`, then `Name`, then `TestObject.SerialNumberOrOriginalSerialNumber`.
|
||||
- **`GetGraphId()`**, **`GetId()`**, **`GetIdWithSpecificChannelId(long)`** (`string`)
|
||||
Generate unique channel identifiers; `GetGraphId()` appends `DTS.Common.Constants.CURRENT_SUFFIX` for current-type squib channels.
|
||||
|
||||
### `TemplateRegion`
|
||||
- **`TemplateName`**, **`TemplateZone`** (`string`, read-only)
|
||||
Template and zone names.
|
||||
- **`RegionNumber`**, **`RegionName`**, **`RegionDescription`** (`int`, `string`)
|
||||
Region metadata.
|
||||
- **`TestObject`**, **`Position`**, **`MainLocation`**, **`FineLocation1–3`**, **`PhysicalDimension`**, **`Direction`**, **`FilterClass`** (`string`)
|
||||
Spatial and classification attributes.
|
||||
- **`LocalOnly`** (`bool`, read-only)
|
||||
Whether region is local-only.
|
||||
- **`UpperLeft`**, **`LowerRight`** (`System.Drawing.Point`)
|
||||
Bounding box coordinates.
|
||||
- **`GetAllRegions(string templateName, string zoneName)`** (`TemplateRegion[]`, internal static)
|
||||
Fetches regions from database via stored procedure `sp_TemplateRegionsGet`.
|
||||
|
||||
### `IsoCode`
|
||||
- **`StringRepresentation`** (`string`, read/write)
|
||||
16-character ISO code string; pads with `'?'` if shorter, truncates if longer.
|
||||
- **`GetString(MMEPossibleChannels, bool careAboutTestTimeFields)`** (`string`, static)
|
||||
Generates ISO code from channel metadata; masks `Test_Object` and `Default_Filter_Class` with `'?'` if `careAboutTestTimeFields` is `false`.
|
||||
- **`GetString(...)`** (`string`, static)
|
||||
Direct concatenation of ISO components.
|
||||
|
||||
### `TestEngineerDetails`
|
||||
- **`TestEngineerName`**, **`TestEngineerPhone`**, **`TestEngineerFax`**, **`TestEngineerEmail`** (`string`)
|
||||
Contact info; setters ignore empty strings.
|
||||
- **`LocalOnly`** (`bool`)
|
||||
Scope flag.
|
||||
- **`Name`**, **`LastModified`**, **`LastModifiedBy`**, **`Version`** (`string`, `DateTime`, `string`, `int`)
|
||||
Metadata fields.
|
||||
- **`DeleteAllTestEngineerDetails()`**, **`GetAllTestEngineerDetails()`** (`void`, `TestEngineerDetails[]`, static)
|
||||
Database CRUD operations.
|
||||
|
||||
### `TestSetting`
|
||||
- **`Id`**, **`Value`**, **`DefaultValue`** (`string`)
|
||||
Setting identifier, current value, and default value.
|
||||
- **`ToSerializeString()`** (`string`)
|
||||
Serializes as `Id=SEPARATOR=SEPARATOR=Value`.
|
||||
- **`TryParse(string, out TestSetting)`** (`bool`, static)
|
||||
Parses serialized string; sets `DefaultValue = Value` on success.
|
||||
|
||||
### `TestSettingDictionary`
|
||||
- **`GetValue(string id, string defaultValue)`** (`string`)
|
||||
Returns `Value` if present, else `DefaultValue`.
|
||||
- **`SetValue(TestSetting, string)`**, **`SetValue(TestSetting)`**, **`SetValue(string, string)`** (`void`)
|
||||
Updates or adds settings.
|
||||
- **`ToSerializeString()`**, **`LoadSettings(string)`** (`string`, `void`)
|
||||
Serializes/deserializes settings using `ListSeparator` as delimiter.
|
||||
|
||||
### `HardwareChannel`
|
||||
- **`ParentDAS`** (`Hardware`)
|
||||
Parent data acquisition system.
|
||||
- **`SupportedBridges`**, **`SupportedExcitations`**, **`SupportedDigitalInputModes`**, **`SupportedDigitalOutputModes`**, **`SupportedSquibFireModes`** (`int`)
|
||||
Hardware capabilities.
|
||||
- **`ChannelIdx`**, **`DASDisplayOrder`**, **`ModuleSerialNumber`**, **`ModuleArrayIndex`** (`int`, `int`, `string`, `int`)
|
||||
Channel identification and positioning.
|
||||
- **`LocalOnly`** (`bool`)
|
||||
Scope flag.
|
||||
- **`PhysicalCompare(HardwareChannel, HardwareChannel)`** (`int`, static)
|
||||
Compares by `ChannelIdx`.
|
||||
|
||||
### `TestObjectMetaData`, `TestSetupMetaData`
|
||||
- **`TestObject`** (`char`)
|
||||
Test object identifier (e.g., `'?'`).
|
||||
- **`Version`** (`double`)
|
||||
Schema version (`1.06`).
|
||||
- **`NOVALUE`** (`const string`)
|
||||
Placeholder for unset values (`"NOVALUE"`).
|
||||
- **`SetProperty(MetaData)`** (`void`)
|
||||
Adds/updates metadata properties.
|
||||
- **`MetaData`**
|
||||
- `Name`, `IsOptional`, `Value`, `Version` (`string`, `bool`, `string`, `double`)
|
||||
- Represents a single metadata field.
|
||||
|
||||
### `CustomerDetails`
|
||||
- **`CustomerName`**, **`CustomerTestRefNumber`**, **`ProjectRefNumber`**, **`CustomerOrderNumber`**, **`CustomerCostUnit`** (`string`)
|
||||
Customer-related identifiers; setters ignore empty strings for non-required fields.
|
||||
- **`LocalOnly`**, **`Name`**, **`LastModified`**, **`LastModifiedBy`**, **`Version`** (`bool`, `string`, `DateTime`, `string`, `int`)
|
||||
Metadata fields.
|
||||
- **`ReadXML(XmlElement)`**, **`WriteXML(ref XmlWriter)`**, **`DeleteCustomerDetails(string)`** (`CustomerDetails`, `void`, `void`, static)
|
||||
XML persistence and deletion.
|
||||
|
||||
### `LabratoryDetails`
|
||||
- **`LabratoryName`**, **`LabratoryContactName`**, **`LabratoryContactPhone`**, **`LabratoryContactFax`**, **`LabratoryContactEmail`**, **`LabratoryTestRefNumber`**, **`LabratoryProjectRefNumber`** (`string`)
|
||||
Laboratory contact and reference data.
|
||||
- **`Name`**, **`LocalOnly`**, **`LastModified`**, **`LastModifiedBy`**, **`Version`** (`string`, `bool`, `DateTime`, `string`, `int`)
|
||||
Metadata fields.
|
||||
- **`ReadXML(XmlElement)`**, **`DeleteLabratoryDetails()`** (`LabratoryDetails`, `void`, static)
|
||||
XML persistence and deletion.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **`TemplateZone.ZoneName`**: Defaults to `"Default zone"` if database `ZoneName` is `DBNull`.
|
||||
- **`TemplateZone.Description`**: Defaults to `""` if database `ZoneDescription` is `DBNull`.
|
||||
- **`CalculatedValueClass.InputChannelIds`**: Stored as a `byte[]` blob using `CultureInfo.InvariantCulture.TextInfo.ListSeparator` as delimiter; deserialization splits on this separator.
|
||||
- **`TestObjectChannel.HardwareId`**: Setter enforces format `prefix_number` (e.g., strips `x` separators beyond the first two segments).
|
||||
- **`IsoCode.StringRepresentation`**: Always exactly 16 characters; missing characters padded with `'?'`, excess truncated.
|
||||
- **`TestSettingDictionary`**: Preserves `DefaultValue` from existing settings during `LoadSettings`; only updates `Value`.
|
||||
- **`TestEngineerDetails`, `CustomerDetails`, `LabratoryDetails`**: Contact fields (`Phone`, `Fax`, `Email`) ignore empty-string assignments.
|
||||
- **`LevelTriggerChannel`**: Constructor silently ignores exceptions during field parsing (commented logging).
|
||||
- **`TemplateRegion.GetAllRegions`**: Returns empty array on failure; logs exceptions (commented).
|
||||
- **`HardwareChannel`**: Implements `INotifyPropertyChanged`; `SetProperty` raises `PropertyChanged` only on change.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
- **Database Layer**:
|
||||
- `DbOperations`, `DbOperationsEnum.StoredProcedure`, `DTS.Common.Storage.DbOperations` (e.g., `TestEngineerDetailsGet`, `CustomerDetailsDelete`, `LabratoryDetailsDelete`, `sp_TemplateRegionsGet`).
|
||||
- `System.Data`, `System.Data.SqlClient` (ADO.NET types).
|
||||
- **Core Types**:
|
||||
- `DTS.Common.Constants.CURRENT_SUFFIX` (used in `TestObjectChannel.GetGraphId()`).
|
||||
- `DTS.Common.Interface.TestMetaData.ITestEngineerDetailsDbRecord` (used in `TestEngineerDetails` constructor).
|
||||
- `System.Drawing.Point` (used in `TemplateRegion`).
|
||||
- **Serialization**:
|
||||
- `System.Xml` (XML persistence in `CustomerDetails`, `LabratoryDetails`).
|
||||
- `System.Text.Encoding`, `System.Globalization.CultureInfo` (used in `CalculatedValueClass` and `TestSetting`).
|
||||
- **Inheritance/Usage**:
|
||||
- `TestObjectChannel` extends `TestObjectTemplateChannel` and implements `IComparable<TestObjectChannel>`.
|
||||
- `HardwareChannel` implements `INotifyPropertyChanged`.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`TemplateRegion.GetAllRegions`**: Uses `internal` access and database calls; not testable without database connectivity.
|
||||
- **`LevelTriggerChannel` constructor**: Swallows all exceptions during deserialization (commented logging); may silently fail to populate fields.
|
||||
- **`CalculatedValueClass.InputChannelIdsBlob`**: Uses `CultureInfo.InvariantCulture.TextInfo.ListSeparator` (typically `','`), but this may conflict with IDs containing commas.
|
||||
- **`TestObjectChannel.HardwareId` setter**: Normalizes input by stripping `x` separators beyond the first two segments; may alter expected values unexpectedly.
|
||||
- **`IsoCode`**: Masks `Test_Object` and `Default_Filter_Class` with `'?'` when `careAboutTestTimeFields` is `false`, but does not validate input strings (e.g., null/empty `Direction` may cause `IndexOutOfRangeException`).
|
||||
- **`TestSettingDictionary.ToSerializeString`**: Uses `ListSeparator` as delimiter between settings, but escapes `=` with `SEPARATOR = "_x_"` or `"_X_"`; mismatched separators in `LoadSettings` could cause parsing errors.
|
||||
- **`TestEngineerDetails`, `CustomerDetails`, `LabratoryDetails`**: Contact fields ignore empty strings, but `NOVALUE` is used as default—this may cause confusion if `NOVALUE` is stored in the database.
|
||||
- **`TemplateZone`**: `TemplateRegions` is populated only in the `DataRow` constructor; the parameterized constructor does not initialize regions.
|
||||
- **`TestObjectMetaData`/`TestSetupMetaData`**: `NOVALUE` is used as default, but `TestSetupMetaData` replaces `NOVALUE` with `string.Empty` for specific fields when `requireXCrashCompatibilityForISOExports` is `true`.
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Interface/DataRecorders/IHardwareChannel.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Interface/DataRecorders/IDASHardware.cs
|
||||
generated_at: "2026-04-16T04:31:18.077844+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "bd947523624c1bb7"
|
||||
---
|
||||
|
||||
# DataRecorders
|
||||
|
||||
## 1. Purpose
|
||||
This module defines foundational interfaces (`IHardwareChannel` and `IDASHardware`) within the `DatabaseImport` namespace, intended to represent abstractions for hardware-related data entities during TTS (presumably *Test Time Series* or similar) database import operations. As of the provided source, these interfaces are empty markers—likely placeholders for future extension or for use in type constraints elsewhere in the codebase—but they establish a conceptual separation between channel-specific hardware (`IHardwareChannel`) and general hardware (`IDASHardware`) within the import pipeline.
|
||||
|
||||
## 2. Public Interface
|
||||
No public members are defined on either interface.
|
||||
|
||||
- **`IHardwareChannel`**
|
||||
- *Type*: `interface`
|
||||
- *Namespace*: `DatabaseImport`
|
||||
- *Description*: Marker interface intended to represent a hardware channel in TTS import. Currently has no members.
|
||||
|
||||
- **`IDASHardware`**
|
||||
- *Type*: `interface`
|
||||
- *Namespace*: `DatabaseImport`
|
||||
- *Description*: Marker interface representing hardware in TTS import, per its XML summary. Currently has no members.
|
||||
|
||||
## 3. Invariants
|
||||
- Both interfaces are *marker interfaces* with no state or behavior defined; thus, no behavioral invariants apply.
|
||||
- No explicit constraints (e.g., inheritance, implementation requirements) are declared in the source.
|
||||
|
||||
## 4. Dependencies
|
||||
- **Imports/References**: Neither interface declares any `using` directives or external dependencies in the provided source.
|
||||
- **Depended upon**: Inferred from naming and namespace (`DatabaseImport.Interface.DataRecorders`), these interfaces are likely consumed by other components in the `DatabaseImporter` module (e.g., concrete recorder classes, import logic), but no such consumers are visible in the provided files.
|
||||
|
||||
## 5. Gotchas
|
||||
- **Ambiguity in intent**: The distinction between `IHardwareChannel` and `IDASHardware` is not documented beyond their names. Without further context (e.g., implementation files, usage sites), it is unclear whether they are meant to be mutually exclusive, hierarchical, or overlapping.
|
||||
- **Empty interfaces**: As marker interfaces with no methods or properties, they provide no runtime guarantees—consumers must rely on external documentation or conventions to interpret their meaning.
|
||||
- **No versioning or deprecation cues**: No attributes (e.g., `[Obsolete]`) or comments suggest these are deprecated or experimental.
|
||||
- *None identified from source alone.*
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Interface/Hardware/IISOHardware.cs
|
||||
generated_at: "2026-04-16T04:31:11.809282+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "31b50715cab0bca0"
|
||||
---
|
||||
|
||||
# Hardware
|
||||
|
||||
1. **Purpose**
|
||||
This module defines the `IISOHardware` interface within the `DatabaseImport` namespace, which appears to be part of a larger system responsible for importing data—likely from external sources—into a database. The interface currently serves as an empty marker interface, suggesting it is intended to represent or categorize hardware-related entities involved in the import process (e.g., ISO-compliant hardware specifications or devices), but no behavior or contract has yet been defined.
|
||||
|
||||
2. **Public Interface**
|
||||
No public methods, properties, or events are defined. The interface `IISOHardware` is empty and contains no members.
|
||||
|
||||
3. **Invariants**
|
||||
No invariants can be inferred, as the interface imposes no constraints or guarantees. Its sole purpose at this stage appears to be type identification or tagging.
|
||||
|
||||
4. **Dependencies**
|
||||
- **Internal**: This interface resides in the `DatabaseImport` namespace, implying it is part of the `DatabaseImporter` module, likely consumed by other components in the same assembly or dependent assemblies (e.g., import pipeline logic, hardware mapping layers).
|
||||
- **External**: No external dependencies are referenced in this file.
|
||||
- **Consumers**: Unknown from this file alone; would require analysis of other modules (e.g., classes implementing `IISOHardware` or methods accepting `IISOHardware` as a parameter).
|
||||
|
||||
5. **Gotchas**
|
||||
- **Empty Interface Risk**: As a marker interface with no members, `IISOHardware` may be a placeholder for future functionality. Developers should verify whether implementations are expected to exist elsewhere or if this interface is intended to be extended in a future version.
|
||||
- **Ambiguous Semantics**: Without documentation or usage context, it is unclear what qualifies as "ISOHardware"—e.g., whether it refers to ISO/IEC 14443, ISO 8583, or another standard.
|
||||
- **No Validation or Contract**: Consumers cannot rely on any behavioral guarantees; runtime type checks (`is IISOHardware`) may be used for categorization only.
|
||||
- **None identified from source alone.**
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Interface/Sensors/ISensorData.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Interface/Sensors/ISensorCalibration.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Interface/Sensors/ICalibrationRecords.cs
|
||||
generated_at: "2026-04-16T04:31:06.327262+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "21dc4c3dfa01bdb8"
|
||||
---
|
||||
|
||||
# Sensors
|
||||
|
||||
## 1. Purpose
|
||||
This module defines a set of empty marker interfaces (`ISensorData`, `ISensorCalibration`, `ICalibrationRecords`) within the `DatabaseImport` namespace. These interfaces serve as type contracts or tags for sensor-related data structures involved in database import operations, likely intended to be implemented by concrete classes elsewhere in the codebase. Their purpose is to enable compile-time type safety and polymorphic handling of sensor data, calibration metadata, and calibration record collections during data ingestion—though the interfaces themselves contain no members and thus convey no behavioral semantics.
|
||||
|
||||
## 2. Public Interface
|
||||
No public members are defined in any of the interfaces. All three interfaces are empty:
|
||||
|
||||
- `ISensorData`
|
||||
- *Description:* Marker interface for sensor data types. Intended to be implemented by classes representing raw or processed sensor measurements (e.g., temperature, pressure readings).
|
||||
- `ISensorCalibration`
|
||||
- *Description:* Marker interface for sensor calibration parameters or coefficients (e.g., offset, gain, polynomial terms).
|
||||
- `ICalibrationRecords`
|
||||
- *Description:* Marker interface for collections or containers of calibration records (e.g., time-series of calibration events or lookup tables).
|
||||
|
||||
## 3. Invariants
|
||||
- All three interfaces are *marker interfaces* (also known as tag interfaces): they impose no runtime constraints, validation rules, or behavioral guarantees.
|
||||
- Implementing types are not required to expose any specific properties, methods, or events by virtue of implementing these interfaces.
|
||||
- No ordering, lifecycle, or consistency guarantees are enforced by these interfaces alone.
|
||||
|
||||
## 4. Dependencies
|
||||
- **Namespace:** All interfaces reside in the `DatabaseImport` namespace, suggesting they are part of a larger database import pipeline module (`DataPRO/Modules/DatabaseImporter/DatabaseImport`).
|
||||
- **Usage context (inferred):** These interfaces are likely referenced by other types in the `DatabaseImport` module (e.g., import handlers, mappers, or validators) that operate on sensor-related data. However, no direct dependencies (imports, `using` statements, or references) are visible in the provided source files.
|
||||
- **No external dependencies** are declared in the source files (no `using` directives or external references).
|
||||
|
||||
## 5. Gotchas
|
||||
- **Empty interfaces may indicate incomplete or aspirational design:** These interfaces currently convey no semantics and could be placeholders for future functionality. Relying on them for type-based dispatch without additional constraints (e.g., via generics or attributes) may lead to runtime errors if implementers do not conform to expected conventions.
|
||||
- **No documentation or examples provided:** The absence of XML comments or sample implementations makes it unclear how these interfaces are intended to be used or what concrete types implement them.
|
||||
- **Risk of misuse:** Developers may incorrectly assume these interfaces imply specific data structures or behaviors (e.g., that `ISensorData` implies a `Timestamp` or `Value` property), leading to assumptions not enforced by the type system.
|
||||
- **None identified from source alone** — but the emptiness of the interfaces themselves is a potential anti-pattern requiring external context to validate correctness.
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Interface/TestSetups/TestSetupsList/ITestSetup.cs
|
||||
generated_at: "2026-04-16T04:31:20.119441+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "1e3ba8a6dc409c4f"
|
||||
---
|
||||
|
||||
# TestSetupsList
|
||||
|
||||
1. **Purpose**
|
||||
This module defines the `ITestSetup` interface, a marker interface intended to identify types that represent test setup configurations within the `DatabaseImport` module’s test infrastructure. Its existence suggests a design pattern where different test scenarios or data initialization routines can be tagged and potentially discovered or processed via reflection or dependency injection—though the interface itself currently carries no members, indicating it may be a placeholder for future extensibility or a convention-based tagging mechanism.
|
||||
|
||||
2. **Public Interface**
|
||||
- **`ITestSetup`** (`interface`)
|
||||
A marker interface with no members. Any class implementing `ITestSetup` is considered a test setup definition. As written, it provides no behavioral contract—its sole purpose is type identification.
|
||||
|
||||
3. **Invariants**
|
||||
- Any type claiming to implement `ITestSetup` must be a class (interfaces cannot be instantiated directly).
|
||||
- Since the interface is empty, there are no runtime invariants enforced by its definition. Validation or ordering guarantees (if any) must be enforced by consumers of this interface, which are not visible in this file.
|
||||
|
||||
4. **Dependencies**
|
||||
- **Internal**: Depends only on the `DatabaseImport` namespace (no external or framework imports beyond standard C# runtime).
|
||||
- **Consumers**: Unknown from this file alone. The interface is likely used elsewhere in the `DatabaseImport` module (e.g., in test runners, setup factories, or DI containers), but no such usages are present in the provided source.
|
||||
|
||||
5. **Gotchas**
|
||||
- The interface is currently a *marker interface* with no methods or properties, which may indicate incomplete implementation or reliance on external conventions (e.g., naming, attributes, or DI registration).
|
||||
- Developers may mistakenly assume `ITestSetup` implies lifecycle management, initialization logic, or configuration capabilities—none of which are defined here.
|
||||
- No documentation comments or attributes (e.g., `[Obsolete]`, `[EditorBrowsable]`) are present, so tooling or future maintainers may lack context about intended usage.
|
||||
- None identified from source alone.
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Properties/AssemblyInfo.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Properties/Settings.Designer.cs
|
||||
generated_at: "2026-04-16T04:30:25.113253+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "ae1921064164fa41"
|
||||
---
|
||||
|
||||
# Properties
|
||||
|
||||
## Documentation: DatabaseImport Module
|
||||
|
||||
### 1. Purpose
|
||||
This module (`DatabaseImport`) is a .NET assembly responsible for managing database import functionality within the DataPRO system. It provides configuration-driven behavior for import operations, including specifying where downloaded data is stored (`DownloadFolder`), controlling whether automatic arming of systems is permitted (`AllowAutoArm`), defining calibration warning thresholds (`CalWarningPeriodDays`), selecting the target database type (`DBType`), and enforcing compatibility requirements for ISO export generation (`RequireXCrashCompatibilityForISOExports`). Its role is to encapsulate and expose application-level settings used during database import workflows.
|
||||
|
||||
### 2. Public Interface
|
||||
The module exposes only one public type:
|
||||
- **`DatabaseImport.Properties.Settings`** (internal sealed class, but accessible via `Settings.Default` static property)
|
||||
A strongly-typed settings class derived from `System.Configuration.ApplicationSettingsBase`. Provides read/write access to application and user-scoped configuration values.
|
||||
|
||||
- **`public static Settings Default { get; }`**
|
||||
Returns the singleton instance of the `Settings` class, synchronized for thread safety.
|
||||
|
||||
- **`public string DownloadFolder { get; }`**
|
||||
*Application-scoped*. Returns the default path for downloaded data files. Default value: `"..\Data"`.
|
||||
|
||||
- **`public bool AllowAutoArm { get; }`**
|
||||
*Application-scoped*. Controls whether automatic arming (likely of measurement or acquisition systems) is permitted during import. Default value: `false`.
|
||||
|
||||
- **`public int CalWarningPeriodDays { get; set; }`**
|
||||
*User-scoped*. Specifies the number of days before calibration expiry at which a warning should be issued. Default value: `7`. Supports runtime modification (setter present).
|
||||
|
||||
- **`public int DBType { get; }`**
|
||||
*Application-scoped*. Encodes the type of database to target for import (e.g., enum-like integer). Default value: `1`. Interpretation of values is not defined in this file.
|
||||
|
||||
- **`public bool RequireXCrashCompatibilityForISOExports { get; }`**
|
||||
*Application-scoped*. Enforces compatibility with "XCrash" format when exporting ISO data. Default value: `true`.
|
||||
|
||||
### 3. Invariants
|
||||
- `Settings.Default` is a singleton and thread-safe (via `ApplicationSettingsBase.Synchronized`).
|
||||
- `DownloadFolder`, `AllowAutoArm`, `DBType`, and `RequireXCrashCompatibilityForISOExports` are *application-scoped* and immutable at runtime (read-only properties).
|
||||
- `CalWarningPeriodDays` is *user-scoped* and mutable at runtime (has a public setter).
|
||||
- All settings have explicitly defined default values via `[DefaultSettingValueAttribute]`.
|
||||
- No runtime validation of setting values (e.g., `DBType` values, `CalWarningPeriodDays` sign) is present in this file.
|
||||
|
||||
### 4. Dependencies
|
||||
- **Dependencies of this module**:
|
||||
- `System.Configuration` (for `ApplicationSettingsBase`, attributes like `ApplicationScopedSettingAttribute`, `UserScopedSettingAttribute`)
|
||||
- `System.Runtime.CompilerServices`, `System.CodeDom.Compiler`, `System.Diagnostics` (for attributes)
|
||||
- `System` (core types)
|
||||
- **Depended upon by**:
|
||||
- Other modules in the `DataPRO.Modules.DatabaseImporter` solution (e.g., import logic that consumes `Settings.Default.DownloadFolder`, `Settings.Default.DBType`, etc.).
|
||||
- UI layers (e.g., settings dialogs) that bind to `Settings.Default` for user-modifiable values like `CalWarningPeriodDays`.
|
||||
|
||||
### 5. Gotchas
|
||||
- **`DBType` semantics are opaque**: The integer value has no documented meaning (e.g., 1 = SQLite? SQL Server? Custom DB?). Consumers must infer or document externally.
|
||||
- **`DownloadFolder` is relative**: Path `"..\Data"` is relative to the application’s base directory; behavior may vary if the app is launched from a different working directory.
|
||||
- **No schema versioning**: Settings are not versioned or migrated; changing defaults (e.g., `DBType`) may break existing user configurations if not handled by a higher-level updater.
|
||||
- **`AllowAutoArm` default is `false`**: If auto-arm is expected to be enabled by default in production, this may indicate legacy or safety-conscious design.
|
||||
- **User-scoped settings persist per-user**: Changes to `CalWarningPeriodDays` are saved per-user profile; may cause inconsistent behavior in shared environments (e.g., terminals, kiosks).
|
||||
- **Auto-generated file**: `Settings.Designer.cs` is generated by Visual Studio’s Settings Designer; manual edits risk being overwritten.
|
||||
|
||||
None identified beyond the above.
|
||||
@@ -0,0 +1,239 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/SensorRange.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/SensorDB.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/DigitalInputSetting.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/DigitalOutputSetting.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/SquibSetting.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/FilterClass.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/SensorCalibrationList.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/CalibrationRecords.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/IsoCode.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/SensorsCollection.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SensorDB/SensorCalibration.cs
|
||||
generated_at: "2026-04-16T04:31:14.887778+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "927e0a96c4cf2bf8"
|
||||
---
|
||||
|
||||
# Sensor Database Module Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides data structures and services for importing, managing, and accessing sensor configuration and calibration data from a database into the DataPRO system. It defines concrete types for various sensor categories (analog, digital input, digital output, squib), their associated calibration records, and supporting classes for ISO code parsing, filter classification, and range definitions. The module acts as the data layer abstraction for sensor metadata, enabling consistent representation of sensor properties, calibration parameters, and configuration settings across the application.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Classes
|
||||
|
||||
#### `SensorRange`
|
||||
- **`SensorRange(string value)`**
|
||||
Parses a comma-separated string of three doubles into `Low`, `Medium`, and `High` properties. Throws `InvalidDataException` if the input does not contain exactly three values.
|
||||
- **`SensorRange(double low, double medium, double high)`**
|
||||
Constructor that directly initializes `Low`, `Medium`, and `High` properties.
|
||||
|
||||
#### `LowHigh`
|
||||
- **`LowHigh(double low, double high)`**
|
||||
Constructor initializing `Low` and `High` properties.
|
||||
- **`LowHigh(string value)`**
|
||||
Parses a comma-separated string of two doubles into `Low` and `High`. Throws `InvalidDataException` if fewer than two values are present. Uses `InvariantCulture` for parsing.
|
||||
|
||||
#### `FilterClass`
|
||||
- **`FilterClass(FilterClassType fc)`**
|
||||
Constructor initializing `FClass` and `Frequency` based on predefined CFC filter types. Throws `Exception` for unknown types.
|
||||
- **`FilterClass(string fclass)`**
|
||||
Constructor parsing a string representation (e.g., `"17"`, `"CFC60"`, `"1000"`, `"AdHoc"`) into `FClass` and `Frequency`. Supports numeric codes, CFC names, and arbitrary numeric values for `AdHoc`.
|
||||
- **`ToString()`**
|
||||
Returns a human-readable string representation (e.g., `"17 (CFC10)"`, `"None"`, `"100"` for `AdHoc`).
|
||||
- **`FilterClassType` enum**:
|
||||
`None = 0`, `AdHoc = -1`, `CFC10 = 17`, `CFC60 = 100`, `CFC180 = 300`, `CFC600 = 1000`, `CFC1000 = 1650`.
|
||||
|
||||
#### `IsoCode`
|
||||
- **`IsoCode(string isoCode)`**
|
||||
Constructor initializing the 16-character ISO code. Truncates or pads with `'?'` as needed.
|
||||
- **`StringRepresentation` property (string)**
|
||||
Gets/sets the full 16-character ISO code string.
|
||||
- **Component properties** (all `string` type, each representing a fixed-width segment):
|
||||
- `TestObject` (1 char, index 0)
|
||||
- `Position` (1 char, index 1)
|
||||
- `MainLocation` (4 chars, indices 2–5)
|
||||
- `FineLocation1` (2 chars, indices 6–7)
|
||||
- `FineLocation2` (2 chars, indices 8–9)
|
||||
- `FineLocation3` (2 chars, indices 10–11)
|
||||
- `PhysicalDimension` (2 chars, indices 12–13)
|
||||
- `Direction` (1 char, index 14)
|
||||
- `FilterClass` (1 char, index 15)
|
||||
Each property setter pads with `'?'` or truncates as needed; empty or null inputs default to `'?'`.
|
||||
|
||||
#### `SensorCalibration`
|
||||
- **`SensorCalibration()`**
|
||||
Default constructor.
|
||||
- **`SensorCalibration(string s)`**
|
||||
Deserializes from a `ListSeparator`-delimited string (see `SEPARATOR_REPLACEMENT`).
|
||||
- **`SensorCalibration(DataRow dr)`**
|
||||
Populates from a database row using `DbOperations.SensorDB.SensorCalibrationFields` enum.
|
||||
- **`SensorCalibration(SensorCalibration sc)`**
|
||||
Copy constructor.
|
||||
- **`FromSerializedString(string s)`**
|
||||
Deserializes from a string using `SEPARATOR_REPLACEMENT` (`"__SC__"`) to escape list separators.
|
||||
- **`NewDigitalSC()`**
|
||||
Static factory returning a default calibration for digital sensors (`Sensitivity=1`, `EngineeringUnits="V"`, `Excitation=Volt5`, `IsProportional=false`, `RemoveOffset=false`).
|
||||
- **`GetLatestCalibrationBySerialNumberAndExcitation(SensorData sd, ExcitationVoltageOption exc)`**
|
||||
Static method delegating to `SensorCalibrationList.GetLatestCalibrationBySerialNumberAndExcitation`.
|
||||
- **`CompareTo(SensorCalibration other)`**
|
||||
Implements `IComparable<SensorCalibration>`: sorts descending by `CalibrationDate`, then `ModifyDate`, then `CalVersion`.
|
||||
- **Properties**:
|
||||
- `CalVersion` (`long`)
|
||||
- `CalibrationDate` (`DateTime`)
|
||||
- `ModifyDate` (`DateTime`)
|
||||
- `SerialNumber` (`string`)
|
||||
- `Username` (`string`)
|
||||
- `Records` (`CalibrationRecords`)
|
||||
- `IsProportional` (`bool`, read-only logic: `!NonLinear && _isProportional`)
|
||||
- `RemoveOffset` (`bool`, read-only logic: `!NonLinear && _bRemoveOffset`)
|
||||
- `NonLinear` (`bool`)
|
||||
- `LocalOnly` (`bool`)
|
||||
- `ZeroMethod` (`ZeroMethod`)
|
||||
- `InitialOffset` (`InitialOffset`)
|
||||
- `CertificationDocuments` (`string[]`)
|
||||
|
||||
#### `SensorCalibrationList`
|
||||
- **`Reload()`**
|
||||
Static method that clears and rebuilds the internal `_calibrationList` singleton instance (thread-safe via `LOCK`).
|
||||
- **`GetLatestCalibrationBySerialNumberAndExcitation(SensorData sd, ExcitationVoltageOption exc)`**
|
||||
Static method returning the most recent calibration for a given sensor and excitation. Returns `SensorCalibration.NewDigitalSC()` for digital/squib types. Uses `_cachedCalibrations` if available; otherwise queries `_calibrationList`.
|
||||
- **`DeleteAll()`**
|
||||
Static method calling stored procedure `sp_SensorCalibrationsDelete`, clearing `_calibrationList._calibrations`, and logging errors.
|
||||
|
||||
#### `CalibrationRecords`
|
||||
- **`CalibrationRecords()`**
|
||||
Default constructor initializing `Records` to a single default `CalibrationRecord`.
|
||||
- **`CalibrationRecords(string records)`**
|
||||
Parses a serialized string using `"__x__"` as primary separator and `"___xx___"` as backup escape sequence.
|
||||
- **`CalibrationRecords(CalibrationRecords copy)`**
|
||||
Deep copy constructor.
|
||||
- **`FromSerializedString(string s)`**
|
||||
Parses serialized string into `Records` array.
|
||||
|
||||
#### `CalibrationRecord`
|
||||
- **`CalibrationRecord()`**
|
||||
Default constructor initializing `Poly` to a new `LinearizationFormula`.
|
||||
- **`CalibrationRecord(string s)`**
|
||||
Parses from a `ListSeparator`-delimited string (e.g., `";"` in `InvariantCulture`).
|
||||
- **`CalibrationRecord(CalibrationRecord copy)`**
|
||||
Copy constructor.
|
||||
- **`FromString(string s)`**
|
||||
Deserializes from a `ListSeparator`-delimited string. Uses `"x_Separator_x"` as escape sequence for list separators.
|
||||
- **Properties**:
|
||||
- `Sensitivity` (`double`)
|
||||
- `ZeroPoint` (`double`, computed from `Poly.ZeroPositionIntercept / Poly.CalibrationFactor` if `Poly.CalibrationFactor != 0`, else stored `_zeroPoint`)
|
||||
- `Poly` (`LinearizationFormula`)
|
||||
- `AtCapacity` (`bool`)
|
||||
- `EngineeringUnits` (`string`, default `"g"`)
|
||||
- `SensitivityUnits` (`SensUnits`, default `NONE`)
|
||||
- `Excitation` (`ExcitationVoltageOption`, default `Volt5`)
|
||||
- `CapacityOutputIsBasedOn` (`double`, default `1.0`)
|
||||
|
||||
#### `DigitalInputSetting`
|
||||
- **`DigitalInputSetting(IDataRecord reader)`**
|
||||
Constructor populating from database record using `DbOperations.DigitalInputSettings.Fields` enum. Calls `SetDefaults(this)` first. Catches and logs exceptions.
|
||||
- **`SetDefaults(SensorData sd)`**
|
||||
Static method setting default values for digital input sensors (e.g., `Bridge=DigitalInput`, `Capacity=1`, `DisplayUnit="V"`, `Shunt=ShuntMode.None`).
|
||||
|
||||
#### `DigitalOutputSetting`
|
||||
- **`DigitalOutputSetting()`**
|
||||
Default constructor calling `SetDefaults(this)`.
|
||||
- **`DigitalOutputSetting(IDataRecord reader)`**
|
||||
Constructor populating from database record using `DbOperations.DigitalOutputSettings.Fields` enum. Sets `Bridge` to `TOMDigital` before calling `SetDefaults(this)`.
|
||||
- **`ChannelDescription` property**
|
||||
Getter returns `SerialNumber`; setter assigns to `SerialNumber` and raises `PropertyChanged("ChannelDescription")`.
|
||||
- **`SetDefaults(SensorData sd)`**
|
||||
Static method setting defaults for digital output sensors (e.g., `Bridge=TOMDigital`, `SupportedExcitation=[Volt5]`, `DisplayUnit="V"`).
|
||||
|
||||
#### `SquibSetting`
|
||||
- **`SquibSetting(IDataRecord reader)`**
|
||||
Constructor populating from database record using `DbOperations.Squib.Fields` enum. Calls `SetDefaults(this)` first, then overrides with DB values. Ensures `Comment` is non-null (defaults to `SerialNumber` if empty).
|
||||
- **`SquibDescription` property**
|
||||
Getter returns `SerialNumber`; setter assigns to `SerialNumber` and raises `PropertyChanged("SquibDescription")`.
|
||||
- **`ArticleId` property**
|
||||
Getter returns `Id`; setter assigns to `Id` and raises `PropertyChanged("ArticleId")`.
|
||||
- **`BypassCurrentFilter` / `BypassVoltageFilter` properties**
|
||||
Boolean properties with `SetProperty` pattern for `INotifyPropertyChanged`.
|
||||
- **`SetDefaults(SensorData sd)`**
|
||||
Static method setting defaults for squib sensors (e.g., `Bridge=SQUIB`, `Capacity=5`, `SupportedExcitation=[Volt5]`, `DisplayUnit="V"`).
|
||||
|
||||
#### `SensorsCollection`
|
||||
- **`SensorsList` property**
|
||||
Static singleton property (thread-safe via `Lock`).
|
||||
- **`GetSensorBySerialNumber(string serialNumber, bool excludeBroken = true, bool bUseCache = true)`**
|
||||
Returns a `SensorData` (or derived type) by serial number. Checks cache first if `bUseCache`. Queries database via stored procedures in order: `sp_SensorsAnalogGet`, `sp_SensorsDigitalInGet`, `sp_SensorsSquibGet`, `sp_SensorsDigitalOutGet`. Returns `null` if not found. Handles test-specific digital output serial numbers.
|
||||
- **`DeleteAll()`**
|
||||
Static method calling `sp_SensorDeleteAll` stored procedure, then calling `SensorCalibrationList.DeleteAll()`, and raising `OnPropertyChanged("AllSensors")`.
|
||||
- **`HookedUp` property**
|
||||
Controls whether `OnPropertyChanged` events are raised (if `false`, events suppressed).
|
||||
|
||||
### Enums
|
||||
|
||||
#### `ShuntMode` (SensorDB.cs)
|
||||
`None`, `Emulation`, `Internal`, `External`
|
||||
|
||||
#### `BridgeLeg` (SensorDB.cs)
|
||||
`First`, `Second`, `Third`, `Fourth`
|
||||
|
||||
#### `CouplingModes` (SensorDB.cs)
|
||||
`AC = 0`, `DC`
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **`SensorRange`**: Must contain exactly three comma-separated numeric values; otherwise, `InvalidDataException` is thrown.
|
||||
- **`LowHigh`**: Must contain at least two comma-separated numeric values; otherwise, `InvalidDataException` is thrown.
|
||||
- **`FilterClass`**: `Frequency` is always set to the numeric value corresponding to `FClass` (e.g., `CFC10` → `17.0`). `AdHoc` type stores arbitrary numeric frequency.
|
||||
- **`IsoCode`**: The internal `_isoCodeFull` array is always exactly 16 characters. Any component property setter ensures its segment is exactly the correct width (1, 2, or 4 chars) by padding with `'?'` or truncating. Invalid/empty inputs default to `'?'`.
|
||||
- **`SensorCalibration`**:
|
||||
- `IsProportional` and `RemoveOffset` are forced to `false` when `NonLinear` is `true`.
|
||||
- `ZeroPoint` in `CalibrationRecord` is computed from `Poly` if possible; otherwise, it uses the stored `_zeroPoint`.
|
||||
- Serialization uses `SEPARATOR_REPLACEMENT = "__SC__"` to escape list separators.
|
||||
- **`CalibrationRecords`**: Uses `"__x__"` as primary separator and `"___xx___"` as escape sequence during serialization/deserialization.
|
||||
- **`CalibrationRecord`**: Uses `InvariantCulture` for numeric parsing and `"x_Separator_x"` as escape sequence for list separators.
|
||||
- **`DigitalInputSetting`, `DigitalOutputSetting`, `SquibSetting`**: All inherit from `SensorData` and call `SetDefaults()` during construction to ensure consistent baseline properties.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Internal Dependencies (from source)
|
||||
- **`DbOperations`**: Used for database field names (`DbOperations.*.Fields.*`), SQL command creation (`GetSQLCommand`), and stored procedure names (`DbOperationsEnum.StoredProcedure.*`).
|
||||
- **`Test.Module.Channel.Sensor`**: Referenced for `BridgeType`, `SensUnits`, and `ExcitationVoltageOptions`.
|
||||
- **`ZeroMethod`**, **`InitialOffset`**, **`LinearizationFormula`**, **`SensorData`**: Referenced but not included in the provided source files. Their definitions are assumed to exist elsewhere in the codebase.
|
||||
- **`ICalibrationRecords`**, **`ISensorCalibration`**: Interfaces implemented by `CalibrationRecords` and `SensorCalibration` respectively.
|
||||
|
||||
### External Dependencies
|
||||
- **System**: `System`, `System.ComponentModel`, `System.Data`, `System.Data.SqlClient`, `System.Globalization`, `System.Linq`, `System.Text`, `System.Xml`.
|
||||
- **Database**: SQL Server stored procedures:
|
||||
- `sp_SensorDeleteAll`
|
||||
- `sp_SensorCalibrationsDelete`
|
||||
- `sp_SensorsAnalogGet`
|
||||
- `sp_SensorsDigitalInGet`
|
||||
- `sp_SensorsSquibGet`
|
||||
- `sp_SensorsDigitalOutGet`
|
||||
|
||||
### Dependencies on this Module
|
||||
- `SensorsCollection.SensorsList` is used to retrieve sensor configurations by serial number.
|
||||
- `SensorCalibrationList.GetLatestCalibrationBySerialNumberAndExcitation` is used to retrieve calibration data.
|
||||
- `SensorRange`, `LowHigh`, `FilterClass`, `IsoCode` are likely used for parsing configuration strings and ISO codes elsewhere in the system.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`SensorRange` constructor**: Throws `InvalidDataException` for malformed input, but no validation is performed on the numeric values (e.g., `Low > Medium` is allowed).
|
||||
- **`LowHigh` constructor**: Uses `InvariantCulture` for parsing, but `SensorRange` does not specify culture—assumes current culture or default parsing behavior.
|
||||
- **`FilterClass` constructor**: Ambiguity in parsing `"1000"`: matches both `CFC600` (1000 Hz) and `CFC1000` (1650 Hz)? The code prioritizes exact numeric match (`case 1000` → `CFC600`), but `"CFC1000"` string match would take precedence if present.
|
||||
- **`IsoCode`**: Setter for `StringRepresentation` pads with `'0'` if input is shorter than 16 chars, but constructor pads with `'?'`. Inconsistent behavior.
|
||||
- **`CalibrationRecord.ZeroPoint`**: The computed value depends on `Poly.CalibrationFactor`; if `Poly` is uninitialized or `CalibrationFactor == 0`, the stored `_zeroPoint` is returned. This could lead to stale or incorrect values if `Poly` is modified after `ZeroPoint` is set.
|
||||
- **`SensorCalibrationList.GetLatestCalibrationBySerialNumberAndExcitation`**: Uses `_cachedCalibrations` if available, but this field is never populated in the provided source—likely populated elsewhere (e.g., during `Reload()` or initial load). If `_cachedCalibrations` is null, it falls back to `_calibrationList`, which may be uninitialized if `Reload()` hasn’t been called.
|
||||
- **`SensorCalibrationList.DeleteAll()`**: Clears `_calibrationList._calibrations` but does not clear `_cachedCalibrations`, potentially leaving stale data in memory.
|
||||
- **`DigitalInputSetting` constructor**: Assigns `Comment = UserValue1` (line 25), but `UserValue1` is also assigned from `DbOperations.DigitalInputSettings.Fields.UserValue1.ToString()` (line 18). This may be intentional, but could be a source of confusion.
|
||||
- **`SquibSetting` constructor**: Assigns `Comment = UserValue1` after reading from DB, but then reassigns `Comment = SerialNumber` if `Comment` is null/whitespace. This double-assignment is redundant and could be simplified.
|
||||
- **`DigitalOutputSetting.ChannelDescription`**: Setter modifies `SerialNumber` and raises `PropertyChanged("ChannelDescription")`. This is unusual—typically, a property named `ChannelDescription` would not mutate `SerialNumber`.
|
||||
- **`SensorCalibration` serialization**: Uses `SEPARATOR_REPLACEMENT = "__SC__"` to escape list separators, but `CalibrationRecord` uses `"x_Separator_x"`—different escaping schemes for nested serialization.
|
||||
- **`SensorCalibrationList` constructor**: The private constructor contains a comment indicating removed code that “appeared it would never work (wrong parameters to sql sp)”, suggesting potential instability or incomplete implementation.
|
||||
- **`SensorsCollection.GetSensorBySerialNumber`**: Does not use the `excludeBroken` parameter in the provided code—broken sensors are not filtered out despite the parameter name.
|
||||
- **`SensorCalibrationList.GetLatestCalibrationBySerialNumberAndExcitation`**: Returns `SensorCalibration.NewDigitalSC()` for digital/squib sensors, but this default calibration may not reflect actual sensor behavior (e.g., `Sensitivity=1` is arbitrary).
|
||||
@@ -0,0 +1,126 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SettingsDB/GlobalSetting.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SettingsDB/SettingsDB.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/SettingsDB/Setting.cs
|
||||
generated_at: "2026-04-16T04:30:58.292022+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f40d6df6287d52df"
|
||||
---
|
||||
|
||||
# SettingsDB
|
||||
|
||||
## Documentation: Global Settings Module (`DatabaseImport`)
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides a centralized, thread-safe mechanism for managing **application-wide (global) settings** stored in a SQL Server database. It abstracts the persistence logic for global configuration properties, ensuring that each setting is lazily loaded from the database on first access, falls back to a provided default value if missing, and caches the setting instance in memory for subsequent lookups. It is part of the `DatabaseImporter` module and serves as the canonical source for global configuration values used during database import operations.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `SettingsDB` (Static Class)
|
||||
|
||||
- **`public static string GetGlobalValue(string id, string defaultValue)`**
|
||||
Retrieves the global setting value for `id`. If the setting does not exist in the cache or database, it is created with `defaultValue`, stored in the DB, and returned. Thread-safe via singleton + lock.
|
||||
|
||||
- **`public static bool GetGlobalValueBool(string id, bool defaultValue)`**
|
||||
Retrieves the global setting as a `bool`. Converts the stored string value using `bool.TryParse`; if parsing fails, returns `defaultValue`. Thread-safe.
|
||||
|
||||
- **`public static void SetGlobalValue(string id, string value)`**
|
||||
Sets the global setting `id` to `value`. Updates the in-memory cache and persists to the database via `StoreInDB()`. Thread-safe.
|
||||
|
||||
- **`public static void SetGlobalValueBoolean(string id, bool value)`**
|
||||
Sets the global setting `id` to the string representation of `value` (using `InvariantCulture`). Updates cache and persists. Thread-safe.
|
||||
|
||||
#### `GlobalSetting` (Concrete Class, inherits `Setting`)
|
||||
|
||||
- **`public GlobalSetting(string id, string defaultPropertyValue)`**
|
||||
Constructor. Initializes a `GlobalSetting` with `PropertyType = Global`, `UserId = "SYSTEM"`, and triggers `GetPropertyValue(defaultPropertyValue)`.
|
||||
|
||||
#### `Setting` (Abstract Base Class)
|
||||
|
||||
- **`public string PropertyId { get; }`**
|
||||
Read-only identifier of the setting (e.g., `"ImportBatchSize"`).
|
||||
|
||||
- **`public string PropertyValue { get; }`**
|
||||
Current value of the setting (as `string`). *Note: No length validation is enforced at this layer.*
|
||||
|
||||
- **`public string UserId { get; }`**
|
||||
User context for the setting. For `GlobalSetting`, this is always `"SYSTEM"`.
|
||||
|
||||
- **`public void SetValue(string value)`**
|
||||
Updates `_propertyValue` and persists the change via `StoreInDB()`.
|
||||
|
||||
- **`protected abstract void GetPropertyValue(string defaultValue)`**
|
||||
Implemented by subclasses to fetch the value from the database (or other source). `GlobalSetting` implements this to query the DB.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **Singleton & Thread Safety**: `SettingsDB` is a singleton with lazy initialization. All public static methods (`GetGlobalValue`, `SetGlobalValue`, etc.) are guarded by a `lock (LOCK_OBJECT)` on the singleton instance, ensuring thread-safe access to `_settingsLookup` and DB operations.
|
||||
|
||||
- **Global Scope**: `GlobalSetting` instances are always associated with `UserId = "SYSTEM"` and `PropertyType = PropertyTypes.Global` (value `2`).
|
||||
|
||||
- **Default Fallback**: If a setting does not exist in the database, `GetPropertyValue` falls back to the provided `defaultValue`, stores it in the DB via `StoreInDB()`, and returns it.
|
||||
|
||||
- **Caching**: Once instantiated, a `Setting` object is cached in `SettingsDB._settingsLookup`. Subsequent lookups for the same `id` reuse the cached instance.
|
||||
|
||||
- **DB Schema Assumption**: The module assumes:
|
||||
- A stored procedure `sp_SettingsGet` exists, accepting `@UserId` (NVARCHAR) and `@PropertyId` (NVARCHAR), returning a result set with a column named `PropertyValue` (via `DbOperations.Settings.UserFields.PropertyValue`).
|
||||
- A stored procedure `sp_SettingsUpdateInsert` exists, accepting parameters: `@PropertyId`, `@PropertyType`, `@PropertyValue`, `@UserId`, `@new_id` (OUTPUT), `@errorNumber` (OUTPUT), `@errorMessage` (OUTPUT). All string parameters are NVARCHAR(255).
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### **Dependencies *of* this module:**
|
||||
- `System.Data` and `System.Data.SqlClient` (for `SqlDataAdapter`, `SqlCommand`, `SqlParameter`, `SqlDbType`, etc.)
|
||||
- `DbOperations` (static class, not shown) — provides:
|
||||
- `GetSQLCommand(bool)` → returns `SqlCommand`
|
||||
- `Connection.QueryDataSet(SqlCommand)` → returns `DataSet`
|
||||
- `Settings.UserFields.PropertyValue` → string constant for column name (e.g., `"PropertyValue"`)
|
||||
- `DbOperationsEnum.StoredProcedure.sp_SettingsGet`, `sp_SettingsUpdateInsert` → enum values for stored procedure names.
|
||||
|
||||
#### **Dependencies *on* this module:**
|
||||
- Any code requiring global configuration (e.g., import batch size, timeout, feature flags) calls `SettingsDB.GetGlobalValue(...)` or `GetGlobalValueBool(...)`.
|
||||
|
||||
#### **Inferred callers:**
|
||||
- `DatabaseImporter` module (e.g., import pipeline components that read global settings like `"MaxRetryCount"`, `"DefaultSchema"`).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **Exception Handling is Minimal**:
|
||||
`GetPropertyValue` and `StoreInDB` both catch `Exception` and silently fall back to `defaultValue` or do nothing, respectively. No logging is active (commented-out `APILogger.LogException` suggests future intent). This makes debugging DB issues difficult.
|
||||
|
||||
- **No Validation on Value Length**:
|
||||
`PropertyValue` is stored as `NVARCHAR(255)` in DB calls, but no validation occurs in `Setting` or `GlobalSetting`. Passing a >255-character value may cause a DB error (silently ignored in `StoreInDB`).
|
||||
|
||||
- **Race Condition in Initialization (Low Risk)**:
|
||||
While `GetGlobalValue` locks before checking `_settingsLookup`, the *first* call for a new `id` creates a new `GlobalSetting` *inside* the lock. However, `GlobalSetting` constructor calls `GetPropertyValue`, which performs a DB round-trip *while holding the lock*. This can cause contention if many settings are requested concurrently for the first time.
|
||||
|
||||
- **Hardcoded `"SYSTEM"` User**:
|
||||
`GlobalSetting` hardcodes `UserId = "SYSTEM"`. This is not configurable and assumes all global settings are owned by a system user.
|
||||
|
||||
- **`_allGlobalSetting` Cache is Unused**:
|
||||
The `GetPropertyValue` method contains commented-out code for a `_allGlobalSetting` cache. This suggests a previous optimization attempt that was reverted or incomplete — the current implementation hits the DB on *every* first access for a new `id`.
|
||||
|
||||
- **Culture-Specific Boolean Parsing**:
|
||||
`GetGlobalValueBool` uses `defaultValue.ToString(CultureInfo.InvariantCulture)` for the fallback string, but `bool.TryParse` is culture-insensitive for `"True"/"False"`. This is safe, but the use of `InvariantCulture` here is redundant and could mislead.
|
||||
|
||||
- **No Explicit Disposal of `Setting` Instances**:
|
||||
`Setting` instances are stored in `_settingsLookup` and never removed. If settings are frequently added/removed at runtime, this could lead to memory leaks.
|
||||
|
||||
- **No Distinction Between `null` and Empty String**:
|
||||
If the DB stores `NULL` for `PropertyValue`, `Convert.ToString(...)` returns `""` (empty string), not `null`. This may or may not be intended.
|
||||
|
||||
---
|
||||
|
||||
*Documentation generated from provided source files. No external assumptions or behaviors inferred beyond what is explicitly present.*
|
||||
@@ -0,0 +1,198 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Storage/IDbTimeStampAware.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Storage/DbOperationsEnum.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Storage/DbOperations.cs
|
||||
generated_at: "2026-04-16T04:30:21.712903+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "604c24fe0c2a5ffe"
|
||||
---
|
||||
|
||||
# Storage
|
||||
|
||||
## Documentation: `DatabaseImport` Storage Module
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides foundational infrastructure for database versioning, timestamp tracking, and database abstraction within the `DatabaseImport` subsystem. Its primary role is to enable consistent detection of data staleness (via `IDbTimeStampAware`) and to centralize database operation utilities (via `DbOperations`), including stored procedure enumeration (`DbOperationsEnum`), database schema metadata (via nested `abstract class` enums), and connection management. It supports both local and centralized SQL Server databases, with authentication configurable at runtime.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `IDbTimeStampAware` Interface
|
||||
*Defined in `IDbTimeStampAware.cs`*
|
||||
|
||||
- **`long GetTimeStampMemory()`**
|
||||
Returns the in-memory timestamp value (stored in the protected `DbTimeStamp` field).
|
||||
|
||||
- **`void SetTimeStampMemory(long value)`**
|
||||
Sets the in-memory timestamp to `value`.
|
||||
|
||||
- **`long GetTimeStampDb()`**
|
||||
Returns the database timestamp for the current object. *Currently unimplemented* — always returns `0`. The commented-out code suggests it was intended to query a database table (`tblDbVersions` or similar) using constraints derived from `GetConstraints()` (not present in this file).
|
||||
|
||||
- **`bool IsOutOfDate()`**
|
||||
Compares the in-memory and database timestamps. Returns `true` if the database timestamp (`db`) is non-zero and differs from the in-memory timestamp (`mem`). If `mem == 0` and `db != 0`, it auto-updates `mem` to `db` before comparison.
|
||||
|
||||
#### `DbTimeStampBase` Abstract Class
|
||||
*Defined in `IDbTimeStampAware.cs`*
|
||||
|
||||
- **`event PropertyChangedEventHandler PropertyChanged`**
|
||||
Implements `INotifyPropertyChanged`. Notifies listeners of property changes.
|
||||
|
||||
- **`protected bool SetProperty<T>(ref T storage, T value, string propertyName = null)`**
|
||||
Sets `storage` to `value` if different, raises `PropertyChanged`, and returns `true`. Otherwise returns `false`.
|
||||
|
||||
- **`protected void OnPropertyChanged(string propertyName = null)`**
|
||||
Invokes the `PropertyChanged` event with the given property name.
|
||||
|
||||
- **`public long GetTimeStampMemory()`**
|
||||
Returns the current value of the protected field `DbTimeStamp`.
|
||||
|
||||
- **`public void SetTimeStampMemory(long value)`**
|
||||
Sets `DbTimeStamp` to `value`.
|
||||
|
||||
- **`public void SetTimeStampMemory(DataRow row)`**
|
||||
Sets `DbTimeStamp` to `0`. *No-op beyond assignment*.
|
||||
|
||||
- **`public void SetTimeStampMemory(IDataReader reader)`**
|
||||
Sets `DbTimeStamp` to `0`. *No-op beyond assignment*.
|
||||
|
||||
- **`public long GetTimeStampDb(Dictionary<string, long> lookup)`**
|
||||
Returns `0`. *Unimplemented*. Commented-out code suggests lookup by constraint values.
|
||||
|
||||
- **`public long GetTimeStampDb()`**
|
||||
Returns `0`. *Unimplemented*. Commented-out code shows intended SQL query logic.
|
||||
|
||||
#### `DbOperationsEnum.StoredProcedure` Enum
|
||||
*Defined in `DbOperationsEnum.cs`*
|
||||
|
||||
- **`StoredProcedure` enum**
|
||||
Lists all stored procedure names used in the system (e.g., `sp_UserDelete`, `sp_DBImportUsers`, `sp_TestSetupsUpdateInsert`). Used to parameterize stored procedure calls.
|
||||
|
||||
#### `DbOperations` Class
|
||||
*Defined in `DbOperations.cs`*
|
||||
|
||||
- **`public const int CURRENT_DB_VERSION = 61`**
|
||||
Hardcoded current database schema version.
|
||||
|
||||
- **`public static bool _usingCentralizedDB`**
|
||||
`true` if using a remote centralized server; `false` for local `SqlLocalDb`.
|
||||
|
||||
- **`public static bool _usingMSSQL`**
|
||||
`true` if using Microsoft SQL Server.
|
||||
|
||||
- **`public static bool _usingNTLMAuthentication`**
|
||||
`true` if using Windows Authentication (NTLM); otherwise SQL authentication.
|
||||
|
||||
- **`public static string _previousDir`**
|
||||
Stores the previous working directory (unused in current code).
|
||||
|
||||
- **`public static DbOperations Connection`**
|
||||
Singleton instance of `DbOperations`. Thread-safe via `lock(dbLock)`.
|
||||
|
||||
- **`public static SqlCommand GetSQLCommand(bool newCommand = false)`**
|
||||
Returns a `SqlCommand` instance, reusing `_cmd` unless `newCommand` is `true`. Automatically opens a connection using `Connection.GetLocalConnectionString()` if needed.
|
||||
|
||||
- **`public static bool IsServerConnected()`**
|
||||
Returns `true` if a connection to the local database (via `Connection.GetLocalConnectionString()`) succeeds.
|
||||
|
||||
- **`public DataSet QueryDataSet(SqlCommand icmd)`**
|
||||
Executes `icmd` and returns results in a `DataSet`. Throws exceptions on failure.
|
||||
|
||||
- **`public string GetLocalConnectionString()`**
|
||||
Builds and caches the connection string based on `_usingNTLMAuthentication`, `Server`, `DBName`, `Username`, and `Password`. Throws if connection not initialized.
|
||||
|
||||
- **`public string Server`, `Username`, `Password`, `DBName`**
|
||||
Properties used to configure connection parameters.
|
||||
|
||||
#### Nested Abstract Classes (Schema Metadata)
|
||||
*Defined in `DbOperations.cs`*
|
||||
|
||||
These provide strongly-typed field names and database column metadata for various tables. All use `enum` fields annotated with `[DbTypeAttr(...)]` where applicable.
|
||||
|
||||
- **`Tags.TagFields`**
|
||||
`TagId`, `TagText`, `Obsolete`
|
||||
|
||||
- **`DbVersions.DbVersionFields`**
|
||||
`Version`, `Step`, `Date`, `Remarks`, `UserField`
|
||||
|
||||
- **`Settings.UserFields`**
|
||||
`PropertyId`, `PropertyType`, `PropertyValue`, `UserId`
|
||||
|
||||
- **`Users.UserFields`**, **`Users.UIItemFields`**
|
||||
User and UI item schema fields.
|
||||
|
||||
- **`SensorDB.*Fields`**
|
||||
Sensor, SensorModel, and SensorCalibration schema fields (e.g., `SerialNumber`, `Model`, `CalibrationDate`).
|
||||
|
||||
- **`CalculatedChannels.Fields`**
|
||||
Includes `[DbTypeAttr(...)]` annotations (e.g., `Id` → `"INTEGER PRIMARY KEY NOT NULL"`).
|
||||
|
||||
- **`LevelTriggers.Fields`**
|
||||
Trigger configuration fields (e.g., `GreaterThanEU`, `TriggerInside`).
|
||||
|
||||
- **`TestSetups.*Fields`**
|
||||
Test setup, hardware, channel settings, graphs, and object metadata fields.
|
||||
|
||||
- **`DigitalOutputSettings.Fields`**, **`Squib.Fields`**, **`DigitalInputSettings.Fields`**
|
||||
Device-specific configuration fields.
|
||||
|
||||
- **`MMETables.*Fields`**
|
||||
MME (likely "Measurement Management Environment") lookup table fields (e.g., `MMEFineLocations1Fields`, `MMETestObjectsFields`).
|
||||
|
||||
- **`DAS.Fields`**, **`DAS.DASChannelFields`**
|
||||
DAS (Data Acquisition System) device and channel schema fields.
|
||||
|
||||
#### `DbTypeAttr` Attribute
|
||||
*Defined in `DbOperations.cs`*
|
||||
|
||||
- **`public static string GetDbType(object o)`**
|
||||
Retrieves the `DbType` string from a `[DbTypeAttr(...)]`-annotated enum value.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **`DbTimeStamp` is always initialized to `0`** on construction or via `SetTimeStampMemory(DataRow)`/`SetTimeStampMemory(IDataReader)`.
|
||||
- **`IsOutOfDate()` never returns `true` if `GetTimeStampDb()` returns `0`**, even if `GetTimeStampMemory() != 0`.
|
||||
- **`GetTimeStampDb()` always returns `0`** — the implementation is stubbed and untested.
|
||||
- **`DbOperations.Connection` is a singleton** — only one instance exists per AppDomain.
|
||||
- **`_usingCentralizedDB`, `_usingMSSQL`, `_usingNTLMAuthentication` are global flags** — changing them affects all subsequent connection attempts.
|
||||
- **`CURRENT_DB_VERSION` is fixed at compile time** — no runtime schema migration logic is visible in this module.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### *This Module Depends On*
|
||||
- `System.Data` (for `DataSet`, `SqlDataAdapter`, `SqlDataReader`, `DataRow`, `ConnectionState`)
|
||||
- `System.Data.SqlClient` (for `SqlConnection`, `SqlCommand`)
|
||||
- `System.ComponentModel` (for `INotifyPropertyChanged`)
|
||||
- `System` (for `Attribute`, `Exception`, `StringBuilder`, `BitConverter`, `Trace`, `Dictionary`, `string`)
|
||||
|
||||
#### *This Module Is Used By*
|
||||
- Any module requiring database timestamp checks (e.g., import/export logic, cache invalidation).
|
||||
- Modules that execute stored procedures (via `DbOperationsEnum.StoredProcedure`).
|
||||
- Modules that construct SQL queries or map database rows to objects (via `DbOperations.*Fields` enums).
|
||||
- UI layers that bind to objects implementing `IDbTimeStampAware` (for change tracking).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **`GetTimeStampDb()` is unimplemented** — always returns `0`. This renders `IsOutOfDate()` effectively useless for detecting *real* DB staleness unless the caller manually populates `DbTimeStamp` and assumes DB matches memory.
|
||||
- **`SetTimeStampMemory(DataRow)` and `SetTimeStampMemory(IDataReader)` ignore their inputs** — they unconditionally set `DbTimeStamp = 0`, which may be unintentional.
|
||||
- **`GetTimeStampDb(Dictionary<string, long> lookup)` is unimplemented** — the `lookup` parameter is unused.
|
||||
- **`DbOperations.Connection` is a singleton with mutable state** — `Server`, `Username`, `Password`, `DBName` are settable properties, but not thread-safe for concurrent reconfiguration.
|
||||
- **`_cmd` is a static field reused across calls** — calling `GetSQLCommand()` without `newCommand: true` may cause parameter leakage between queries if callers do not clear parameters.
|
||||
- **`IsServerConnected()` only tests the *local* connection string** — if `_usingCentralizedDB == true`, it may not reflect connectivity to the remote server.
|
||||
- **`CURRENT_DB_VERSION` is hardcoded** — no schema versioning logic (e.g., migration, upgrade checks) is present in this module.
|
||||
- **No actual database access occurs in `DbTimeStampBase`** — all DB-related methods are stubbed. Real DB logic may reside elsewhere (not visible here).
|
||||
- **`DbTypeAttr.GetDbType()` relies on reflection** — may be slow or fail if enum values lack attributes or are not defined in the expected way.
|
||||
|
||||
None identified beyond the above.
|
||||
@@ -0,0 +1,98 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Users/User.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Users/ITagAware.cs
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Users/Tags.cs
|
||||
generated_at: "2026-04-16T04:30:38.280273+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f22aee5e7f816592"
|
||||
---
|
||||
|
||||
# Users
|
||||
|
||||
## Documentation: `User` Class and Related Tag Infrastructure
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
This module provides foundational data structures for handling *tag-aware* entities—specifically, the `User` class, which represents a single user in the system and inherits tag-related functionality from `TagAwareBase`. Tags are metadata labels (ID + text) used to categorize or annotate entities; they are immutable in structure (no delete/modify operations, only add) and stored in a binary blob (`TagsBlobBytes`) for efficient serialization/deserialization. The module supports importing user data (and by extension, other tag-aware entities) from database records via `IDataRecord`, and enables cloning of tag definitions.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `class User : TagAwareBase`
|
||||
- **Inherits** all members of `TagAwareBase` (see below).
|
||||
- **No additional public members** declared in the provided source.
|
||||
- **Purpose**: Encapsulates a single user; tag-related behavior is inherited.
|
||||
|
||||
#### `interface ITagAware`
|
||||
- **Empty interface**.
|
||||
- **Purpose**: Marker interface for classes that support tagging. No methods or properties defined.
|
||||
|
||||
#### `abstract class TagAwareBase : DbTimeStampBase`
|
||||
*(Note: `DbTimeStampBase` is referenced but not defined in the provided source—its members are unknown.)*
|
||||
- **`public int[] TagIDs { get; set; }`**
|
||||
- Gets/sets an array of integer tag IDs associated with the entity.
|
||||
- Setter is null-safe: assigns `new int[0]` if `value` is `null`.
|
||||
- **`public byte[] TagsBlobBytes { get; set; }`**
|
||||
- **Getter**: Converts `TagIDs` to a `byte[]` via `Buffer.BlockCopy` (int array → bytes).
|
||||
- **Setter**: Attempts to reconstruct `TagIDs` from a `byte[]` by interpreting bytes as `int` values.
|
||||
- Silently returns if `value.Length < sizeof(int)` (i.e., < 4 bytes).
|
||||
- Silently ignores exceptions during `Buffer.BlockCopy` (no rethrow or logging—commented-out `APILogger.Log` suggests intentional suppression).
|
||||
|
||||
#### `class Tags.Tag : ICloneable`
|
||||
*(Nested within `Tags` class)*
|
||||
- **`public int ID { get; set; }`**
|
||||
- Unique identifier for the tag.
|
||||
- **`public string Text { get; set; }`**
|
||||
- Human-readable label for the tag.
|
||||
- **`public bool IsObsolete { get; set; }`**
|
||||
- Indicates whether the tag is deprecated (but not deleted).
|
||||
- **`public Tag(Tag copy)`**
|
||||
- Copy constructor: initializes fields from another `Tag` instance.
|
||||
- **`public Tag(IDataRecord reader)`**
|
||||
- Constructor that populates the `Tag` from a database record.
|
||||
- Reads fields via `DbOperations.Tags.TagFields` enum (values: `TagId`, `Obsolete`, `TagText`).
|
||||
- Silently ignores exceptions during parsing (commented-out logging).
|
||||
- **`public object Clone()`**
|
||||
- Returns a shallow copy of the `Tag` via the copy constructor.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
- **`TagIDs` is never `null`**: The setter enforces `value ?? new int[0]`.
|
||||
- **`TagsBlobBytes` ↔ `TagIDs` consistency**:
|
||||
- Getter always produces a `byte[]` of length `TagIDs.Length * sizeof(int)`.
|
||||
- Setter *attempts* to restore `TagIDs` from `TagsBlobBytes`, but may silently fail (e.g., if `value.Length` is not a multiple of `sizeof(int)` or contains invalid data).
|
||||
- **Tag immutability constraints**:
|
||||
- Tags are *not* deletable or editable (per `Tags.cs` summary). Only new tags may be added.
|
||||
- `IsObsolete` is a flag but does not imply deletion; obsolete tags remain in the system.
|
||||
- **`DbTimeStampBase` inheritance**: `TagAwareBase` inherits from `DbTimeStampBase` (not shown), implying timestamp-related fields (e.g., `Created`, `Modified`) are expected but not defined here.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
- **Internal dependencies**:
|
||||
- `DbOperations.Tags.TagFields` enum (used in `Tags.Tag` constructor).
|
||||
- `DbTimeStampBase` (base class of `TagAwareBase`; not provided).
|
||||
- `APILogger` (referenced in commented-out logging statements; assumed external).
|
||||
- **External dependencies**:
|
||||
- `System` (for `Buffer`, `Exception`, `ICloneable`).
|
||||
- `System.Data` (for `IDataRecord`).
|
||||
- **Depended upon by**:
|
||||
- `User` (direct consumer of `TagAwareBase`).
|
||||
- Likely other tag-aware entities (e.g., `Project`, `Asset`) not included in this source set.
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
- **Silent failure in `TagsBlobBytes` setter**: Exceptions during deserialization are caught and ignored—no error is surfaced to callers. This may mask data corruption or schema mismatches.
|
||||
- **No validation of `TagIDs`**: The `TagIDs` array may contain IDs that do not correspond to valid tags (no cross-reference validation).
|
||||
- **`IsObsolete` is not enforced**: While tags *can* be marked obsolete, the system does not prevent their use (e.g., assignment to users).
|
||||
- **`TagAwareBase` inherits from `DbTimeStampBase`**: Behavior of timestamp fields is undefined here; assume they exist but require external documentation.
|
||||
- **`Tags` class is not a collection**: Despite its name, `Tags` only defines the `Tag` inner class—no methods for managing a set of tags (e.g., add/remove/lookup). Tag management is implied to occur elsewhere.
|
||||
- **No thread-safety guarantees**: `TagsBlobBytes` and `TagIDs` use simple field access; concurrent modification risks exist if shared across threads.
|
||||
|
||||
*None identified beyond the above.*
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Utilities/DiskUtility.cs
|
||||
generated_at: "2026-04-16T04:30:13.126152+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f18ece9cd807d7b1"
|
||||
---
|
||||
|
||||
# Utilities
|
||||
|
||||
## 1. Purpose
|
||||
`DiskUtility` is a static utility class providing disk-related validation logic for file and path names within the `DatabaseImport` module. Its primary role is to enforce naming constraints on file and directory names used during database import operations—specifically, to reject names containing any characters deemed invalid by the .NET runtime *and* any period (`.`) characters, which are explicitly disallowed beyond standard OS restrictions. This helps prevent filesystem errors and potential security issues (e.g., path traversal, ambiguous extensions) during file I/O operations.
|
||||
|
||||
## 2. Public Interface
|
||||
- **`bool ValidateFileAndPathNameChars(string nameToValidate)`**
|
||||
Validates whether the input string is a permissible file or path name. Returns `false` if:
|
||||
- The trimmed string is empty or whitespace-only,
|
||||
- It contains *any* character returned by `Path.GetInvalidFileNameChars()`,
|
||||
- It contains *any* character returned by `Path.GetInvalidPathChars()`,
|
||||
- It contains a period (`.`) character anywhere in the string.
|
||||
Returns `true` only if all checks pass.
|
||||
|
||||
## 3. Invariants
|
||||
- **Empty/whitespace rejection**: Any input that trims to zero length is invalid.
|
||||
- **Strict character filtering**: The presence of *any* invalid filename *or* path character (as defined by `Path.GetInvalidFileNameChars()` and `Path.GetInvalidPathChars()` for the current platform) causes failure.
|
||||
- **Period prohibition**: The literal `'.'` character is *always* invalid, regardless of context (e.g., even in otherwise valid names like `"file.txt"` or `"."`), per the explicit `Contains('.')` check.
|
||||
- **No partial validation**: The method performs *all* checks and returns `false` on the *first* failure encountered (due to short-circuiting via `bValid = false` without early exit), but the logic ensures *all* invalid conditions are evaluated before returning.
|
||||
|
||||
## 4. Dependencies
|
||||
- **Imports**: `System.IO` (for `Path.GetInvalidFileNameChars()`, `Path.GetInvalidPathChars()`), `System.Linq` (for `Contains()` extension method on `string`).
|
||||
- **Usage context**: Inferred to be used by other components in the `DatabaseImport` namespace (e.g., import pipeline logic that constructs file paths from user input or metadata). No external dependencies beyond the .NET runtime.
|
||||
- **Dependents**: Not specified in source; must be determined via codebase search for `DiskUtility.ValidateFileAndPathNameChars`.
|
||||
|
||||
## 5. Gotchas
|
||||
- **Overly restrictive period check**: The explicit ban on `.` prevents valid names like `"data"` (if followed by an extension in practice) or `"."` (for current directory), but also blocks *all* extensions (e.g., `"file.csv"` fails). This may conflict with standard filesystem behavior where `.` is only invalid in *certain* positions (e.g., not at the start/end of a filename on Windows).
|
||||
- **No early exit**: The method sets `bValid = false` but continues iterating through all invalid characters—even after failure—resulting in unnecessary work.
|
||||
- **Case sensitivity**: `Contains()` is case-sensitive by default; if `nameToValidate` contains uppercase invalid characters (e.g., `':'` is invalid on Windows), it will still be caught, but this behavior is platform-dependent (e.g., `Path.GetInvalidFileNameChars()` returns platform-specific invalid chars).
|
||||
- **No distinction between filename vs. path**: The method validates *both* filename and path characters in one pass, but a path like `"C:\folder\file"` contains `\` (valid in paths but *invalid* in filenames). This may cause false negatives for legitimate paths.
|
||||
- **Commented-out base class**: The class declaration is `public class DiskUtility //: Exceptional`, suggesting past inheritance from an `Exceptional` type (possibly for error handling), but this is inactive. No exception-throwing behavior is present.
|
||||
- **No localization or culture considerations**: Relies on `string.Contains(char)`, which is culture-invariant for `char`, but the underlying `Path.GetInvalid*Chars()` results depend on the OS/runtime environment.
|
||||
Reference in New Issue
Block a user