Files
DP44/enriched-partialglm/DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReport/ViewModel.md
2026-04-17 14:55:32 -04:00

8.4 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReport/ViewModel/PSDReportMainViewModel.cs
2026-04-16T11:03:20.289994+00:00 zai-org/GLM-5-FP8 1 280cd655454826b4

Documentation: PSDReportMainViewModel

1. Purpose

The PSDReportMainViewModel class serves as the primary view model for the PSD Report module within the DTS Viewer application. It acts as a central coordinator, managing the lifecycle and composition of various child views (graphs, tests, settings, navigation) via Prism's RegionManager and Unity dependency injection. This module handles user interactions related to data selection, calibration settings, and channel view modes, while maintaining state for loaded and selected tests/graphs and communicating changes to other components via an IEventAggregator.

2. Public Interface

Constructor

  • PSDReportMainViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
    • Initializes the view model, creates interaction requests (NotificationRequest, ConfirmationRequest), resolves the main view (IPSDReportMainViewGrid), and sets the DataContext.

Properties

  • IBaseView View { get; set; }: Gets or sets the associated view instance.
  • InteractionRequest<Notification> NotificationRequest { get; }: Request object for triggering notifications.
  • InteractionRequest<Confirmation> ConfirmationRequest { get; }: Request object for triggering confirmation dialogs.
  • Region Context Properties:
    • object ContextNavigationRegion: Content for the Navigation region.
    • object ContextGraphsRegion: Content for the GraphList region. Note: Getter/Setter references GraphListRegion.
    • object ContextGraphListRegion: Content for the GraphList region. Note: Identical to ContextGraphsRegion.
    • object ContextTestsRegion: Content for the Tests region.
    • object ContextLegendRegion: Content for the Legend region.
    • object ContextPropertyRegion: Auto-property; does not appear to interact with the View.
    • object ContextChartOptionsRegion: Content for the ChartOptions region.
    • object ContextViewerSettingsRegion: Content for the Settings region.
    • object ContextReportDataSelectRegion: Content for the DataSelect region.
    • object ContextGraphRegion: Content for the Graph region.
    • object ContextReportChartOptionsRegion: Content for the ReportChartOptions region.
    • object ContextReportResultsRegion: Content for the ReportResults region.
  • string ConfigPath { get; set; }: Throws NotImplementedException.
  • string TitleTests { get; set; }: Title for the Tests section, updated based on selection counts.
  • int TotalSelectedTests { get; set; }: Count of selected tests; updates TitleTests.
  • int TotalLoadedTests { get; set; }: Count of loaded tests; updates TitleTests.
  • string TitleGraphs { get; set; }: Title for the Graphs section.
  • int TotalSelectedGraphs { get; set; }: Count of selected graphs.
  • int TotalLoadedGraphs { get; set; }: Count of loaded graphs.
  • string SelectedDataFolder { get; set; }: Sets the data folder and publishes DataFolderChangedEvent. Ignores null/empty values.
  • string SelectedDataFile { get; set; }: Sets the data file and publishes DataFolderChangedEvent. Ignores null/empty values.
  • IsoViewMode ChannelCodeViewMode { get; set; }: Gets or sets the channel view mode; publishes ChannelCodesViewChangedEvent.
  • CalibrationBehaviors CalibrationBehaviorSetting { get; set; }: Gets or sets calibration behavior; publishes CalibrationBehaviorSettingChangedEvent.
  • bool CalibrationBehaviorSettableInViewer { get; set; }: Determines if calibration is settable; publishes CalibrationBehaviorSettableInViewerChangedEvent and manipulates View tab selection directly.
  • Visibility SettingsVisibility { get; }: Controls visibility of settings.
  • bool IsBusy { get; set; }: Controls busy indicator visibility.
  • string IsBusyMessage { get; set; }: Text displayed when busy.
  • bool IsMenuIncluded { get; set; }: Flag for menu inclusion.
  • bool IsNavigationIncluded { get; set; }: Flag for navigation inclusion.
  • bool IsDirty: Throws NotImplementedException.

