12 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T11:09:33.877186+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 multiplier/offset, T0 timing, line fit, software filters, data flags, and descriptions) and handles the persistence of these changes to both .dts metadata files and binary .chn channel files. The module supports backup/restore operations to allow reverting modifications and maintains change tracking to indicate which properties have been modified from their original values.
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 a configuration key for controlling T0 modification behavior.
TestModificationModel.cs
TestModificationModel Class
Implements ITestModificationModel. A model class that tracks modification state for a selected test channel.
Calibration Properties:
| Property | Type | Description |
|---|---|---|
CalDate |
string |
Returns calibration date as short date string, or empty if Cal is null. |
ModifyDate |
string |
Returns modify date/time string, or empty if Cal is null. |
CalSensitivity |
double |
Gets/sets sensitivity from first calibration record. Returns double.NaN if unavailable. |
ProportionalToExcitation |
bool |
Returns whether calibration is proportional to excitation. |
ShowSensorCal |
bool |
Returns true if Cal and Sensor are non-null and calibration is not non-linear. |
NonLinear |
bool |
Returns whether calibration is non-linear. |
Cal |
ISensorCalDbRecord |
The latest calibration record for the channel. |
Sensor |
ISensorDbRecord |
The sensor corresponding to the channel. |
Channel Selection & Modification Tracking:
| Property | Type | Description |
|---|---|---|
SelectedChannel |
ITestChannel |
The currently selected test channel. |
Description |
string |
Channel description string. |
IsModifiedDescription |
bool |
True if Description differs from SelectedChannel.ChannelDescriptionString. |
EuMultiplier |
double |
EU multiplier value. |
IsModifiedEuMultiplier |
bool |
True if EuMultiplier differs from SelectedChannel.Multiplier. |
EuOffset |
double |
EU offset value. |
IsModifiedEuOffset |
bool |
True if EuOffset differs from SelectedChannel.UserOffsetEu. |
T0 |
double |
T0 timing offset (in ms). |
IsModifiedT0 |
bool |
True if T0 is not 0. |
T1 |
double |
Line fit start point (in ms). |
T2 |
double |
Line fit end point (in ms). |
IsModifiedLineFit |
bool |
True if T1 or T2 is not 0. |
Sensitivity |
double |
Sensitivity value. |
IsModifiedSensitivity |
bool |
True if Sensitivity differs from SelectedChannel.Sensitivity. |
SelectedFilter |
IFilterClass |
Selected software filter (defaults to FilterClassType.Unfiltered). |
IsModifiedFilter |
bool |
True if SelectedFilter differs from channel's software filter. |
SelectedDataFlag |
DataFlag |
Selected data flag. |
IsModifiedDataFlag |
bool |
True if SelectedDataFlag differs from channel's data flag. |
IsModified |
bool |
Aggregate flag indicating any modification exists and SelectedChannel is not null. |
Control Enable/Disable Properties:
| Property | Type | Default |
|---|---|---|
EnableSensitivityControl |
bool |
true |
EnableLineFitControl |
bool |
true |
EnableEUOffsetControl |
bool |
true |
EnableEUMultiplierControl |
bool |
true |
EnableFilterControl |
bool |
true |
EnableDescriptionControl |
bool |
true |
IsDataFlagEnabled |
bool |
true |
IsT0Enabled |
bool |
true |
T0 Mode Properties:
| Property | Type | Description |
|---|---|---|
T0Mode |
T0Mode |
Gets/sets T0 mode (Test or DAS). When IsT0ModeTestOnly is true, setter forces value to T0Mode.Test. |
IsT0ModeTestOnly |
bool |
When true, restricts T0 mode to Test only. |
Other Properties:
| Property | Type | Description |
|---|---|---|
Parent |
ITestModificationViewModel |
Reference to parent view model. |
IsSaved |
bool |
Property exists but has no implementation visible. |
Methods:
public bool ValidateT0()
- Validates that T0 falls within the dataset's time range (between start and end times).
- Returns
trueifSelectedChannelorSelectedChannel.ParentModuleis null. - Calculates valid range from
StartRecordSampleNumber,TriggerSampleNumbers[0],NumberOfSamples, andSampleRateHz.
public void OnPropertyChanged(string propertyName)
- Raises
PropertyChangedevent. - Updates
IsModifiedaggregate flag when non-IsModified properties change. - Calls
Parent?.PublishChanges().
Commands:
public DelegateCommand UpdateDatabaseCommand
- Executes
UpdateDatabaseMethod()which delegates toParent.UpdateDatabaseMethod().
TestModelManipulation.cs
TestModelManipulation Class
Static utility class for file-based test modification operations.
Constants:
| Constant | Value | Description |
|---|---|---|
UNUSED_START_TIME |
0 |
Placeholder for test serialization. |
UNUSED_DATA_COLLECTION_LENGTH |
0 |
Placeholder for test serialization. |
BackupHeaderExtension |
".header.bak" |
Extension for header-only backups. |
BackupFileExtension |
".bak" |
Extension for full file backups. |
Public Methods:
public static void UndoAllModification(ITestModificationModel model)
- Reverts all modifications by restoring
.dtsand all.chnfiles from backups. - Publishes
ChannelsModificationNotification,RefreshTestRequestEvent, andTestModificationEvent.
public static bool BackupExists(ITestModificationModel model)
- Returns true if either
.dts.bakor.chn.bakfiles exist for the selected channel.
public static bool SaveModification(ITestModificationModel model, bool useISOCodeFilterMapping, bool bUseZeroForUnfiltered)
- Persists all modifications to disk.
- Handles T0 changes (applying to test or DAS based on
T0Mode). - Handles filter changes with optional ISO code mapping.
- Handles sensitivity, EU multiplier/offset, description, data flag, and line fit changes.
- Publishes
TestModificationEventon completion.
public static bool SaveModificationDataFlag(ITestModificationModel model)
- Saves only data flag modifications.
- Publishes
ChannelsModificationNotificationand repopulates model from channel.
public static void ApplyLineFit(ITestModificationModel model, Test.Module.Channel channel)
- Applies linear interpolation between sample indices derived from
T1andT2. - Backs up channel file (full backup, not header-only).
- Modifies ADC data in place using straight-line fit between two points.
public static void PreviewLineFit(ITestModificationModel model)
- Publishes
ChannelsModificationLineFitNotificationwith calculated start/end indices for UI preview without disk modification.
public static void UndoModification(ITestModificationModel model)
- Reverts in-memory changes by repopulating from channel.
- Publishes
ChannelsModificationNotification.
public static void PopulateFromChannel(ITestModificationModel model)
- Initializes model properties from
SelectedChannelvalues. - Resets
T0,T1,T2to 0.
3. Invariants
-
Calibration Record Access:
CalSensitivitygetter assumesCal.Records.Records[0]exists if the collection is non-null and non-empty. No bounds checking beyond length > 0. -
Modification Flag Consistency:
IsModifiedis alwaysfalsewhenSelectedChannelis null, regardless of other modification flags. -
T0Mode Restriction: When
IsT0ModeTestOnlyistrue, theT0Modesetter always forces the value toT0Mode.Test, ignoring the provided value. -
Backup File Semantics: Backup files (
.bak) represent the original unmodified files. If a backup exists, it is never overwritten by subsequent backup operations. -
Line Fit Index Ordering:
ApplyLineFitautomatically swaps start/end indices ifstartIndex > endIndex. -
T0 Validation Range:
ValidateT0()calculates time range assumingTriggerSampleNumbers[0]exists (no bounds check on the list). -
Channel Matching:
SaveModificationmatches channels by bothChannelIdANDBinaryFileNamesuffix for most operations (except T0 modifications which apply more broadly).
4. Dependencies
Imports (This module depends on):
From TestModificationModel.cs:
DTS.Common- Common utilitiesDTS.Common.Classes.Sensors- Sensor classesDTS.Common.Enums.Sensors- Sensor enumsDTS.Common.Interface- Common interfacesDTS.Common.Interface.Sensors- Sensor interfacesDTS.Common.Interface.Sensors.SoftwareFilters- Filter interfacesDTS.SensorDB- Sensor database interfaces (ISensorCalDbRecord,ISensorDbRecord)Prism.Commands-DelegateCommand
From TestModelManipulation.cs:
DTS.Common- Common utilitiesDTS.Common.Classes.Sensors- Sensor classesDTS.Common.Events- Event types (TestModificationEvent,TestModificationArgs,ChannelsModificationNotification,ChannelsModificationLineFitNotification,LineFitArgs,RefreshTestRequestEvent)DTS.Common.Interface-ITestChannelDTS.Common.Settings-SettingsDBDTS.Common.Utilities.Logging-APILoggerDTS.Serialization- Serialization utilities (Serialization.SliceRaw.File)Prism.Ioc-ContainerLocatorPrism.Events-IEventAggregator
External Type References (Interfaces expected from elsewhere):
ITestModificationModel- Interface implemented byTestModificationModelITestModificationViewModel- Parent view model interfaceITestChannel- Test channel interfaceISensorCalDbRecord- Calibration database recordISensorDbRecord- Sensor database recordIFilterClass/FilterClass- Software filter abstractionT0Mode- Enum for T0 modification scopeDataFlag- Enum for data flagsTest.Module.Channel/Test.Module.AnalogInputChannel- Channel types from serializationTest/TestSetup- Test structure types
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. -
IsSaved Property: The
IsSavedproperty has a getter but no visible setter or backing field implementation. Its behavior is unclear from source alone. -
T0 Mode DAS Logic: In
SaveModification, whenT0Mode == T0Mode.DAS, T0 changes are applied to modules that do not contain the selected channel but share the sameBaseSerialNumberas the module that does. This could affect more channels than expected. -
Line Fit Data Type:
ApplyLineFitcasts ADC data toshortafter floating-point interpolation, which could cause precision loss or overflow for extreme values. -
Thread.Sleep in File Writing:
WriteDTSFileChangesincludesSystem.Threading.Thread.Sleep(10)after writing the DTS file. The reason for this delay is not documented in source. -
Backup Strategy Selection:
BackupChannelIfNeededuses header-only backup for sensitivity/T0/filter changes (whenuseISOCodeFilterMappingis true), but full backup for line fit. This is a performance optimization but means different modification types have different restore behaviors. -
FilterClassType Default:
SelectedFilterdefaults toFilterClassType.Unfiltered, but the source does not show the definition ofFilterClassTypeenum. -
PropertyChanged Event Naming:
RebindCalPropertiesraises events with string property names rather than usingnameof()operator, which could lead to runtime errors if property names change.