10 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-16T04:31:49.040833+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 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. CopiesChannelNumber,Sensor,_testObjectChannel,Hardware, and_isoChannelfromcopy.public HardwareChannel(ISO.HardwareChannel channel, DASHardware hardware)
Constructor initializing from anISO.HardwareChanneland its parentDASHardware.public int CompareTo(HardwareChannel right)
Compares twoHardwareChannelinstances first byDASDisplayOrder, then byChannelIdx(0-based index). Returns0if either operand isnullor 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)
Returnstrueif the underlyingISO.HardwareChannel.SupportedBridgesbitmask includes the specifiedbridgeType.public int ChannelNumber { get; }
0-based channel index (ISO.HardwareChannel.ChannelIdx).public DASHardware Hardware { get; }
ParentDASHardwareinstance.public SensorData Sensor { get; set; }
Optional sensor configuration associated with this channel.public ISO.HardwareChannel GetISOChannel()
Returns the underlyingISO.HardwareChannelinstance.
DASHardware
public DASHardware(Hardware hardware)
Constructor initializing from aHardwareinstance. PopulatesChannelsby wrapping eachISO.HardwareChannelin aHardwareChannel.public DASHardware(DASHardware copy, DASHardware parentDAS)
Constructor for creating a child DAS from acopy, withparentDASas its logical parent. CopiesChannels(deep copy viaHardwareChannelcopy constructor) andDbTimeStamp.public bool IsPseudoRack()
Returnstrueif the hardware type isSLICE_LabEthernet,SLICE_EthernetController, orSLICE6DB, indicating it should be UI-rendered as a rack despite not physically being one.public bool IsDummy()
ReturnstrueifSerialNumbercontains the substring"Dummy".public int CompareTo(DASHardware right)
Implements ordering logic:null→1- Same reference or
SerialNumbermatch →0 - Parent/child relationship → child sorts after parent
- Same parent and
PositionOnDistributor→ sort byPositionOnDistributor - 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 usingHardwareChannel.CompareTo()before assignment.public int GetHardwareTypeInt()
Returns the raw integer type (_hardware.DASType).public HardwareTypes GetHardwareTypeEnum()
CastsGetHardwareTypeInt()toHardwareTypesenum.public long GetMaxMemoryLong()
Returns_hardware.MaxMemory.public Hardware GetHardware()
Returns the underlyingHardwareinstance.
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 andGetList().)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 withbThrowExceptionIfChanged = true,changed = out boolignored.public DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache = true)
Retrieves aDASHardwarebyid. Uses_cachedHardwareif available andbUseCacheistrue. Falls back toHardware.GetAllDAS(id, null). Returnsnullif not found.
Note: Legacy logic for detecting hardware type changes (includingHardwareTypeChangedException) 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.ChannelNumberis always non-negative and corresponds toISO.HardwareChannel.ChannelIdx.HardwareChannel.GetId()produces a 1-based channel index (i.e.,ChannelNumber + 1).DASHardware.Channelsis always sorted byHardwareChannel.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.
DASSettingsis a pure data container with no runtime validation or normalization. Values are assumed valid per database schema.
4. Dependencies
Internal Dependencies
ISO.HardwareandISO.HardwareChannel
Core data models representing raw database records. Used inHardwareChannelandDASHardwareconstructors.SensorData
Referenced inHardwareChannel.Sensor. Must be defined elsewhere in the codebase.Test.Module.Channel.Sensor.BridgeType
Referenced inHardwareChannel.IsSupportedBridgeType().HardwareTypes
Enum used inDASHardware.GetHardwareTypeEnum(). Must be defined externally.DbTimeStampBase
Base class forDASHardware. Provides timestamping functionality.
External Dependencies
System(core .NET types)DatabaseImport.Hardware(static class)
Used inDASHardwareList.GetHardware()viaHardware.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.,
DatabaseImporterentry points, UI layers).
5. Gotchas
- Singleton caching is non-functional:
GetList()instantiates_list, but_list.PopulateHardware()is commented out. Similarly,ReloadAll()and caching logic inGetHardware()are commented out. As written,DASHardwareListdoes not cache hardware data beyond the initial instantiation. HardwareTypeChangedExceptionis unused: The exception class exists but is never thrown—legacy logic for detecting hardware type changes is disabled.CompareTo()returns0fornull: InHardwareChannel.CompareTo(), passingnullreturns0, which violates theIComparable<T>contract (should throwArgumentExceptionor return non-zero). This may cause unexpected behavior in sorting or collections.GetHardware()inDASHardwareListsilently returnsnull: 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()usesChannelNumber + 1, which may cause off-by-one confusion ifChannelNumberis 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 inSerialNumber, which may yield false positives (e.g.,"Dummy123"vs"MyDummyDAS").DASHardwareList.GetHardware()does not handle duplicate IDs: IfHardware.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.