Files
DP44/docs/ai/DataPRO/Modules/Hardware/HardwareList/ViewModel.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/ViewModel/HardwareListViewModel.cs
2026-04-17T16:01:30.188313+00:00 zai-org/GLM-5-FP8 1 516e7030d5d58a0c

HardwareListViewModel Documentation

1. Purpose

HardwareListViewModel is the ViewModel for the Hardware List module in a WPF/Prism-based application. It manages the display, filtering, sorting, and manipulation of hardware devices (DAS units, SLICE modules, racks, etc.) within the system. The class handles hardware configuration including sample rates, anti-aliasing filter rates, clock synchronization, PTP domain IDs, calibration tracking, and SLICE6-to-SLICE6DB associations. It serves as the intermediary between hardware data models and the UI views, exposing bindable properties and commands for hardware management operations.


2. Public Interface

Constructor

public HardwareListViewModel(IHardwareListView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)

Initializes the ViewModel with its associated view, Prism region manager, event aggregator for pub/sub messaging, and Unity DI container. Sets up event subscriptions for RaiseNotification and BusyIndicatorChangeNotification events.

Properties

Property Type Description
View IHardwareListView The associated view, with DataContext set to this ViewModel
OverdueView IHardwareListOverdueView View for overdue hardware display
SelectView IHardwareListSelectView View for hardware selection
ReplaceView IHardwareListReplaceView View for hardware replacement
SLICE6TreeView ISLICE6TreeView Tree view for SLICE6/Slice 6 Air hardware hierarchy
NotificationRequest InteractionRequest<Notification> Interaction request for showing notifications
ConfirmationRequest InteractionRequest<Confirmation> Interaction request for confirmations
StreamingDSPProfile IStreamingFilterProfile Profile for DSP streaming filter calculations
Hardware IHardware[] Array of hardware items for display
OverdueHardware IHardware[] Array of hardware with overdue calibration
SelectedHardwareItems ObservableCollection<IHardware> Currently selected hardware items
ShowCompact bool Whether to show compact view (hides rack modules)
IsBusy bool Busy indicator state for UI
IsEdit bool Edit mode flag
ListViewId string Returns "HardwareListView"

Calibration Period Properties

public int TDASCalPeriod { get; set; }
public int G5CalPeriod { get; set; }
public int SLICE1CalPeriod { get; set; }
public int SLICE1_5CalPeriod { get; set; }
public int SLICE2_CalPeriod { get; set; }
public int SLICE6_CalPeriod { get; set; }
public int POWERPRO_CalPeriod { get; set; }
public int SLICE6Air_CalPeriod { get; set; }
public int SLICE6AirBridge_CalPeriod { get; set; }
public int SLICE6DB_CalPeriod { get; set; }
public int TSRAir_CalPeriod { get; set; }
public int SLICETC_CalPeriod { get; set; }
public int SLICE_PRO_CAN_FD_CalPeriod { get; set; }

Key Methods

Hardware Loading and Management

public void GetHardware(bool bIncludeModules, bool bIncludeOverdue, bool bIncludeBridges, int? testId, int? groupId)

Loads all DAS hardware from the system, applies filtering based on parameters, aggregates child module properties to parent devices, and populates Hardware and OverdueHardware arrays.

public void LoadTreeView(string serialNumber)

Loads SLICE6 tree nodes for a given serial number, populating SLICE6TreeNodes and AvailableSLICE6.

public void Unset()

Clears all hardware arrays, filters, cached data, and publishes ListViewStatusEvent with Unloaded status.

Sample Rate Methods

public void GetAvailableSampleRates(int[] availableSampleRates)
public void SetTestSampleRates(Dictionary<string, double> testSampleRates)
public void UpdateTestSampleRate(string childSerialNumber, double testSampleRate)

Manage sample rate configuration for hardware. SetTestSampleRates automatically selects the next highest available rate if a requested rate is unavailable (except for TSRAIR hardware).

Anti-Aliasing Filter Methods

public void SetTestAAFRates(Dictionary<string, float> testAAFRates)
public void UpdateTestAAFilterRate(string childSerialNumber, float testAAFilterRate)
public internal float GetAAFForHardware(IISOHardware h, int sampleRate)

Configure anti-aliasing filter rates. GetAAFForHardware routes to different AAF calculations based on DASTypeEnum (TDAS vs SLICE types).

public Func<SerializableAAF.DAS_TYPE, int, float> GetAAFForHardwareFunc { get; set; }

Injectable function for AAF calculation, allowing external implementation.

Clock and PTP Methods

public void SetTestClockProfiles(DTS.Common.ClockSyncProfile masterProfile, DTS.Common.ClockSyncProfile slaveProfile)
public void SetTestClockMasters(Dictionary<string, bool> testClockMasters)
public void UpdateTestClockMaster(string childSerialNumber, bool testClockMaster)
public void SetTestPTPDomainIDs(Dictionary<string, byte> testPTPDomainIDs)
public void UpdateTestPTPDomainID(string childSerialNumber, byte ptpDomainId)

Event Publishing Methods

public void FireAAFilterRate(IHardware hardware, string testAAFilterRate)
public void FireSampleRate(IHardware hardware, string testSampleRate)
public void FireClockMaster(IHardware hardware, bool isClockMaster)
public void FireIncluded(IHardware hardware)
public void FirePTPDomainID(IHardware hardware, byte ptpDomainID)

Publish corresponding Prism events via IEventAggregator.

Filtering and Sorting

public void Filter(string term)
public void Filter(object tag, string term)
public void Sort(object o, bool bColumnClick)
public void SortOverdue(object o, bool bColumnClick)
public void ClearAllFilters()

