init
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Model/Enums.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Model/TestModificationModel.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Model/TestModelManipulation.cs
|
||||
generated_at: "2026-04-16T13:47:44.691721+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "1e3214665d63bf12"
|
||||
---
|
||||
|
||||
# Test Modification Module Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides functionality for modifying test data within the DTS Viewer application. It manages the state of user-initiated modifications to channel parameters (sensitivity, EU offset/multiplier, T0 timing, line fit, software filters, data flags, and descriptions), tracks which values have been modified from their originals, and handles the persistence of these changes to both `.dts` XML files and binary `.chn` channel files. The module also manages backup/restore operations to allow undoing modifications.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Enums.cs
|
||||
|
||||
#### `Keys` Enum
|
||||
```csharp
|
||||
public enum Keys
|
||||
{
|
||||
ApplyShiftT0ModsTestOnly // System Setting for whether to restrict "Shift T0" test modifications to "Test" only.
|
||||
}
|
||||
```
|
||||
- Defines configuration keys used by the TestModification module.
|
||||
|
||||
---
|
||||
|
||||
### TestModificationModel.cs
|
||||
|
||||
#### `TestModificationModel` Class
|
||||
Implements `ITestModificationModel`. A model class that tracks modification state for a selected test channel.
|
||||
|
||||
**Calibration Properties:**
|
||||
- `string CalDate` — Read-only; returns calibration date or empty string if `Cal` is null.
|
||||
- `string ModifyDate` — Read-only; returns modify date/time or empty string if `Cal` is null.
|
||||
- `double CalSensitivity` — Gets/sets sensitivity from the first calibration record; returns `double.NaN` if unavailable.
|
||||
- `bool ProportionalToExcitation` — Read-only; returns whether calibration is proportional to excitation.
|
||||
- `bool ShowSensorCal` — Read-only; returns true if `Cal` and `Sensor` exist and calibration is not non-linear.
|
||||
- `bool NonLinear` — Read-only; returns whether calibration is non-linear.
|
||||
- `ISensorCalDbRecord Cal` — Gets/sets the latest calibration record for the channel.
|
||||
- `ISensorDbRecord Sensor` — Gets/sets the sensor corresponding to the channel.
|
||||
|
||||
**Selection & Description:**
|
||||
- `ITestChannel SelectedChannel` — The currently selected test channel.
|
||||
- `string Description` — Channel description string.
|
||||
- `bool IsModifiedDescription` — True if description differs from `SelectedChannel.ChannelDescriptionString`.
|
||||
|
||||
**EU (Engineering Units) Properties:**
|
||||
- `double EuMultiplier` — EU multiplier value.
|
||||
- `bool IsModifiedEuMultiplier` — True if multiplier differs from `SelectedChannel.Multiplier`.
|
||||
- `double EuOffset` — EU offset value.
|
||||
- `bool IsModifiedEuOffset` — True if offset differs from `SelectedChannel.UserOffsetEu`.
|
||||
|
||||
**Timing Properties:**
|
||||
- `double T0` — T0 shift value (milliseconds).
|
||||
- `bool IsModifiedT0` — True if T0 is not equal to 0.
|
||||
- `T0Mode T0Mode` — Indicates whether T0 changes apply to DAS or Test; coerced to `T0Mode.Test` if `IsT0ModeTestOnly` is true.
|
||||
- `bool IsT0ModeTestOnly` — Internal setter; restricts T0 mode selection.
|
||||
|
||||
**Line Fit Properties:**
|
||||
- `double T1` — Line fit start point (milliseconds).
|
||||
- `double T2` — Line fit end point (milliseconds).
|
||||
- `bool IsModifiedLineFit` — True if T1 or T2 are non-zero.
|
||||
|
||||
**Sensitivity & Filter:**
|
||||
- `double Sensitivity` — Channel sensitivity value.
|
||||
- `bool IsModifiedSensitivity` — True if sensitivity differs from `SelectedChannel.Sensitivity`.
|
||||
- `IFilterClass SelectedFilter` — Selected software filter; defaults to `FilterClass(FilterClassType.Unfiltered)`.
|
||||
- `bool IsModifiedFilter` — True if filter differs from `SelectedChannel.SoftwareFilter`.
|
||||
|
||||
**Data Flag:**
|
||||
- `DataFlag SelectedDataFlag` — Selected data flag; defaults to `DataFlag.None`.
|
||||
- `bool IsModifiedDataFlag` — True if data flag differs from `SelectedChannel.DataFlag`.
|
||||
|
||||
**Control Enable Properties (internal setters):**
|
||||
- `bool EnableSensitivityControl`
|
||||
- `bool EnableLineFitControl`
|
||||
- `bool EnableEUOffsetControl`
|
||||
- `bool EnableEUMultiplierControl`
|
||||
- `bool EnableFilterControl`
|
||||
- `bool EnableDescriptionControl`
|
||||
- `bool IsDataFlagEnabled`
|
||||
- `bool IsT0Enabled`
|
||||
|
||||
**State Tracking:**
|
||||
- `bool IsModified` — True if any modification flag is true and `SelectedChannel` is not null.
|
||||
- `bool IsSaved` — Read-only property (appears unimplemented in source).
|
||||
- `ITestModificationViewModel Parent` — Reference to parent view model.
|
||||
|
||||
**Methods:**
|
||||
- `void OnPropertyChanged(string propertyName)` — Raises `PropertyChanged` event and recalculates `IsModified`.
|
||||
- `bool ValidateT0()` — Validates that T0 falls within the dataset's start and end time bounds.
|
||||
|
||||
**Commands:**
|
||||
- `DelegateCommand UpdateDatabaseCommand` — Executes `Parent.UpdateDatabaseMethod()`.
|
||||
|
||||
---
|
||||
|
||||
### TestModelManipulation.cs
|
||||
|
||||
#### `TestModelManipulation` Class
|
||||
Static utility class for file-based test modification operations.
|
||||
|
||||
**Constants:**
|
||||
```csharp
|
||||
public const double UNUSED_START_TIME = 0;
|
||||
public const int UNUSED_DATA_COLLECTION_LENGTH = 0;
|
||||
private const string BackupHeaderExtension = ".header.bak";
|
||||
private const string BackupFileExtension = ".bak";
|
||||
```
|
||||
|
||||
**Public Methods:**
|
||||
|
||||
- `static void UndoAllModification(ITestModificationModel model)` — Reverts all modifications by restoring `.dts` and all binary `.chn` files from backups. Publishes `TestModificationEvent` and optionally `ChannelsModificationNotification`/`RefreshTestRequestEvent`.
|
||||
|
||||
- `static bool BackupExists(ITestModificationModel model)` — Returns true if a `.dts.bak` or `.chn.bak` file exists for the selected channel.
|
||||
|
||||
- `static bool SaveModification(ITestModificationModel model, bool useISOCodeFilterMapping, bool bUseZeroForUnfiltered)` — Persists all modifications to disk. Handles T0 (Test or DAS mode), line fit, sensitivity, filter, EU offset/multiplier, description, and data flag changes. Returns true on success.
|
||||
|
||||
- `static bool SaveModificationDataFlag(ITestModificationModel model)` — Saves only data flag modifications to the `.dts` file.
|
||||
|
||||
- `static void ApplyLineFit(ITestModificationModel model, Test.Module.Channel channel)` — Applies a linear interpolation between T1 and T2 sample indices, modifying the channel's ADC data in place.
|
||||
|
||||
- `static void PreviewLineFit(ITestModificationModel model)` — Publishes `ChannelsModificationLineFitNotification` with line fit parameters for UI preview without disk modification.
|
||||
|
||||
- `static void UndoModification(ITestModificationModel model)` — Reverts in-memory model state from the selected channel and publishes `ChannelsModificationNotification`.
|
||||
|
||||
- `static void PopulateFromChannel(ITestModificationModel model)` — Initializes model properties from `SelectedChannel` values.
|
||||
|
||||
- `static void BackupChannelIfNeeded(Test.Module.Channel testModuleChannel, bool headerOnly)` — Creates a backup of a `.chn` file (full file or header only).
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **IsModified Consistency**: `IsModified` is always `false` when `SelectedChannel` is `null`, regardless of other property states.
|
||||
|
||||
2. **T0Mode Coercion**: When `IsT0ModeTestOnly` is `true`, the `T0Mode` setter always coerces the value to `T0Mode.Test`.
|
||||
|
||||
3. **Backup File Semantics**: Backup files (`.bak` and `.header.bak`) represent the *original* unmodified state. If a backup already exists, it is not overwritten—this preserves the original file for undo operations.
|
||||
|
||||
4. **Line Fit Index Ordering**: In `ApplyLineFit`, if `startIndex > endIndex`, the values are swapped before processing.
|
||||
|
||||
5. **Calibration Record Access**: `CalSensitivity` always accesses `Cal.Records.Records[0]` (first record); behavior is undefined if multiple records exist and others are relevant.
|
||||
|
||||
6. **T0 Validation Bounds**: `ValidateT0()` returns `true` (valid) if `SelectedChannel` or `SelectedChannel.ParentModule` is null, treating unavailable data as "no constraint."
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
**This module depends on:**
|
||||
- `DTS.Common` — Core utilities and interfaces
|
||||
- `DTS.Common.Classes.Sensors` — Sensor-related classes
|
||||
- `DTS.Common.Enums.Sensors` — Sensor enumerations including `DataFlag`, `T0Mode`
|
||||
- `DTS.Common.Interface` — Core interfaces including `ITestChannel`
|
||||
- `DTS.Common.Interface.Sensors` — Sensor interfaces including `ISensorCalDbRecord`, `ISensorDbRecord`
|
||||
- `DTS.Common.Interface.Sensors.SoftwareFilters` — `IFilterClass`, `FilterClass`, `FilterClassType`
|
||||
- `DTS.Common.Events` — Event types (`TestModificationEvent`, `TestModificationArgs`, `ChannelsModificationNotification`, `ChannelsModificationLineFitNotification`, `LineFitArgs`, `RefreshTestRequestEvent`)
|
||||
- `DTS.Common.Settings` — `SettingsDB` for global settings
|
||||
- `DTS.Common.Utilities.Logging` — `APILogger`
|
||||
- `DTS.Serialization` — Serialization utilities for `.chn` and `.dts` files
|
||||
- `DTS.SensorDB` — Sensor database interfaces
|
||||
- `Prism.Commands` — `DelegateCommand`
|
||||
- `Prism.Ioc` — `ContainerLocator`
|
||||
- `Prism.Events` — `IEventAggregator`
|
||||
|
||||
**Consumers of this module:**
|
||||
- Not explicitly shown in source; inferred consumer is `ITestModificationViewModel` implementation referenced via `Parent` property.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Namespace Mismatch**: `TestModificationModel.cs` declares namespace `DTS.Viewer.ChartOptions.Model` while the file path suggests `DTS.Viewer.TestModification.Model`. This inconsistency may cause confusion or require external namespace mapping.
|
||||
|
||||
2. **IsSaved Property Unimplemented**: The `IsSaved` property has a getter but no setter or backing field initialization, meaning it will always return `false` (default for `bool`).
|
||||
|
||||
3. **T0 DAS Mode Scope**: When `T0Mode.DAS` is used, T0 changes are applied to all modules matching the `BaseSerialNumber` of the module containing the selected channel—even if those modules don't contain the selected channel itself. This is a cross-module modification.
|
||||
|
||||
4. **Line Fit Boundary Handling**: `ApplyLineFit` uses indices `startIndex + 1` through `endIndex - 1` for interpolation, meaning the actual start and end points are not modified (they define the line but are not overwritten).
|
||||
|
||||
5. **File Encoding Assumption**: `WriteDTSFileChanges` forces UTF-16 encoding with a fallback to default encoding on exception. The comment indicates this is intentional for `.dts` file compatibility.
|
||||
|
||||
6. **Thread.Sleep in File Write**: `WriteDTSFileChanges` includes `System.Threading.Thread.Sleep(10)` after writing—purpose is unclear from source alone, possibly a workaround for file locking or timing issues.
|
||||
|
||||
7. **ISO Code Filter Mapping Side Effect**: When `useISOCodeFilterMapping` is true in `SaveModification`, modifying the filter also modifies the channel's `IsoCode` field, which triggers a header backup even if only the filter was changed.
|
||||
|
||||
8. **BackupExists Returns True for Any Backup**: The method returns `true` if either `.dts.bak` or `.chn.bak` exists, not necessarily both. This could indicate partial backup state.
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Properties/AssemblyInfo.cs
|
||||
generated_at: "2026-04-16T13:46:59.533949+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "159c8c375f9a8da3"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.TestModification Assembly Configuration
|
||||
|
||||
## 1. Purpose
|
||||
This file provides assembly-level metadata attributes for the `DTS.Viewer.TestModification` module. It configures the embedded manifest for the compiled .NET assembly, defining its identity, version, copyright information, and COM visibility settings. It exists to satisfy .NET build requirements for assembly information, particularly in older project formats or when explicit assembly info generation is required.
|
||||
|
||||
## 2. Public Interface
|
||||
This file does not expose any classes, methods, or functions for programmatic invocation. It strictly uses assembly-level attributes to configure the compiled binary. The defined attributes are:
|
||||
|
||||
* **`AssemblyTitle`**: Set to `"DTS.Viewer.TestModification"`.
|
||||
* **`AssemblyDescription`**: Set to an empty string.
|
||||
* **`AssemblyConfiguration`**: Set to an empty string.
|
||||
* **`AssemblyCompany`**: Set to an empty string.
|
||||
* **`AssemblyProduct`**: Set to `"DTS.Viewer.TestModification"`.
|
||||
* **`AssemblyCopyright`**: Set to `"Copyright © 2017"`.
|
||||
* **`AssemblyTrademark`**: Set to an empty string.
|
||||
* **`AssemblyCulture`**: Set to an empty string (indicates the assembly is culture-neutral).
|
||||
* **`ComVisible`**: Set to `false`. Prevents types within the assembly from being visible to COM components.
|
||||
* **`Guid`**: Set to `"5ee7c61f-e9fe-479b-be1f-78a142341c3b"`. Acts as the ID for the type library if the assembly is exposed to COM.
|
||||
* **`AssemblyVersion`**: Set to `"1.0.0.0"`. Defines the version used by the common language runtime.
|
||||
* **`AssemblyFileVersion`**: Set to `"1.0.0.0"`. Defines the version stored in the file's Win32 file version resource.
|
||||
|
||||
## 3. Invariants
|
||||
* **COM Visibility:** The attribute `[assembly: ComVisible(false)]` ensures that no types in this assembly are exposed to COM by default. To expose a specific type, this attribute would need to be overridden at the class level.
|
||||
* **Versioning:** Both the assembly version and file version are explicitly fixed at `1.0.0.0`. They will not auto-increment with builds unless the file is manually updated or the build process modifies it externally.
|
||||
* **Culture:** The assembly is strictly culture-neutral (`AssemblyCulture("")`), implying it does not contain satellite resources for a specific language.
|
||||
|
||||
## 4. Dependencies
|
||||
* **Internal Dependencies:**
|
||||
* `System.Reflection`: Required for the assembly attributes.
|
||||
* `System.Runtime.CompilerServices`: Required for assembly attributes.
|
||||
* `System.Runtime.InteropServices`: Required for the `Guid` and `ComVisible` attributes.
|
||||
* **External Dependencies:** None inferred from this file alone. This file is a configuration artifact consumed by the compiler during the build of the `DTS.Viewer.TestModification` project.
|
||||
|
||||
## 5. Gotchas
|
||||
* **Empty Metadata:** Several informational attributes (`AssemblyDescription`, `AssemblyCompany`, `AssemblyConfiguration`) are initialized as empty strings. This may result in sparse metadata when inspecting the compiled DLL properties in Windows Explorer.
|
||||
* **Legacy Project Format:** The presence of an explicit `AssemblyInfo.cs` with commented-out wildcard versioning syntax (`// [assembly: AssemblyVersion("1.0.*")]`) suggests this project uses a legacy (non-SDK style) .NET project format. Modern .NET Core/5+ projects typically auto-generate this information in the `.csproj` file, which can lead to build conflicts (CS0579 duplicate attribute errors) if this file is left in a modern project without disabling auto-generation.
|
||||
* **Hardcoded Version:** The version numbers are hardcoded. If continuous integration relies on auto-incrementing build numbers, this file would need to be modified by the build server or replaced with wildcard syntax.
|
||||
@@ -0,0 +1,117 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Resources/TranslateExtension.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Resources/StringResources.Designer.cs
|
||||
generated_at: "2026-04-16T13:46:55.298377+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "46010437bced3eec"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.TestModification.Resources
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides localization support for the DTS Viewer Test Modification feature. It enables XAML-based string resource lookup through a WPF markup extension (`TranslateExtension`) backed by a strongly-typed, auto-generated resource class (`StringResources`). The module centralizes all user-facing strings for the test modification UI, supporting potential internationalization and ensuring consistent string management.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### TranslateExtension (public class)
|
||||
|
||||
**Namespace:** `DTS.Viewer.TestModification`
|
||||
**Base Class:** `System.Windows.Markup.MarkupExtension`
|
||||
**Attribute:** `[MarkupExtensionReturnType(typeof(string))]`
|
||||
|
||||
A WPF markup extension that enables XAML bindings to localized string resources.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| Constructor | `TranslateExtension(string key)` | Initializes the extension with the resource key to look up. The key is stored in a readonly field `_key`. |
|
||||
| Method | `public override object ProvideValue(IServiceProvider serviceProvider)` | Returns the localized string for the provided key via `StringResources.ResourceManager.GetString(_key)`. Returns `#stringnotfound#` if key is null/empty, or `#stringnotfound# {key}` if the key is not found in resources. |
|
||||
|
||||
**Constants:**
|
||||
- `private const string NotFound = "#stringnotfound#"` — Fallback value returned when a resource key is invalid or missing.
|
||||
|
||||
---
|
||||
|
||||
### StringResources (internal class)
|
||||
|
||||
**Namespace:** `DTS.Viewer.TestModification.Resources`
|
||||
**Attributes:** `[GeneratedCode]`, `[DebuggerNonUserCode]`, `[CompilerGenerated]`
|
||||
|
||||
An auto-generated strongly-typed resource class. **Do not modify manually** — edits will be lost on regeneration.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| Property | `internal static ResourceManager ResourceManager` | Returns the cached `ResourceManager` instance for the resource bundle `"DTS.Viewer.TestModification.Resources.StringResources"`. Lazily initialized. |
|
||||
| Property | `internal static CultureInfo Culture` | Gets or sets the `CultureInfo` used for resource lookups. Overrides `CurrentUICulture` for this resource class. |
|
||||
|
||||
**Localized String Properties (all `internal static string`):**
|
||||
|
||||
| Property | Default Value (from comments) |
|
||||
|----------|-------------------------------|
|
||||
| `CalDate` | "Cal date" |
|
||||
| `DataFlag` | "Data Flag:" |
|
||||
| `Description` | "Description:" |
|
||||
| `EUMultiplier` | "EU Multiplier:" |
|
||||
| `EUOffset` | "EU Offset:" |
|
||||
| `FailedToModifySensitivity` | "Failed to modify sensitivity: " |
|
||||
| `Filter` | "Filter:" |
|
||||
| `LineFit` | "Line Fit:" |
|
||||
| `ModifyDate` | "Modify date" |
|
||||
| `NonLinear` | "Non-linear" |
|
||||
| `PleaseLockHeader` | "To enable, please lock a single channel." |
|
||||
| `Preview` | "Preview" |
|
||||
| `ProportionalToExcitation` | "Proportional to excitation" |
|
||||
| `Sensitivity` | "Sensitivity:" |
|
||||
| `SensorCalibration` | "Sensor calibration (most recent in db)" |
|
||||
| `ShiftT0ms` | "Shift T₀ (ms):" |
|
||||
| `T0MustBeInDataset` | "Modification can not be made, T0 must be in the dataset." |
|
||||
| `T1ms` | "T₁ (ms):" |
|
||||
| `T2ms` | "T₂ (ms):" |
|
||||
| `Undo` | "Cancel" |
|
||||
| `UndoAll` | "Restore All" |
|
||||
| `UndoAllPrompt` | "This will revert your saved test modifications to the backup on file. Continue?" |
|
||||
| `UndoPrompt` | "This will undo any change(s) to this channel made before saving. Continue?" |
|
||||
| `UpdateDatabase` | "Update database" |
|
||||
| `WriteFiles` | "Write" |
|
||||
| `WriteFilesPrompt` | "Are you sure you want to write these changes to disk?" |
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Key immutability:** The `_key` field in `TranslateExtension` is readonly and set only at construction time.
|
||||
2. **Fallback behavior:** `ProvideValue` will never return null — it always returns either a valid localized string or a string containing `#stringnotfound#`.
|
||||
3. **Error differentiation:** A null/empty key returns `"#stringnotfound#"` alone; a missing key returns `"#stringnotfound# {key}"` (includes the key name).
|
||||
4. **Resource manager singleton:** `StringResources.ResourceManager` is lazily initialized and cached; subsequent accesses return the same instance.
|
||||
5. **Auto-generated code:** `StringResources.Designer.cs` is regenerated by tooling; manual changes will be overwritten.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This module depends on:
|
||||
- `System` — Core .NET types
|
||||
- `System.Windows.Markup` — `MarkupExtension` base class for XAML support
|
||||
- `System.Resources` — `ResourceManager` for resource lookup
|
||||
- `System.Globalization` — `CultureInfo` for localization
|
||||
- `System.CodeDom.Compiler`, `System.Diagnostics`, `System.Runtime.CompilerServices` — Attributes for auto-generated code
|
||||
|
||||
### What depends on this module:
|
||||
- XAML files in `DTS.Viewer.TestModification` that use the `{x:Static}` or `{local:Translate}` markup extension pattern for localized UI strings
|
||||
- Code-behind in the TestModification module that accesses `StringResources` properties directly
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Different error formats:** A null/empty key returns `"#stringnotfound#"` without the key name, while a valid-but-missing key returns `"#stringnotfound# {key}"`. This could cause confusion when debugging missing resources.
|
||||
|
||||
2. **Auto-generated file:** `StringResources.Designer.cs` is tool-generated. To add or modify strings, edit the `.resx` file, not this file. The comments explicitly warn: "Changes to this file may cause incorrect behavior and will be lost if the code is regenerated."
|
||||
|
||||
3. **Internal visibility:** `StringResources` is `internal`, limiting access to within the assembly. `TranslateExtension` is `public`, making it usable from XAML regardless of assembly boundaries.
|
||||
|
||||
4. **Culture management:** The `Culture` property on `StringResources` allows overriding the lookup culture, but this is a global setting for the class. If set, it affects all subsequent resource lookups through this class. It is unclear from source alone whether/how the application manages this property at runtime.
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/View/TestModificationView.xaml.cs
|
||||
generated_at: "2026-04-16T13:47:19.361025+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "3165a969f0d942bf"
|
||||
---
|
||||
|
||||
# Documentation: TestModificationView.xaml.cs
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides the code-behind for a WPF view component (`TestModificationView`) within the DTS Viewer application's TestModification module. It implements the `ITestModificationView` interface and exposes available filter class options to the view layer, serving as a bridge between the sensor database configuration and the UI for test modification functionality.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `TestModificationView` (Class)
|
||||
|
||||
**Implements:** `ITestModificationView`
|
||||
|
||||
#### Constructor
|
||||
|
||||
```csharp
|
||||
public TestModificationView()
|
||||
```
|
||||
Initializes the view component by calling `InitializeComponent()`, which loads the associated XAML.
|
||||
|
||||
#### Property: `AvailableCFC`
|
||||
|
||||
```csharp
|
||||
public List<IFilterClass> AvailableCFC { get; }
|
||||
```
|
||||
Returns a list of available filter classes (CFC = Channel Filter Classes, per comment "FB 13120"). Each access instantiates a new `AnalogSettingDefaults` object and returns its `FilterOptions` property.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- The `AvailableCFC` property always returns a non-null `List<IFilterClass>` (the actual nullability depends on `AnalogSettingDefaults.FilterOptions` implementation, which is external to this file).
|
||||
- The view is a partial class; the XAML counterpart (`TestModificationView.xaml`) must exist for `InitializeComponent()` to succeed.
|
||||
- The class implements `ITestModificationView`, implying contractual obligations defined in that interface (not visible in this source).
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This module depends on:
|
||||
- `DTS.Common.Interface` — provides `ITestModificationView` interface
|
||||
- `DTS.Common.Interface.Sensors.SoftwareFilters` — provides `IFilterClass` interface
|
||||
- `DTS.SensorDB` — provides `AnalogSettingDefaults` class
|
||||
- `System.Windows.Controls` — WPF infrastructure (UserControl base, implied by `InitializeComponent()` pattern)
|
||||
|
||||
### Unused import:
|
||||
- `System.Text.RegularExpressions` — imported but not referenced in this file
|
||||
|
||||
### What depends on this module:
|
||||
- Cannot be determined from this source file alone (likely referenced by a module registration/bootstrapper or a parent view).
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Object allocation on every property access**: The `AvailableCFC` getter creates a new `AnalogSettingDefaults` instance on every call. If this property is data-bound and accessed frequently by WPF, it could cause unnecessary allocations. Consider whether caching is appropriate.
|
||||
|
||||
2. **Unused import**: `System.Text.RegularExpressions` is imported but not used in this file. This may indicate dead code, a missing implementation, or usage in the XAML portion.
|
||||
|
||||
3. **Namespace suppression**: The file includes `// ReSharper disable CheckNamespace`, suggesting the namespace may not match the folder structure. This could cause confusion when navigating the codebase.
|
||||
|
||||
4. **FB 13120 reference**: The comment references a tracking item (likely a bug or feature request). The context and resolution status of this item are unknown from the source alone.
|
||||
@@ -0,0 +1,135 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/ViewModel/TestModificationViewModel.cs
|
||||
generated_at: "2026-04-16T13:45:56.000728+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "297454e79e1ccbbd"
|
||||
---
|
||||
|
||||
# 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, descriptions, EU multipliers/offsets, filters, and data flags) for selected channels. The class coordinates between the UI, a sensor calibration database, and the broader application via event aggregation, while enforcing permission-based edit controls and providing undo/redo capabilities for modifications.
|
||||
|
||||
---
|
||||
|
||||
## 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 four events: `RaiseNotification`, `GraphSelectedChannelsNotification`, `ShiftT0Event`, and `SetUseZeroForUnfilteredEvent`.
|
||||
|
||||
### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `View` | `ITestModificationView` | Gets/sets the associated view instance. |
|
||||
| `Parent` | `IBaseViewModel` | Gets/sets the parent ViewModel reference. |
|
||||
| `Model` | `TestModificationModel` | The model containing channel modification state. Setting updates the model's `Parent` reference. |
|
||||
| `PreviewCommand` | `DelegateCommand` | Executes `PreviewMethod()` to preview line fit changes. |
|
||||
| `WriteCommand` | `DelegateCommand` | Executes `WriteMethod()` to persist modifications after validation and user confirmation. |
|
||||
| `UndoCommand` | `DelegateCommand` | Executes `UndoMethod()` to revert the last modification. |
|
||||
| `UndoAllCommand` | `DelegateCommand` | Executes `UndoAllMethod()` to revert all modifications. |
|
||||
| `TestModificationVisability` | `bool` | Controls visibility of the modification panel; true only when exactly one channel is selected. |
|
||||
| `IsBackedUp` | `bool` | Indicates whether a backup exists for the current model state. Private setter. |
|
||||
| `UseISOCodeFilterMapping` | `bool` | When true, forces ISOCode field filter to match channel's SoftwareFilter. Defaults to `false`. |
|
||||
| `UseZeroForUnfiltered` | `bool` | Gets/sets whether to use zero for unfiltered values. Set via `SetUseZeroForUnfilteredEvent`. |
|
||||
| `IsFilterEnabled` | `bool` | Gets/sets filter enabled state with property change notification. |
|
||||
| `HeaderInfo` | `string` | Returns `"TestSummaryRegion"`. |
|
||||
| `IsBusy` | `bool` | Busy indicator with property change notification. |
|
||||
| `IsDirty` | `bool` | Dirty state flag. |
|
||||
| `IsNavigationIncluded` | `bool` | Navigation inclusion flag. |
|
||||
| `NotificationRequest` | `InteractionRequest<Notification>` | Interaction request for notifications. |
|
||||
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | Interaction request for confirmations. |
|
||||
|
||||
### Methods
|
||||
|
||||
```csharp
|
||||
public void UpdateDatabaseMethod()
|
||||
```
|
||||
Updates calibration in the database. Sets `CalibrationId = -1`, updates `ModifyDate` to `DateTime.Now`, creates a new `SensorCalibration`, inserts via `DbOperations.SensorCalibrationsInsert()`, then refreshes `Model.Cal` from latest database record. Publishes `PageErrorEvent` on failure.
|
||||
|
||||
```csharp
|
||||
public override void Initialize()
|
||||
```
|
||||
Empty override.
|
||||
|
||||
```csharp
|
||||
public override void Initialize(object parameter)
|
||||
```
|
||||
Sets `Parent` to the provided parameter cast as `IBaseViewModel`.
|
||||
|
||||
```csharp
|
||||
public void PublishChanges()
|
||||
```
|
||||
If not populating and `Model.IsModifiedDataFlag` is true, immediately saves the data flag modification and updates `IsBackedUp`. Always publishes `TestModificationChangedEvent` with the current model.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Single-Channel Selection**: `TestModificationVisability` is `true` only when `channels.Count == 1 && channels.Count(x => x.IsSelected) == 1`. Multi-channel or no selection disables the modification panel.
|
||||
|
||||
2. **T0 Validation**: T0 shifts are validated via `Model.ValidateT0()` before write operations. T0 cannot shift beyond the dataset bounds (addresses case #14661).
|
||||
|
||||
3. **Calibration Sorting**: Calibration records are sorted in ascending order by `CalibrationDate`, then by `ModifyDate` as a tiebreaker (see `CompareCalibrations`).
|
||||
|
||||
4. **Analog Sensor Calibration Display**: Calibrations are only displayed for sensors where `SensorType == 0` (analog sensors).
|
||||
|
||||
5. **Permission-Based Controls**: Edit permissions (`EnableSensitivityControl`, `EnableLineFitControl`, `EnableDescriptionControl`, `EnableEUMultiplierControl`, `EnableEUOffsetControl`, `EnableFilterControl`, `IsT0Enabled`, `IsDataFlagEnabled`) are gated by `IViewerMainViewModel.DoesUserHaveEditPermission`.
|
||||
|
||||
6. **Population Guard**: The static `IsPopulating` flag prevents `PublishChanges()` from executing data flag saves during model population.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This Module Depends On:
|
||||
- `DTS.Common.Base` (`BaseViewModel<T>`)
|
||||
- `DTS.Common.Events` (`PageErrorEvent`, `PageErrorArg`, `ShiftT0Event`, `ShiftT0EventArguments`, `TestModificationChangedEvent`, `ShowT0CursorEvent`, `GraphSelectedChannelsNotification`, `GraphSelectedChannelsNotificationArg`, `RaiseNotification`, `SetUseZeroForUnfilteredEvent`)
|
||||
- `DTS.Common.Interactivity` (`Notification`, `Confirmation`, `NotificationContentEventArgs`, `InteractionRequest<T>`)
|
||||
- `DTS.Common.Interface` (`IBaseViewModel`, `IViewerMainViewModel`)
|
||||
- `DTS.Common.Interface.Sensors` (`ISensorDbRecord`, `ISensorCalDbRecord`)
|
||||
- `DTS.Common.Settings` (`SettingsDB`, `Keys`)
|
||||
- `DTS.Common.Storage` (implied via `DbOperations`)
|
||||
- `DTS.Common.Utilities.Logging` (`APILogger`)
|
||||
- `DTS.SensorDB` (`DbOperations`, `SensorCalibration`)
|
||||
- `DTS.Viewer.ChartOptions.Model` (channel types)
|
||||
- `DTS.Viewer.TestModification.Model` (`TestModificationModel`, `TestModelManipulation`)
|
||||
- `Prism.Commands` (`DelegateCommand`)
|
||||
- `Prism.Events` (`IEventAggregator`)
|
||||
- `Prism.Regions` (`IRegionManager`)
|
||||
- `Unity` (`IUnityContainer`)
|
||||
|
||||
### What Depends On This Module:
|
||||
- `ITestModificationView` (the associated View)
|
||||
- `ITestModificationViewModel` (interface consumers)
|
||||
- Event subscribers to `TestModificationChangedEvent`
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Typo in Property Name**: `TestModificationVisability` is misspelled (should be "Visibility"). This is a historical naming quirk.
|
||||
|
||||
2. **Silent Exception Swallowing**: `GetLatestCalibration()` catches all exceptions and returns `null` without logging. The comment explicitly states: "there's no access to APILogger here, so rather than adding a reference, just eat the error."
|
||||
|
||||
3. **Malformed XML Comment**: The `<summary>` tag for `GetLatestCalibration` is not properly closed (uses `<summary>` instead of `</summary>`).
|
||||
|
||||
4. **Base Member Hiding**: Multiple properties (`Model`, `IsBusy`, `IsDirty`, `IsNavigationIncluded`, `PropertyChanged`, `OnPropertyChanged`) use the `new` keyword to hide base class members, which may indicate design issues or legacy refactoring.
|
||||
|
||||
5. **Static `IsPopulating` Flag**: The `IsPopulating` property is static, meaning it is shared across all instances of `TestModificationViewModel`. This could cause unexpected behavior if multiple instances exist.
|
||||
|
||||
6. **Hardcoded CalibrationId**: `UpdateDatabaseMethod()` sets `CalibrationId = -1` before insertion. The significance of `-1` is not documented in source.
|
||||
|
||||
7. **Database Setting Fallback**: `UseISOCodeFilterMapping` defaults to `false` but is retrieved from settings in `WriteMethod()` with a default of `true` via `SettingsDB.GetGlobalValueBool("UseISOCodeFilterMapping", true)`. The property default and settings default are inconsistent.
|
||||
|
||||
8. **Null Check Inconsistency**: Some null checks use `null == sensor` style while others use `sensor == null` (likely ReSharper-generated variations).
|
||||
Reference in New Issue
Block a user