9.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T03:18:16.331578+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 00d9f02148080370 |
DiagnosticRun and DiagnosticEntry Documentation
1. Purpose
This module defines core data transfer objects (DiagnosticRun and DiagnosticEntry) used to represent analog sensor diagnostic test sessions and individual channel measurements within the DTS (Data Transfer System) framework. DiagnosticRun models a single diagnostic test execution (e.g., a pre-test or post-test run), capturing metadata like user, test ID, and run type. DiagnosticEntry models a single sensor channel’s diagnostic results within a run, including measured values (excitation, offset, range, noise, shunt), status flags, and associated sensor/DAS (Data Acquisition System) identification. These classes are primarily used for deserializing data from SQL Server database queries (via SqlDataReader) and serve as the canonical in-memory representation of diagnostic test data for reporting, analysis, and persistence.
2. Public Interface
DiagnosticRun
-
DiagnosticRun()
Parameterless constructor; initializes all properties to their default values (nullfor nullable types,string.Emptyfor strings,trueforPreTest). -
DiagnosticRun(SqlDataReader reader)
Constructor that populates the object from aSqlDataReaderpositioned on a valid row. Reads columns:Id,DataPROUser,TestId,TestName,PreTest. Skips assignment if the column value isDBNull.Value. -
long? Id { get; set; }
Database primary key or unique identifier for the diagnostic run. Nullable; defaults tonull. -
string DataPROUser { get; set; }
Username of the operator who executed the diagnostic run. Defaults tostring.Empty. -
int? TestId { get; set; }
Foreign key or identifier linking to a specific test configuration. Nullable; defaults tonull. -
string TestName { get; set; }
Human-readable name of the test being run. Defaults tostring.Empty. -
bool PreTest { get; set; }
Indicates whether this run is a pre-test (true) or post-test (false). Defaults totrue.
DiagnosticEntry
-
DiagnosticEntry()
Parameterless constructor; initializes all properties to their default values (nullfor nullable types,0for numeric primitives,DateTime.MinValueforTimestamp,DiagnosticStatus.Untestedfor status fields,string.Emptyfor strings). -
DiagnosticEntry(SqlDataReader reader)
Constructor that populates the object from aSqlDataReaderrow. Reads columns:Id,DiagnosticRunId,Excitation,ExcitationStatus,Offset,OffsetStatus,ActualRange,ActualRangeStatus,Noise,NoiseStatus,Shunt,ShuntStatus,SensorId,SensorSerialNumber,DASId,DASSerialNumber,DASChannelIdx,UserCode,UserChannelName,IsoCode,IsoChannelName,ScaleFactor,CalibrationRecordId,CalibrationRecordXML,Timestamp. Skips assignment if the column value isDBNull.Value. -
long? Id { get; set; }
Database primary key or unique identifier for the diagnostic entry. Nullable; defaults tonull. -
long DiagnosticRunId { get; set; }
Foreign key linking this entry to aDiagnosticRun. Non-nullable; defaults to-1. -
double? Excitation { get; set; }
Measured excitation voltage (e.g., in mV/V). Nullable; defaults tonull. -
DiagnosticStatus ExcitationStatus { get; set; }
Status of the excitation measurement (e.g., Passed, Failed, Untested). Defaults toDiagnosticStatus.Untested. -
double? Offset { get; set; }
Measured offset voltage. Nullable; defaults tonull. -
DiagnosticStatus OffsetStatus { get; set; }
Status of the offset measurement. Defaults toDiagnosticStatus.Untested. -
double? ActualRange { get; set; }
Measured actual range (e.g., span). Nullable; defaults tonull. -
DiagnosticStatus ActualRangeStatus { get; set; }
Status of the range measurement. Defaults toDiagnosticStatus.Untested. -
double? Noise { get; set; }
Measured noise level. Nullable; defaults tonull. -
DiagnosticStatus NoiseStatus { get; set; }
Status of the noise measurement. Defaults toDiagnosticStatus.Untested. -
double? Shunt { get; set; }
Measured shunt calibration value. Nullable; defaults tonull. -
DiagnosticStatus ShuntStatus { get; set; }
Status of the shunt measurement. Defaults toDiagnosticStatus.Untested. -
int? SensorId { get; set; }
Identifier for the sensor being tested. Nullable; defaults tonull. -
string SensorSerialNumber { get; set; }
Serial number of the sensor. Defaults tostring.Empty. -
int? DASId { get; set; }
Identifier for the Data Acquisition System used. Nullable; defaults tonull. -
string DASSerialNumber { get; set; }
Serial number of the DAS. Defaults tostring.Empty. -
int DASChannelIdx { get; set; }
Zero-based index of the channel on the DAS. Defaults to0. -
string UserCode { get; set; }
User-defined code or label for the channel. Defaults tostring.Empty. -
string UserChannelName { get; set; }
User-friendly name for the channel. Defaults tostring.Empty. -
string IsoCode { get; set; }
ISO-standard code for the channel configuration. Defaults tostring.Empty. -
string IsoChannelName { get; set; }
ISO-standard name for the channel. Defaults tostring.Empty. -
double ScaleFactor { get; set; }
Scaling factor applied to raw measurements. Defaults to1. -
int CalibrationRecordId { get; set; }
Identifier linking to a calibration record. Non-nullable; defaults to-1. -
string CalibrationRecordXML { get; set; }
XML blob containing full calibration record details. Defaults tostring.Empty. -
DateTime Timestamp { get; set; }
Timestamp of when the diagnostic entry was recorded. Defaults toDateTime.MinValue.
3. Invariants
DiagnosticRunIdinDiagnosticEntryis non-nullable and defaults to-1, implying a validDiagnosticRunmust be associated (though-1may indicate an unassigned or invalid state).DASChannelIdxis a non-nullableintdefaulting to0, suggesting zero-based indexing is assumed.- All
DiagnosticStatusproperties default toDiagnosticStatus.Untested, indicating a safe initial state before validation. PreTestdefaults totrue, implying the system assumes pre-test unless explicitly marked otherwise.- Null handling in constructors: Values from
SqlDataReaderare only assigned if!DBNull.Value.Equals(...). This means missing database columns orNULLvalues result in the property retaining its default value (e.g.,null,0,string.Empty,DiagnosticStatus.Untested). DiagnosticEntryproperties map directly to database column names (e.g.,reader["Timestamp"]→Timestampproperty). Column name casing must match exactly in the database.
4. Dependencies
- Depends on:
DTS.Common.Interface.Sensors.AnalogDiagnosticsnamespace (forIDiagnosticRunandIDiagnosticEntryinterfaces).System.Data.SqlClient(forSqlDataReaderusage).DiagnosticStatusenum (used inDiagnosticEntryproperties; defined inDTS.Common.Interface.Sensors.AnalogDiagnostics, not shown in source).
- Depended on by:
- Data access layers (e.g., repositories or data readers) that populate these objects from SQL queries.
- Reporting or analysis modules that consume diagnostic test results.
- Likely used in conjunction with
IDiagnosticRun/IDiagnosticEntryinterfaces for testability or inversion of control.
5. Gotchas
-
DASChannelIdxis read asshortfromSqlDataReaderbut stored asint:DASChannelIdx = (short)reader["DASChannelIdx"];This may cause runtime exceptions if the database column is larger than
Int16(e.g.,intorbigint). Type mismatch is not validated at compile time. -
DiagnosticStatuscast assumes underlying type isshort:ExcitationStatus = (DiagnosticStatus)(short)reader["ExcitationStatus"];If the database column is stored as
intortinyint, this cast may throwInvalidCastExceptionor produce incorrect values. -
No validation or business logic: These are pure DTOs. Consumers must enforce constraints (e.g.,
DiagnosticRunId != -1,PreTestsemantics). -
Default
DiagnosticRunId = -1is ambiguous: May indicate "uninitialized" or "invalid", but no explicit check or constant is defined for this sentinel value. -
No immutability guarantees: All properties have public setters; objects can be mutated after construction.
-
Timestampproperty name vs. database column: The property is namedTimestamp(PascalCase), but SQL Server column is likelyTimestamp(case-insensitive). However, if the DB usestimestamp(deprecated synonym forrowversion) instead ofdatetime, the cast(DateTime)reader["Timestamp"]will fail. -
No null-safety for string properties: If
reader["DataPROUser"]returnsnull(notDBNull), the cast(string)reader["..."]succeeds but may yieldnull(notstring.Empty). OnlyDBNullis guarded against. -
No error handling in constructor: Exceptions from invalid casts or missing columns propagate unhandled.