11 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-17T15:55:05.952766+00:00 | zai-org/GLM-5-FP8 | 1 | 8c9823f92db20638 |
Test Modification Module Documentation
1. Purpose
This module provides functionality for modifying test data within the DTS Viewer application. It enables users to adjust channel parameters (sensitivity, EU multiplier/offset, T0 time shifts, line fit, software filters, data flags, and descriptions) and persist those changes to both binary channel files (.chn) and test configuration files (.dts). The module implements a backup-and-restore system to allow reverting modifications, and tracks modification state to indicate unsaved changes to the user interface.
2. Public Interface
Enums.cs
Keys Enum
public enum Keys
{
ApplyShiftT0ModsTestOnly // System Setting for whether to restrict "Shift T0" test modifications to "Test" only.
}
A configuration key enum used to control T0 modification behavior restrictions.
TestModificationModel.cs
TestModificationModel Class
Implements ITestModificationModel and provides INotifyPropertyChanged for data binding.
Calibration Properties:
string CalDate— Read-only; returnsCal.CalibrationDate.ToShortDateString()or empty string ifCalis null.string ModifyDate— Read-only; returns formatted modify date/time or empty string ifCalis null.double CalSensitivity— Gets/sets sensitivity fromCal.Records.Records[0].Sensitivity; returnsdouble.NaNif unavailable.bool ProportionalToExcitation— Read-only; returnsCal.IsProportional.bool NonLinear— Read-only; returnsCal.NonLinear.bool ShowSensorCal— Read-only; returns true ifCalandSensorare non-null andNonLinearis false.ISensorCalDbRecord Cal— Gets/sets the latest calibration record; triggersRebindCalProperties()on set.ISensorDbRecord Sensor— Gets/sets the sensor record; triggersRebindCalProperties()on set.
Channel Selection:
ITestChannel SelectedChannel— The currently selected channel for modification.
Modification Value Properties:
string Description— Channel description text.double EuMultiplier— EU multiplier value.double EuOffset— EU offset value.double T0— T0 time shift value (milliseconds).double T1— Line fit start point (milliseconds).double T2— Line fit end point (milliseconds).double Sensitivity— Channel sensitivity value.IFilterClass SelectedFilter— Selected software filter; defaults toFilterClass(FilterClassType.Unfiltered).DataFlag SelectedDataFlag— Selected data flag; defaults toDataFlag.None.T0Mode T0Mode— T0 application mode (T0Mode.TestorT0Mode.DAS); defaults toT0Mode.Test.
Modification State Properties (Read-only):
bool IsModifiedDescription— True ifDescriptiondiffers fromSelectedChannel.ChannelDescriptionString.bool IsModifiedEuMultiplier— True ifEuMultiplierdiffers fromSelectedChannel.Multiplier.bool IsModifiedEuOffset— True ifEuOffsetdiffers fromSelectedChannel.UserOffsetEu.bool IsModifiedT0— True ifT0is not zero.bool IsModifiedLineFit— True ifT1orT2is not zero.bool IsModifiedSensitivity— True ifSensitivitydiffers fromSelectedChannel.Sensitivity.bool IsModifiedFilter— True ifSelectedFilterdiffers from the channel's current software filter.bool IsModifiedDataFlag— True ifSelectedDataFlagdiffers fromSelectedChannel.DataFlag.bool IsModified— Aggregate flag indicating any modification exists andSelectedChannelis non-null.
Control Enable Properties:
bool EnableSensitivityControl— Controls UI sensitivity control visibility.bool EnableLineFitControl— Controls UI line fit control visibility.bool EnableEUOffsetControl— Controls UI EU offset control visibility.bool EnableEUMultiplierControl— Controls UI EU multiplier control visibility.bool EnableFilterControl— Controls UI filter control visibility.bool EnableDescriptionControl— Controls UI description control visibility.bool IsDataFlagEnabled— Controls UI data flag control visibility.bool IsT0Enabled— Controls UI T0 control visibility.bool IsT0ModeTestOnly— When true, forcesT0ModetoT0Mode.Test.
Other Properties:
ITestModificationViewModel Parent— Reference to parent view model.bool IsSaved— Read-only property (no setter visible in source).
Methods:
void OnPropertyChanged(string propertyName)— RaisesPropertyChangedevent and recalculatesIsModified.bool ValidateT0()— Validates T0 falls within the channel's dataset time range; returns true ifSelectedChannelorParentModuleis null.
Commands:
DelegateCommand UpdateDatabaseCommand— ExecutesParent.UpdateDatabaseMethod().
TestModelManipulation.cs
TestModelManipulation Class
Static utility class for file-based test modification operations.
Constants:
double UNUSED_START_TIME = 0int UNUSED_DATA_COLLECTION_LENGTH = 0string BackupHeaderExtension = ".header.bak"(private)string BackupFileExtension = ".bak"(private)
Public Methods:
-
static void UndoAllModification(ITestModificationModel model)— Reverts all modifications by restoring.dtsand all binary channel files from backups. PublishesChannelsModificationNotification,RefreshTestRequestEvent, andTestModificationEvent. -
static bool BackupExists(ITestModificationModel model)— Returns true if either.dts.bakor.chn.bakbackup files exist for the model's selected channel. -
static void BackupChannelIfNeeded(Test.Module.Channel testModuleChannel, bool headerOnly)— Creates backup of channel binary file. IfheaderOnlyis true, backs up only the header portion; otherwise backs up the entire file. -
static bool SaveModification(ITestModificationModel model, bool useISOCodeFilterMapping, bool bUseZeroForUnfiltered)— Persists all modifications to disk. Returns true on success. Handles T0 (Test and DAS modes), line fit, filter, sensitivity, EU multiplier/offset, description, and data flag modifications. -
static bool SaveModificationDataFlag(ITestModificationModel model)— Saves only data flag modifications to disk. -
static void ApplyLineFit(ITestModificationModel model, Test.Module.Channel channel)— Applies linear interpolation betweenT1andT2sample indices on the channel's ADC data. -
static void PreviewLineFit(ITestModificationModel model)— PublishesChannelsModificationLineFitNotificationwith calculated start/end indices without modifying disk. -
static void UndoModification(ITestModificationModel model)— Re-populates model from channel and publishesChannelsModificationNotification. -
static void PopulateFromChannel(ITestModificationModel model)— Initializes model properties fromSelectedChannelvalues.
3. Invariants
-
Backup File Semantics: Backup files (
.bakand.header.bak) represent the original unmodified files. Once a backup exists, it is never overwritten by subsequent modifications—this preserves the ability to revert to the original state. -
IsModified Aggregation:
IsModifiedis true if and only if at least oneIsModified*property is true ANDSelectedChannelis non-null. -
T0Mode Restriction: When
IsT0ModeTestOnlyis true,T0Modesetter forces the value toT0Mode.Testregardless of the input value. -
Calibration Property Dependencies:
CalSensitivity,ProportionalToExcitation,NonLinear,ShowSensorCal,CalDate, andModifyDateall depend onCalbeing non-null; they return default values (false,NaN, empty string) whenCalis null. -
Line Fit Index Ordering: In
ApplyLineFit, ifstartIndex > endIndex, the values are swapped before processing. -
T0 Validation Range:
ValidateT0()returnstrue(valid) ifSelectedChannelorParentModuleis null, treating missing 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 includingTestModificationEvent,TestModificationArgs,ChannelsModificationNotification,RefreshTestRequestEvent,ChannelsModificationLineFitNotification,LineFitArgsDTS.Common.Settings—SettingsDBfor global configuration valuesDTS.Common.Utilities.Logging—APILoggerDTS.Common.ISO—IsoCodeclassDTS.Serialization— Serialization utilities includingSliceRaw.FileDTS.SensorDB— Sensor database interfacesPrism.Commands—DelegateCommandPrism.Ioc—ContainerLocatorPrism.Events—IEventAggregator
What Depends On This Module:
- Not determinable from the provided source files alone.
5. Gotchas
-
Namespace Mismatch:
TestModificationModel.csis declared in namespaceDTS.Viewer.ChartOptions.Modeldespite residing inDTS.Viewer.TestModification/Model/. This may cause confusion when locating the class. -
ReSharper Suppressions: The
TestModificationModel.csfile contains multiple ReSharper suppressions (InconsistentNaming,RedundantDefaultMemberInitializer,CheckNamespace,UnassignedGetOnlyAutoProperty), suggesting known code style deviations. -
IsSaved Property Never Set: The
IsSavedproperty has a getter but no visible setter or initialization in the provided source, making its purpose unclear. -
Backup Strategy Complexity: Binary channels can be backed up in two ways (header-only vs. full file). The
BackupChannelIfNeededmethod handles conversion between these modes, but developers should be aware that a header backup may be promoted to a full backup if subsequent modifications require it. -
T0 DAS Mode Scope: When
T0Mode.DASis used, T0 changes are applied to all channels on the same DAS (matchingBaseSerialNumber), not just the selected channel. This is a broader scope than might be expected. -
Line Fit Overwrites Data:
ApplyLineFitpermanently replaces ADC data between T1 and T2 with linearly interpolated values. There is no undo mechanism specific to line fit beyond the full file restore. -
File Encoding Assumption:
WriteDTSFileChangesforces UTF-16 encoding for.dtsfiles. The code catches exceptions and falls back toEncoding.Default, but this fallback could produce files incompatible with other consumers. -
Thread.Sleep in File Writing:
WriteDTSFileChangesincludes a 10msThread.Sleep()after writing, suggesting a timing-related workaround for file system operations.