14 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T04:38:28.250792+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | e010e06b613fee2c |
HardwareList.Model Module Documentation
1. Purpose
This module provides data models and persistence logic for representing and managing hardware devices (DAS units) in the DataPRO diagnostics system. It defines core entities (HardwareChannelAssignment, SLICE6TreeNode, HardwareModel) that model hardware topology, channel assignments, and device metadata. The module enables querying device hierarchies (e.g., SLICE6DB parent-child relationships), persisting association changes to the database, and exposing hardware properties for UI binding (via INotifyPropertyChanged). It serves as the data layer for the Hardware List view, supporting configuration, sorting, filtering, and calibration tracking.
2. Public Interface
HardwareChannelAssignment
-
HardwareChannelAssignment(string channelNumber, string sensor, string name)
Constructor. Initializes immutable properties with provided values. Represents a mapping between a hardware channel, its connected sensor type, and a user-defined name. -
string ChannelNumber { get; }
Channel identifier (e.g., "CH1", "A0"). -
string Sensor { get; }
Type of sensor connected to the channel. -
string Name { get; }
User-assigned name for the channel.
SLICE6TreeNode
-
SLICE6TreeNode(int dasId, string serialNumber, int port, int number, int positionOnChain)
Constructor. Initializes properties for a SLICE6 device node in a tree structure. -
int DASId { get; set; }
Primary key ID from the DAS database table. -
string SerialNumber { get; set; }
Device serial number. -
int Port { get; set; }
Physical port number on the S6DB (distributor) to which the device is connected. -
string PortString { get; }
Readable string representation ofPort; returns"---"ifPort < 0. -
int Number { get; set; }
Order of the device on the S6DB (i.e., its position index among siblings). -
int PositionOnChain { get; set; }
Position of the device within its daisy-chain on a given port. -
string PositionOnChainString { get; }
Readable string representation ofPositionOnChain; returns"---"ifPositionOnChain < 0. -
static ISLICE6TreeNode[] GetAvailableTreeNodes(string serialNumberParent)
Queries the database for all SLICE6 devices not associated withserialNumberParent. Returns an array ofISLICE6TreeNodeinstances sorted bySerialNumber. Returns empty array ifserialNumberParentis null/empty. -
static ISLICE6TreeNode[] GetTreeNodes(string serialNumberParent)
Queries the database for all SLICE6 devices associated withserialNumberParent. Returns an array ofISLICE6TreeNodeinstances sorted byNumber(i.e.,PositionOnDistributor). Returns empty array ifserialNumberParentis null/empty. -
static void SwapNodes(string serialNumberA, string serialNumberB)
Swaps all child devices between two SLICE6DB units (serialNumberAandserialNumberB) in the database. Note: There is a bug in the implementation—bothlistAandlistBare associated toserialNumberBin the secondAssociatecall, notserialNumberAandserialNumberBrespectively. -
static void SaveAssociations(string serialNumber, ISLICE6TreeNode[] attachedSLICE6)
Commits the current association state of SLICE6 devices to a parent SLICE6DB (serialNumber). First clears all existing associations forserialNumber, then updates each device inattachedSLICE6with its newParentDAS,PositionOnDistributor,PositionOnChain, andPort.
HardwareModel
-
HardwareModel(IISOHardware d, ...)
Constructor. Populates properties from anIISOHardwareinstance and calculates derived values (e.g.,CalDueDate,ChannelCount). Requires calibration period parameters per hardware type. -
int DASId { get; set; }
Database ID of the device. -
bool Disabled { get; set; }
Whether the device is disabled. -
string SerialNumber { get; set; }
Device serial number. -
string HardwareType { get; set; }
Localized string description of the hardware type (e.g.,"SLICE6_BASE"). -
string ChannelCount { get; set; }
Human-readable string listing channel types and counts (e.g.,"8 Analog, 2 Digital In"). -
bool HasIncludedChildren { get; set; }
Indicates if this device has child devices marked asIncluded. -
string Firmware { get; set; }
Firmware version string. -
double? MaxSampleRate { get; set; }
Maximum supported sample rate (Hz);nullif unknown or not applicable. -
double TestSampleRate { get; set; }
Current test/sample rate selected for the device. -
double TestAAFilterRateHz { get; set; }
Anti-aliasing filter rate (Hz) corresponding toTestSampleRate. -
DateTime? CalDate { get; set; }
Last calibration date. -
DateTime? CalDueDate { get; set; }
Calculated calibration due date based onCalDateand hardware-specific period. -
string[] AvailableSampleRates { get; set; }
Array of available sample rate strings (e.g.,["1000", "2000"]). -
string SelectedSampleRateItem { get; set; }
Currently selected sample rate string. -
int SelectedSampleRateIndex { get; set; }
Index of the current sample rate in_availableSampleRates. Setter updatesTestSampleRateandTestAAFilterRateHz. -
object Hardware { get; set; }
BackingIISOHardwareinstance. -
int AnalogChannels { get; set; }
Number of analog input channels. -
int SquibChannels { get; set; }
Number of squib (explosive device) channels. -
int DigitalInChannels { get; set; },int DigitalOutChannels { get; set; },int UartChannels { get; set; },int StreamOutChannels { get; set; },int StreamInChannels { get; set; },int CanChannels { get; set; }
Channel counts for respective interface types. -
string IPAddress { get; set; }
IP address or"USB"if connected via USB. -
bool Included { get; set; }
Whether the device is included in the current configuration. -
double DSPStreamingFilter { get; set; }
DSP streaming filter value. -
DTS.Common.ClockSyncProfile MasterProfile { get; set; },DTS.Common.ClockSyncProfile SlaveProfile { get; set; }
Clock synchronization profiles (master/slave). -
bool IsClockMaster { get; set; }
Whether the device is configured as a clock master. Only valid ifIsClockedDASis true. -
bool IsClockedDAS { get; }
Returnstrueif the device type supports clocking (e.g., SLICE6, S6A_EthernetRecorder, TSR_AIR). -
byte PTPDomainID { get; set; }
PTP domain ID for precision time protocol. -
bool IsPTPSync { get; }
Returnstrueif PTP synchronization is active (E2E profile in use). -
bool MixedRates { get; set; }
Whether the device is part of a mixed-sample-rate configuration. -
bool IsDistributor { get; }
Returnstrueif the device is a distributor (e.g., SLICE6DB, SLICE_Distributor). -
bool IsBattery { get; }
Returnstrueif the device is a PowerPro. -
bool IsTSRAIR { get; }
Returnstrueif the device is a TSR_AIR or embedded sensor type. -
bool IncludedAndNotMixedRatesAndCompactOrNotDistributor { get; },bool IncludedAndMixedRatesAndCompact { get; }
Derived UI flags for conditional rendering. -
string ParentDAS { get; set; }
Serial number of the parent device (distributor). -
int PositionOnChain { get; set; },int PositionOnDistributor { get; set; },int Port { get; set; }
Position metadata for hierarchical placement. -
bool HasTreeView { get; set; }
Indicates if a tree view should be shown for this device (e.g., for SLICE6DB). -
string SerialNumberDisplay { get; }
Display name:SerialNumberunlessStandInis true, in which case it returns the hardware type description. -
static IHardware[] GetAvailableSLICE6DB(string serialNumber)
Returns all SLICE6DB devices (includingSLICE6DB_InDummy) not currently assigned to any parent, excludingserialNumber. -
void DetermineChannelCount(bool showCompact, IHardware[] allHardware)
UpdatesChannelCountandMaxSampleRatebased on device type and child devices. For distributors, calculates min sample rate among children ifshowCompactis true. -
void SetIncluded(bool bIncluded),void SetMixedRates(bool mixedRates)
Updates state and fires property change notifications. -
bool Filter(string term)
ReturnstrueifSerialNumber,Firmware, orHardwareTypecontainsterm(case-insensitive). -
class HardwareComparer : IComparer<IHardware>
Implements sorting forIHardwareobjects. Supports sorting byHardwareListTags(e.g.,SerialNumber,CalDate,FirstUseDate). Handles nulls anddouble?/DateTime?comparisons.FirstUseDatesorts nulls last when valid.
3. Invariants
-
SLICE6TreeNodePort,Number, andPositionOnChainmust be non-negative integers for valid hardware placements. Negative values are represented as"---"in UI viaPortString/PositionOnChainString.GetAvailableTreeNodesandGetTreeNodesonly query devices withType = SLICE6_BaseandPosition ≠ 'Prototype'(forGetAvailableTreeNodes).SwapNodesassumes all child devices of both parents are retrieved in one query and re-associated. Bug: Both lists are associated toserialNumberB.
-
HardwareModelCalDueDateis derived fromCalDate(orFirstUseDateifIsFirstUseValid) plus a hardware-specific calibration period.MaxSampleRateisnullifd.MaxSampleRateis<= 0oruint.MaxValue.IsClockedDASis determined by a fixed set ofHardwareTypes.IncludedandMixedRatesflags affect derived properties (IncludedAndNotMixedRatesAndCompactOrNotDistributor,IncludedAndMixedRatesAndCompact).ChannelCountfor distributors is"N/A"ifshowCompactis false or no children exist.
-
General
- All database operations use
DTS.Common.Storage.DbOperations.GetSQLCommand()and explicitly dispose connections infinallyblocks. HardwareModelinstances are constructed with a non-nullHardwareListViewModel(_vm) reference for event callbacks.
- All database operations use
4. Dependencies
Dependencies of this module:
-
DTS.Common.*DTS.Common.Base.BasePropertyChanged(base class forSLICE6TreeNode)DTS.Common.Storage.DbOperations(database access)DTS.Common.Enums.Hardware.HardwareTypes(device type enumeration)DTS.Common.Interface.DASFactory.Diagnostics.IISOHardware,IHardware(hardware abstraction interfaces)DTS.Common.Converters.EnumDescriptionTypeConverter(localized enum descriptions)DTS.Common.ClockSyncProfile(clock sync profiles)
-
HardwareList.Resources.StringResources- Used for localized strings (e.g.,
"Analog","USB","N/A").
- Used for localized strings (e.g.,
Dependencies on this module:
HardwareList.HardwareListViewModel- Passed into
HardwareModelconstructor; used for event callbacks (FireSampleRate,FireClockMaster, etc.).
- Passed into
- UI Layer
HardwareModelproperties (e.g.,Included,CalDueDate,ChannelCount) are bound to views.SLICE6TreeNodeis used to populate tree views for SLICE6DB hierarchies.
- HardwareList Module
HardwareList.Modelis the core data model for theHardwareListmodule.
5. Gotchas
-
SLICE6TreeNode.SwapNodesBug:
TheAssociatemethod is called twice—once forlistAwithserialNumberB, and again forlistBalso withserialNumberB. This means devices originally underserialNumberBare incorrectly moved toserialNumberB(no-op), and devices underserialNumberAare moved toserialNumberB, but the reverse move does not occur. The intended behavior is likelyAssociate(serialNumberB, listA)andAssociate(serialNumberA, listB). -
HardwareModel.CalDueDateCalculation:
UsesFirstUseDateonly ifIsFirstUseValidis true. IfFirstUseDateisnullandIsFirstUseValidis true, it defaults toDateTime.Today. This may cause unexpected recalculations ifFirstUseDateis set later. -
HardwareModel.TestSampleRateSetter Side Effect:
SettingTestSampleRatetriggersOnPropertyChanged("SelectedSampleRateIndex"), but the getter forSelectedSampleRateIndexre-computesSelectedSampleRateItemand calls_vm.FireSampleRate. This could cause redundant UI updates ifTestSampleRateis set multiple times. -
HardwareModel.DetermineChannelCountfor Distributors:
MaxSampleRateis recalculated as the minimum sample rate of child devices. If children have no sample rate (null),ChannelCountbecomes"N/A"andMaxSampleRateis set tonull. This may mask missing configuration. -
HardwareModel.FilterCase Sensitivity:
Filtering is case-insensitive (term.ToLower()), butSerialNumberDisplayusesisoHW.StandInlogic, which may cause display mismatches ifStandInis toggled dynamically. -
HardwareModel.Hardwareisobject:
TheHardwareproperty is typed asobject, requiring casting toIISOHardwarefor type-specific checks (e.g.,IsClockedDAS,IsDistributor). This risks runtime errors if the underlying type is notIISOHardware. -
SLICE6TreeNodeSQL Injection Risk:
GetAvailableTreeNodesuses string interpolation forHardwareTypes.SLICE6_Basein theWHEREclause ([(int)HardwareTypes.SLICE6_Base]). While the enum value is fixed, this pattern is fragile and error-prone. -
HardwareModelConstructor Side Effects:
The constructor callsd.GetChannelsString(...)and computesCalDueDatebased ond.DASTypeEnum. IfHardwareisnullorDASTypeEnumis invalid, it throwsArgumentOutOfRangeException. -
HardwareComparer.NumericCompareLogic:
Fordouble/DateTime,a > breturns-1(descending order), but the method returns1for all other cases. This may cause inconsistent sorting if types are mixed (e.g.,doublevsDateTime).