Hardware Replacement

public void InitializeReplace(ITestSetup testSetup, IsoViewMode viewMode)
public void Replace()

InitializeReplace prepares the replacement workflow by loading channel assignments. Replace executes the replacement and publishes HardwareReplaceEvent.

SLICE6 Association Methods

public void SaveSLICE6Associations(string serialNumber)
public void Associate(ISLICE6TreeNode node)
public void Associate(IHardware node)
public void UnAssociate(ISLICE6TreeNode node)

Manage SLICE6-to-SLICE6DB associations. Changes are in-memory until SaveSLICE6Associations is called.

Selection

public IHardware[] GetSelectedItems()
public void SetIncluded(string[] serialNumbers, bool included)
public void SetIncluded(int[] ids)

Nested Enum

public enum Fields
{
    SerialNumber, HardwareType, IPAddress, ChannelCount, Firmware,
    MaxSampleRate, TestSampleRate, CalDate, CalDueDate,
    IsClockMaster, FirstUseDate, PTPDomainID
}

Used for field-specific filtering.

Event

public event PropertyChangedEventHandler PropertyChanged
public void OnPropertyChanged(string propertyName)

Standard INotifyPropertyChanged implementation.


3. Invariants

  1. Selection Synchronization: SelectedHardwareItems collection changes trigger FireSelectionChanged(), which publishes HardwareListHardwareSelectedEvent with serial numbers, unless SelectedItemsStatus.GetUpdating() returns true.

  2. Parent-Child Hardware Aggregation: In GetHardware(), child module properties (channel counts, calibration dates, max sample rates) are aggregated to parent DAS devices. Parent MaxSampleRate takes the minimum of children; parent CalDate/CalDueDate takes the earliest date.

  3. Duplicate Prevention: GetHardware() uses a HashSet<string> (processed) to prevent double-counting hardware by serial number during aggregation.

  4. Mixed Rate Detection: When a child's sample rate differs from siblings with the same ParentDAS, the parent's MixedRates property is set to true.

  5. Overdue Hardware Separation: Hardware with CalDueDate <= DateTime.Today is always added to OverdueHardware array regardless of other filters.

  6. Sort State Consistency: _sortField and _sortAscending track current sort state; clicking the same column toggles direction.


4. Dependencies

Imports (This Module Depends On)

  • DTS.Common.Classes.Hardware - Hardware data classes
  • DTS.Common.Enums.Hardware - Hardware type enumerations
  • DTS.Common.Events / DTS.Common.Events.Hardware.HardwareList - Event definitions
  • DTS.Common.Interface.DASFactory.Diagnostics.HardwareList - Diagnostic interfaces
  • DTS.Common.Interface.DASFactory.Diagnostics - DAS factory interfaces
  • DTS.Common.Interface.TestSetups.TestSetupsList - Test setup interfaces
  • DTS.Common.Enums / DTS.Common.Enums.DASFactory - Enumerations
  • DTS.Common.Utilities.Logging - APILogger for logging
  • DTS.Common.Classes.DSP - DSP-related classes
  • DTS.Common.Interactivity - InteractionRequest, Notification, Confirmation
  • DTS.Common.ISO.Hardware - ISO hardware interfaces (referenced via IISOHardware)
  • HardareList.Model - Note: namespace appears to have a typo (missing 'w')
  • Unity - IoC container
  • Prism.Regions / Prism.Events - Prism framework

Published Events (Consumed By Others)

  • HardwareListEditHardwareEvent
  • HardwareListHardwareTestAAFilterRateEvent
  • HardwareListHardwareTestSampleRateEvent
  • HardwareListHardwareTestClockMasterEvent
  • HardwareListHardwareIncludedEvent
  • HardwareListHardwareSelectedEvent
  • HardwareListHardwareTestPTPDomainIDEvent
  • HardwareReplaceEvent
  • HardwareListShowCompactEvent
  • ListViewStatusEvent
  • PageErrorEvent

Subscribed Events

  • RaiseNotification
  • BusyIndicatorChangeNotification

5. Gotchas

  1. Incomplete SetCache Implementation: The method SetCache(IISOHardware[] hardware) only clears _cachedHardware but never populates it with the passed parameter. This appears to be incomplete functionality.

  2. Namespace Typo: The namespace HardareList.Model is imported (missing 'w' in "Hardware"), suggesting a historical naming inconsistency.

  3. IsDirty Never Set: The IsDirty property is declared with a private setter but is never assigned true anywhere in the class. Its purpose is unclear from the source.

  4. Empty Lifecycle Methods: Initialize(), Initialize(object), Initialize(object, object), InitializeAsync(), InitializeAsync(object), Activated(), Cleanup(), and CleanupAsync() all have empty or Task.CompletedTask implementations, suggesting either interface compliance or placeholder code.

  5. ReSharper Suppressions: The file includes // ReSharper disable directives for CheckNamespace, MemberCanBePrivate.Global, and InconsistentNaming, indicating intentional deviations from standard conventions.

  6. TSRAIR Special Handling: GetAvailableSampleRates() applies different valid sample rates (DFConstantsAndEnums.TSRAIR_ValidSampleRates) for TSRAIR hardware, and SetTestSampleRates() skips the "next highest rate" fallback for TSRAIR.

  7. AAF Rate Fallback Behavior: In SetTestAAFRates(), if a serial number is missing from the dictionary, the code logs a warning, calculates a default AAF rate, and shows a user notification—but only on the first occurrence (shown flag).

  8. Module Visibility Logic: In Filter(string term), when ShowCompact is true, modules with a non-empty ParentDAS are excluded from the main list but still added to OverdueHardware if calibration is overdue.