11 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T13:47:44.691721+00:00 | zai-org/GLM-5-FP8 | 1 | 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
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 ifCalis null.string ModifyDate— Read-only; returns modify date/time or empty string ifCalis null.double CalSensitivity— Gets/sets sensitivity from the first calibration record; returnsdouble.NaNif unavailable.bool ProportionalToExcitation— Read-only; returns whether calibration is proportional to excitation.bool ShowSensorCal— Read-only; returns true ifCalandSensorexist 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 fromSelectedChannel.ChannelDescriptionString.
EU (Engineering Units) Properties:
double EuMultiplier— EU multiplier value.bool IsModifiedEuMultiplier— True if multiplier differs fromSelectedChannel.Multiplier.double EuOffset— EU offset value.bool IsModifiedEuOffset— True if offset differs fromSelectedChannel.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 toT0Mode.TestifIsT0ModeTestOnlyis 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 fromSelectedChannel.Sensitivity.IFilterClass SelectedFilter— Selected software filter; defaults toFilterClass(FilterClassType.Unfiltered).bool IsModifiedFilter— True if filter differs fromSelectedChannel.SoftwareFilter.
Data Flag:
DataFlag SelectedDataFlag— Selected data flag; defaults toDataFlag.None.bool IsModifiedDataFlag— True if data flag differs fromSelectedChannel.DataFlag.
Control Enable Properties (internal setters):
bool EnableSensitivityControlbool EnableLineFitControlbool EnableEUOffsetControlbool EnableEUMultiplierControlbool EnableFilterControlbool EnableDescriptionControlbool IsDataFlagEnabledbool IsT0Enabled
State Tracking:
bool IsModified— True if any modification flag is true andSelectedChannelis not null.bool IsSaved— Read-only property (appears unimplemented in source).ITestModificationViewModel Parent— Reference to parent view model.
Methods:
void OnPropertyChanged(string propertyName)— RaisesPropertyChangedevent and recalculatesIsModified.bool ValidateT0()— Validates that T0 falls within the dataset's start and end time bounds.
Commands:
DelegateCommand UpdateDatabaseCommand— ExecutesParent.UpdateDatabaseMethod().
TestModelManipulation.cs
TestModelManipulation Class
Static utility class for file-based test modification operations.
Constants:
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.dtsand all binary.chnfiles from backups. PublishesTestModificationEventand optionallyChannelsModificationNotification/RefreshTestRequestEvent. -
static bool BackupExists(ITestModificationModel model)— Returns true if a.dts.bakor.chn.bakfile 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.dtsfile. -
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)— PublishesChannelsModificationLineFitNotificationwith line fit parameters for UI preview without disk modification. -
static void UndoModification(ITestModificationModel model)— Reverts in-memory model state from the selected channel and publishesChannelsModificationNotification. -
static void PopulateFromChannel(ITestModificationModel model)— Initializes model properties fromSelectedChannelvalues. -
static void BackupChannelIfNeeded(Test.Module.Channel testModuleChannel, bool headerOnly)— Creates a backup of a.chnfile (full file or header only).
3. Invariants
-
IsModified Consistency:
IsModifiedis alwaysfalsewhenSelectedChannelisnull, regardless of other property states. -
T0Mode Coercion: When
IsT0ModeTestOnlyistrue, theT0Modesetter always coerces the value toT0Mode.Test. -
Backup File Semantics: Backup files (
.bakand.header.bak) represent the original unmodified state. If a backup already exists, it is not overwritten—this preserves the original file for undo operations. -
Line Fit Index Ordering: In
ApplyLineFit, ifstartIndex > endIndex, the values are swapped before processing. -
Calibration Record Access:
CalSensitivityalways accessesCal.Records.Records[0](first record); behavior is undefined if multiple records exist and others are relevant. -
T0 Validation Bounds:
ValidateT0()returnstrue(valid) ifSelectedChannelorSelectedChannel.ParentModuleis null, treating unavailable data as "no constraint."
4. Dependencies
This module depends on:
DTS.Common— Core utilities and interfacesDTS.Common.Classes.Sensors— Sensor-related classesDTS.Common.Enums.Sensors— Sensor enumerations includingDataFlag,T0ModeDTS.Common.Interface— Core interfaces includingITestChannelDTS.Common.Interface.Sensors— Sensor interfaces includingISensorCalDbRecord,ISensorDbRecordDTS.Common.Interface.Sensors.SoftwareFilters—IFilterClass,FilterClass,FilterClassTypeDTS.Common.Events— Event types (TestModificationEvent,TestModificationArgs,ChannelsModificationNotification,ChannelsModificationLineFitNotification,LineFitArgs,RefreshTestRequestEvent)DTS.Common.Settings—SettingsDBfor global settingsDTS.Common.Utilities.Logging—APILoggerDTS.Serialization— Serialization utilities for.chnand.dtsfilesDTS.SensorDB— Sensor database interfacesPrism.Commands—DelegateCommandPrism.Ioc—ContainerLocatorPrism.Events—IEventAggregator
Consumers of this module:
- Not explicitly shown in source; inferred consumer is
ITestModificationViewModelimplementation referenced viaParentproperty.
5. Gotchas
-
Namespace Mismatch:
TestModificationModel.csdeclares namespaceDTS.Viewer.ChartOptions.Modelwhile the file path suggestsDTS.Viewer.TestModification.Model. This inconsistency may cause confusion or require external namespace mapping. -
IsSaved Property Unimplemented: The
IsSavedproperty has a getter but no setter or backing field initialization, meaning it will always returnfalse(default forbool). -
T0 DAS Mode Scope: When
T0Mode.DASis used, T0 changes are applied to all modules matching theBaseSerialNumberof the module containing the selected channel—even if those modules don't contain the selected channel itself. This is a cross-module modification. -
Line Fit Boundary Handling:
ApplyLineFituses indicesstartIndex + 1throughendIndex - 1for interpolation, meaning the actual start and end points are not modified (they define the line but are not overwritten). -
File Encoding Assumption:
WriteDTSFileChangesforces UTF-16 encoding with a fallback to default encoding on exception. The comment indicates this is intentional for.dtsfile compatibility. -
Thread.Sleep in File Write:
WriteDTSFileChangesincludesSystem.Threading.Thread.Sleep(10)after writing—purpose is unclear from source alone, possibly a workaround for file locking or timing issues. -
ISO Code Filter Mapping Side Effect: When
useISOCodeFilterMappingis true inSaveModification, modifying the filter also modifies the channel'sIsoCodefield, which triggers a header backup even if only the filter was changed. -
BackupExists Returns True for Any Backup: The method returns
trueif either.dts.bakor.chn.bakexists, not necessarily both. This could indicate partial backup state.