--- source_files: - DataPRO/Reports/ChannelCalibrationList.cs - DataPRO/Reports/DASLayout.cs - DataPRO/Reports/DiagnosticsReport.cs generated_at: "2026-04-16T03:51:09.548515+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "574c22aeaf057df0" --- # ChannelCalibrationList Documentation ## 1. Purpose The `ChannelCalibrationList` class generates a calibration status report for sensor channels, aggregating calibration dates, next due dates, and status indicators (OK, Warn, Overdue) into structured Excel and/or PDF reports. It extends `ReportBase` and is responsible for transforming an array of `ChannelHelper` objects—containing channel-specific calibration data—into a formatted table report, applying conditional styling based on calibration status for the `NextCal` column. This report supports test-specific naming and optional dual-format output (Excel + PDF), and is used to provide auditable calibration traceability for test channels. ## 2. Public Interface ### `ChannelCalibrationList.Fields` enum Defines the column fields for the report table: - `Location` - `SensorAxis` - `SerialNo` - `Cal` - `NextCal` ### `ChannelHelper` class Encapsulates channel calibration data: - **Properties**: - `string Location` - `string SensorAxis` - `string SerialNo` - `string SerialNumberWithAxis` *(not used in current implementation)* - `string Cal` *(calibration date string)* - `string NextCal` *(next calibration due date string)* - `ResultStatus CalStatus` *(enum: `OK`, `Overdue`, `Warn`)* - **Constructors**: - `ChannelHelper()` – initializes all string properties to `""`. - `ChannelHelper(string location, string sensorAxis, string serialNo, string cal, string nextCal)` – initializes the first five properties. ### `ChannelHelper.ResultStatus` enum Indicates calibration status: - `OK` - `Overdue` - `Warn` ### `ChannelCalibrationList()` Default constructor; no side effects. ### `GetReportFilenamePath(string reportPath, string testId)` **Signature**: `public static string GetReportFilenamePath(string reportPath, string testId)` Returns the full path for the report file. If `testId` is non-empty, prepends it to the filename (e.g., `"T123 ChannelCalibrationList.xlsx"`); otherwise, returns `"ChannelCalibrationList.xlsx"` in `reportPath`. ### `DoReport(...)` **Signature**: `public void DoReport(ChannelHelper[] channels, string outputFileName, string folderNameId, string sensitivityDisplayFormat, bool generateExcelReports, bool generatePDFReports)` Generates the calibration report: - Builds a `DataTable` (`dt`) with columns from `Fields` enum. - Populates rows from `channels`, mapping `ChannelHelper` properties to columns. - Applies styling to the `NextCal` column via a parallel `dtStyles` DataTable: - `OK` → `FillStyles.Pass` - `Warn` → `FillStyles.Warn` - `Overdue` → `FillStyles.Fail` - Only if `NextCal` is non-empty and not `"--"`. - Deletes existing `outputFileName` if present (logs via `ReportFileWillBeOverwritten`/`ReportFileInUse`). - Sets `TemplateFilename` to the base template path (via `GetReportFilenamePath(GetTemplateReportPath(), string.Empty)`). - If `generateExcelReports`: - Calls `OutputReport(new DataTable[] { dt }, new DataTable[] { dtStyles })`. - Copies result to `folderNameId` via `CopyReportIfNeeded`. - If `generatePDFReports`: - Replaces `.xlsx` with `.pdf` in `outputFileName`. - Sets `DestinationTemplateFilename` to a temp file (`.xlsx` → `.tmp`). - Calls `OutputReportPDF(...)` with `sensitivityDisplayFormat`. - Copies PDF result via `CopyReportIfNeeded`. ## 3. Invariants - `dtStyles` is only populated for `NextCal` and `Cal` columns (others default to `-1`). - `NextCal` styling is applied *only* when the value is non-null/whitespace and not `"--"`. - `Cal` column data is copied directly from `ch.Cal` without styling. - Excel and PDF outputs share the same base template (from `GetTemplateReportPath()`), but PDF generation uses a temporary template copy to avoid overwriting the Excel-filled template. - `outputFileName` is overwritten in-place for PDF generation only if `generatePDFReports` is true. - `channels` array may be empty; no explicit validation is performed. ## 4. Dependencies - **Base class**: `ReportBase` (provides `OutputReport`, `OutputReportPDF`, `CopyReportIfNeeded`, `ReportFileWillBeOverwritten`, `ReportFileInUse`, `GetTemplateReportPath`, `TemplateFilename`, `OutputFilename`, `DestinationTemplateFilename`). - **Enums used**: `ReportBase.FillStyles` (values: `Pass`, `Warn`, `Fail`, `NotTested`). - **Namespaces**: `System`, `System.Linq`, `System.Data`, `System.IO`. - **Consumers**: Likely invoked by higher-level test orchestration logic (e.g., test runner or report generator) that provides `ChannelHelper[]` data. ## 5. Gotchas - `SerialNumberWithAxis` property in `ChannelHelper` is defined but never used in `DoReport`. - `Cal` column has no styling applied, even though `dtStyles` is created for it—only `NextCal` uses `dtStyles`. - Date formatting for `Cal`/`NextCal` is assumed to be handled by the caller (strings passed directly); no parsing or validation occurs in `DoReport`. - PDF generation reuses `outputFileName` (replaces `.xlsx` → `.pdf`), meaning the Excel file is overwritten *before* PDF generation if both formats are requested. The `DestinationTemplateFilename` workaround (`... + ".tmp"`) is used to preserve the Excel template, but the original Excel output is overwritten. - No handling for `null` in `channels` array or `null`/empty `ChannelHelper` instances—could throw `NullReferenceException`. - `GetReportFilenamePath` does not use `testId` for PDF naming in `DiagnosticsReport` or `DASLayout`; only `DASLayout` uses `testId` in its own `GetReportFilenamePath`. - `ChannelHelper` constructor overloads do not initialize `CalStatus`; default is `OK` (enum default), but this may be misleading if not explicitly set by caller. - None identified from source alone.