7.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:52:03.540484+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | cb6b20481dcc9200 |
ViewModel
Purpose
The CachedItemsListViewModel class serves as the ViewModel for the CachedItemsList module, responsible for managing and exposing a list of items (sensors, hardware, and calibrations) that may be out of sync between the current test setup and the persistent database. It coordinates UI state (e.g., busy indicators, notifications), integrates with Prism’s event aggregation and region management, and provides a foundation for detecting discrepancies (e.g., missing or modified items). Though the core logic for populating CachedItems is currently commented out, the class defines the structure and infrastructure needed to support cache validation and synchronization workflows.
Public Interface
Constructor
public CachedItemsListViewModel(
ICachedItemsListView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
Initializes the ViewModel, sets the View and its DataContext, registers event subscriptions for RaiseNotification and BusyIndicatorChangeNotification, and initializes InteractionRequest properties for UI notifications.
Properties
-
public ICachedItemsListView View { get; set; }
Reference to the associated view. Set during construction. -
public ICachedItem[] CachedItems { get; set; } = new ICachedItem[0];
Array of cached items representing potential discrepancies. Currently unpopulated in active code. -
public bool IsDirty => false;
Always returnsfalse; no dirty-state tracking logic is implemented. -
public bool IsBusy { get; set; }
Binds to UI busy indicator. RaisesPropertyChangedon change. -
public bool IsMenuIncluded { get; set; }
Controls visibility of menu UI elements. RaisesPropertyChangedon change. -
public bool IsNavigationIncluded { get; set; }
Controls visibility of navigation UI elements. RaisesPropertyChangedon change. -
public bool HasOutofDateCachedItems => CachedItems.Any();
Indicates if any cached items exist (i.e., potential discrepancies). AlwaysfalsewhileCachedItemsis empty. -
public bool HasMissingSensors { get; }
ReturnstrueifCachedItemscontains at least one sensor item withDBTime == DateTime.MinValue. Currently alwaysfalse.
Methods
-
public void Unset()
Empty stub; no cleanup logic. -
public void Cleanup()
Empty stub; no cleanup logic. -
public Task CleanupAsync()
ReturnsTask.CompletedTask; no async cleanup. -
public void Initialize()
Empty stub. -
public void Initialize(object parameter)
Empty stub. -
public void Initialize(object parameter, object model)
Empty stub. -
public Task InitializeAsync()
ReturnsTask.CompletedTask. -
public Task InitializeAsync(object parameter)
ReturnsTask.CompletedTask. -
public void Activated()
Empty stub. -
public bool SetCachedItems(ISensorData[] sensors, ISensorCalibration[] sensorCalibrations, IDASHardware[] hardware, IDASHardware[] allDAS)
Currently returnsfalseimmediately.
Intended to compare in-memory sensor/hardware/calibration data against database records and populateCachedItemswith discrepancies. Logic is commented out but includes:- Grouping sensors by type (analog, squib, digital input/output).
- Filtering out test-specific digital outputs (via
IsTestSpecificDigitalOutput). - Detecting out-of-date or missing items by comparing
LastModified/CalibrationDate/ModifyDate. - Using
DbOperationsmethods (e.g.,SensorsAnalogGet,SensorCalibrationsGet) to fetch DB records. - Returning
trueif any discrepancies were found.
Event Handlers (Private)
-
private void OnBusyIndicatorNotification(bool eventArg)
UpdatesIsBusybased on event argument. -
private void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)
ConvertsNotificationContentEventArgstoNotificationand raisesNotificationRequest.
InteractionRequests
-
public InteractionRequest<Notification> NotificationRequest { get; }
Used to trigger notification popups. -
public InteractionRequest<Confirmation> ConfirmationRequest { get; }
Used to trigger confirmation dialogs.
Event
public event PropertyChangedEventHandler PropertyChanged;
ImplementsINotifyPropertyChanged.public void OnPropertyChanged(string propertyName)
RaisesPropertyChangedfor the specified property.
Invariants
CachedItemsis always a non-null array (default: empty).IsBusyis synchronized with theBusyIndicatorChangeNotificationevent.IsTestSpecificDigitalOutputuses the constantTEST_SPECIFIC_DIGITAL_OUT = "TSD_"to exclude test-specific digital outputs from cache validation.HasMissingSensorsrelies onDBTime == DateTime.MinValueandObjectType == Resources.StringResources.Sensorto identify missing sensors.CachedItemsis not populated in the current implementation (allInitialize*/SetCachedItemsmethods are no-ops or stubs).
Dependencies
Imports/References
DTS.Common.Events(e.g.,RaiseNotification,BusyIndicatorChangeNotification)DTS.Common.Interface.TestSetups.CachedItemsList(e.g.,ICachedItemsListViewModel,ICachedItemsListView,ICachedItem)DTS.Common.Interface.DataRecorders(e.g.,IDASHardware)DTS.Common.Interface.Sensors(e.g.,ISensorData,ISensorCalibration)Prism.Events(IEventAggregator)Prism.Regions(IRegionManager)Unity(IUnityContainer)DTS.Common.Interactivity(InteractionRequest<T>)System.ComponentModel(INotifyPropertyChanged)
External Components Used
DbOperations(referenced in commented code, e.g.,DbOperations.SensorsAnalogGet) — not imported directly but assumed to be available at runtime.Resources.StringResources(e.g.,Resources.StringResources.Sensor) — assumed static resource.
Depended Upon By
ICachedItemsListView(view) binds to this ViewModel.- Other modules may publish
RaiseNotificationorBusyIndicatorChangeNotificationevents consumed by this ViewModel.
Gotchas
- Critical functionality is commented out: The
SetCachedItemsmethod and all initialization logic are non-functional. The class currently does not populateCachedItemsor detect discrepancies. IsDirtyis hardcoded tofalse: No actual dirty-state tracking is implemented.DbOperationsis not imported: The commented code referencesDbOperations, but nousingorusing staticdirective for it exists. Its availability at runtime is unverifiable from this file alone.Resources.StringResourcesusage is implicit: Nousingdirective for theResourcesnamespace is present; its structure and members (e.g.,Sensor,Hardware,SensorCal) are assumed.TEST_SPECIFIC_DIGITAL_OUTprefix"TSD_"is hardcoded: No configuration or external definition is provided for this value.CachedItemsis a public auto-property: Direct mutation (e.g.,CachedItems = new ICachedItem[0]) bypassesOnPropertyChanged, but the property is not raised when set (onlyIsBusy,IsMenuIncluded,IsNavigationIncludedraisePropertyChanged). This may cause UI binding issues ifCachedItemsis reassigned.- No disposal logic:
Unset,Cleanup, andCleanupAsyncare empty; event subscriptions (e.g.,_eventAggregator) are not unsubscribed, risking memory leaks. IsTestSpecificDigitalOutputis static but uses instance constant: The method isstatic, butTEST_SPECIFIC_DIGITAL_OUTis an instance field—though valid in C#, this is unusual and could be confusing.