--- source_files: - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/Hardware/DASSettings.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/Hardware/HardwareChannel.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/Hardware/DASHardware.cs generated_at: "2026-04-16T04:59:11.131587+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "45f7e783788f3070" --- # Hardware ## Documentation: DAS Hardware Abstraction Layer (Version 57) ### 1. Purpose This module provides a version-specific abstraction layer for DAS (Data Acquisition System) hardware configuration and metadata within the `DatabaseExport` subsystem of the DataPRO system. It enables serialization of DAS settings (e.g., sample rate, AAF, trigger timing) into the legacy database schema (`tblTestSetupDASSettings`, `tblDAS`, `tblDASChannel`) and supports hardware discovery, comparison, and channel management. The classes (`DASSettings`, `HardwareChannel`, `DASHardware`, `DASHardwareList`) serve as DTOs and adapters for interacting with historical database structures, preserving compatibility with Version 57 schema while abstracting underlying `Hardware` and `ISOHardwareChannel` objects. --- ### 2. Public Interface #### `DASSettings` - **Properties** - `string DASSerialNumber { get; set; }` — Serial number of the DAS device associated with the test settings. - `double SampleRate { get; set; }` — Sampling rate (Hz) configured for the test. - `int ExcitationWarmupTimeMS { get; set; }` — Warm-up time (milliseconds) for excitation voltage before data acquisition. - `double HardwareAAF { get; set; }` — Hardware anti-aliasing filter cutoff frequency (Hz). - `double PreTriggerSeconds { get; set; }` — Duration (seconds) of data captured *before* a trigger event. - `double PostTriggerSeconds { get; set; }` — Duration (seconds) of data captured *after* a trigger event. - `bool StatusLineCheck { get; set; }` — Flag indicating whether status line monitoring is enabled. - `bool BatteryCheck { get; set; }` — Flag indicating whether battery voltage monitoring is enabled. - `double InputVoltageMin { get; set; }` — Minimum acceptable input voltage (volts). - `double InputVoltageMax { get; set; }` — Maximum acceptable input voltage (volts). - `double BatteryVoltageMin { get; set; }` — Minimum acceptable battery voltage (volts). - `double BatteryVoltageMax { get; set; }` — Maximum acceptable battery voltage (volts). #### `HardwareChannel` - **Constructors** - `HardwareChannel(HardwareChannel copy)` — Deep-copies channel data (including `Sensor`). - `HardwareChannel(ISOHardwareChannel channel, DASHardware hardware)` — Initializes from an `ISOHardwareChannel` and its parent `DASHardware`. - **Properties** - `DASHardware Hardware { get; }` — Parent DAS hardware instance. - `int ChannelNumber { get; }` — Zero-based channel index (`ChannelIdx` from `ISOHardwareChannel`). - `SensorData Sensor { get; set; }` — Sensor configuration for this channel (nullable). - `TestObjectChannel TestObjectChannel { get; set; }` — Logical test object channel mapped to this hardware channel. - **Methods** - `ISOHardwareChannel GetISOChannel()` — Returns the underlying `ISOHardwareChannel` instance. - `int CompareTo(HardwareChannel right)` — Compares channels first by `DASDisplayOrder`, then by `ChannelIdx`. - `string GetId()` — Returns a unique ID in the format `{HardwareId}x{1-based ChannelNumber}`. - `bool IsSupportedBridgeType(Test.Module.Channel.Sensor.BridgeType bridgeType)` — Checks if `bridgeType` is supported by this channel (via bitwise AND with `SupportedBridges`). #### `DASHardware` - **Properties** - `string SerialNumber { get; set; }` — DAS serial number (from `_hardware.SerialNumber`). - `string Connection { get; set; }` — Network address (e.g., IP) for the DAS (from `_hardware.IPAddress`). - `DateTime CalDate { get; }` — Calibration date (read-only, from `_hardware.CalDate`). - `HardwareChannel[] Channels { get; set; }` — Sorted array of channels (sorted by `CompareTo` in setter). - `bool LocalOnly { get; set; }` — Flag indicating local-only operation (from `_hardware.LocalOnly`). - **Methods** - `Hardware GetHardware()` — Returns the underlying `Hardware` instance. - `int GetHardwareTypeInt()` — Returns `_hardware.DASType` as an integer. - `HardwareTypes GetHardwareTypeEnum()` — Casts `DASType` to `Hardware.HardwareTypes` enum. - `long GetMaxMemoryLong()` — Returns `_hardware.MaxMemory`. - `Dictionary GetValues()` — Serializes DAS metadata (e.g., serial, type, firmware, sample rates, channel types) into a dictionary keyed by `DbOperations.DAS.Fields` enum values. - `Dictionary GetChannelValues(HardwareChannel channel)` — Serializes channel metadata (e.g., `ChannelIdx`, `SupportedBridges`, `DASDisplayOrder`) into a dictionary keyed by `DbOperations.DAS.DASChannelFields` enum values. - `bool IsDummy()` — Returns `true` if `SerialNumber` contains `"Dummy"`. - **Inherited from `DbTimeStampBase`** - `override string LookupTable => "tblDAS"` — Database table name for persistence. - `override ConstraintHelper[] GetConstraints()` — Returns a constraint for `SerialNumber` (used for DB lookups). #### `DASHardwareList` (Singleton) - **Methods** - `static DASHardwareList GetList()` — Returns the singleton instance (lazy-initialized via `PopulateHardware`). - `DASHardware GetHardware(string id)` — Retrieves DAS by ID (hardware ID or serial number). - `DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed)` — Retrieves DAS; if ID format includes a type suffix (e.g., `SN_123`) and the hardware type has changed, throws `HardwareTypeChangedException` (if `bThrowExceptionIfChanged=true`) or sets `changed=true`. - `DASHardware[] Hardware { get; }` — Returns all non-prototype DAS instances. - **Nested Exception** - `HardwareTypeChangedException : Exception` — Thrown when hardware type mismatch is detected during lookup. --- ### 3. Invariants - **Channel Ordering**: `HardwareChannel.CompareTo` enforces ordering by `DASDisplayOrder` first, then `ChannelIdx`. - **Channel Array Consistency**: Setting `DASHardware.Channels` sorts the array internally and raises `OnPropertyChanged` for both `Channels` and `ChannelCount`. - **Hardware ID Format**: `HardwareChannel.GetId()` uses `1 + ChannelNumber` (1-based indexing in ID, 0-based in `ChannelNumber`). - **Prototype Exclusion**: `DASHardwareList.GetAllHardware()` filters out hardware with `Position == "Prototype"`. - **Serial Number Uniqueness**: `DASHardwareList` uses `_hardware.ContainsKey(h.GetHardware().GetId())` for deduplication during population. - **Dummy Detection**: `IsDummy()` checks for substring `"Dummy"` in `SerialNumber` (case-sensitive). --- ### 4. Dependencies - **Internal Dependencies** - `Hardware` (from `DatabaseExport.Hardware` namespace) — Core data model for DAS hardware metadata. - `ISOHardwareChannel` — Encapsulates channel-level metadata (e.g., `ChannelIdx`, `SupportedBridges`). - `DbOperations.DAS.Fields` / `DbOperations.DAS.DASChannelFields` — Enumerations defining database column names (used in `GetValues`/`GetChannelValues`). - `DbTimeStampBase` — Base class for time-stamped database entities (provides `LookupTable`, `GetConstraints`, `DbTimeStamp`). - `SensorData` — Sensor configuration (used in `HardwareChannel`). - `Test.Module.Channel.Sensor.BridgeType` — Bridge type enum (used in `IsSupportedBridgeType`). - **External Dependencies** - `System.Collections.Generic`, `System.Linq`, `System.Data.SqlDbType` — Standard .NET libraries. - `System.IComparable` — Implemented by `HardwareChannel` and `DASHardware`. --- ### 5. Gotchas - **`CompareTo` Null Handling**: `HardwareChannel.CompareTo` returns `0` for `null` input (non-standard behavior; typically `null` comparisons should return `1`). - **`GetHardware(string id)` Ambiguity**: Lookup prioritizes hardware ID (e.g., `"DAS_123"`) over serial number, but falls back to serial if ID fails. If the ID contains `_` (e.g., `"SN_123"`), it truncates to `"SN"` for serial matching, risking incorrect matches. - **`Channels` Setter Sorts In-Place**: The setter sorts the input list and replaces `_channels`, but does not validate channel uniqueness or consistency with `_hardware.ISOChannels`. - **`IsDummy()` Substring Match**: `IsDummy()` uses `Contains("Dummy")`, which may yield false positives (e.g., `"MyDummyDAS"`). - **`DASHardwareList` Singleton Initialization**: Thread-safety is not guaranteed (no locking in `GetList()`). - **Hardcoded Prototype Filter**: Prototype exclusion uses a magic string `"Prototype"` (comment notes `/*DbOperations.DAS.PROTOTYPE_POSITION*/` suggests a constant should be used). - **`GetChannelValues` Field Names**: Uses `DbOperations.DAS.DASChannelFields` enum values directly as keys; mismatches here would cause DB schema errors. - **No Validation in `DASSettings`**: Properties lack validation (e.g., negative `SampleRate` or `PreTriggerSeconds` allowed). None identified beyond these source-observable quirks.