Files
DP44/docs/ai/DataPRO/DASFactoryDb/Diagnostics.md
2026-04-17 14:55:32 -04:00

4.5 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/DASFactoryDb/Diagnostics/Diagnostics.cs
2026-04-17T15:59:34.341673+00:00 zai-org/GLM-5-FP8 1 82e5a9a5a5472a3a

Documentation: DASFactoryDb.Diagnostics

1. Purpose

This module provides a data access layer for recording and clearing diagnostic actions and results for a Data Acquisition System (DAS). It serves as the persistence mechanism for diagnostic test configurations and their outcomes across analog, digital, and squib (pyrotechnic) channels. The class abstracts database stored procedure calls into simple static methods, handling parameter construction, execution, and error reporting for factory diagnostic operations.


2. Public Interface

ClearDiagnosticActionsAllChannels(int idasRecordId)

Signature: public static void ClearDiagnosticActionsAllChannels(int idasRecordId)

Clears all diagnostic actions for all channels associated with a given DAS communication record. Invokes the stored procedure sp_DiagnosticActionsClear, passing null for the channel number parameter to indicate "all channels." Silently returns without action if DbWrapper.Connected is false.


InsertDiagnosticAction(...)

Signature:

public static void InsertDiagnosticAction(
    int dasRecordId,
    int dasChannelNumber,
    bool measureExcitation,
    bool measureOffset,
    bool checkDigitalState,
    bool measureInternalOffset,
    bool removeOffset,
    bool measureNoise,
    bool performShuntCheck,
    bool squibFireCheck,
    bool performVoltageInsertCheck,
    bool performCalSignalCheck,
    bool measureBridgeResistance
)

Inserts a diagnostic action configuration for a specific DAS channel. Each boolean parameter specifies whether a particular diagnostic check should be performed. Invokes sp_DiagnosticsActionsInsert. The stored procedure returns a @new_id output parameter, but this value is not exposed to callers. Silently returns without action if DbWrapper.Connected is false.


ClearExistingDiagnosticsAllChannels(int idasRecordId = -1)

Signature: public static void ClearExistingDiagnosticsAllChannels(int idasRecordId = -1)

Clears all diagnostics and events results for all channels associated with a DAS record. Invokes sp_DiagnosticsResultsClear, passing null for both @DASChannelNumber and @EventNumber parameters to indicate "all." The default parameter value of -1 is used if no argument is provided. Silently returns without action if DbWrapper.Connected is false.


InsertAnalogDiagnosticResult(...)

Signature:

public static void InsertAnalogDiagnosticResult(
    int iDASRecordId,
    int dasChannelNumber,
    int eventNumber,
    double scalefactorMilliVoltsPerADC,
    double expectedExcitationMilliVolts,
    double? measuredExcitationMilliVolts,
    bool negativeExcitation,
    double? measuredOffsetMilliVolts,
    double? measuredInternalOffsetMilliVolts,
    double? autoZeroPercentDeviation,
    short? finalOffsetADC,
    int? removedOffsetADC,
    int? removedInternalOffsetADC,
    double? noisePercentFullScale,
    bool shuntDeflectionFailed,
    bool calSignalCheckFailed,
    double? measuredShuntDeflectionMv,
    double? measuredCalSignalMv,
    double? targetCalSignalMv,
    double? targetGain,
    double? measuredGain,
    double? queriedGain,
    double? targetShuntDeflectionMv,
    double? bridgeResistance,
    double zeroMVInADC,
    double windowAverageADC
)

Inserts analog diagnostic measurement results for a specific channel and event. Captures excitation measurements, offset values, noise metrics, shunt check results, calibration signal data, gain measurements, and bridge resistance. Invokes sp_DiagnosticsResultsAnalogInsert. Silently returns without action if DbWrapper.Connected is false.


InsertSquibDiagnosticResult(...)

Signature:

public static void InsertSquibDiagnosticResult(
    int iDASRecordId,
    int dasChannelNumber,
    int eventNumber,
    double[] squibFireCurrentData,
    double[] squibFireVoltageData,
    double[] squibFireTimeAxis,
    double? measuredDurationMS,
    double? measuredDelayMS,
    bool? squibFirePassed,
    bool? squibDurationPassed,
    bool? squibDelayPassed,
    double squibThreshold,
    double squibVoltageScaler,
    double squibCurrentScaler
)

Inserts squib (pyrotechnic firing) diagnostic results. The squibFireCurrentData, squibFireVoltageData, and squibFireTimeAxis arrays are serialized to binary format (8 bytes per double using BitConverter.GetBytes)