5.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T11:01:33.528546+00:00 | zai-org/GLM-5-FP8 | 1 | 7cb2cb6c499c73c1 |
Documentation: PSDReportResultsViewModel
1. Purpose
PSDReportResultsViewModel is a Prism-based view model responsible for displaying PSD (Power Spectral Density) report results, specifically GRMS (Root Mean Square) summary data for channels. It serves as a subscriber to report update events and provides user-initiated export functionality to PDF and CSV formats. The view model participates in a parent-child relationship with another view model (passed during initialization) and filters incoming events to ensure it only processes data intended for its specific context.
2. Public Interface
Properties
| Name | Type | Description |
|---|---|---|
View |
IBaseView |
Gets or sets the associated view instance. Assigned in constructor. |
Parent |
IBaseViewModel |
Gets or sets the parent view model. Used to filter event subscriptions. Set during Initialize. |
Results |
ObservableCollection<IChannelGRMSSummary> |
Collection of GRMS summary results displayed to the user. Cleared and repopulated on PSDReportGRMSValuesUpdatedEvent. |
NotificationRequest |
InteractionRequest<Notification> |
Interaction request for showing notifications to the user. |
ConfirmationRequest |
InteractionRequest<Confirmation> |
Interaction request for showing confirmation dialogs. Declared with new keyword (hides base member). |
ExportToPDFCommand |
DelegateCommand |
Command that triggers PDF export by publishing SaveReportToPDFRequestedEvent. Lazily instantiated. |
ExportToCSVCommand |
DelegateCommand |
Command that triggers CSV export by publishing SaveReportToCSVRequestedEvent. Lazily instantiated. |
Methods
| Signature | Description |
|---|---|
PSDReportResultsViewModel(IPSDReportSettingsView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Constructor. Accepts an IPSDReportSettingsView (note: not IPSDReportResultsView), assigns it to View, sets DataContext to itself, and initializes interaction requests and service references. |
override void Initialize(object parameter) |
Initializes the view model. Expects parameter to be castable to IBaseViewModel (assigned to Parent). Creates empty Results collection and subscribes to events. |
3. Invariants
-
Parent-based event filtering: Both
OnGRMSValuesUpdatedandOnGraphSelectedChannelsChangedcheckif (Parent != arg.ParentVM) return;— events are ignored if the sender's parent view model does not match this instance's parent. -
Results collection lifecycle:
Resultsis instantiated as an emptyObservableCollection<IChannelGRMSSummary>inInitialize, not in the constructor. It is cleared before repopulation inOnGRMSValuesUpdated. -
Directory derivation: The private
Directoryproperty is derived from the first selected channel'sBinaryFilePathwith"Binary"replaced by"Reports"viaReplaceLast. If no channels are selected,Directoryis set tostring.Empty. -
Lazy command instantiation: Both
ExportToPDFCommandandExportToCSVCommanduse lazy initialization via null-coalescing pattern.
4. Dependencies
This module depends on:
- DTS.Common.Base —
BaseViewModel<T> - DTS.Common.Events —
PSDReportGRMSValuesUpdatedEvent,PSDReportGRMSValuesUpdatedEventArg,GraphSelectedChannelsNotification,GraphSelectedChannelsNotificationArg,SaveReportToPDFRequestedEvent,SaveReportToPDFRequestedEventArgs,SaveReportToCSVRequestedEvent,SaveReportToCSVRequestedEventArgs - DTS.Common.Interactivity —
InteractionRequest<T>,Notification,Confirmation - DTS.Common.Interface —
IBaseView,IBaseViewModel,IPSDReportResultsViewModel,IChannelGRMSSummary,ITestChannel,IPSDReportSettingsView - DTS.Common.Utils —
ReplaceLastextension method (inferred from usage on string) - Prism.Delegates —
DelegateCommand - Prism.Events —
IEventAggregator,ThreadOption - Prism.Regions —
IRegionManager - Unity —
IUnityContainer - System.Collections.ObjectModel —
ObservableCollection<T>
What depends on this module:
- Not determinable from this source file alone. Consumers would implement
IPSDReportResultsViewand resolveIPSDReportResultsViewModelvia the container.
5. Gotchas
-
Constructor parameter type mismatch: The constructor accepts
IPSDReportSettingsViewbut the class implementsIPSDReportResultsViewModel. This appears inconsistent — the view type name suggests "settings" while the view model is for "results". This may be intentional coupling or a copy-paste error. -
Member hiding with
newkeyword:_regionManageris declared withnew, hiding the base class's_regionManager.ConfirmationRequestis declared withnew, hiding a base class member.- This suggests the base class
BaseViewModel<T>already defines these members, and the derived class is overriding them shadow-style rather than using proper override/virtual patterns.
-
Unused service references:
_eventAggregator,_unityContainer, and_regionManagerare stored as private fields despite the base class constructor already receiving them. Thenewkeyword on_regionManagerindicates potential confusion about inheritance. -
Null-conditional handling inconsistency:
OnGraphSelectedChannelsChangeduses null-conditional operators (arg?.ParentVM,arg?.SelectedChannels) whileOnGRMSValuesUpdateddoes not. This suggests different assumptions about event argument nullability. -
Unused imports:
System.Threading.Tasksis imported but no async/await or Task usage is present in the file.