Files
DP44/docs/ai/DataPRO/Modules/Hardware/HardwareList/Model.md
2026-04-17 14:55:32 -04:00

12 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/Hardware/HardwareList/Model/HardwareChannelAssignment.cs
DataPRO/Modules/Hardware/HardwareList/Model/SLICE6TreeNode.cs
DataPRO/Modules/Hardware/HardwareList/Model/Hardware.cs
2026-04-17T15:56:03.551323+00:00 zai-org/GLM-5-FP8 1 f80851e7f913e0b5

Hardware List Model Documentation

1. Purpose

This module provides the data models for representing and managing hardware devices (DAS - Data Acquisition Systems) within the Hardware List feature. It handles hardware configuration state, channel assignments, SLICE6 device tree node relationships, database persistence for device associations, and calibration date calculations. The models serve as the bridge between raw hardware interface objects (IISOHardware) and the UI layer, exposing computed properties for display and user interaction.


2. Public Interface

HardwareChannelAssignment (HardwareList.Model)

A simple immutable data transfer object representing a channel-to-sensor mapping.

Member Signature Description
ChannelNumber string { get; } Read-only channel identifier.
Sensor string { get; } Read-only sensor identifier.
Name string { get; } Read-only name for the assignment.
Constructor HardwareChannelAssignment(string channelNumber, string sensor, string name) Initializes all three properties.

SLICE6TreeNode (HardareList.Model)

Note: Namespace has a typo ("HardareList" vs "HardwareList").

Represents a SLICE6 device node in a tree structure, with database operations for managing parent-child relationships between SLICE6 devices and SLICE6DB distributors.

Member Signature Description
DASId int { get; set; } Database ID of the DAS record.
SerialNumber string { get; set; } Serial number of the DAS.
Port int { get; set; } Port number on the S6DB.
PortString string { get; } Returns "---" if Port < 0, otherwise Port.ToString().
Number int { get; set; } Order of the DAS on the S6DB.
PositionOnChain int { get; set; } Order on the chain for a given port.
PositionOnChainString string { get; } Returns "---" if PositionOnChain < 0, otherwise PositionOnChain.ToString().
Constructor SLICE6TreeNode(int dasId, string serialNumber, int port, int number, int positionOnChain) Initializes all properties.
GetAvailableTreeNodes static ISLICE6TreeNode[](string serialNumberParent) Returns all SLICE6 devices NOT associated with the given S6DB serial number. Filters by HardwareTypes.SLICE6_Base and excludes 'Prototype' positions. Results sorted by SerialNumber.
GetTreeNodes static ISLICE6TreeNode[](string serialNumberParent) Returns all SLICE6 devices associated with the given S6DB serial number. Results sorted by Number.
SwapNodes static void(string serialNumberA, string serialNumberB) Swaps all child DAS associations between two distributors.
SaveAssociations static void(string serialNumber, ISLICE6TreeNode[] attachedSLICE6) Commits SLICE6-to-S6DB associations to the database. First clears all associations, then applies new ones.

HardwareModel (HardareList.Model)

Primary model for hardware devices, implementing IHardware.

Member Signature Description
FirstUseDate DateTime? { get; set; } First date of use after calibration; null if not used since calibration.
IsFirstUseValid bool { get; set; } Whether hardware supports and is using first use date.
DASId int { get; set; } Database ID.
Disabled bool { get; set; } Whether device is disabled.
SerialNumber string { get; set; } Device serial number.
HardwareType string { get; set; } Localized hardware type name.
ChannelCount string { get; set; } Formatted channel count string.
HasIncludedChildren bool { get; set; } Whether device has included child devices.
Firmware string { get; set; } Firmware version.
MaxSampleRate double? { get; set; } Maximum sample rate, null if not applicable.
TestSampleRate double { get; set; } Sample rate for testing; setter fires SelectedSampleRateIndex change.
TestAAFilterRateHz double { get; set; } Anti-alias filter rate; setter calls _vm.FireAAFilterRate().
CalDate DateTime? { get; set; } Calibration date.
CalDueDate DateTime? { get; set; } Calculated calibration due date based on hardware type.
Included bool { get; set; } Whether device is included in test; setter fires multiple property changes and calls _vm.FireIncluded().
DSPStreamingFilter double { get; set; } DSP streaming filter value.
MasterProfile DTS.Common.ClockSyncProfile { get; set; } Clock sync profile for master mode.
SlaveProfile DTS.Common.ClockSyncProfile { get; set; } Clock sync profile for slave mode.
IsClockMaster bool { get; set; } Whether device is clock master; setter calls _vm.FireClockMaster().
IsClockedDAS bool { get; } True for SLICE6_AIR, S6A_EthernetRecorder, SLICE6_Base, SLICE6_AIR_BR, SLICE6DB, SLICE6DB3, SLICE6DB_InDummy, TSR_AIR, TSR_AIR_RevB, SLICE6_AIR_TC.
PTPDomainID byte { get; set; } PTP domain ID; setter calls _vm.FirePTPDomainID().
IsPTPSync bool { get; } Computed from MasterProfile/SlaveProfile containing "E2E".
MixedRates bool { get; set; } Whether mixed rates are enabled.
IsDistributor bool { get; } True for SLICE_EthernetController, SLICE_Distributor, SLICE_Mini_Distributor, SLICE6DB, SLICE_LabEthernet, SLICE6DB3, SLICE6DB_InDummy, SLICE_Pro_Distributor.
IsBattery bool { get; } True for PowerPro.
IsTSRAIR bool { get; } True for TSR_AIR, TSR_AIR_RevB, DKR, DIR.
IncludedAndNotMixedRatesAndCompactOrNotDistributor bool { get; } Computed property for UI binding.
IncludedAndMixedRatesAndCompact bool { get; } Computed property for UI binding.
ParentDAS string { get; set; } Serial number of parent DAS.
PositionOnChain int { get; set; } Position on chain.
PositionOnDistributor int { get; set; } Position on distributor.
Port int { get; set; } Port number.
HasTreeView bool { get; set; } Whether device has a tree view (true for SLICE6DB, SLICE6DB3, SLICE6DB_InDummy).
SerialNumberDisplay string { get; } Returns hardware type description if StandIn is true, otherwise SerialNumber.
Constructor HardwareModel(IISOHardware d, int tdasCalPeriod, ...) Takes 14 calibration period parameters and a view model reference. Calculates CalDueDate based on hardware type.
DetermineChannelCount void(bool showCompact, IHardware[] allHardware) Builds channel count string and determines MaxSampleRate for distributors.
SetIncluded void(bool bIncluded) Sets included flag without firing _vm.FireIncluded().
SetMixedRates void(bool mixedRates) Sets mixed rates flag.
Filter bool(string term) Returns true if term matches SerialNumber, Firmware, or HardwareType (case-insensitive).
GetAvailableSLICE6DB static IHardware[](string serialNumber) Returns SLICE6DB devices excluding the one matching the given serial number.
ToString override string() Returns SerialNumberDisplay.

