Files
DP44/enriched-qwen3-coder-next/DataPRO/Modules/Reports/PedestrianAndHeadReports/ViewModel.md
2026-04-17 14:55:32 -04:00

14 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/Reports/PedestrianAndHeadReports/ViewModel/HeadReportViewModel.cs
DataPRO/Modules/Reports/PedestrianAndHeadReports/ViewModel/TRLReportViewModel.cs
2026-04-16T04:55:26.671118+00:00 Qwen/Qwen3-Coder-Next-FP8 1 3e435356eaf751fb

Documentation: HeadReportViewModel and TRLReportViewModel

1. Purpose

These two view models (HeadReportViewModel and TRLReportViewModel) serve as shared data contexts for input and output views in the Pedestrian and Head Reports module of the DataPRO application. They implement Prism-based MVVM patterns to manage UI state (e.g., busy indicators, dirty state, inclusion flags for menu/navigation), handle notification/confirmation interactions via InteractionRequest, and expose properties for report configuration (e.g., time/acceleration units, channel selections). HeadReportViewModel is a simpler implementation focused on generic report UI state, while TRLReportViewModel extends this with domain-specific properties and initialization logic tied to a DTS.Serialization.Test object, including channel population and unit filtering. Both are exported as views (IHeadReportInputView/IHeadReportOutputView and ITRLReportInputView/ITRLReportOutputView) and are intended to coordinate data flow between UI and backend (though current functionality is limited to XML string exchange per comments).


2. Public Interface