Methods

  • List<FrameworkElement> GetRegions(): Retrieves child elements named "Region" from the MainShell.
  • void Initialize(): Calls Subscribe() to register event listeners.
  • void Initialize(object parameter): Sets the Parent window model, updates parent properties, and subscribes to events.
  • void LeftKeyPress(): Throws NotImplementedException.
  • void RightKeyPress(): Throws NotImplementedException.
  • void ZoomReset(): Publishes ResetZoomChangedEvent.
  • void SelectAndIncludeDataFile(string value): Sets the selected file and publishes a DataFolderChangedEvent with SetSelected flag.
  • event PropertyChangedEventHandler PropertyChanged: Event for property change notifications (hides base event).

3. Invariants

  • View Resolution: The View property is expected to be an instance of PSDReportMainViewGrid (resolved via IPSDReportMainViewGrid). All region properties cast View to this concrete type, implying the interface IPSDReportMainViewGrid is not used for region access, or the concrete type is strictly required for UI element access.
  • Event Aggregator: The class relies heavily on _eventAggregator being non-null for almost all property setters and initialization logic.
  • Parent Type: In Initialize(object parameter), the parameter must be castable to IBaseWindowModel.
  • Busy Counter: The private reads integer is used to track nested "busy" states during graph channel reading; it assumes a balanced start/stop notification pattern.

4. Dependencies

External Dependencies (Inferred from usings)

  • Prism: IEventAggregator, IRegionManager, InteractionRequest, Notification, Confirmation.
  • Unity: IUnityContainer.
  • System.Windows: FrameworkElement, Visibility.

Internal Dependencies (DTS Namespace)

  • Common: BaseViewModel, IBaseView, IBaseWindowModel, IBaseViewModel, Utils.
  • Enums: IsoViewMode, CalibrationBehaviors.
  • Events: DataFolderChangedEvent, ChannelCodesViewChangedEvent, CalibrationBehaviorSettingChangedEvent, LoadViewModulEvent, TestLoadedCountNotification, etc.
  • Views/ViewModels (Resolved via Unity):
    • IPSDReportMainViewGrid
    • INavigationView / INavigationViewModel
    • IPSDReportResultsView / IPSDReportResultsViewModel
    • IPSDReportSettingsView / IPSDReportSettingsViewModel
    • IChartOptionsView / IChartOptionsViewModel
    • IGraphView / IGraphViewModel
    • IGraphMainView / IGraphMainViewModel
    • IViewerSettingsView / IViewerSettingsViewModel
    • ITestSummaryListView / ITestSummaryListViewModel

5. Gotchas

  • Not Implemented Members: Several members throw NotImplementedException (ConfigPath, IsDirty, LeftKeyPress, RightKeyPress). These are likely interface requirements that have not been fulfilled.
  • Duplicate Region Properties: ContextGraphsRegion and ContextGraphListRegion are functionally identical; both access ((PSDReportMainViewGrid)View).GraphListRegion.Content. This may be a copy-paste error or redundant API surface.
  • MVVM Violation (View Coupling): The CalibrationBehaviorSettableInViewer setter directly manipulates View UI elements (graphsTab, testsTab, chartResultsTab) by casting View to PSDReportMainViewGrid. This breaks the separation of concerns typically enforced in MVVM and creates a hard dependency on the concrete View type.
  • Member Hiding: The new keyword is used to hide inherited members (IsBusy, IsBusyMessage, IsMenuIncluded, IsNavigationIncluded, PropertyChanged, OnPropertyChanged). This suggests a mismatch between the base class implementation and the requirements of this specific view model, which could lead to confusion if the object is referenced via a base type pointer.
  • Unused Property: ContextPropertyRegion is defined as an auto-property but is never assigned or used within the class logic, unlike other region properties.
  • Magic Strings: Region names (e.g., "Graph", "DataSelect") and property names in OnPropertyChanged are passed as string literals.