HardwareComparer (HardareList.Model)

Comparer class for sorting IHardware instances.

Member Signature Description
SortField HardwareListTags { get; set; } Field to sort by.
SortAscending bool { get; set; } Sort direction; default is true.
Compare int(IHardware left, IHardware right) Compares two hardware instances based on SortField. Handles nulls and various data types.

Supported sort fields: Included, DSPStreamingFilter, SerialNumber, HardwareType, ChannelCount, Firmware, MaxSampleRate, CalDate, CalDueDate, IPAddress, FirstUseDate.


3. Invariants

  1. PortString / PositionOnChainString: Always return "---" when the underlying integer value is negative; otherwise return the string representation of the value.

  2. CalDueDate Calculation: Always calculated from dateOfFirstUse (either CalDate or FirstUseDate or DateTime.Today depending on IsFirstUseValid) plus the hardware-type-specific calibration period. Throws ArgumentOutOfRangeException for unknown HardwareTypes values.

  3. GetAvailableTreeNodes: Returns empty array if serialNumberParent is null or whitespace. Always sorts results by SerialNumber.

  4. GetTreeNodes: Returns empty array if serialNumberParent is null or whitespace. Always sorts results by Number.

  5. GetAvailableSLICE6DB: Returns empty array if serialNumber is null or whitespace. Filters for Position='' (empty string).

  6. SaveAssociations: Always performs a two-step process: first clears all associations (sets IsModule=0, PositionOnDistributor=-1, PositionOnChain=-1, Port=-1, ParentDAS=''), then applies new associations.

  7. IsPTPSync: Returns true only if the appropriate profile's description contains "E2E".

  8. IsClockMaster: Returns false if IsClockedDAS is false, regardless of _bIsClockMaster value.


4. Dependencies

This module depends on:

  • DTS.Common.Base.BasePropertyChanged - Base class for property change notification
  • DTS.Common.Interface.DASFactory.Diagnostics.HardwareList.ISLICE6TreeNode - Interface for SLICE6 tree nodes
  • DTS.Common.Interface.DASFactory.Diagnostics.IHardware - Interface for hardware model
  • DTS.Common.Interface.DASFactory.Diagnostics.IISOHardware - Interface for ISO hardware objects
  • DTS.Common.Enums.Hardware.HardwareTypes - Enum for hardware type identification
  • DTS.Common.Enums.HardwareListTags - Enum for sort field identification
  • DTS.Common.ClockSyncProfile - Enum for clock synchronization profiles
  • DTS.Common.Storage.DbOperations - Database access utilities
  • DTS.Common.Converters.EnumDescriptionTypeConverter - For enum description conversion
  • DTS.Common.Classes.Hardware - Hardware-related classes
  • System.Data.SqlClient.SqlParameter - SQL parameter construction
  • HardwareList.Resources.StringResources - Localized string resources
  • HardwareList.HardwareListViewModel - View model reference (passed to HardwareModel constructor)

Database Dependencies:

  • [DAS] table with columns: DASId, SerialNumber, PositionOnDistributor, PositionOnChain, Port, ParentDAS, Type, Position, IsModule, FirmwareVersion, CalDate, MaxSampleRate, IPAddress

5. Gotchas

  1. Namespace Typo: SLICE6TreeNode and HardwareModel are in namespace HardareList.Model (missing 'w'), while HardwareChannelAssignment is in HardwareList.Model. This inconsistency may cause resolution issues.

  2. Bug in SwapNodes: The method contains a likely bug where Associate is called with serialNumberB for both lists:

    if (listA.Any()) { Associate(serialNumberB, listA.ToArray()); }
    if (listB.Any()) { Associate(serialNumberB, listB.ToArray()); }  // Should be serialNumberA?
    

    This would result in all nodes being associated with serialNumberB instead of swapping.

  3. Direct Field Access in SetIncluded: The SetIncluded method sets _bIncluded directly and calls OnPropertyChanged, but does NOT call _vm.FireIncluded(). The Included property setter does call _vm.FireIncluded(). This inconsistency may cause unexpected behavior.

  4. Database Connection Disposal: All database