8.2 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T03:52:56.599244+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 435708341e9b9055 |
Diagnostics
Documentation: DASFactoryDb.Diagnostics.Diagnostics Module
1. Purpose
This module provides a set of static methods to interact with diagnostic-related database operations for DAS (Data Acquisition System) communication records. It serves as the primary interface for inserting, clearing, and managing diagnostic actions (configured test parameters) and diagnostic results (observed test outcomes) across channels and events. The module abstracts low-level ADO.NET database calls into higher-level operations, delegating actual data persistence to stored procedures in the DASFactory database.
2. Public Interface
All methods are public static and reside in the DASFactoryDb.Diagnostics.Diagnostics class.
ClearDiagnosticActionsAllChannels(int idasRecordId)
- Behavior: Clears all diagnostic action configurations for all channels associated with the given
idasRecordId. Uses the stored proceduresp_DiagnosticActionsClear. - Parameters:
idasRecordId: ID of the DAS communication record to clear actions for.
- Note: Passes
nullfor@DASChannelNumberto indicate “all channels”.
InsertDiagnosticAction(...)
- Behavior: Inserts a new diagnostic action configuration for a specific DAS channel. Uses the stored procedure
sp_DiagnosticsActionsInsert. - Parameters:
dasRecordId: ID of the DAS communication record.dasChannelNumber: Channel number (0-based or 1-based? — not specified in source).- Boolean flags indicating which diagnostic tests to perform (e.g.,
measureExcitation,measureOffset,squibFireCheck, etc.).
- Returns: Output parameter
@new_id(ID of inserted record) is captured but not returned by this method.
ClearExistingDiagnosticsAllChannels(int idasRecordId = -1)
- Behavior: Clears all diagnostic results for a given DAS communication record (or all records if
idasRecordId == -1). Uses the stored proceduresp_DiagnosticsResultsClear. - Parameters:
idasRecordId: Optional; defaults to-1(clear all records). If non-negative, clears only for that record.
- Note: Passes
nullfor both@DASChannelNumberand@EventNumber, indicating “all channels and events”.
InsertAnalogDiagnosticResult(...)
- Behavior: Inserts a full analog diagnostic result record for a specific channel and event. Uses the stored procedure
sp_DiagnosticsResultsAnalogInsert. - Parameters:
iDASRecordId,dasChannelNumber,eventNumber: Identifiers for the diagnostic result context.- Numerous
double,short?,bool?parameters representing measured/calculated values (e.g., excitation, offset, noise, gain, shunt deflection, bridge resistance).
- Returns: Output parameter
@new_idis captured but not returned.
InsertSquibDiagnosticResult(...)
- Behavior: Inserts a squib (pyro) fire diagnostic result, including raw time-series data (current, voltage, time axis) as binary blobs. Uses the stored procedure
sp_DiagnosticsResultsSquibInsert. - Parameters:
iDASRecordId,dasChannelNumber,eventNumber: Identifiers.squibFireCurrentData,squibFireVoltageData,squibFireTimeAxis: Arrays ofdoublerepresenting raw waveform data.- Optional metrics:
measuredDurationMS,measuredDelayMS, pass/fail flags. - Calibration/scaling parameters:
squibThreshold,squibVoltageScaler,squibCurrentScaler.
- Special Behavior:
- Early return if
squibFireCurrentData == null(prevents exception inBitConverter.GetBytes). - Converts
double[]arrays tobyte[]viaBitConverter.GetBytesbefore storing inVARBINARYparameters.
- Early return if
InsertDigitalDiagnosticResult(...)
- Behavior: Inserts a digital diagnostic result (e.g., for digital input state verification). Uses the stored procedure
sp_DiagnosticsResultsDigitalInsert. - Parameters:
iDASRecordId,dasChannelNumber,eventNumber: Identifiers.digitalInputActiveState: Boolean indicating whether the digital input was in its active state.
3. Invariants
- Database Connection Check: Every method first checks
DbWrapper.Connected. Iffalse, the method returns early without executing any DB operation or raising an exception. - Stored Procedure Execution: All methods use
CommandType.StoredProcedureand callDbWrapper.ProcessReturn(errorNumber, errorMessage)after execution. This implies:- Stored procedures are expected to set
@errorNumberand@errorMessageoutput parameters. DbWrapper.ProcessReturn(...)likely throws or logs on non-zero@errorNumber.
- Stored procedures are expected to set
- Connection Disposal: All
SqlCommandobjects are wrapped inusingblocks, andcmd.Connection.Dispose()is called explicitly infinallyblocks — ensuring connections are released even on failure. - Null Handling for Parameters: Parameters with nullable types (e.g.,
double?) are passed directly asValue = nullableValue. ADO.NET treatsnullas SQLNULL, which is consistent with the stored procedure expectations (e.g.,@EventNumbercan benullinClearExistingDiagnosticsAllChannels). - No Return of Output Values: While
@new_idand error parameters are declared and populated, only errors are processed viaDbWrapper.ProcessReturn(...). The@new_idvalues are not exposed to callers.
4. Dependencies
Internal Dependencies
DASFactoryDb.Diagnostics.Diagnosticsdepends on:DbWrapper(static class, not shown here) — provides:ConnectedpropertyGetDASFactoryCommand()method (returnsSqlCommand)ProcessReturn(SqlParameter errorNumber, SqlParameter errorMessage)method
System.Data,System.Data.SqlClient— standard ADO.NET types.
External Dependencies
- Database:
- Stored procedures:
sp_DiagnosticActionsClearsp_DiagnosticsActionsInsertsp_DiagnosticsResultsClearsp_DiagnosticsResultsAnalogInsertsp_DiagnosticsResultsSquibInsertsp_DiagnosticsResultsDigitalInsert
- Tables implied by the procedures (not visible in source).
- Stored procedures:
- Assumed Schema:
- Tables likely include
IDASCommunicationRecordId,DASChannelNumber,EventNumberas composite keys or foreign keys. - Analog/digital/squib results stored in separate tables (based on procedure names).
- Tables likely include
Dependents
- Unknown — not visible in this file. Likely consumed by higher-level diagnostic orchestration or test execution modules.
5. Gotchas
- Silent Failures on Disconnected State: If
DbWrapper.Connectedisfalse, all methods return immediately with no indication of failure (no exception, no log). This may mask configuration or runtime issues. - Missing Return of Inserted IDs: The
@new_idoutput parameter is declared and populated by the stored procedure but never returned to the caller. Callers cannot reference newly inserted records. - Squib Data Null Guard is Incomplete: While
squibFireCurrentData == nulltriggers early return,squibFireVoltageDataorsquibFireTimeAxisbeingnullwould cause aNullReferenceExceptionin theforeachloop. This is inconsistent and risky. - Typo in Parameter Name: In
InsertAnalogDiagnosticResult, the parameter@AutoZeroPercentDeviationhas a trailing space in the name ("AutoZeroPercentDeviation "), which may cause a mismatch with the stored procedure definition if not also defined with a trailing space. - No Validation on Channel/Event Numbers: No checks for negative or out-of-range
dasChannelNumberoreventNumber. Relies on DB constraints or stored procedure logic. - Binary Data Conversion:
double[]→byte[]conversion assumes little-endian architecture (standard on .NET on Windows), but may differ on other platforms (though DAS systems are typically Windows-based). - Ambiguous Channel Numbering: Source does not clarify whether
dasChannelNumberis 0-based or 1-based — critical for correct usage.
None identified from source alone for other potential issues (e.g., transactional consistency, concurrency, error logging behavior beyond
ProcessReturn).