Files
2026-04-17 14:55:32 -04:00

39 lines
2.5 KiB
Markdown

---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/ViewModel/TestModificationViewModel.cs
generated_at: "2026-04-17T15:59:06.360686+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "7c56b83b77bf5525"
---
# Documentation: TestModificationViewModel
## 1. Purpose
`TestModificationViewModel` is a Prism-based ViewModel that manages the test modification UI panel in the DTS Viewer application. It enables users to modify test data properties (T0 timing, sensitivity, line fit, EU multiplier/offset, filters, data flags) for selected channels, persist those modifications to files, and optionally update sensor calibration data back to the Sensor Database. The module coordinates between the UI, event-driven channel selection, and the `TestModelManipulation` helper class for actual data operations.
## 2. Public Interface
### Constructor
```csharp
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 |
|--------|-----------|-------------|
| `UpdateDatabaseMethod` | `void UpdateDatabaseMethod()` | Updates calibration in the Sensor Database. Sets `CalibrationId = -1`, updates `ModifyDate` to `DateTime.Now`, creates a `SensorCalibration` from `Model.Cal`, and inserts via `DbOperations.SensorCalibrationsInsert`. Refreshes `Model.Cal` from latest database record. |
| `Initialize` | `void Initialize()` | Empty override. |
| `Initialize` | `void Initialize(object parameter)` | Sets `Parent` property from parameter cast to `IBaseViewModel`. |
| `PublishChanges` | `void PublishChanges()` | If not populating and `Model.IsModifiedDataFlag` is true, immediately saves data flag modification via `TestModelManipulation.SaveModificationDataFlag`. Publishes `TestModificationChangedEvent` with the Model. |
### Commands
| Command | Method | Description |
|---------|--------|-------------|
| `PreviewCommand` | `PreviewMethod()` | Calls `TestModelManipulation.PreviewLineFit(Model)`. |
| `WriteCommand` | `WriteMethod()` | Validates T0 if modified, prompts user with Yes/No dialog, retrieves `UseISOCodeFilterMapping` setting, and calls `TestModelManipulation.SaveModification`. Updates `IsBackedUp`. |
| `UndoCommand` | `UndoMethod()` |