8.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T11:08:10.828283+00:00 | zai-org/GLM-5-FP8 | 1 | 297454e79e1ccbbd |
Documentation: TestModificationViewModel
1. Purpose
TestModificationViewModel is a Prism-based ViewModel responsible for managing test data modifications within the DTS Viewer application. It provides functionality to modify channel properties such as T0 (time zero), sensitivity, line fit, EU multipliers/offsets, filters, and data flags. The module interfaces with the sensor database to retrieve and update calibration records, and coordinates with the broader application via event aggregation for channel selection, T0 shifting, and modification state synchronization.
2. Public Interface
Constructor
public TestModificationViewModel(
ITestModificationView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
Initializes the ViewModel, sets up the View's DataContext, creates interaction requests, and subscribes to RaiseNotification, GraphSelectedChannelsNotification, ShiftT0Event, and SetUseZeroForUnfilteredEvent events.
Public Methods
| Method | Signature | Description |
|---|---|---|
Initialize |
void Initialize() |
Override; no-op implementation. |
Initialize |
void Initialize(object parameter) |
Override; sets Parent property from parameter cast to IBaseViewModel. |
UpdateDatabaseMethod |
void UpdateDatabaseMethod() |
Updates calibration in the sensor database. Sets CalibrationId to -1, updates ModifyDate to current time, creates a new SensorCalibration, inserts via DbOperations.SensorCalibrationsInsert, and refreshes Model.Cal with latest calibration. Publishes PageErrorEvent on failure. |
PublishChanges |
void PublishChanges() |
If Model.IsModifiedDataFlag is true, saves data flag modification immediately via TestModelManipulation.SaveModificationDataFlag. Publishes TestModificationChangedEvent with the Model. |
Public Properties
| Property | Type | Description |
|---|---|---|
View |
ITestModificationView |
Gets/sets the associated View. |
Parent |
IBaseViewModel |
Gets/sets the parent ViewModel. |
NotificationRequest |
InteractionRequest<Notification> |
Interaction request for displaying notifications. |
ConfirmationRequest |
InteractionRequest<Confirmation> |
Interaction request for displaying confirmations. |
PreviewCommand |
DelegateCommand |
Executes PreviewMethod() - calls TestModelManipulation.PreviewLineFit(Model). |
WriteCommand |
DelegateCommand |
Executes WriteMethod() - validates T0, prompts user, calls TestModelManipulation.SaveModification. |
UndoCommand |
DelegateCommand |
Executes UndoMethod() - prompts user, calls TestModelManipulation.UndoModification. |
UndoAllCommand |
DelegateCommand |
Executes UndoAllMethod() - prompts user, calls TestModelManipulation.UndoAllModification. |
UseISOCodeFilterMapping |
bool |
Controls whether ISOCode field filter matches channel's SoftwareFilter. Default: false. |
Model |
TestModificationModel |
The model containing test modification state. Setter updates Parent reference. |
UseZeroForUnfiltered |
bool |
Gets/sets whether to use zero for unfiltered values. |
IsFilterEnabled |
bool |
Gets/sets filter enabled state. Raises OnPropertyChanged. |
TestModificationVisability |
bool |
Controls visibility of test modification UI. Raises OnPropertyChanged. |
HeaderInfo |
string |
Returns "TestSummaryRegion". |
IsBusy |
bool |
Gets/sets busy state. Raises OnPropertyChanged. |
IsDirty |
bool |
Gets/sets dirty state. |
IsNavigationIncluded |
bool |
Gets/sets navigation inclusion state. |
IsBackedUp |
bool |
Gets (private sets) whether backup exists. Raises OnPropertyChanged. |
Events
| Event | Type | Description |
|---|---|---|
PropertyChanged |
PropertyChangedEventHandler |
Raised when a property value changes. |
3. Invariants
-
Single-Channel Selection:
TestModificationVisabilityistrueonly when exactly one channel is selected (channels.Count == 1 && channels.Count(x => x.IsSelected) == 1). -
T0 Validation: T0 cannot be shifted beyond the bounds of the test dataset.
Model.ValidateT0()must returntruebefore write operations proceed. -
Calibration ID Reset: When updating the database via
UpdateDatabaseMethod(),CalibrationIdis always set to-1before insertion. -
Analog Sensor Calibration Display: Calibration records are only loaded/displayed for sensors where
SensorType == 0(analog sensors). -
Calibration Sorting: Calibrations are sorted ascending by
CalibrationDate, then byModifyDateas a tiebreaker. The "latest" calibration is the last element after sorting. -
Permission-Based Controls: All edit controls (
EnableSensitivityControl,EnableLineFitControl,EnableDescriptionControl,EnableEUMultiplierControl,EnableEUOffsetControl,EnableFilterControl,IsT0Enabled,IsDataFlagEnabled) are gated byviewModel.DoesUserHaveEditPermission.
4. Dependencies
This Module Depends On:
DTS.Common.Base-BaseViewModel<T>DTS.Common.Events- Event types (PageErrorEvent,RaiseNotification,GraphSelectedChannelsNotification,ShiftT0Event,SetUseZeroForUnfilteredEvent,TestModificationChangedEvent,ShowT0CursorEvent)DTS.Common.Interactivity-InteractionRequest<T>,Notification,ConfirmationDTS.Common.Interface-IBaseViewModel,ITestModificationViewModel,ITestModificationView,IViewerMainViewModelDTS.Common.Interface.Sensors-ISensorDbRecord,ISensorCalDbRecordDTS.Common.Settings-SettingsDB,KeysDTS.Common.Storage- (content not visible, inferred from namespace)DTS.Common.Utilities.Logging-APILoggerDTS.SensorDB-DbOperations,SensorCalibrationDTS.Viewer.ChartOptions.Model- (content not visible)DTS.Viewer.TestModification.Model-TestModificationModel,TestModelManipulationPrism.Commands-DelegateCommandPrism.Events-IEventAggregatorPrism.Regions-IRegionManagerUnity-IUnityContainer
What Depends On This Module:
- Not determinable from source alone. Inferred consumers would be the View (
TestModificationView) and the main application shell via region navigation.
5. Gotchas
-
Typo in Property Name:
TestModificationVisabilityis misspelled (should be "Visibility"). This may cause confusion when referencing the property. -
Malformed XML Comment: The
GetLatestCalibrationmethod has a malformed XML comment with<summary>used as both opening and closing tag instead of</summary>. -
Silent Exception Swallowing:
GetLatestCalibrationcatches all exceptions and returnsnullwithout logging. The comment explicitly states: "there's no access to APILogger here, so rather than adding a reference, just eat the error". -
Member Hiding with
newKeyword: Several members (OnPropertyChanged,PropertyChanged,IsBusy,IsDirty,IsNavigationIncluded) use thenewkeyword to hide base class members, which can lead to unexpected behavior when casting to base types. -
Yoda Condition Style: The codebase uses Yoda conditions (
null == sensorinstead ofsensor == null) consistently throughout. -
Hardcoded Calibration ID:
cal.CalibrationId = -1is used as a marker for new calibrations. The significance of-1is not documented in code. -
Static
IsPopulatingProperty:IsPopulatingis a static property used to preventPublishChangesfrom executing during model population, which could cause issues if multiple instances exist. -
Feature Request Reference: A comment references an internal case URL:
http://manuscript.dts.local/f/cases/43735/for the database update feature.