5.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T13:39:37.629543+00:00 | zai-org/GLM-5-FP8 | 1 | 7cb2cb6c499c73c1 |
Documentation: PSDReportResultsViewModel.cs
1. Purpose
PSDReportResultsViewModel is a Prism-based ViewModel responsible for displaying PSD (Power Spectral Density) report results, specifically GRMS (G-RMS) summary data for channels. It serves as a child view model that receives data via event aggregation from a parent view model, maintains an observable collection of results for UI binding, and provides user-initiated export functionality to PDF and CSV formats.
2. Public Interface
Class: PSDReportResultsViewModel
Inheritance: BaseViewModel<IPSDReportResultsViewModel>
Implements: IPSDReportResultsViewModel
Constructor
public PSDReportResultsViewModel(
IPSDReportSettingsView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
Initializes the view model, sets the View's DataContext to itself, and creates NotificationRequest and ConfirmationRequest instances.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
View |
IBaseView |
get/set | The associated view instance. |
Parent |
IBaseViewModel |
get/set | Reference to the parent view model, used to filter event payloads. |
Results |
ObservableCollection<IChannelGRMSSummary> |
get/set | Collection of GRMS summary results bound to the UI. |
NotificationRequest |
InteractionRequest<Notification> |
get/private set | Interaction request for displaying notifications. |
ConfirmationRequest |
InteractionRequest<Confirmation> |
get/private set | Interaction request for displaying confirmations. |
ExportToPDFCommand |
DelegateCommand |
get | Lazily-initialized command that publishes SaveReportToPDFRequestedEvent. |
ExportToCSVCommand |
DelegateCommand |
get | Lazily-initialized command that publishes SaveReportToCSVRequestedEvent. |
Methods
public override void Initialize(object parameter)
Sets Parent from the parameter, initializes Results as an empty collection, and subscribes to events.
3. Invariants
- Parent Filtering: Event handlers
OnGRMSValuesUpdatedandOnGraphSelectedChannelsChangedwill early-return ifParentdoes not matcharg.ParentVM(orarg?.ParentVM). This ensures the view model only processes events intended for its specific parent context. - Results Initialization:
Resultsis always initialized as a new emptyObservableCollection<IChannelGRMSSummary>inInitialize()before any events are processed. - Lazy Command Initialization: Both
ExportToPDFCommandandExportToCSVCommandare lazily instantiated using the null-coalescing pattern. - UIThread Subscription:
OnGRMSValuesUpdatedis explicitly subscribed withThreadOption.UIThread, ensuring the handler executes on the UI thread.
4. Dependencies
External Dependencies (Imports)
| Namespace | Usage |
|---|---|
DTS.Common.Base |
BaseViewModel<T>, IBaseView, IBaseViewModel |
DTS.Common.Events |
PSDReportGRMSValuesUpdatedEvent, PSDReportGRMSValuesUpdatedEventArg, GraphSelectedChannelsNotification, GraphSelectedChannelsNotificationArg, SaveReportToPDFRequestedEvent, SaveReportToPDFRequestedEventArgs, SaveReportToCSVRequestedEvent, SaveReportToCSVRequestedEventArgs |
DTS.Common.Interactivity |
InteractionRequest<T>, Notification, Confirmation |
DTS.Common.Interface |
IPSDReportResultsViewModel, IChannelGRMSSummary, ITestChannel, IPSDReportSettingsView |
DTS.Common.Utils |
ReplaceLast extension method (inferred from usage on string) |
Prism.Commands |
DelegateCommand |
Prism.Events |
IEventAggregator, ThreadOption |
Prism.Regions |
IRegionManager |
Unity |
IUnityContainer |
Event Dependencies
- Subscribes to:
PSDReportGRMSValuesUpdatedEvent— populatesResultscollectionGraphSelectedChannelsNotification— setsDirectoryfor export operations
- Publishes:
SaveReportToPDFRequestedEvent— triggered byExportToPDFCommandSaveReportToCSVRequestedEvent— triggered byExportToCSVCommand
5. Gotchas
-
Constructor Parameter Type Mismatch: The constructor accepts
IPSDReportSettingsViewbut assigns it toViewwhich is typed asIBaseView. This impliesIPSDReportSettingsViewmust inherit fromIBaseView, but the relationship is not visible in this file. -
Member Hiding with
newKeyword: BothConfirmationRequestand_regionManageruse thenewkeyword, hiding base class members with the same names. This could cause unexpected behavior if the base class members are accessed through a base-class reference. -
Property Name Shadows System Type: The private property
DirectoryshadowsSystem.IO.Directory. While scoped locally, this could cause confusion during debugging or ifusing System.IO;is added. -
ReplaceLastExtension Method Undefined Here: The call tochannels[0].BinaryFilePath.ReplaceLast("Binary", "Reports")depends on an extension method fromDTS.Common.Utils. Its behavior (e.g., what happens if "Binary" is not found) is not defined in this source. -
No Unsubscribe Logic: The
Subscribe()method subscribes to events, but there is no correspondingUnsubscribe()or cleanup in this file. If the view model lifecycle is not managed correctly, this could lead to memory leaks or stale event handlers.