HeadReportViewModel

  • HeadReportViewModel(IHeadReportInputView inputView, IHeadReportOutputView outputView, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
    Constructor. Assigns views, sets up DataContext, initializes InteractionRequests, and subscribes to RaiseNotification and BusyIndicatorChangeNotification events.

  • IHeadReportInputView InputView { get; set; }
    Reference to the input view instance.

  • IHeadReportOutputView OutputView { get; set; }
    Reference to the output view instance.

  • InteractionRequest<Notification> NotificationRequest { get; }
    Prism interaction request used to trigger notification popups (e.g., alerts).

  • InteractionRequest<Confirmation> ConfirmationRequest { get; }
    Prism interaction request used to trigger confirmation dialogs.

  • bool IsDirty { get; }
    Read-only property indicating whether the model has unsaved changes. Currently never set to true in source.

  • bool IsBusy { get; set; }
    Bindable property indicating whether the UI is busy. Set via OnBusyIndicatorNotification(bool) event handler.

  • bool IsMenuIncluded { get; set; }
    Bindable property indicating whether the report should include the menu. Defaults to false.

  • bool IsNavigationIncluded { get; set; }
    Bindable property indicating whether the report should include navigation. Defaults to false.

  • string HeaderInfo { get; }
    Returns the literal string "MainRegion".

  • void OnPropertyChanged(string propertyName)
    Raises the PropertyChanged event for the specified property.

  • event PropertyChangedEventHandler PropertyChanged
    Standard INotifyPropertyChanged event.

  • Lifecycle methods (no-op):
    Cleanup(), CleanupAsync(), Initialize(), Initialize(object), Initialize(object, object), InitializeAsync(), InitializeAsync(object), Activated()
    All are empty stubs; no behavior implemented.

  • OnRaiseNotification(NotificationContentEventArgs) (private)
    Event handler that reformats NotificationContentEventArgs and raises NotificationRequest.

  • OnBusyIndicatorNotification(bool) (private)
    Event handler that sets IsBusy to the incoming boolean.


TRLReportViewModel

  • TRLReportViewModel(ITRLReportInputView inputView, ITRLReportOutputView outputView, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer, DTS.Serialization.Test test)
    Constructor. Initializes Test, AvailableTimeUnits, SelectedTimeUnits, AvailableAccelerationUnits, and SelectedAccelerationUnit. Calls PopulateChannels() to populate channel arrays. Assigns views, sets up DataContext, initializes InteractionRequests, and subscribes to events.

  • ITRLReportInputView InputView { get; set; }
    Reference to the input view instance.

  • ITRLReportOutputView OutputView { get; set; }
    Reference to the output view instance.

  • InteractionRequest<Notification> NotificationRequest { get; }
    Prism interaction request for notifications.

  • InteractionRequest<Confirmation> ConfirmationRequest { get; }
    Prism interaction request for confirmations.

  • DTS.Serialization.Test Test { get; set; }
    The test object used to populate channels and metadata.

  • bool IsDirty { get; }
    Read-only property indicating unsaved changes. Currently never set to true.

  • bool IsBusy { get; set; }
    Bindable busy state. Set via OnBusyIndicatorNotification(bool).

  • bool IsMenuIncluded { get; set; }
    Bindable flag for menu inclusion. Defaults to false.

  • bool IsNavigationIncluded { get; set; }
    Bindable flag for navigation inclusion. Defaults to false.

  • string HeaderInfo { get; }
    Returns "MainRegion".

  • string TestNumber { get; set; }
    Bindable string for test number.

  • string DateTimeText { get; set; }
    Bindable string representation of _dateTime. Getter uses CultureInfo.CurrentCulture; setter parses via DateTime.Parse.

  • string CarName { get; set; }
    Bindable string for car name.

  • string Model { get; set; }
    Bindable string for model.

  • string TestTemperature { get; set; }
    Bindable string for test temperature.

  • string MeasurementPoint { get; set; }
    Bindable string for measurement point.

  • string CrashVelocity { get; set; }
    Bindable string for crash velocity.

  • string ImpactorID { get; set; }
    Bindable string for impactor ID.

  • string[] AvailableImpactorTypes => throw new NotImplementedException();
    Unimplemented; throws NotImplementedException.

  • string SelectedImpactor { get; set; }
    Bindable string for selected impactor.

  • string ImpactorWeight { get; set; }
    Bindable string for impactor weight.

  • string Examiner { get; set; }
    Bindable string for examiner name.

  • string Reserved1 { get; set; }
    Bindable string for reserved field 1.

  • string Reserved2 { get; set; }
    Bindable string for reserved field 2.

  • DTS.SensorDB.FilterClass[] AvailableCFCs => throw new NotImplementedException();
    Unimplemented; throws NotImplementedException.

  • DTS.SensorDB.FilterClass SelectedCFC { get; set; }
    Bindable filter class.

  • DTS.SensorDB.MeasurementUnit[] AvailableAccelerationUnits { get; set; }
    Array of available acceleration units (initialized to "m/sec^2" and "g").

  • DTS.SensorDB.MeasurementUnit SelectedAccelerationUnit { get; set; }
    Selected acceleration unit. Defaults to first in AvailableAccelerationUnits.

  • ConstantsAndEnums.TimeUnits[] AvailableTimeUnits { get; set; }
    Array of available time units (Seconds, MilliSeconds).

  • ConstantsAndEnums.TimeUnits SelectedTimeUnits { get; set; }
    Selected time unit. Defaults to Seconds.

  • Event.Module.AnalogInputChannel[] AccelerationChannels { get; set; }
    Array of acceleration channels (populated in PopulateChannels()).

  • Event.Module.Channel SelectedAccelerationChannel { get; set; }
    Selected acceleration channel.

  • Event.Module.AnalogInputChannel[] AvailableBendingChannels { get; set; }
    Array of bending channels (populated in PopulateChannels()).

  • Event.Module.Channel SelectedBendingChannel { get; set; }
    Selected bending channel.

  • Event.Module.AnalogInputChannel[] AvailableShearChannels { get; set; }
    Array of shear channels (populated in PopulateChannels()).

  • Event.Module.Channel SelectedShearChannel { get; set; }
    Selected shear channel.

  • void PopulateChannels() (private)
    Filters Test.Channels into acceleration, bending, and shear channel arrays based on engineering units. Uses DTS.SensorDB.MeasurementUnitList.GetMeasurementUnit() for unit lookups.

  • void OnPropertyChanged(string propertyName)
    Raises PropertyChanged event.

  • event PropertyChangedEventHandler PropertyChanged
    Standard INotifyPropertyChanged event.

  • Lifecycle methods (no-op):
    Same as HeadReportViewModel: Cleanup(), CleanupAsync(), Initialize(), Initialize(object), Initialize(object, object), InitializeAsync(), InitializeAsync(object), Activated() — all empty.

  • OnRaiseNotification(NotificationContentEventArgs) (private)
    Same behavior as in HeadReportViewModel.

  • OnBusyIndicatorNotification(bool) (private)
    Same behavior as in HeadReportViewModel.


3. Invariants

  • View-ViewModel Binding: Both InputView and OutputView have their DataContext set to this in the constructor. This binding is immutable after construction.
  • Event Subscription: Both view models subscribe to RaiseNotification and BusyIndicatorChangeNotification events during construction. Subscriptions are not cleaned up (no Unsubscribe calls).
  • IsBusy State: IsBusy is always set via OnBusyIndicatorNotification(bool) and never modified directly elsewhere in the code.
  • IsDirty State: IsDirty is read-only and never set to true in the provided code. Its value remains false for the lifetime of the object.
  • HeaderInfo: Always returns "MainRegion"; no dynamic behavior.
  • Test Object: In TRLReportViewModel, Test must be non-null before PopulateChannels() is called (called in constructor), or Test.Channels will throw NullReferenceException.
  • Channel Population Logic: PopulateChannels() only processes channels where ch.emc is Event.Module.AnalogInputChannel. Non-analog channels are skipped.
  • Unit Matching: Channel filtering uses unit.UnitMatches(emc.EngineeringUnits) — behavior depends on implementation of UnitMatches, not visible in source.

4. Dependencies

Internal Dependencies (from imports)

  • Prism Framework:
    • Microsoft.Practices.Prism.Events (IEventAggregator, RaiseNotification, BusyIndicatorChangeNotification)
    • Microsoft.Practices.Prism.Interactivity.InteractionRequest (InteractionRequest<T>, Notification, Confirmation)
    • Microsoft.Practices.Prism.Regions (IRegionManager)
    • Microsoft.Practices.Prism.Commands (DelegateCommand, commented out but referenced)
  • Unity Container: Microsoft.Practices.Unity (IUnityContainer)
  • Common Libraries:
    • DTS.Common.Events (RaiseNotification, BusyIndicatorChangeNotification, NotificationContentEventArgs)
    • DTS.Common.Interface (IHeadReportInputView, IHeadReportOutputView, ITRLReportInputView, ITRLReportOutputView, IHeadReportViewModel, ITRLReportViewModel)
    • DTS.Common.Utils (unused in visible code)
    • DTS.Serialization.Test (Test property in TRLReportViewModel)
    • DTS.SensorDB.MeasurementUnitList, DTS.SensorDB.FilterClass, DTS.SensorDB.MeasurementUnit
    • PedestrianAndHeadReports.Classes (ConstantsAndEnums.TimeUnits)
    • DTS.Slice.Control (unused in visible code)
  • System Libraries:
    • System.ComponentModel (INotifyPropertyChanged)
    • System.Threading.Tasks (Task)
    • System.Linq (Where, AddRange)
    • System.Collections.Generic (List<T>, Array)
    • System.Text (unused in visible code)

External Dependencies

  • UI Framework: WPF (inferred from Prism usage, InteractionRequest, and OpenFileDialog in commented code).
  • Export Contracts:
    • IHeadReportInputView, IHeadReportOutputView (for HeadReportViewModel)
    • ITRLReportInputView, ITRLReportOutputView (for TRLReportViewModel)
      These interfaces must be implemented by views in the UI layer.

What Depends on This Module?

  • The application shell or region manager must import and display views of type IHeadReportInputView, IHeadReportOutputView, ITRLReportInputView, and ITRLReportOutputView.
  • Event publishers for RaiseNotification and BusyIndicatorChangeNotification must exist (e.g., a global busy indicator manager or notification service).

5. Gotchas

  • IsDirty is never updated: Both view models expose IsDirty as a read-only property, but it is never set to true. This may mislead consumers expecting change tracking.
  • NotImplementedException in TRLReportViewModel: AvailableImpactorTypes and AvailableCFCs throw NotImplementedException. Any binding to these properties will crash at runtime.
  • DateTimeText setter is unsafe: Uses DateTime.Parse(value) without culture or exception handling. May throw FormatException or OverflowException on invalid input.
  • No cleanup logic: Cleanup() and CleanupAsync() are empty stubs. Event subscriptions (_eventAggregator.GetEvent<...>().Subscribe(...)) are never unsubscribed, risking memory leaks.
  • Channel population assumes non-null Test: PopulateChannels() accesses Test.Channels without null checks. If Test is null, a NullReferenceException occurs during construction.
  • UnitMatches behavior unknown: Filtering channels relies on unit.UnitMatches(...), whose implementation is not visible. May cause incorrect channel inclusion/exclusion.
  • Redundant code: Both view models duplicate identical logic for OnRaiseNotification, OnBusyIndicatorNotification, and lifecycle methods. Consider refactoring to a base class.
  • Commented-out import logic: Both files contain commented-out ImportBrowseCommand and related code. This suggests incomplete or deprecated functionality; avoid relying on it.
  • Namespace PedestrianAndHeadReports: Despite the namespace, HeadReportViewModel is not used for pedestrian reports (per file path and naming), only head reports. TRLReportViewModel appears to handle TRL (Test Report Layout) reports.
  • HeaderInfo is hardcoded: Returns "MainRegion" literally — likely a placeholder or legacy value with no dynamic meaning.