6.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T11:14:59.450875+00:00 | zai-org/GLM-5-FP8 | 1 | 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. CallsInitializeComponent()to load the XAML-defined UI. No other behavior.
TestDataView
Signature: public partial class TestDataView : ITestDataView
TestDataView()- Default constructor. CallsInitializeComponent(). 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. CallsInitializeComponent(). -
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
trueon success,falseon exception. ThrowsDirectoryNotFoundExceptionif 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
trueon success,falseon 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 onActualMin,Value,ActualMax, andScale. -
double GetDispMax(this Axis axis)- Extension method calculating display maximum based onActualMin,Value,ActualMax, andScale.
3. Invariants
- PDF Paper Size: Determined by
System.Globalization.RegionInfo.CurrentRegion.IsMetric— usesPaperKind.A4for metric regions,PaperKind.Letterotherwise. - Data Series Access:
SaveReportToPDFandSaveReportToCSVassumeMainChart.DataContextis castable toTestDataSeriesViewModelwith a non-nullGraphDataSeriesproperty. - Data Series Uniformity: CSV export assumes all data series have equal-length
XvalueandYvaluearrays (loop condition checks all series). - Color Casting: PDF export assumes
ds.GraphColoris castable toSystem.Windows.Media.SolidColorBrush. - File Naming: Both export methods generate filenames using the current
DateTimewith specific formatting patterns.
4. Dependencies
This module depends on:
- DTS.Common.Interface — Provides
IGraphView,ITestDataView,ITestDataSeriesViewinterfaces - DTS.Common.Utilities.Logging — Provides
APILoggerfor 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
-
Extensive Dead Code: Both
TestDataViewandTestDataSeriesViewcontain large blocks of commented-out functionality including zoom/pan features, mouse event handling, and data point tracking. This suggests incomplete refactoring or feature rollback. -
Tight ViewModel Coupling:
SaveReportToPDFandSaveReportToCSVdirectly castMainChart.DataContextto the concreteTestDataSeriesViewModeltype rather than using an interface, creating tight coupling. -
Silent Failure Pattern: Both export methods catch all exceptions, log them, and return
falsewithout rethrowing. Callers receive no exception details beyond the boolean result. -
Encoding Fallback:
SaveReportToCSVattempts to get a specific encoding by code page, falling back toEncoding.Defaulton failure. This could cause inconsistent file encoding across different systems. -
File Path Construction: Both methods construct file paths using string concatenation with
"\\"rather thanPath.Combine()for the filename portion (thoughPath.Combineis used elsewhere). -
Empty Event Handlers:
MainChart_OnKeyUpandMainChart_OnMouseWheelare wired but have empty or commented-out implementations — unclear if they are placeholders or remnants. -
AxisExtension Usage Unclear: The
AxisExtensionclass provides zoom-related calculations, but no code in these files appears to call these methods.