init
This commit is contained in:
@@ -0,0 +1,220 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Model/TestDataSeries.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Model/TestDataSeriesModel.cs
|
||||
generated_at: "2026-04-16T11:14:33.699820+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "1630e6f30be700ba"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.Graph Module - Data Series Models
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides the data models for representing and transforming test channel data into graphable series within the DTS Viewer application. `TestDataSeries` serves as the primary data transfer object holding X/Y values, metadata, and computed statistics for a single graphable channel. `TestDataSeriesModel` acts as a factory/processor that transforms raw `ITestChannel` data into `TestDataSeries` objects, handling time-series, FFT (Fast Fourier Transform), and PSD (Power Spectral Density) conversions with optional filtering and windowing. Together, they bridge the gap between raw binary sensor data and the visualization layer.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### TestDataSeries Class
|
||||
|
||||
**Namespace:** `DTS.Viewer.Graph.Model`
|
||||
**Inherits:** `Common.Base.BasePropertyChanged`
|
||||
**Implements:** `ITestDataSeries`
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `HIC` | `bool` | Indicates if Head Injury Criteria data is present. |
|
||||
| `HICValue` | `string` | Formatted HIC value. |
|
||||
| `T1Time`, `T2Time` | `string` | T1/T2 timestamp strings for HIC calculations. |
|
||||
| `TestGroup` | `string` | Group identifier for the test. |
|
||||
| `TestId` | `string` | Unique test identifier. |
|
||||
| `TestSetupName` | `string` | Name of the test setup configuration. |
|
||||
| `ChannelId` | `string` | Channel identifier. |
|
||||
| `Xvalue` | `double[]` | Array of X-axis values (time or frequency). |
|
||||
| `Yvalue` | `double[]` | Array of Y-axis values (amplitude, magnitude, or PSD). |
|
||||
| `GraphColor` | `Brush` | WPF brush for graph rendering; getter creates new `SolidColorBrush` from internal `byte[]`. |
|
||||
| `HardwareChannel` | `string` | Hardware channel name (auto-property). |
|
||||
| `GroupName` | `string` | Channel group name (auto-property). |
|
||||
| `SWAAF` | `string` | Software anti-aliasing filter setting (auto-property). |
|
||||
| `Bridge` | `string` | Bridge type identifier (auto-property). |
|
||||
| `HWAAF` | `string` | Hardware anti-aliasing filter rate (auto-property). |
|
||||
| `SampleRate` | `string` | Sample rate in Hz (auto-property). |
|
||||
| `ISOCode`, `ISOChannelName` | `string` | ISO-related identifiers (auto-properties). |
|
||||
| `UserCode`, `UserChannelName` | `string` | User-defined identifiers (auto-properties). |
|
||||
| `ChannelName`, `Description` | `string` | Channel naming and description (auto-properties). |
|
||||
| `SensorSN` | `string` | Sensor serial number (auto-property). |
|
||||
| `SensorSNDisplay` | `string` | Display-friendly serial number; returns `"N/A"` if test-specific embedded per `SensorConstants.IsTestSpecificEmbedded()`. |
|
||||
| `EngineeringUnits` | `string` | Engineering units string (auto-property). |
|
||||
| `Excitation` | `string` | Excitation voltage (auto-property). |
|
||||
| `Polarity` | `string` | Sensor polarity (auto-property). |
|
||||
| `MinY`, `MaxY`, `AvgY`, `StdDevY` | `string` | Statistical values; default to `Strings.Table_NA`. |
|
||||
| `PeakMagnitude` | `double` | Peak magnitude for FFT data; default `0`. |
|
||||
| `PeakFrequency` | `double` | Frequency of peak magnitude; default `0`. |
|
||||
| `GRMS` | `double` | Root-mean-squared acceleration for PSD; default `0`. |
|
||||
| `FFT` | `bool` | Indicates if series contains FFT/PSD data; default `false`. |
|
||||
| `T0EUValue` | `string` | T0 value string; default empty. |
|
||||
| `RecordingMode` | `string` | Recording mode description (auto-property). |
|
||||
| `IsSaved` | `bool` | Read-only auto-property (getter only). |
|
||||
|
||||
#### Methods
|
||||
|
||||
```csharp
|
||||
public void SetStatsFromYValues()
|
||||
```
|
||||
Sets `AvgY`, `StdDevY`, `MinY`, `MaxY`, `T0EUValue` from internal `Yvalue` array. Formats using `"G5"` format string.
|
||||
|
||||
```csharp
|
||||
public void SetStatsFromYValues(double[] values)
|
||||
```
|
||||
Overload that accepts an external `double[]` array. Handles null/empty arrays by setting all stats to `NaN` (displayed as `Table_NA`).
|
||||
|
||||
```csharp
|
||||
public void SetStatsFromChannel(ITestChannel channel)
|
||||
```
|
||||
Copies pre-calculated statistics from an `ITestChannel` instance using `channel.MinY`, `channel.MaxY`, `channel.AveY`, `channel.StdDevY`, `channel.T0Value`.
|
||||
|
||||
---
|
||||
|
||||
### TestDataSeriesModel Class
|
||||
|
||||
**Namespace:** `DTS.Viewer.Graph`
|
||||
**Implements:** `IBaseModel`
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `Parent` | `IGraphViewModel` | Parent view model reference. |
|
||||
| `_eventAggregator` | `IEventAggregator` | Prism event aggregator for publishing progress events. |
|
||||
| `ErrorMessage` | `string` | Error message string with property change notification. |
|
||||
| `IsSaved` | `bool` | Read-only auto-property. |
|
||||
|
||||
#### Methods
|
||||
|
||||
```csharp
|
||||
public Task<ITestDataSeries> GetTestDataAsync(ITestChannel channel, IChartOptionsModel chartOptions, bool bVolts, IPSDReportSettingsModel psdSettings = null)
|
||||
```
|
||||
Async wrapper returning `GetTestData()`. **Warning:** Lacks `await` operators (runs synchronously per compiler warning suppression).
|
||||
|
||||
```csharp
|
||||
public Task<List<ITestDataSeries>> GetTestDataAsync(List<ITestChannel> channels, IChartOptionsModel chartOptions, bool bVolts, IPSDReportSettingsModel psdSettings = null)
|
||||
```
|
||||
Async wrapper for batch channel processing. Catches `OutOfDataException` and re-throws with context. Optionally adds envelope channel if `psdSettings.ShowEnvelope` is true.
|
||||
|
||||
```csharp
|
||||
public List<ITestDataSeries> GetTestData(List<ITestChannel> channels, IChartOptionsModel chartOptions, bool bVolts, IPSDReportSettingsModel psdSettings = null)
|
||||
```
|
||||
Synchronous batch processing. Maps each channel through `GetTestData()`. Handles `OutOfDataException` with sample index context.
|
||||
|
||||
```csharp
|
||||
public ITestDataSeries GetTestData(ITestChannel channel, IChartOptionsModel chartOptions, bool bVolts, IPSDReportSettingsModel psdSettings = null)
|
||||
```
|
||||
Returns `AddTestChannelToChart()` result.
|
||||
|
||||
```csharp
|
||||
public TestDataSeries AddTestChannelToChart(ITestChannel channel, IChartOptionsModel chartOptions, bool bVolts, IPSDReportSettingsModel psdSettings = null)
|
||||
```
|
||||
**Primary processing method.** Reads binary channel data via `Serialization.SliceRaw.File.Reader.ReadChannelsBinaryData()`, then branches based on `chartOptions.UnitType`:
|
||||
- **FFT mode** (`ChartUnitTypeEnum.FFT` with `psdSettings == null`): Sets `FFT = true`, populates `PeakFrequency`, `PeakMagnitude`, calculates stats.
|
||||
- **Regular time-series** (`psdSettings == null`): Handles HIC data if present, applies time unit multiplier, copies stats from channel.
|
||||
- **PSD mode** (`psdSettings != null`): Trims data to selected range, applies optional low/high pass filters, computes PSD via `FftSharp.Transform.PSD_Welch()`, calculates GRMS.
|
||||
|
||||
Returns `null` if `channel.ErrorMessage` is not empty.
|
||||
|
||||
```csharp
|
||||
private ITestDataSeries GetEnvelopeChannel(List<ITestDataSeries> data)
|
||||
```
|
||||
Creates a synthetic "envelope" series by taking the maximum Y-value at each frequency index across all input series. Sets `FFT = true`, color to black.
|
||||
|
||||
```csharp
|
||||
private double CalculateGRMS(double[] freq, double[] psd)
|
||||
```
|
||||
Calculates Grms using numerical integration of PSD. Uses logarithmic interpolation formula; handles `N = -1` edge case separately. Returns `Math.Sqrt(aRMS.Sum())`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Array Length Consistency**: `Xvalue` and `Yvalue` arrays should have matching lengths after processing by `TestDataSeriesModel`.
|
||||
|
||||
2. **FFT Flag Consistency**: When `FFT == true`, `Xvalue` represents frequency (Hz) and `Yvalue` represents magnitude or PSD. When `FFT == false`, `Xvalue` represents time.
|
||||
|
||||
3. **Statistics Default**: `MinY`, `MaxY`, `AvgY` default to `Strings.Table_NA` (not null or empty string).
|
||||
|
||||
4. **GraphColor Thread Safety**: `GraphColor` getter creates a new `SolidColorBrush` on each call; the underlying color data is stored as `byte[] _graphColorARGB` to ensure thread safety (per comment referencing issue #34455).
|
||||
|
||||
5. **FFT/PSD Filter Bypass**: When `chartOptions.UnitType` is `FFT` or `PSD`, `channel.SoftwareFilter` is forcibly set to `"none"` before reading data.
|
||||
|
||||
6. **PSD Data Length**: PSD calculations require input length to be an even power of 2; `Utils.GetEnclosingPower2()` is used to resize the array with zero-padding if necessary.
|
||||
|
||||
7. **HIC Validity**: `HIC` is only set to `true` when `channel.HIC != 0` AND `channel.T2Sample > 0`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### TestDataSeries Dependencies
|
||||
|
||||
**External Dependencies:**
|
||||
- `System.Windows.Media` - `Brush`, `SolidColorBrush`, `Color`, `Colors`
|
||||
- `DTS.Common.Enums.Sensors` - `SensorConstants` for serial number validation
|
||||
- `DTS.Common.Interface` - `ITestDataSeries` interface
|
||||
- `DTS.Common.Strings` - Localized string constants (`Table_NA`)
|
||||
- `DTS.Common.Base` - `BasePropertyChanged` for INPC implementation
|
||||
|
||||
**Dependents (Inferred):**
|
||||
- `TestDataSeriesModel` - Primary consumer/factory
|
||||
- Graph view models and charting components (via `ITestDataSeries`)
|
||||
|
||||
### TestDataSeriesModel Dependencies
|
||||
|
||||
**External Dependencies:**
|
||||
- `System.Windows.Media` - Color types
|
||||
- `Prism.Events` - `IEventAggregator` for event publishing
|
||||
- `FftSharp` - FFT/PSD transforms (`Transform.PSD_Welch`, `Transform.FFTfreq`, `WindowType`, `WindowAveragingType`)
|
||||
- `Exocortex.DSP` - `PassFilter.LowPass`/`HighPass` filtering
|
||||
|
||||
**Internal Dependencies:**
|
||||
- `DTS.Common.Interface` - `ITestChannel`, `ITestDataSeries`, `IGraphViewModel`, `IChartOptionsModel`, `IPSDReportSettingsModel`, `IBaseModel`
|
||||
- `DTS.Common.Enums.Viewer` - `ChartUnitTypeEnum`, `TimeUnitTypeEnum`, `Reports.WindowType`, `Reports.WindowAveragingType`
|
||||
- `DTS.Common.Enums.Sensors` - `SensorConstants.BridgeType.DigitalInput`
|
||||
- `DTS.Common.Enums.DASFactory` - `DFConstantsAndEnums.RecordingMode`
|
||||
- `DTS.Common.Converters` - `EnumDescriptionTypeConverter`
|
||||
- `DTS.Common.Exceptions` - `OutOfDataException`
|
||||
- `DTS.Common.Events` - `GraphChannelReadCalcProgressChangedEvent`, `GraphChannelReadCalcProgressChangedEventArgs`
|
||||
- `DTS.Common.Utilities.Logging` - `APILogger`
|
||||
- `DTS.Common.Utils` - `Utils.GetEnclosingPower2()`
|
||||
- `DTS.Common.Strings` - Localized strings
|
||||
- `Serialization.SliceRaw.File.Reader` - `ReadChannelsBinaryData()` for binary data deserialization
|
||||
- `ChannelFilter` - `AdHoc` filter constant
|
||||
|
||||
**Dependents (Inferred):**
|
||||
- Graph view models implementing `IGraphViewModel`
|
||||
- PSD report generation components
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Async Methods Are Not Truly Async**: Both `GetTestDataAsync` overloads have suppressed compiler warning CS1998 and run synchronously. The `async` keyword is misleading—these methods will block the calling thread.
|
||||
|
||||
2. **GraphColor Getter Allocates on Every Call**: The `GraphColor` property getter instantiates a new `SolidColorBrush` on every access. Frequent access in UI binding scenarios could cause unnecessary allocations.
|
||||
|
||||
3. **PSD Frequency Array Mutation**: In PSD processing, `freq[0] = 1` forcibly sets the first frequency bin to 1 Hz, potentially overwriting the actual DC component value from `FftSharp.Transform.FFTfreq()`.
|
||||
|
||||
4. **CalculateStdDev Uses Population Formula Incorrectly**: The method divides by `(values.Length - 1)` (sample standard deviation) but does not check for single-element arrays, which would cause division by zero.
|
||||
|
||||
5. **T0EUValue Naming Is Misleading**: Per the source comment: *"this is the T0 value regardless of units ... it's not really EU but since it's already in use I'm not going to change it"* — historical naming debt.
|
||||
|
||||
6. **Envelope Channel Returns Empty Series on Null Input**: `GetEnvelopeChannel()` returns a default `TestDataSeries()` if input list is null or empty, rather than returning null or throwing.
|
||||
|
||||
7. **IEPE Bridge Hardcoded**: The constant `IEPE_BRIDGE = "IEPE"` is used for special-casing excitation display, but the value is not sourced from a shared constant.
|
||||
|
||||
8. **Digital Channel Detection Uses String Prefix**: `channel.Bridge.StartsWith(SensorConstants.BridgeType.DigitalInput.ToString())` relies on string matching rather than enum comparison.
|
||||
|
||||
9. **GRMS Calculation Has Index Bounds Check**: The loop condition `i < psd.Length - 2 && i < freq.Length - 2` skips the last two elements, which is correct for the pairwise calculation but may silently drop data if arrays have different lengths.
|
||||
@@ -0,0 +1,105 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Properties/AssemblyInfo.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Properties/Annotations.cs
|
||||
generated_at: "2026-04-16T11:14:19.143964+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "530eff79443974f8"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.Graph Properties
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
The `DTS.Viewer.Graph` module defines a component within the larger "DTS Viewer" application, ostensibly responsible for graph-related functionality. The provided source files serve administrative and tooling roles: `AssemblyInfo.cs` establishes the assembly's identity, version, and metadata, while `Annotations.cs` provides a comprehensive set of code analysis attributes (sourced from JetBrains) to enhance static analysis, null-checking, and IDE support within the project.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Assembly Metadata (`AssemblyInfo.cs`)
|
||||
This file configures the assembly-level attributes for `DTS.Viewer.Graph.dll`.
|
||||
|
||||
* **`AssemblyTitle`**: Set to `"Graph"`.
|
||||
* **`AssemblyProduct`**: Set to `"Graph"`.
|
||||
* **`AssemblyCopyright`**: Set to `"Copyright © 2017"`.
|
||||
* **`ComVisible`**: Set to `false`, making types invisible to COM components.
|
||||
* **`Guid`**: `61261c58-c32e-4dea-a87a-d7f956f28b4d` (COM TypeLib ID).
|
||||
* **`AssemblyVersion`**: `"1.0.0.0"`.
|
||||
* **`AssemblyFileVersion`**: `"1.0.0.0"`.
|
||||
|
||||
### Code Annotations (`Annotations.cs`)
|
||||
This file defines the namespace `DTS.Viewer.Graph.Annotations`, containing numerous attributes and enums used for static code analysis. These types do not affect runtime behavior but instruct the IDE (ReSharper/Rider) on code contracts and usage.
|
||||
|
||||
**Nullability and Contracts:**
|
||||
* `CanBeNullAttribute`: Indicates a value may be `null`.
|
||||
* `NotNullAttribute`: Indicates a value should never be `null`.
|
||||
* `ItemNotNullAttribute` / `ItemCanBeNullAttribute`: Applied to collections or `Task`/`Lazy` to indicate the nullability of contained items.
|
||||
* `ContractAnnotationAttribute`: Describes method input/output dependencies (e.g., `null => null`).
|
||||
* `PureAttribute`: Indicates a method has no side effects.
|
||||
* `MustUseReturnValueAttribute`: Indicates a method's return value must be utilized.
|
||||
|
||||
**Code Usage and Reflection:**
|
||||
* `UsedImplicitlyAttribute`: Marks symbols used via reflection or external libraries to suppress "unused" warnings.
|
||||
* `MeansImplicitUseAttribute`: Applied to other attributes to indicate that targets should be considered "used".
|
||||
* `PublicAPIAttribute`: Marks API that should not be removed as it is public-facing.
|
||||
* `ImplicitUseKindFlags` (Enum): Flags defining how a symbol is used (`Access`, `Assign`, `InstantiatedWithFixedConstructorSignature`, etc.).
|
||||
* `ImplicitUseTargetFlags` (Enum): Flags defining target scope (`Itself`, `Members`, `WithMembers`).
|
||||
|
||||
**String and Formatting:**
|
||||
* `StringFormatMethodAttribute`: Marks a method as a string format method (like `string.Format`).
|
||||
* `RegexPatternAttribute`: Indicates a parameter is a regex pattern.
|
||||
* `LocalizationRequiredAttribute`: Indicates if a string should be localized.
|
||||
|
||||
**Assertion and Control Flow:**
|
||||
* `AssertionMethodAttribute`: Marks a method as an assertion (halts control flow on failure).
|
||||
* `AssertionConditionAttribute`: Marks a parameter as the condition for an assertion.
|
||||
* `AssertionConditionType` (Enum): Defines assertion types (`IS_TRUE`, `IS_FALSE`, `IS_NULL`, `IS_NOT_NULL`).
|
||||
* `TerminatesProgramAttribute`: **[Obsolete]** Use `ContractAnnotation("=> halt")` instead.
|
||||
|
||||
**Collections and LINQ:**
|
||||
* `CollectionAccessAttribute`: Describes how a method affects a collection.
|
||||
* `CollectionAccessType` (Enum): Flags for `None`, `Read`, `ModifyExistingContent`, `UpdatedContent`.
|
||||
* `InstantHandleAttribute`: Indicates a delegate/enumerable parameter is handled during the method execution.
|
||||
* `LinqTunnelAttribute`: Marks a method as a pure LINQ method with postponed enumeration.
|
||||
* `NoEnumerationAttribute`: Indicates an `IEnumerable` parameter is not enumerated.
|
||||
|
||||
**ASP.NET MVC and Razor Specifics:**
|
||||
* `AspMvcActionAttribute`, `AspMvcControllerAttribute`, `AspMvcAreaAttribute`, `AspMvcViewAttribute`: Hints for MVC parameters.
|
||||
* `AspMvc*LocationFormatAttribute`: Various attributes for specifying view location formats (e.g., `AspMvcAreaViewLocationFormatAttribute`).
|
||||
* `RazorSectionAttribute`, `RazorImportNamespaceAttribute`, `RazorDirectiveAttribute`: Hints for Razor syntax.
|
||||
|
||||
**XAML Specifics:**
|
||||
* `XamlItemsControlAttribute`: Marks a type as an ItemsControl for XAML analysis.
|
||||
* `XamlItemBindingOfItemsControlAttribute`: Hints at DataContext binding types.
|
||||
|
||||
**Miscellaneous:**
|
||||
* `NotifyPropertyChangedInvocatorAttribute`: Marks a method as a property change notifier.
|
||||
* `SourceTemplateAttribute`: Marks an extension method as a source template for code completion.
|
||||
* `MacroAttribute`: Defines macros for source templates.
|
||||
* `NoReorderAttribute`: Prevents member reordering in the IDE.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
* **COM Visibility:** The assembly is configured with `ComVisible(false)`, guaranteeing that types are not exposed to COM by default.
|
||||
* **Versioning:** The assembly version is strictly defined as `1.0.0.0` in the source; automatic versioning (e.g., using wildcards) is commented out.
|
||||
* **Namespace Consistency:** All annotation attributes reside strictly within the `DTS.Viewer.Graph.Annotations` namespace.
|
||||
* **Attribute Usage:** The attributes in `Annotations.cs` are strictly for metadata; they contain no runtime logic (constructors only set properties).
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
* **Internal Dependencies:**
|
||||
* `System`: Used by `Annotations.cs` for the base `Attribute` type and `Type`, `FlagsAttribute`, etc.
|
||||
* `System.Reflection`: Used by `AssemblyInfo.cs`.
|
||||
* `System.Runtime.CompilerServices`: Used by `AssemblyInfo.cs`.
|
||||
* `System.Runtime.InteropServices`: Used by `AssemblyInfo.cs` for `ComVisible` and `Guid`.
|
||||
|
||||
* **External Consumers:**
|
||||
* The `DTS.Viewer.Graph` assembly is likely consumed by other modules in the "DTS Viewer" solution (inferred from the `Modules` directory structure).
|
||||
* The `Annotations.cs` types are consumed by the C# compiler and static analysis tools (IDEs like ReSharper or Rider).
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
* **Third-Party Code Inclusion:** The `Annotations.cs` file is explicitly licensed under the MIT License and copyrighted by JetBrains (2016). It is a standard boilerplate file often included in projects for ReSharper compatibility. Developers should not modify the logic here, but may update the file if a newer version of the JetBrains annotations is required.
|
||||
* **Obsolete Attribute:** The `TerminatesProgramAttribute` is marked `[Obsolete]` in the source. New code should use `[ContractAnnotation("=> halt")]` instead.
|
||||
* **Empty Description:** The `AssemblyDescription` attribute in `AssemblyInfo.cs` is currently an empty string, which may result in sparse metadata for the compiled DLL.
|
||||
* **Static Analysis Dependency:** The attributes in `Annotations.cs` have no effect if the code is analyzed by tools that do not recognize them (e.g., standard Visual Studio without ReSharper). However, they do not cause runtime errors.
|
||||
@@ -0,0 +1,104 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Resources/TranslateExtension.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Resources/StringResources.Designer.cs
|
||||
generated_at: "2026-04-16T11:13:28.138314+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "ea967aac84c55893"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.Graph.Resources
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides localization infrastructure for the `DTS.Viewer.Graph` namespace. It enables XAML-based string localization through a WPF markup extension (`TranslateExtension`) backed by a strongly-typed resource class (`StringResources`). The resources defined here support user-facing messaging for chart operations, data filtering validation, and file export functionality (PDF/CSV).
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `TranslateExtension` (class)
|
||||
**Namespace:** `DTS.Viewer.Graph`
|
||||
**Inheritance:** `System.Windows.Markup.MarkupExtension`
|
||||
**Attribute:** `[MarkupExtensionReturnType(typeof(string))]`
|
||||
|
||||
A XAML markup extension that resolves localized strings from the resource manager at runtime.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| Constructor | `TranslateExtension(string key)` | Initializes the extension with the resource key to look up. The `key` parameter is stored in a readonly field `_key`. |
|
||||
| Method | `override object ProvideValue(IServiceProvider serviceProvider)` | Returns the localized string for `_key` via `StringResources.ResourceManager.GetString(_key)`. Returns `NotFound` if `_key` is null or empty. Returns `NotFound + " " + _key` if the key is not found in resources. |
|
||||
|
||||
**Constants:**
|
||||
- `private const string NotFound = "#stringnotfound#"` — Sentinel value returned when a resource key cannot be resolved.
|
||||
|
||||
---
|
||||
|
||||
### `StringResources` (class)
|
||||
**Namespace:** `DTS.Viewer.Graph.Resources`
|
||||
**Accessibility:** `internal`
|
||||
**Attribute:** `[GeneratedCode]`, `[DebuggerNonUserCode]`, `[CompilerGenerated]`
|
||||
|
||||
An auto-generated strongly-typed resource class. Do not edit manually; regenerate from `.resx` file.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| Property | `static ResourceManager ResourceManager` | Lazily initializes and returns a cached `ResourceManager` instance bound to `"DTS.Viewer.Graph.Resources.StringResources"`. |
|
||||
| Property | `static CultureInfo Culture` | Gets or sets the culture used for resource lookups. Defaults to `null` (uses current thread's `CurrentUICulture`). |
|
||||
|
||||
**Resource String Properties (all `internal static string`):**
|
||||
|
||||
| Property Name | Purpose |
|
||||
|---------------|---------|
|
||||
| `BadDataFromCustomFilter` | Error message for filter frequency causing out-of-bounds data. Format placeholders: `{0}` (frequency), `{1}` (additional info). |
|
||||
| `BadDataFromTestSetupDefaultFilter` | Error message for test setup default filter issues. Format placeholder: `{0}`. |
|
||||
| `BadDataUnfilteredUnknown` | Error message for unviewable channel data. Format placeholder: `{0}`. |
|
||||
| `ReadingChannelData` | Status message: "Reading channel data...." |
|
||||
| `SavePDFError` | Error message for chart PDF save failure. |
|
||||
| `SavePDFSuccess` | Success message for chart PDF save. Format placeholders: `{0}`, `{1}`, `{2}`, `{3}`. |
|
||||
| `SaveReportCSVError` | Error message for report CSV save failure. |
|
||||
| `SaveReportCSVSuccess` | Success message for report CSV save. Format placeholder: `{0}` (path). |
|
||||
| `SaveReportPDFError` | Error message for report PDF save failure. |
|
||||
| `SaveReportPDFSuccess` | Success message for report PDF save. Format placeholder: `{0}` (path). |
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Key immutability:** `_key` in `TranslateExtension` is `readonly` and set only at construction.
|
||||
2. **Non-null return:** `TranslateExtension.ProvideValue` never returns `null`. It always returns either a valid localized string or a `NotFound` sentinel (with optional key suffix).
|
||||
3. **Fallback behavior:** If `StringResources.ResourceManager.GetString(_key)` returns `null`, the extension returns `"#stringnotfound# " + _key`.
|
||||
4. **Empty key handling:** If `_key` is `null` or empty string, `ProvideValue` returns exactly `"#stringnotfound#"` without a trailing space or key.
|
||||
5. **Auto-generation constraint:** `StringResources` class is tool-generated. Manual edits will be lost upon regeneration.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
**This module depends on:**
|
||||
- `System` (core types)
|
||||
- `System.Windows.Markup` (`MarkupExtension` base class, `MarkupExtensionReturnTypeAttribute`)
|
||||
- `System.Resources` (`ResourceManager`)
|
||||
- `System.Globalization` (`CultureInfo`)
|
||||
- `System.CodeDom.Compiler` (`GeneratedCodeAttribute`)
|
||||
- `System.Diagnostics` (`DebuggerNonUserCodeAttribute`)
|
||||
- `System.Runtime.CompilerServices` (`CompilerGeneratedAttribute`)
|
||||
|
||||
**Dependents (inferred):**
|
||||
- XAML files within `DTS.Viewer.Graph` that use `{x:Static}` or `{local:Translate}` markup extensions for localized strings.
|
||||
- Code within `DTS.Viewer.Graph` that directly references `StringResources` properties for message formatting.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Sentinel value is private:** The `NotFound` constant is `private`, so consuming code cannot programmatically check if a lookup failed by comparing against the sentinel. The sentinel string `"#stringnotfound#"` is effectively hardcoded in behavior.
|
||||
|
||||
2. **Key leakage in fallback:** When a key is not found, the returned string includes the key name (`"#stringnotfound# " + _key`). This could expose internal resource key names to end users in production if keys are missing.
|
||||
|
||||
3. **Inconsistent fallback format:** Empty/null keys return `"#stringnotfound#"` (no trailing space), while missing keys return `"#stringnotfound# " + _key` (with space and key). This inconsistency may complicate string comparison or testing.
|
||||
|
||||
4. **Internal visibility:** `StringResources` is `internal`, so it cannot be accessed from outside the `DTS.Viewer.Graph` assembly. External assemblies must use `TranslateExtension` in XAML or have no access to these resources.
|
||||
|
||||
5. **Designer file coupling:** The `.resx` file backing `StringResources` is not included in the provided source. The actual string values and any additional resources are defined elsewhere and regenerated into this designer file.
|
||||
@@ -0,0 +1,112 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/View/GraphView.xaml.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/View/TestDataView.xaml.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/View/TestDataSeriesView.xaml.cs
|
||||
generated_at: "2026-04-16T11:14:59.450875+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "8c5a8096c69954ca"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.Graph Views
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides WPF view components for rendering and exporting graphical test data within the DTS Viewer application. It contains three XAML code-behind classes—`GraphView`, `TestDataView`, and `TestDataSeriesView`—that implement view interfaces from `DTS.Common.Interface`. The primary functionality resides in `TestDataSeriesView`, which supports exporting chart data to PDF reports and CSV files (specifically for Power Spectral Density data). The module integrates with ComponentOne charting and PDF libraries for visualization and document generation.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### GraphView
|
||||
**Signature:** `public partial class GraphView : IGraphView`
|
||||
|
||||
- **`GraphView()`** - Default constructor. Calls `InitializeComponent()` to load the XAML-defined UI. No other behavior.
|
||||
|
||||
---
|
||||
|
||||
### TestDataView
|
||||
**Signature:** `public partial class TestDataView : ITestDataView`
|
||||
|
||||
- **`TestDataView()`** - Default constructor. Calls `InitializeComponent()`. Contains extensive commented-out zoom functionality (mouse handlers, reversible frame drawing) that is not active.
|
||||
|
||||
---
|
||||
|
||||
### TestDataSeriesView
|
||||
**Signature:** `public partial class TestDataSeriesView : ITestDataSeriesView`
|
||||
|
||||
- **`TestDataSeriesView()`** - Default constructor. Calls `InitializeComponent()`.
|
||||
|
||||
- **`bool SaveReportToPDF(string directory)`** - Generates a PDF report containing:
|
||||
- Test setup name and test ID from the first data series
|
||||
- Chart image rendered as PNG and embedded
|
||||
- A tabular summary of channel names, sample rates, and gRMS values with color indicators
|
||||
- Returns `true` on success, `false` on exception. Throws `DirectoryNotFoundException` if directory is null/whitespace (caught internally).
|
||||
|
||||
- **`bool SaveReportToCSV(string directory)`** - Exports PSD (Power Spectral Density) data to CSV format:
|
||||
- Header row: "Frequency" followed by channel names
|
||||
- Units row: "Hz" followed by engineering units in format `{units}^2/Hz`
|
||||
- Data rows: X values (frequency) and corresponding Y values for each channel
|
||||
- Returns `true` on success, `false` on exception.
|
||||
|
||||
- **`void MainChart_OnMouseWheel(object sender, MouseWheelEventArgs e)`** - Event handler (currently empty implementation; zoom logic commented out).
|
||||
|
||||
- **`void MainChart_OnKeyUp(object sender, KeyEventArgs e)`** - Event handler (empty implementation).
|
||||
|
||||
- **`void obj_DataPointChanged(object sender, EventArgs e)`** - Event handler (currently empty; data point label update logic commented out).
|
||||
|
||||
---
|
||||
|
||||
### AxisExtension (Static Helper Class)
|
||||
**Signature:** `public static class AxisExtension`
|
||||
|
||||
- **`double GetDispMin(this Axis axis)`** - Extension method calculating display minimum based on `ActualMin`, `Value`, `ActualMax`, and `Scale`.
|
||||
|
||||
- **`double GetDispMax(this Axis axis)`** - Extension method calculating display maximum based on `ActualMin`, `Value`, `ActualMax`, and `Scale`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **PDF Paper Size:** Determined by `System.Globalization.RegionInfo.CurrentRegion.IsMetric` — uses `PaperKind.A4` for metric regions, `PaperKind.Letter` otherwise.
|
||||
- **Data Series Access:** `SaveReportToPDF` and `SaveReportToCSV` assume `MainChart.DataContext` is castable to `TestDataSeriesViewModel` with a non-null `GraphDataSeries` property.
|
||||
- **Data Series Uniformity:** CSV export assumes all data series have equal-length `Xvalue` and `Yvalue` arrays (loop condition checks all series).
|
||||
- **Color Casting:** PDF export assumes `ds.GraphColor` is castable to `System.Windows.Media.SolidColorBrush`.
|
||||
- **File Naming:** Both export methods generate filenames using the current `DateTime` with specific formatting patterns.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This module depends on:
|
||||
- **DTS.Common.Interface** — Provides `IGraphView`, `ITestDataView`, `ITestDataSeriesView` interfaces
|
||||
- **DTS.Common.Utilities.Logging** — Provides `APILogger` for logging operations and exceptions
|
||||
- **DTS.Common.Utils** — Provides `FileUtils.GetEncoding(int)`
|
||||
- **C1.WPF.Chart** — ComponentOne FlexChart library
|
||||
- **C1.WPF.C1Chart** — ComponentOne chart components (`Axis`, `ImageFormat`)
|
||||
- **C1.WPF.C1Chart.Extended** — Extended chart functionality
|
||||
- **C1.WPF.Pdf** — ComponentOne PDF generation (`C1PdfDocument`, `PaperKind`, `Font`, `Pen`)
|
||||
- **System.Windows** — WPF core (UI elements, input, media)
|
||||
- **System.IO** — File and directory operations
|
||||
|
||||
### What depends on this module:
|
||||
- **Unknown from source alone** — The interfaces (`IGraphView`, `ITestDataView`, `ITestDataSeriesView`) suggest consumption by a presentation layer or DI container, but concrete consumers are not visible in these files.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Extensive Dead Code:** Both `TestDataView` and `TestDataSeriesView` contain large blocks of commented-out functionality including zoom/pan features, mouse event handling, and data point tracking. This suggests incomplete refactoring or feature rollback.
|
||||
|
||||
2. **Tight ViewModel Coupling:** `SaveReportToPDF` and `SaveReportToCSV` directly cast `MainChart.DataContext` to the concrete `TestDataSeriesViewModel` type rather than using an interface, creating tight coupling.
|
||||
|
||||
3. **Silent Failure Pattern:** Both export methods catch all exceptions, log them, and return `false` without rethrowing. Callers receive no exception details beyond the boolean result.
|
||||
|
||||
4. **Encoding Fallback:** `SaveReportToCSV` attempts to get a specific encoding by code page, falling back to `Encoding.Default` on failure. This could cause inconsistent file encoding across different systems.
|
||||
|
||||
5. **File Path Construction:** Both methods construct file paths using string concatenation with `"\\"` rather than `Path.Combine()` for the filename portion (though `Path.Combine` is used elsewhere).
|
||||
|
||||
6. **Empty Event Handlers:** `MainChart_OnKeyUp` and `MainChart_OnMouseWheel` are wired but have empty or commented-out implementations — unclear if they are placeholders or remnants.
|
||||
|
||||
7. **AxisExtension Usage Unclear:** The `AxisExtension` class provides zoom-related calculations, but no code in these files appears to call these methods.
|
||||
@@ -0,0 +1,114 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/ViewModel/GraphViewModel.cs
|
||||
generated_at: "2026-04-16T11:13:10.472796+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "cd4107fac05f80cd"
|
||||
---
|
||||
|
||||
# GraphViewModel Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`GraphViewModel` is the ViewModel component for the Graph module within the DTS Viewer application. It serves as the mediator between the graph view (`IGraphView`) and the underlying data layer, managing chart visualization state, handling user notifications, and coordinating event-driven communication with parent ViewModels. The class supports multiple initialization contexts—either as a child of `IViewerMainViewModel` or `IPSDReportMainViewModel`—with different subscription behaviors and UI configurations based on the context (e.g., "DataSelect" mode vs. default/result mode).
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Constructor
|
||||
|
||||
```csharp
|
||||
public GraphViewModel(IGraphView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
|
||||
```
|
||||
Initializes the ViewModel with its associated view, region manager for navigation, event aggregator for pub/sub messaging, and Unity container for dependency resolution. Sets the view's `DataContext` to itself and instantiates interaction requests.
|
||||
|
||||
### Properties
|
||||
|
||||
| Property | Type | Access | Description |
|
||||
|----------|------|--------|-------------|
|
||||
| `View` | `IGraphView` | get; private set | The associated graph view instance. |
|
||||
| `DataSeriesView` | `ITestDataSeriesView` | get; set | The data series view used for chart rendering. |
|
||||
| `NotificationRequest` | `InteractionRequest<Notification>` | get; private set | Interaction request for displaying notifications. |
|
||||
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | get; private set | Interaction request for displaying confirmations (shadows base member). |
|
||||
| `ContextGraphRegion` | `object` | get; set | Gets/sets the content of the `GraphRegion` on the view; raises `OnPropertyChanged` on set. |
|
||||
| `MessageText` | `string` | get; set | Status message text; default is `"Please select Event(s) to export data"`. |
|
||||
| `MessageVisibility` | `bool` | get; set | Controls visibility of the message panel; triggers `FireVisibilities()` on set. |
|
||||
| `ProgressPercent` | `double` | get; set | Progress percentage for loading operations; default `0D`. |
|
||||
| `ProgressText` | `string` | get; set | Progress status text; default `"Reading channel data..."`. |
|
||||
| `ProgressVisibility` | `bool` | get; set | Controls visibility of progress indicators; triggers `FireVisibilities()` on set. |
|
||||
| `GraphInfoVisibility` | `bool` | get; set | Controls visibility of graph info panel; triggers `FireVisibilities()` on set. |
|
||||
| `GraphVisibility` | `bool` | get | Computed as `!MessageVisibility`. |
|
||||
| `HeaderInfo` | `string` | get | Returns `"GraphRegion"`. |
|
||||
| `IsBusy` | `bool` | get; set | Busy state indicator (shadows base member). |
|
||||
| `IsDirty` | `bool` | get | Always returns `false` (shadows base member). |
|
||||
|
||||
### Methods
|
||||
|
||||
```csharp
|
||||
public override void Initialize()
|
||||
```
|
||||
Empty override; no behavior.
|
||||
|
||||
```csharp
|
||||
public override void Initialize(object parameter)
|
||||
```
|
||||
Primary initialization logic. Behavior depends on `parameter` type:
|
||||
- **If `IViewerMainViewModel`**: Calls `Subscribe()` and sets `Parent` and `DataSeriesView`.
|
||||
- **If `Tuple<IBaseViewModel, string>` where `Item1` is `IPSDReportMainViewModel`**: Calls `SubscribeDataSelect()` or `SubscribeResult()` based on `Item2` value (`"DataSelect"` vs. default). Configures chart scrollbars and actions based on mode.
|
||||
|
||||
### Events
|
||||
|
||||
```csharp
|
||||
public new event PropertyChangedEventHandler PropertyChanged
|
||||
```
|
||||
Shadows base `PropertyChanged` event; raised via `OnPropertyChanged(string)`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Parent Matching**: Event handlers `OnTestSelectedCountChanged` and `OnGraphSelectedCountChanged` will early-return if `Parent != arg.ParentVM` or `Parent != arg?.ParentVM` respectively.
|
||||
2. **GraphVM Identity Check**: `OnGraphChannelsReadCompleted` and `OnGraphChannelReadCalcProgressChangedEvent` require `this == arg.GraphVM` to proceed.
|
||||
3. **Null Argument Handling**: `OnGraphChannelsReadCompleted` returns immediately if `arg` is null.
|
||||
4. **Progress Bounds**: `ProgressPercent` is only updated if `arg.ProgressPercent >= 0`.
|
||||
5. **Visibility Relationships**: `GraphVisibility` is always the logical inverse of `MessageVisibility`.
|
||||
6. **Initialization Contract**: `Initialize(object parameter)` expects either `IViewerMainViewModel` or a specific `Tuple<IBaseViewModel, string>` pattern; other types result in no initialization.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This Module Depends On:
|
||||
- **C1.WPF.C1Chart** - ComponentOne charting library (used for `AxisScrollBar` type casting)
|
||||
- **DTS.Common.Base** - `BaseViewModel<T>`, `IBaseViewModel`, `IBaseModel`
|
||||
- **DTS.Common.Events** - Event types: `RaiseNotification`, `GraphSelectedChannelCountNotification`, `TestSummaryCountNotification`, `TestModificationChangedEvent`, `GraphChannelsReadCompletedNotification`, `GraphChannelReadCalcProgressChangedEvent`
|
||||
- **DTS.Common.Interactivity** - `InteractionRequest<T>`, `Notification`, `Confirmation`
|
||||
- **DTS.Common.Interface** - `IGraphViewModel`, `IGraphView`, `ITestDataSeriesView`, `ITestDataSeriesViewModel`, `ITestModificationModel`, `IViewerMainViewModel`, `IPSDReportMainViewModel`
|
||||
- **Prism.Events** - `IEventAggregator`, `ThreadOption`
|
||||
- **Prism.Regions** - `IRegionManager`
|
||||
- **Unity** - `IUnityContainer`
|
||||
|
||||
### Concrete Type Dependencies (Internal):
|
||||
- `GraphView` - Referenced in `ContextGraphRegion` property
|
||||
- `TestDataSeriesView` - Referenced in `Initialize()` for chart configuration
|
||||
- `TestDataSeriesViewModel` - Referenced in `GetTestDataSeriesView()` for PSD subscription
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Shadowed Base Members**: Multiple members use the `new` keyword to shadow base class implementations (`PropertyChanged`, `OnPropertyChanged`, `IsBusy`, `IsDirty`, `ConfirmationRequest`, `Model`). This may cause unexpected behavior if consumers interact through base class references.
|
||||
|
||||
2. **Code Duplication**: `Subscribe()`, `SubscribeDataSelect()`, and `SubscribeResult()` have nearly identical implementations. The only difference is that `Subscribe()` additionally subscribes to `TestModificationChangedEvent`, but the handler `OnTestModificationChanged` is empty.
|
||||
|
||||
3. **Empty Handler**: `OnTestModificationChanged(ITestModificationModel obj)` has no implementation—potential tech debt or placeholder.
|
||||
|
||||
4. **Concrete Type Casting**: The code directly casts to `GraphView` and `TestDataSeriesView` concrete types, breaking the abstraction provided by interfaces. This creates tight coupling and could cause runtime failures if different implementations are registered.
|
||||
|
||||
5. **Unused Private Field**: `Model` property is declared but never used (suppressed by `// ReSharper disable NotAccessedField.Local`).
|
||||
|
||||
6. **Hardcoded Strings**: Chart type comparison uses literal strings (`"DataSelect"`, `"Graph"`) without constants, risking typos.
|
||||
|
||||
7. **Thread Affinity**: `GraphChannelsReadCompletedNotification` and `GraphChannelReadCalcProgressChangedEvent` are explicitly subscribed with `ThreadOption.UIThread`, indicating UI updates must occur on the dispatcher thread.
|
||||
Reference in New Issue
Block a user