Files
DP44/docs/ai/Common/DTS.Common/Classes/DTS.Viewer/TestMetadata.md
2026-04-17 14:55:32 -04:00

191 lines
13 KiB
Markdown

---
source_files:
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestMetadata.cs
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestGraphs.cs
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestSetupMetadata.cs
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestRunMetadata.cs
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestSummary.cs
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestModule.cs
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestChannel.cs
- Common/DTS.Common/Classes/DTS.Viewer/TestMetadata/TestMetadataList.cs
generated_at: "2026-04-17T15:35:18.985744+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "6e14a81754a7f26b"
---
# TestMetadata Module Documentation
## 1. Purpose
This module provides the data model layer for test metadata in the DTS (Data Test System) application. It defines entity classes representing the hierarchical structure of test data: `TestMetadata` contains `TestRunMetadata` and `TestSetupMetadata`; `TestRunMetadata` contains `TestModule` instances; and each module contains `TestChannel` instances. The `TestMetadataList` class serves as a factory/parser that deserializes XML documents (`.dts` files) into these object graphs. These classes implement `INotifyPropertyChanged` and integrate with Prism commands to support MVVM data binding in the viewer application.
---
## 2. Public Interface
### TestMetadata
Implements `ITestMetadata`. A container class aggregating run and setup metadata.
| Member | Signature | Description |
|--------|-----------|-------------|
| `TestRun` | `ITestRunMetadata { get; set; }` | Contains test run information (channels, modules, file paths). |
| `TestSetup` | `ITestSetupMetadata { get; set; }` | Contains test setup configuration (graphs, calibration behavior). |
### TestGraphs
Implements `ITestGraphs`. Represents a graph configuration with associated channels.
| Member | Signature | Description |
|--------|-----------|-------------|
| `Name` | `string { get; set; }` | Graph name. |
| `HardwareChannelName` | `string { get; set; }` | Hardware channel identifier. |
| `ChannelIds` | `List<string> { get; set; }` | List of channel IDs belonging to this graph. |
| `Channels` | `List<ITestChannel> { get; set; }` | Resolved channel objects. |
### TestSetupMetadata
Implements `ITestSetupMetadata`. Contains test setup configuration.
| Member | Signature | Description |
|--------|-----------|-------------|
| `SetupName` | `string { get; set; }` | Name of the test setup. |
| `TimeStamp` | `DateTime { get; set; }` | Setup creation/modified timestamp. |
| `TestGraphs` | `List<ITestGraphs> { get; set; }` | Graph configurations for this setup. |
| `CalibrationBehavior` | `CalibrationBehaviors { get; set; }` | Calibration mode (enum from `DTS.Common.Enums.Sensors`). |
### TestRunMetadata
Implements `ITestRunMetadata`. Contains test run information with property change notification.
| Member | Signature | Description |
|--------|-----------|-------------|
| `Name` | `string { get; set; }` | Test name (ID from DTS file). |
| `Id` | `string { get; set; }` | File name without extension. |
| `Description` | `string { get; set; }` | Test description. |
| `InlineSerializedData` | `bool { get; set; }` | Whether data is inline serialized. |
| `TestGuid` | `string { get; set; }` | Unique test identifier. |
| `FaultFlags` | `int { get; set; }` | Fault status flags. |
| `Software` | `string { get; set; }` | Software name used for test. |
| `SoftwareVersion` | `string { get; set; }` | Software version. |
| `DataType` | `string { get; set; }` | Data type identifier. |
| `FileDate` | `DateTime { get; set; }` | File creation date. |
| `FilePath` | `string { get; set; }` | Full file path. |
| `Modules` | `List<ITestModule> { get; set; }` | List of test modules. |
| `Channels` | `List<ITestChannel> { get; set; }` | All channels across modules. |
| `CalculatedChannels` | `List<ITestChannel> { get; set; }` | Calculated/virtual channels. |
| `IsSelected` | `bool { get; set; }` | Selection state for UI. |
| `PropertyChanged` | `event PropertyChangedEventHandler` | Property change notification event. |
| `OnPropertyChanged` | `void OnPropertyChanged([CallerMemberName] string propertyName = null)` | Raises PropertyChanged event. |
### TestSummary
Implements `ITestSummary`. A flattened view of test metadata for list display with selection commands.
| Member | Signature | Description |
|--------|-----------|-------------|
| `ROI_SUFFIX` | `const string = @"_ROI Period"` | Suffix for ROI Period folder names (per bug 18411). |
| `Id` | `string { get; set; }` | Composite ID (TestRun.Id + event number). |
| `SetupName` | `string { get; set; }` | Name from test setup. |
| `Description` | `string { get; set; }` | Test description. |
| `ChannelCount` | `int { get; set; }` | Number of channels. |
| `FileDate` | `DateTime { get; set; }` | File date. |
| `TimeStamp` | `DateTime { get; set; }` | Calculated timestamp (from modules or setup). |
| `DataType` | `string { get; set; }` | Data type. |
| `IsSelected` | `bool { get; set; }` | Selection state; setter triggers `SelectionChanged()`. |
| `Graphs` | `List<ITestGraphs> { get; set; }` | Graph configurations. |
| `Channels` | `List<ITestChannel> { get; set; }` | Channel list. |
| `CalculatedChannels` | `List<ITestChannel> { get; set; }` | Calculated channels. |
| `Parent` | `IBaseViewModel { get; set; }` | Parent view model (expected to be `ITestSummaryListViewModel`). |
| `CalibrationBehavior` | `CalibrationBehaviors { get; set; }` | Defaults to `NonLinearIfAvailable`. |
| `TestMetadata` | `ITestMetadata { get; set; }` | Full metadata reference. |
| `IsSelectedCommand` | `DelegateCommand { get; set; }` | Prism command wrapping `SelectionChanged()`. |
| `SelectionChanged` | `void SelectionChanged()` | Updates parent's `SelectedTestSummaryList` and publishes event. |
| `OnPropertyChanged` | `void OnPropertyChanged(string propertyName)` | Raises PropertyChanged event. |
### TestModule
Implements `ITestModule`. Hardware module information with recording parameters.
| Member | Signature | Description |
|--------|-----------|-------------|
| `SerialNumber` | `string { get; set; }` | Module serial number. |
| `BaseSerialNumber` | `string { get; set; }` | Base serial number. |
| `AaFilterRateHz` | `int { get; set; }` | Anti-aliasing filter rate. |
| `Number` | `int { get; set; }` | Module number. |
| `NumberOfSamples` | `int { get; set; }` | Total samples recorded. |
| `UnsubsampledNumberOfSamples` | `int { get; set; }` | Samples before subsampling. |
| `RequestedPostTriggerSeconds` / `PostTriggerSeconds` | `double { get; set; }` | Post-trigger duration. |
| `RequestedPreTriggerSeconds` / `PreTriggerSeconds` | `double { get; set; }` | Pre-trigger duration. |
| `RecordingMode` | `string { get; set; }` | Recording mode identifier. |
| `SampleRateHz` | `int { get; set; }` | Sample rate in Hz. |
| `StartRecordSampleNumber` | `int { get; set; }` | Starting sample number. |
| `NumberOfChannels` | `int { get; set; }` | Channel count on module. |
| `InlineSerializedData` | `bool { get; set; }` | Inline serialization flag. |
| `StartRecordTimestampSec` / `StartRecordTimestampNanoSec` | `int { get; set; }` | PTP start record timestamp. |
| `TriggerTimestampSec` / `TriggerTimestampNanoSec` | `int { get; set; }` | PTP trigger timestamp. |
| `TriggerSampleNumbers` | `List<ulong> { get; set; }` | Trigger sample indices. |
| `PTPMasterSync` | `bool { get; set; }` | PTP master sync status. |
| `TiltSensorAxis*DegreesPre/Post` | `int { get; set; }` | Tilt sensor readings (X/Y/Z, pre/post). |
| `TemperatureLocation*Pre/Post` | `int { get; set; }` | Temperature readings (4 locations, pre/post). |
| `Channels` | `List<ITestChannel> { get; set; }` | Channel list. |
| `CalculatedChannels` | `List<ITestChannel> { get; set; }` | Calculated channels. |
| `IsSelected` | `bool { get; set; }` | Selection state. |
| `OnPropertyChanged` | `void OnPropertyChanged([CallerMemberName] string propertyName = null)` | Raises PropertyChanged. |
### TestChannel
Implements `ITestChannel`. Extensive channel metadata with statistics and UI state. Marked `[Serializable]`. Inherits from `BasePropertyChanged`.
**Key Properties:**
| Category | Members |
|----------|---------|
| **Identification** | `ChannelId`, `ChannelDisplayName`, `ChannelName2`, `ChannelDescriptionString`, `HardwareChannelName`, `SerialNumber`, `ModuleSerialNumber`, `SensorId`, `TestId`, `TestSetupName` |
| **Configuration** | `ChannelType`, `Number`, `Group`, `SubGroup`, `ChannelGroupName`, `Description`, `Bridge`, `BridgeResistanceOhms`, `Sensitivity`, `SensitivityUnits`, `DesiredRange`, `ExcitationVoltage`, `Eu` |
| **Calibration** | `ZeroPoint`, `ZeroMethod`, `ZeroAverageWindowBegin/End`, `RemoveOffset`, `CalSignalEnabled`, `ShuntEnabled`, `VoltageInsertionCheckEnabled`, `LastCalibrationDate`, `LinearizationFormula`, `MeasuredShuntDeflectionMv`, `TargetShuntDeflectionMv`, `MeasuredExcitationVoltage`, `FactoryExcitationVoltage` |
| **Digital Processing** | `DigitalMultiplier`, `DigitalMode`, `SoftwareFilter`, `IsInverted`, `ProportionalToExcitation`, `IsSubsampled`, `Multiplier`, `UnitConversion`, `UserOffsetEu`, `UseEUScaler`, `ScaleFactorEU` |
| **Range** | `ActualMaxRangeEu`, `ActualMinRangeEu`, `ActualMaxRangeAdc` (returns `short.MaxValue`), `ActualMinRangeAdc` (returns `short.MinValue`), `ActualMaxRangeMv`, `ActualMinRangeMv` |
| **Statistics (ADC)** | `MinADC`, `MaxADC`, `AveADC`, `StdDevADC`, `T0ADC` |
| **Statistics (mV)** | `MinMV`, `MaxMV`, `AveMV`, `StdDevMV`, `T0MV` |
| **Statistics (EU)** | `MinEU`, `MaxEU`, `AveEU`, `StdDevEU`, `T0EU` |
| **Statistics (Current Units)** | `MinY`, `MaxY`, `AveY`, `StdDevY`, `T0Value` |
| **HIC Calculation** | `HIC`, `T1Sample`, `T2Sample` |
| **File Info** | `BinaryFileName`, `BinaryFilePath`, `Start`, `TimeOfFirstSample`, `SampleRateHz`, `UnsubsampledSampleRateHz` |
| **Calculated Channel** | `IsCalculatedChannel`, `SourceChannelNumber`, `SourceModuleNumber`, `SourceModuleSerialNumber`, `Calculation`, `SensorCapacity`, `SensorPolarity`, `AtCapacity`, `CapacityOutputIsBasedOn` |
| **ISO/User Codes** | `IsoCode`, `IsoChannelName`, `UserCode`, `UserChannelName` |
| **EID** | `SetupEID`, `DataCollectionEID` |
| **UI State** | `IsSelected`, `IsLocked`, `IsGraphChannel`, `IsExpanded`, `CanLock`, `CanSelectChannel`, `ChannelColor`, `GraphName`, `AbsoluteDisplayOrder` |
| **Error State** | `IsError`, `ErrorMessage`, `ErrorColor` |
| **Parent References** | `Parent`, `ParentModule`, `ParentTestSetup` |
**Methods:**
| Member | Signature | Description |
|--------|-----------|-------------|
| `Copy` | `ITestChannel Copy()` | Returns shallow copy via `MemberwiseClone()`. |
| `ToString` | `override string ToString()` | Returns `ChannelName2` if test-specific embedded, otherwise `ChannelDescriptionString`. |
| `SetChannelDescriptionAndDisplayName` | `void SetChannelDescriptionAndDisplayName(string channelDescription)` | Sets `ChannelDescriptionString` and builds `ChannelDisplayName`. |
### TestMetadataList
Factory class for parsing XML into metadata objects.
| Member | Signature | Description |
|--------|-----------|-------------|
| `GetTestSummaryListAsync` | `Task<ObservableCollection<ITestSummary>> GetTestSummaryListAsync(IBaseViewModel parent, string path, string file, string pattern = "")` | Async wrapper (not truly async - warning suppressed). |
| `GetTestSummaryList` | `ObservableCollection<ITestSummary> GetTestSummaryList(IBaseViewModel parent, string path, string file = "", string pattern = "")` | Parses XML and returns summary list with parent reference. |
| `GetTestSummaryList` | `ObservableCollection<ITestSummary> GetTestSummaryList(string path, string file = "", string pattern = "")` | Overload without parent reference. |
| `GetTestMetadataList` | `List<ITestMetadata> GetTestMetadataList(XDocument xDoc, string path, string file)` | Parses XDocument into `ITestMetadata` list. |
---
## 3. Invariants
- **Timestamp Fallback**: `GetTimestamp()` uses module PTP timestamps if valid (post-1990); otherwise falls back to `TestSetup.TimeStamp`.
- **Channel Array Pre-allocation**: `GetTestMetadataList()` pre-allocates the `Channels` list size based on sum of `NumberOfChannels` across all modules.
- **Sort Order**: `BuildITestSummary()` always returns summaries ordered by `TimeStamp.Ticks` descending.
- **Default Calibration Behavior**: `TestSummary.CalibrationBehavior` and `TestSetupMetadata.CalibrationBehavior` default to `CalibrationBehaviors.NonLinearIfAvailable`.
- **ADC Range Constants**: `TestChannel.ActualMaxRangeAdc` always returns `short.MaxValue` (32767); `ActualMinRangeAdc` always returns `short.MinValue` (-32768).
- **ChannelId Fallback**: When parsing channels, if `ChannelId` is missing or -1, `GetHashCode().ToString()` is used as fallback.
- **Calculated Channel Fields Wiped**: For calculated channels, `SerialNumber`, `HardwareChannelName`, `IsoCode`, `IsoChannelName`, `UserCode`, `UserChannelName` are set to `Strings.Strings.Table_NA`.
---
## 4. Dependencies
### This module depends on:
- `DTS.Common.Interface` -