137 lines
8.6 KiB
Markdown
137 lines
8.6 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DataPRO/Reports/ChannelCalibrationList.cs
|
||
|
|
- DataPRO/Reports/DASLayout.cs
|
||
|
|
- DataPRO/Reports/DiagnosticsReport.cs
|
||
|
|
generated_at: "2026-04-17T15:52:39.056423+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "3fb37e33d15ad38b"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: DTS.Reports Report Classes
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module contains three report generator classes (`ChannelCalibrationList`, `DASLayout`, `DiagnosticsReport`) that produce Excel and PDF reports for a data acquisition system. Each class inherits from `ReportBase` and transforms domain-specific data into tabular reports with conditional styling (pass/fail/warn indicators). The reports cover calibration status tracking, hardware channel configuration layouts, and diagnostic test results for DAS units, analog channels, and squib channels.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### ChannelCalibrationList
|
||
|
|
|
||
|
|
**Nested Types:**
|
||
|
|
- `ChannelCalibrationList.Fields` - Enum with values: `Location`, `SensorAxis`, `SerialNo`, `Cal`, `NextCal`
|
||
|
|
- `ChannelCalibrationList.ChannelHelper` - Data transfer class with properties:
|
||
|
|
- `string Location`, `string SensorAxis`, `string SerialNo`, `string SerialNumberWithAxis`, `string Cal`, `string NextCal`
|
||
|
|
- `ResultStatus CalStatus` - Enum with values: `OK`, `Overdue`, `Warn`
|
||
|
|
- Two constructors: default (initializes strings to empty) and parameterized constructor
|
||
|
|
|
||
|
|
**Methods:**
|
||
|
|
```csharp
|
||
|
|
public static string GetReportFilenamePath(string reportPath, string testId)
|
||
|
|
```
|
||
|
|
Returns a combined path for the report file. Prepends `testId` to filename if non-empty. Base filename is `"ChannelCalibrationList.xlsx"`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public void DoReport(ChannelHelper[] channels, string outputFileName, string folderNameId,
|
||
|
|
string sensitivityDisplayFormat, bool generateExcelReports, bool generatePDFReports)
|
||
|
|
```
|
||
|
|
Generates the calibration list report. Creates a DataTable with columns from `Fields` enum. Applies conditional styling to `NextCal` column based on `CalStatus`. Outputs Excel and/or PDF based on boolean flags.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### DASLayout
|
||
|
|
|
||
|
|
**Nested Types:**
|
||
|
|
- `DASLayout.Fields` - Enum with values: `DCH`, `Module`, `Channel`, `Description`, `Sensor`, `ISOCode`, `Range`, `SquibFireMode`, `Sens`, `Filter`, `Delay`, `Volt`, `Duration`, `Trigger`, `ChannelType`
|
||
|
|
- `DASLayout.ChannelHelper` - Data transfer class with properties:
|
||
|
|
- `int DCH`, `string Module`, `string Channel`, `string Description`, `string SensorSerial`, `string Sensitivity`, `string ISOCode`, `string Range`, `string SquibFireMode`, `string Filter`, `string Voltage`, `string LevelTrigger`
|
||
|
|
- `double DelayMS`, `double DurationMS`, `int ChannelType`
|
||
|
|
- `IGroupChannel GroupChannel`, `ISensorCalibration Calibration` - References for polarity verification
|
||
|
|
|
||
|
|
**Methods:**
|
||
|
|
```csharp
|
||
|
|
public static string GetReportFilenamePath(string reportPath, string serialNumberDAS, string testId)
|
||
|
|
```
|
||
|
|
Returns combined path. Format: `"{testId} {serialNumberDAS} - {timestamp}Layout.xlsx"` if testId provided, otherwise `"DAS Layout.xlsx"`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public void DoReport(ChannelHelper[] channels, string outputFileName, string folderNameId,
|
||
|
|
string sensitivityDisplayFormat, bool generateExcelReports, bool generatePDFReports)
|
||
|
|
```
|
||
|
|
Generates the DAS layout report. Creates DataTable with typed columns (int for `DCH` and `ChannelType`, double for `Delay` and `Duration`, string for others). No styling DataTable is passed (null).
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### DiagnosticsReport
|
||
|
|
|
||
|
|
**Nested Types:**
|
||
|
|
- `DiagnosticsReport.DASFields` - Private enum: `DAS`, `FW`, `CalDate`, `DueDate`, `Connection`, `Input`, `Battery`
|
||
|
|
- `DiagnosticsReport.AnalogFields` - Private enum: `ExportNum`, `DAS`, `Module`, `Channel`, `Object`, `Sens`, `Desc`, `Exc`, `Offset`, `Shunt`, `Range`, `Noise`
|
||
|
|
- `DiagnosticsReport.SquibFields` - Private enum: `DAS`, `Module`, `Channel`, `Desc`, `ISO`, `FireMode`, `Delay`, `Duration`
|
||
|
|
- `DiagnosticsReport.DASHelper` - Properties: `string DAS`, `string Firmware`, `DateTime CalDate`, `DateTime DueDate`, `string Connection`, `string Input`, `string Battery`
|
||
|
|
- `DiagnosticsReport.AnalogHelper` - Properties include `int ExportNum`, various strings, doubles for measurements (`Exc`, `Offset`, `Shunt`, `Range`, `Noise`), and `ResultStatus` enums for each measurement. `ResultStatus` values: `Passed`, `Failed`, `NotTested`
|
||
|
|
- `DiagnosticsReport.SquibHelper` - Properties include strings, `double Delay`, `double Duration`, `double Resistance`, and `ResultStatus` for delay/duration
|
||
|
|
|
||
|
|
**Methods:**
|
||
|
|
```csharp
|
||
|
|
public static string GetReportFilename(bool isPreTest, string testId)
|
||
|
|
```
|
||
|
|
Returns filename like `"{testId} Pretest Diagnostics {timestamp}.xlsx"` or `"{testId} Post-Test Diagnostics {timestamp}.xlsx"`. Returns `"Diagnostic Results.xlsx"` if testId is null/empty.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static string GetReportFilenamePath(bool isPreTest, string reportPath, string testId)
|
||
|
|
```
|
||
|
|
Combines reportPath with filename from `GetReportFilename`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public void DoReport(DASHelper[] das, AnalogHelper[] analog, SquibHelper[] squib,
|
||
|
|
string outputFileName, string folderNameId, string sensitivityDisplayFormat,
|
||
|
|
bool generateExcelReports, bool generatePDFReports)
|
||
|
|
```
|
||
|
|
Generates diagnostic report with three DataTables (`DAS`, `Analog`, `Squibs`). Applies conditional styling to analog measurement columns and squib delay/duration columns. Special handling for `Range` field (displays "Infinity" or "---" for special double values). Divides `Exc` value by 1000.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
- **Column ordering**: All reports iterate over `Fields` enum values via `Enum.GetValues()` to define column order; column order is determined by enum declaration order.
|
||
|
|
- **Styling defaults**: Style values default to `-1` (no styling) unless explicitly set based on `ResultStatus`.
|
||
|
|
- **Date handling**: In `DiagnosticsReport`, dates with year < 1970 display as empty string; dates equal to `minDate` (1970-01-01) display as `"--"`.
|
||
|
|
- **File existence**: All `DoReport` methods check for existing output files and delete them before writing; if deletion fails (file in use), `ReportFileInUse` is called.
|
||
|
|
- **Template path**: `TemplateFilename` is always set using `GetTemplateReportPath()` with empty testId/serialNumber parameters before report generation.
|
||
|
|
- **PDF generation**: When generating PDF, `DestinationTemplateFilename` is set to the Excel filename with `Common.Constants.TEMP_FILE_EXTENSION` to avoid overwriting the template.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
**This module depends on:**
|
||
|
|
- `System`, `System.Linq`, `System.Data`, `System.IO` (standard .NET libraries)
|
||
|
|
- `DTS.Common.Interface.Channels.IGroupChannel` (referenced in `DASLayout.ChannelHelper`)
|
||
|
|
- `DTS.Common.Interface.Sensors.ISensorCalibration` (referenced in `DASLayout.ChannelHelper`)
|
||
|
|
- `DTS.Common.Constants.TEMP_FILE_EXTENSION` (constant used in PDF generation)
|
||
|
|
- `ReportBase` (base class providing `FillStyles` enum, `OutputReport`, `OutputReportPDF`, `CopyReportIfNeeded`, `GetTemplateReportPath`, `ReportFileWillBeOverwritten`, `ReportFileInUse`, and properties `TemplateFilename`, `OutputFilename`, `DestinationTemplateFilename`)
|
||
|
|
|
||
|
|
**What depends on this module:**
|
||
|
|
- Not determinable from source alone. Callers would invoke `DoReport` methods and `GetReportFilenamePath` static methods.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 5. Gotchas
|
||
|
|
|
||
|
|
1. **Inconsistent null handling in DASLayout**: `DASLayout.DoReport` passes `null` for the styles DataTable array to `OutputReport` and `OutputReportPDF`, whereas the other two classes always provide style DataTables. This may cause issues if the base class methods don't handle null gracefully.
|
||
|
|
|
||
|
|
2. **Exc value scaling**: In `DiagnosticsReport`, the `Exc` field is divided by 1000 (`ch.Exc / 1000D`) before output. This unit conversion is implicit and not documented in the method signature.
|
||
|
|
|
||
|
|
3. **Date comparison bug**: In `DiagnosticsReport.DoReport`, the `DueDate` handling checks `d.CalDate == minDate` instead of `d.DueDate == minDate`, which appears to be a copy-paste error that could cause incorrect display of due dates.
|
||
|
|
|
||
|
|
4. **ChannelHelper class name collision**: Both `ChannelCalibrationList` and `DASLayout` define nested classes named `ChannelHelper` with completely different structures. This could cause confusion when reading code or debugging.
|
||
|
|
|
||
|
|
5. **File deletion exception handling**: All three `DoReport` methods catch `Exception` when deleting existing files and call `ReportFileInUse`, but then continue execution. If the file couldn't be deleted, subsequent write operations may fail.
|
||
|
|
|
||
|
|
6. **Unused properties**: `ChannelCalibrationList.ChannelHelper.SerialNumberWithAxis` and `DiagnosticsReport.AnalogHelper.SerialNumberWithAxis` are defined but never used in report generation.
|
||
|
|
|
||
|
|
7. **Unused properties in AnalogHelper**: `ScalefactorMilliVoltsPerADC` and `ActualRangeMv` are defined but never output to the report.
|