17 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:37:43.305054+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 529cbbf4accc9016 |
ViewModel
Documentation: HardwareListViewModel.cs
1. Purpose
The HardwareListViewModel class serves as the central MVVM ViewModel for the hardware list UI module in the DASFactory diagnostics system. It manages the presentation and interaction logic for hardware inventory—including filtering, sorting, selection, calibration status tracking, sample rate configuration, and SLICE6/SLICE6DB association management. It aggregates raw hardware data from DTS.Common.ISO.Hardware.GetAllDAS, wraps it in HardwareModel instances, and exposes structured collections (Hardware, OverdueHardware, AvailableHardware, etc.) to views. It also coordinates inter-view communication via Prism’s IEventAggregator, handles user actions (e.g., editing, replacing, associating hardware), and enforces domain-specific rules such as parent–child DAS sample rate consistency and channel assignment tracking during hardware replacement.
2. Public Interface
All methods and properties are public unless otherwise noted. The class implements IHardwareListViewModel (inferred from : IHardwareListViewModel).
Constructors
HardwareListViewModel(IHardwareListView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
Initializes the ViewModel with required dependencies, sets up event subscriptions (RaiseNotification,BusyIndicatorChangeNotification), and initializesSelectedHardwareItemsas anObservableCollection<IHardware>.
Public Methods
-
void LoadTreeView(string serialNumber)
PopulatesSLICE6TreeNodes,AvailableSLICE6,SelectedSLICE6DB, andAvailableSLICE6DBfor the given SLICE6DB serial number usingSLICE6TreeNode.GetTreeNodes()andHardwareModel.GetAvailableSLICE6DB(). -
void GetHardware(bool bIncludeModules, bool bIncludeOverdue, bool bIncludeBridges, int? testId, int? groupId)
Loads and processes hardware fromDTS.Common.ISO.Hardware.GetAllDAS(), constructsHardwareModelinstances, aggregates channel counts for parent DAS with child modules, and filters based on overdue status and inclusion flags. Stores results in_allHardware, then callsFilter()andSort(). -
void SetTestSampleRates(Dictionary<string, double> testSampleRates)
Applies sample rates fromtestSampleRatesto all hardware in_allHardware. If a rate is unavailable, uses the next highest available rate. UpdatesTestSampleRate,SelectedSampleRateIndex, and callsSetDSPRate()andCheckForMixedDAS(). -
void UpdateTestSampleRate(string childSerialNumber, double testSampleRate)
Updates sample rate and AAF rate for a specific child hardware (bySerialNumber), then updates DSP filter rate. -
void SetTestAAFRates(Dictionary<string, float> testAAFRates)
Applies AAF rates fromtestAAFRates. If missing for a hardware item, computes default viaGetAAFForHardware()and logs a warning viaPageErrorEvent. -
void UpdateTestAAFilterRate(string childSerialNumber, float testAAFilterRate)
Updates AAF rate for a specific hardware item. -
void SetTestClockMasters(Dictionary<string, bool> testClockMasters)
SetsIsClockMasterfor hardware whoseSerialNumberappears in the dictionary. -
void UpdateTestClockMaster(string childSerialNumber, bool testClockMaster)
SetsIsClockMasterfor a specific hardware item. -
void SetTestPTPDomainIDs(Dictionary<string, byte> testPTPDomainIDs)
SetsPTPDomainIDfor hardware whoseSerialNumberappears in the dictionary. -
void UpdateTestPTPDomainID(string childSerialNumber, byte ptpDomainId)
SetsPTPDomainIDfor a specific hardware item. -
void CheckForMixedDAS(string nonParentSerialNumber, double testSampleRate)
Ensures sample rate consistency between a child DAS and its parent. If siblings have differing rates, marks the parent asMixedRates = true; otherwise, aligns parent rate to child. -
void SetParentMixedRates(string parentDAS, bool mixedRates)
SetsMixedRatesproperty on the parent DAS. -
void SetHasIncludedChildren()
SetsHasIncludedChildren = truefor distributors that have at least one included child. -
bool AnyChildren(string distributorDAS)
Returnstrueif any included hardware hasParentDAS == distributorDAS. -
void Filter(object tag, string term)
Updates filter criteria for a specific field (Fieldsenum) and re-applies filtering. -
void Filter(string term)
Applies_currentSearchTermand field-specific filters to_allHardware, populatingHardwareandOverdueHardware. Handles compact view logic (hides rack modules under certain conditions) and recalculates channel counts. -
void Sort(object o, bool bColumnClick)
SortsHardwareby field (HardwareListTags) and direction (toggle on repeated column click). UsesHardwareComparer. -
void SortOverdue(object o, bool bColumnClick)
SortsOverdueHardwaresimilarly. -
void SetIncluded(string[] serialNumbers, bool included)
SetsIncludedflag for hardware matchingserialNumbersin the filteredHardwarelist. -
void SetIncluded(int[] ids)
SetsIncluded = truefor hardware matchingDASIdin_allHardware. -
void IncludeChildren(IHardware hardware)
SetsIncludedfor all child modules (viaIsPseudoRackModule()) of the given hardware to match itsIncludedvalue. -
void RemoveMultipleButton(IHardware hardware)
Clears sample rate display (TestSampleRate = 0) andMixedRatesflag for the given hardware. -
void Unset()
Resets all hardware collections, SLICE6 associations, and channel assignments; publishesListViewStatusEvent.Unloaded. -
void ClearAllFilters()
Clears_filterByField. -
void Cleanup()/Task CleanupAsync()/void Initialize()/Task InitializeAsync()/void Activated()
No-op stubs (likely required by Prism interfaces). -
void SaveSLICE6Associations(string serialNumber)
Commits SLICE6 associations to DB viaSLICE6TreeNode.SaveAssociations(). If_swappedHardwareis set, swaps nodes first. -
void Associate(ISLICE6TreeNode node)
Adds aSLICE6TreeNodetoSLICE6TreeNodes, assignsNumber,Port,PositionOnChain, and removes fromAvailableSLICE6. -
void Associate(IHardware node)
Sets_swappedHardware, reloads tree view fornode.SerialNumber, and updatesAvailableSLICE6/SLICE6TreeNodes. -
void UnAssociate(ISLICE6TreeNode node)
RemovesnodefromSLICE6TreeNodes, renumbers remaining nodes, resets its metadata, and adds back toAvailableSLICE6. -
void Replace()
Commits hardware replacement: setsReplacementHardware.Included = true, publishesHardwareReplaceEvent, and clearsHardwareToReplace/ReplacementHardware. -
IHardware[] GetSelectedItems()
ReturnsSelectedHardwareItems.ToArray(). -
void SetCalPeriods(...)
Sets all*CalPeriodproperties (e.g.,G5CalPeriod,SLICE6_CalPeriod) for use inHardwareModelconstruction.
Public Properties
-
IHardwareListView View,IHardwareListOverdueView OverdueView,IHardwareListSelectView SelectView,IHardwareListReplaceView ReplaceView,ISLICE6TreeView SLICE6TreeView
View interfaces bound to this ViewModel. -
InteractionRequest<Notification> NotificationRequest,InteractionRequest<Confirmation> ConfirmationRequest
Prism interaction triggers for modal dialogs. -
event PropertyChangedEventHandler PropertyChanged
StandardINotifyPropertyChangedimplementation. -
IHardware[] Hardware
Filtered and sorted list of hardware for display. -
IHardware[] OverdueHardware
Hardware withCalDueDate <= DateTime.Today. -
IHardware[] AvailableHardware
Hardware suitable for replacement (excludes included items, matchesHardwareType, respects rack size constraints). -
IHardware HardwareToReplace,IHardware ReplacementHardware
Current hardware being replaced and its candidate replacement. -
Model.HardwareChannelAssignment[] AssignedChannels
Channels assigned toHardwareToReplace(populated inInitializeReplace()andPopulateAvailableHardware()). -
ISLICE6TreeNode[] SLICE6TreeNodes,ISLICE6TreeNode[] AvailableSLICE6
Associated and available SLICE6 units for a given SLICE6DB. -
IHardware[] AvailableSLICE6DB
SLICE6DB units available for association. -
bool ShowCompact
Controls whether rack modules are hidden (defaulttrue). Triggers re-filtering and publishesHardwareListShowCompactEvent. -
ObservableCollection<IHardware> SelectedHardwareItems
Tracks selected hardware items; raisesHardwareListHardwareSelectedEventon change. -
bool IsBusy
Bound to busy indicator; set viaBusyIndicatorChangeNotificationevent. -
bool IsDirty
Alwaysfalse; not updated anywhere in source. -
string ListViewId => "HardwareListView"
Identifier for the view. -
int TDASCalPeriod,int G5CalPeriod, ...,int SLICE_PRO_CAN_FD_CalPeriod
Calibration period constants passed toHardwareModel. -
IStreamingFilterProfile StreamingDSPProfile
Used to computeDSPStreamingFilterviaGetDSPFilterRate().
Internal/Protected Methods (Not Public Interface)
-
void FireAAFilterRate(...),FireSampleRate(...),FireClockMaster(...),FireIncluded(...),FirePTPDomainID(...)
Publish correspondingHardwareListHardware*Eventinstances. -
private void FireSelectionChanged()
PublishesHardwareListHardwareSelectedEventwith selected serial numbers. -
private void Hardware_PropertyChanged(...)
HandlesTestAAFilterRateHzchanges to callSetDSPRate(). -
private void SetDSPRate(HardwareModel hardware),private void UpdateDSP(HardwareModel hardware)
ComputesDSPStreamingFilterusingStreamingDSPProfile. -
private double GetNextHighestAvailableSampleRate(...)
Helper forSetTestSampleRates. -
internal float GetAAFForHardware(IISOHardware h, int sampleRate)
Returns AAF rate based on DAS type (TDAS vs SLICE). -
private bool AnyMixedChildren(...),private void PopulateAvailableHardware(),private void OnRaiseNotification(...),OnBusyIndicatorNotification(...)
Internal helpers.
3. Invariants
-
Hardware Uniqueness:
_allHardwaremust contain no duplicateSerialNumbers. Duplicates are logged viaAPILogger.Log()duringGetHardware(). -
Parent–Child Sample Rate Consistency: For any child DAS with
ParentDASset,CheckForMixedDAS()ensures the parent’sMixedRatesflag reflects whether any included siblings have differingTestSampleRate. If all children match, the parent’s rate is updated to match. -
Calibration Overdue Logic:
OverdueHardwareincludes all hardware whereCalDueDate <= DateTime.Today. This is recomputed on everyFilter()call. -
Channel Aggregation for Parent DAS: When
bIncludeModules == false, parent DAS channel counts (AnalogChannels,SquibChannels, etc.) are aggregated from included child modules. If a parent has only one analog channel, it is reset to0before adding child channels. -
SLICE6 Association Integrity:
SLICE6TreeNode.Number,Port, andPositionOnChainare managed duringAssociate()/UnAssociate()to maintain ordering and uniqueness. -
Replacement Hardware Constraints: In
PopulateAvailableHardware(), replacement hardware must matchHardwareType. ForTDAS_Pro_Rack, replacement must haveMaxModules >=original’sMaxModules. -
Filtering Scope:
Filter(string term)operates on_allHardware, butSetIncluded(string[])operates on the filteredHardwarelist.
4. Dependencies
Imports/Usings
- Core:
System.Collections.Generic,System.Linq,System.Threading.Tasks,System.ComponentModel,System.Collections.Specialized. - Prism:
Prism.Regions,Prism.Events,Unity(IUnityContainer,IRegionManager,IEventAggregator). - Common Libraries:
DTS.Common.Classes.Hardware,DTS.Common.Enums.Hardware,DTS.Common.Events.Hardware.HardwareListDTS.Common.Interface.DASFactory.Diagnostics.HardwareList(e.g.,IHardwareListView,ISLICE6TreeNode)HardareList.Model(e.g.,HardwareModel,HardwareChannelAssignment)DTS.Common.Interface.TestSetups.TestSetupsList(ITestSetup)DTS.Common.Utilities.Logging(APILogger)DTS.Common.Classes.DSP(IStreamingFilterProfile)DTS.Common.Interactivity(InteractionRequest<T>)
External Types Referenced
IHardware,IISOHardware,HardwareModel,ISLICE6TreeNode,ISLICE6TreeView,ITestSetup,HardwareTypes,SerializableAAF.DAS_TYPE,DTS.Common.ClockSyncProfile,DTS.Common.ISO.Hardware,DFConstantsAndEnums.TSRAIR_ValidSampleRates.
Event Types Published/Consumed
- Consumed:
RaiseNotification,BusyIndicatorChangeNotification,PageErrorEvent. - Published:
HardwareListEditHardwareEvent,HardwareListHardwareTestAAFilterRateEvent,HardwareListHardwareTestSampleRateEvent,HardwareListHardwareTestClockMasterEvent,HardwareListHardwareIncludedEvent,HardwareListHardwareSelectedEvent,HardwareListHardwareTestPTPDomainIDEvent,HardwareReplaceEvent,HardwareListShowCompactEvent,ListViewStatusEvent.
Dependents
- Views (
IHardwareListView,IHardwareListOverdueView, etc.) bind to this ViewModel. - Other modules subscribe to its published events (e.g.,
HardwareReplaceEvent).
5. Gotchas
-
IsDirtyis never set: The property is declared but alwaysfalse. This may indicate incomplete implementation or unused state tracking. -
HardwareFilterusesFieldsenum, butFilter(string term)uses_currentSearchTermfor global search: Field-specific filters are stored in_filterByField, but the primaryFilter(string term)method only uses_currentSearchTerm. This may cause confusion—field filters are only applied viaFilter(object tag, string term). -
SetTestSampleRatessilently overrides unavailable rates: If a requested sample rate is not inhardware._availableSampleRates, it jumps to the next highest without user confirmation. This could mask configuration errors. -
GetAAFForHardwareusesDASTypeEnumto choose betweenTDASandSLICEAAF profiles: Thedefaultcase assumes all non-TDAS hardware is SLICE, which may be incorrect for future hardware types. -
SLICE6TreeNode.Numberassignment assumes sequential numbering:node.Number = 1 + SLICE6TreeNodes.Lengthmay cause conflicts if nodes are added out-of-order or reloaded from persistent state. -
Hardware_PropertyChangedonly handlesTestAAFilterRateHz: Other property changes (e.g.,Included,TestSampleRate) do not trigger DSP recalculation unless explicitly handled elsewhere (e.g.,SetTestSampleRates). -
Unset()does not clear_dasIdToChannels: WhileInitializeReplace()clears it,Unset()does not. IfUnset()is called mid-replace operation, stale channel assignments may persist. -
ShowCompacttriggers re-filtering but not re-sorting: ChangingShowCompactcallsFilter()but notSort(), potentially leaving the list in an inconsistent order until the user re-sorts. -
SelectedHardwareItems.CollectionChangedhandlerSelectedHardwareItemsOnCollectionChangedcallsFireSelectionChanged(): This may fire multiple times if items are added/removed in bulk (e.g., viaSetIncluded()), thoughSelectedItemsStatus.GetUpdating()is checked inFireSelectionChanged()(source ofSelectedItemsStatusnot provided—behavior uncertain). -
GetHardware()aggregates child channels only whenbIncludeModules == false: WhenbIncludeModules == true, parent DAS channel counts are not aggregated, leading to inconsistent channel counts depending on view mode. -
GetAAFForHardwareFuncis a public property: Allows external override of AAF computation logic, but no usage is shown in this file. -
IsEdit,IsMenuIncluded,IsNavigationIncludedare exposed but never set in this file: Their purpose is unclear without context from other modules. -
Typo in namespace import:
using HardareList.Model;(missing 'd' in "Hardware")—likely a ReSharper suppression or legacy artifact. -
SLICE6TreeNode.SwapNodes()andSaveAssociations()are called inSaveSLICE6Associations(): The order (swap first, then save) may be critical for data integrity, but no error handling is visible. -
SelectedHardwareItemsis initialized asnew ObservableCollection<IHardware>()but never cleared inUnset():Unset()reassignsSelectedHardwareItems = null? No—Unset()does not modify it. This may leave stale selections after unloading. -
HardwareandOverdueHardwarearrays are reassigned directly: This bypassesOnPropertyChangedunless explicitly triggered (e.g.,OnPropertyChanged("Hardware")), which is done—but only after sorting/filtering. Direct array mutation (e.g