284 lines
14 KiB
Markdown
284 lines
14 KiB
Markdown
---
|
|
source_files:
|
|
- Common/DTS.Common.DataModel/Classes/Hardware/DASSettings.cs
|
|
- Common/DTS.Common.DataModel/Classes/Hardware/DASHardwareList.cs
|
|
- Common/DTS.Common.DataModel/Classes/Hardware/BatteryAndInputVoltageDefaults.cs
|
|
generated_at: "2026-04-16T03:33:19.361594+00:00"
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
|
schema_version: 1
|
|
sha256: "ea5a7a11d2e6d80b"
|
|
---
|
|
|
|
# Documentation: DAS Hardware and Configuration Data Models
|
|
|
|
## 1. Purpose
|
|
|
|
This module provides core data models and utility classes for managing Data Acquisition System (DAS) hardware configuration and settings within the DataPROWin7 system. It defines structured representations of DAS hardware components (`DASHardware`, referenced indirectly), their specific settings (`DASSettings`), and battery/input voltage thresholds (`DasBatteryInputSettings`), enabling serialization to/from the database (`tblTestSetupDASSettings`), caching for performance optimization during bulk operations, and type-specific default configuration retrieval. The module serves as the data layer abstraction for DAS hardware state and configuration across test setup, validation, and execution workflows.
|
|
|
|
## 2. Public Interface
|
|
|
|
### `DASSettings` (in `DataPROWin7.DataModel` namespace)
|
|
|
|
- **`DASSettings()`**
|
|
Default constructor. Initializes an empty instance.
|
|
|
|
- **`DASSettings(DASSettings setting)`**
|
|
Copy constructor. Copies all property values from the provided `setting` instance.
|
|
|
|
- **`string DASSerialNumber { get; set; }`**
|
|
Serial number of the DAS device. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double SampleRate { get; set; }`**
|
|
Sample rate in Hz. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`int ExcitationWarmupTimeMS { get; set; }`**
|
|
Excitation warm-up time in milliseconds. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double HardwareAAF { get; set; }`**
|
|
Hardware Anti-Aliasing Filter (AAF) setting. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double PreTriggerSeconds { get; set; }`**
|
|
Duration of pre-trigger buffer in seconds. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double PostTriggerSeconds { get; set; }`**
|
|
Duration of post-trigger buffer in seconds. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`bool StatusLineCheck { get; set; }`**
|
|
Flag indicating whether status line monitoring is enabled. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`bool BatteryCheck { get; set; }`**
|
|
Flag indicating whether battery voltage checks are enabled. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double InputVoltageMin { get; set; }`**
|
|
Minimum acceptable input voltage threshold. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double InputVoltageMax { get; set; }`**
|
|
Maximum acceptable input voltage threshold. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double BatteryVoltageMin { get; set; }`**
|
|
Minimum acceptable battery voltage threshold. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
- **`double BatteryVoltageMax { get; set; }`**
|
|
Maximum acceptable battery voltage threshold. Serialized to `tblTestSetupDASSettings`.
|
|
|
|
> **Note**: All properties use `SetProperty` (inherited from `BasePropertyChanged`) for change notification.
|
|
|
|
---
|
|
|
|
### `DASHardwareList` (in `DataPROWin7.DataModel.Classes.Hardware` namespace)
|
|
|
|
- **`static bool Cache { get; set; }`**
|
|
Enables/disables database caching. When `true`, hardware lookups use in-memory cache instead of querying the database. Setting to `false` clears `_cachedDASHardware`.
|
|
|
|
- **`static DASHardwareList GetList()`**
|
|
Returns the singleton instance of `DASHardwareList`. Does *not* auto-populate hardware (commented-out `PopulateHardware()` call).
|
|
|
|
- **`void ReloadAll()`**
|
|
Placeholder method (implementation commented out). Intended to reload hardware list.
|
|
|
|
- **`void SetCache(ICachedContainer container)`**
|
|
Sets the `_cachedHardware` field for use in `GetHardware(string, bool, out bool, bool)`.
|
|
|
|
- **`void ClearCache()`**
|
|
Clears `_cachedHardware`.
|
|
|
|
- **`string GetDASSerialNumberFromId(int id)`**
|
|
Retrieves the serial number for a given DAS ID by querying `DbOperations.DASGet`. Returns empty string if not found.
|
|
|
|
- **`DASHardware GetHardware(int id)`**
|
|
Retrieves `DASHardware` by ID using `GetDASSerialNumberFromId(id)` → `GetHardware(string)`.
|
|
|
|
- **`DASHardware GetHardware(string id, bool bUseCache = true)`**
|
|
Retrieves `DASHardware` by serial number (or key like `"SN_type"`), optionally using cache.
|
|
|
|
- **`DASHardware[] GetHardware(string[] ids, bool bUseCache = true)`**
|
|
Batch retrieval of `DASHardware` instances.
|
|
|
|
- **`DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache = true)`**
|
|
Core retrieval logic. Checks `_cachedHardware` and `_cachedDASHardware` if caching is enabled. Falls back to `DTS.Common.ISO.Hardware.GetAllDAS(id, null)`. Sets `changed = false` unconditionally.
|
|
|
|
- **`class HardwareTypeChangedException : Exception`**
|
|
Exception type declared but never thrown in source.
|
|
|
|
- **`DASHardware GetHardware(string serialNumber, string ipaddress)`**
|
|
Ignores `ipaddress` and delegates to `GetHardware(serialNumber)`.
|
|
|
|
- **`void UpdateMaxMemory(DASHardware h, long newMaxMemory)`**
|
|
Updates `MaxMemory` on the underlying `DTS.Common.ISO.Hardware` object and calls `Update()`.
|
|
|
|
- **`DASHardware GetPrototypeHardware(string serial, int type)`**
|
|
Retrieves prototype hardware using key `"{serial}_{type}"` and `DbOperations.DAS.PROTOTYPE_POSITION`. Sets `CalDate = DateTime.MinValue`.
|
|
|
|
- **`static DASHardware[] GetAllHardware()`**
|
|
Retrieves all DAS hardware via `DTS.Common.ISO.Hardware.GetAllDAS()`. Caches result if `Cache == true`.
|
|
|
|
- **`static List<int> GetEmbeddedModules(IDASHardware[] hardware, int id)`**
|
|
Returns list of `DASId`s of modules whose `Connection` starts with the serial number of the hardware identified by `id`.
|
|
|
|
- **`static Dictionary<string, double> GetEmbeddedModuleInfo(DASHardware[] hardware, int id)`**
|
|
Returns dictionary mapping serial numbers of embedded modules to their `GetMaxSampleRateDouble()` values.
|
|
|
|
- **`enum Tags { Hardware }`**
|
|
Tag used in `OnPropertyChanged` calls.
|
|
|
|
- **`void Commit(DASHardware hardware, bool bExisting = false, bool bCheckExisting = true, bool Unassociate = true)`**
|
|
Persists `DASHardware` state to database via `DTS.Common.ISO.Hardware`.
|
|
- If `Unassociate == true` and `IsPseudoRack()`, calls `UnassociateParentDAS`.
|
|
- If `bCheckExisting == true`, sets `bExisting` based on `DASHardware.GetDataBaseID`.
|
|
- Inserts if `!bExisting`, otherwise updates with incremented `Version`.
|
|
- Raises `OnPropertyChanged(Tags.Hardware.ToString())`.
|
|
|
|
- **`void Delete(IHardware hardware)`**
|
|
Deletes via `IISOHardware.Delete()` if supported.
|
|
|
|
- **`void Delete(DASHardware hardware)`**
|
|
Deletes underlying `ISO.Hardware`, and if `IsPseudoRack()`, calls `UnassociateParentDAS`.
|
|
|
|
- **`void Delete(IHardware[] hardware)` / `void Delete(DASHardware[] hardware)`**
|
|
Batch deletion helpers.
|
|
|
|
- **`static void UnassociateParentDAS(string distributorSerialNumber)`**
|
|
Executes stored procedure `sp_DASChildrenUnAssociate` to remove child associations for the given distributor.
|
|
|
|
---
|
|
|
|
### `DasBatteryInputSettings` (in `DataPROWin7.DataModel.BatteryAndInputVoltageDefaults` namespace)
|
|
|
|
- **`enum Settings`**
|
|
Ordered list of 14 battery/input voltage thresholds. **Order matters for serialization**:
|
|
- `BatteryLowDiagnosticsThreshold`
|
|
- `BatteryHighDiagnosticsThreshold`
|
|
- `BatteryLowArmedThreshold`
|
|
- `BatteryHighArmedThreshold`
|
|
- `InputLowDiagnosticsThreshold`
|
|
- `InputHighDiagnosticsThreshold`
|
|
- `InputLowArmedThreshold`
|
|
- `InputHighArmedThreshold`
|
|
- `MinimumValidBatteryThreshold`
|
|
- `MinimumValidInputThreshold`
|
|
- `MaximumValidBatteryThreshold`
|
|
- `MaximumValidInputThreshold`
|
|
- `BatteryMediumDiagnosticsThreshold`
|
|
- `BatteryMediumArmedThreshold`
|
|
- `InputMediumDiagnosticsThreshold`
|
|
- `InputMediumArmedThreshold`
|
|
|
|
- **Properties (14 total)**
|
|
Each has a `get`/`set` that wraps `GetValue(Settings)` / `SetValue(Settings, double)`.
|
|
|
|
- **`Dictionary<Settings, double> SettingsProperty { get; }`**
|
|
Internal storage for settings.
|
|
|
|
- **`DasBatteryInputSettings(string s)`**
|
|
Parses comma-separated string into settings (assumes order matches `Settings` enum). Uses `double.TryParse(..., CultureInfo.InvariantCulture)`.
|
|
|
|
- **`DasBatteryInputSettings(DasBatteryInputSettings copy)`**
|
|
Copy constructor.
|
|
|
|
- **`DasBatteryInputSettings()`**
|
|
Initializes with hardcoded defaults (e.g., `BatteryLowArmedThreshold = 6.8`, `InputHighArmedThreshold = 15.3`, etc.). Throws `NotSupportedException` for unknown settings.
|
|
|
|
- **`string ToSerializedString()`**
|
|
Serializes settings in `Settings` enum order to comma-separated string.
|
|
|
|
- **`double GetValue(Settings setting)`**
|
|
Returns value for `setting`. Throws `NotSupportedException` if missing.
|
|
|
|
- **`void SetValue(Settings setting, double d)`**
|
|
Sets value for `setting`.
|
|
|
|
---
|
|
|
|
### `InputAndBatterySettings` (static class, same namespace)
|
|
|
|
- **`static Dictionary<HardwareTypes, DasBatteryInputSettings> _cache`**
|
|
Cache of settings per hardware type.
|
|
|
|
- **`static void ClearCache()`**
|
|
Clears `_cache`.
|
|
|
|
- **`static double GetValue(string DasType, DasBatteryInputSettings.Settings setting)`**
|
|
Parses `DasType` to `HardwareTypes`, then calls `GetValue(HardwareTypes, Settings)`. Returns `double.NaN` on parse failure.
|
|
|
|
- **`static DasBatteryInputSettings GetDefaultSettingForHWType(HardwareTypes type)`**
|
|
Returns *default* settings for `type` from `Common.SerializedSettings.*_PowerSetting_Default` fields. Caches if `RunTestVariables.InRunTest && CacheVoltageSettingsInRunTest`. Throws `NotSupportedException` if type unsupported.
|
|
|
|
- **`static void SetSettingForHWType(HardwareTypes type, DasBatteryInputSettings setting)`**
|
|
Assigns `setting` to corresponding `Common.SerializedSettings.*_PowerSetting` field.
|
|
|
|
- **`static DasBatteryInputSettings GetSettingForHWType(HardwareTypes type)`**
|
|
Returns *current* (possibly overridden) settings for `type` from `Common.SerializedSettings.*_PowerSetting` fields. Caches if applicable. Throws `NotSupportedException` if type unsupported.
|
|
|
|
- **`static double GetValue(HardwareTypes type, DasBatteryInputSettings.Settings setting)`**
|
|
Returns `GetSettingForHWType(type).GetValue(setting)`.
|
|
|
|
## 3. Invariants
|
|
|
|
- **`DASSettings`**
|
|
- All properties are nullable (no validation constraints enforced in class).
|
|
- Serialization format is fixed: properties map directly to columns in `tblTestSetupDASSettings`.
|
|
- Property names match exactly those used in `SetProperty` calls (case-sensitive).
|
|
|
|
- **`DASHardwareList`**
|
|
- `Cache` flag controls whether `_cachedDASHardware` is populated/used. Setting `Cache = false` clears `_cachedDASHardware`.
|
|
- `GetHardware(string, bool, out bool, bool)` *always* sets `changed = false`; the `bThrowExceptionIfChanged` parameter is unused.
|
|
- `Commit` assumes `DASHardware` wraps a valid `DTS.Common.ISO.Hardware` instance.
|
|
- `UnassociateParentDAS` is called only for pseudo-rack hardware during `Commit` or `Delete`.
|
|
|
|
- **`DasBatteryInputSettings`**
|
|
- `Settings` enum order *must not change* without updating serialization logic (`ToSerializedString`, constructor from string).
|
|
- Default constructor initializes all 14 settings; missing cases throw `NotSupportedException`.
|
|
- `GetValue`/`SetValue` assume key exists; missing keys throw `NotSupportedException`.
|
|
|
|
## 4. Dependencies
|
|
|
|
### Imports/References (from source):
|
|
- `DTS.Common.Base` → Provides `BasePropertyChanged`.
|
|
- `DTS.Common.ISO.Hardware` → Core hardware data model (`GetAllDAS`, `Hardware`, `HardwareChannel`).
|
|
- `DTS.Common.Storage` → `DbOperations`, `DbOperationsEnum.StoredProcedure`.
|
|
- `DTS.Common.Interface.DASFactory.Diagnostics`, `DTS.Common.Interface.DataRecorders`, `DTS.Common.Interface.DASFactory.Diagnostics.HardwareList` → Interfaces for hardware diagnostics and storage.
|
|
- `System`, `System.Linq`, `System.Collections.Generic`, `System.Windows`, `System.Configuration` → Standard libraries.
|
|
- `DataPROWin7.DataModel.Classes.TestTemplate` → Test template classes.
|
|
- `DTS.Common.Enums`, `DTS.Common.Enums.Hardware` → `HardwareTypes` enum.
|
|
- `Common.SerializedSettings` → Static class holding default/overridden settings per hardware type.
|
|
- `RunTestVariables` → Controls caching behavior during run tests.
|
|
|
|
### Inferred Usage:
|
|
- `DASSettings` is serialized to `tblTestSetupDASSettings` (database table).
|
|
- `DASHardwareList` interacts with `DASHardware` (not shown here but referenced).
|
|
- `InputAndBatterySettings` relies on `Common.SerializedSettings` and `RunTestVariables` for runtime configuration.
|
|
|
|
## 5. Gotchas
|
|
|
|
- **`DASHardwareList.GetHardware(...)` always sets `changed = false`**
|
|
Despite having an `out bool changed` parameter and a `HardwareTypeChangedException` type, the implementation never detects changes or throws the exception.
|
|
|
|
- **`DASHardwareList.GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache)` ignores `bThrowExceptionIfChanged`**
|
|
The parameter is unused in the method body.
|
|
|
|
- **`DASHardwareList.GetHardware(string serialNumber, string ipaddress)` discards `ipaddress`**
|
|
Only uses `serialNumber`.
|
|
|
|
- **`DASHardwareList.Commit` assumes `hardware.GetHardware()` is non-null**
|
|
No null-check before accessing `hardware.GetHardware()` properties.
|
|
|
|
- **`DASHardwareList.UnassociateParentDAS` is called only for pseudo-rack hardware**
|
|
Logic depends on `IsPseudoRack()` (not defined here), but no validation ensures this condition is checked correctly.
|
|
|
|
- **`DasBatteryInputSettings` serialization order is fragile**
|
|
Constructor from string assumes exact enum order; reordering `Settings` will break deserialization.
|
|
|
|
- **`InputAndBatterySettings._cache` is shared globally**
|
|
`ClearCache()` affects all callers; caching behavior depends on `RunTestVariables` flags.
|
|
|
|
- **`DASSettings` copy constructor copies private fields directly**
|
|
No deep-copy or validation; mutable reference types (if added later) could cause side effects.
|
|
|
|
- **`DASHardwareList.GetAllHardware()` may return stale data if `Cache = true`**
|
|
Once cached, `_cachedDASHardware` persists until `Cache` is set to `false`.
|
|
|
|
- **No validation of numeric ranges**
|
|
Properties like `SampleRate`, `PreTriggerSeconds`, or voltage thresholds accept any `double`/`int` without bounds checking.
|
|
|
|
- **`GetEmbeddedModules`/`GetEmbeddedModuleInfo` use `hardware.First(...).SerialNumber` without null-check**
|
|
If no hardware matches `DASId == id`, `First()` throws `InvalidOperationException`. |