--- 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` 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.