Files
DP44/DataPRO/IService/Classes/Diagnostics/DiagnosticActions.cs

151 lines
5.3 KiB
C#
Raw Normal View History

2026-04-17 14:55:32 -04:00
using DASFactoryDb.Diagnostics;
using DTS.Common.Interface.DASFactory;
using DTS.Common.Interface.DASFactory.Diagnostics;
using DTS.Common.Utilities.Logging;
using System;
using System.Data.SqlClient;
using System.Linq;
namespace DTS.DASLib.Service
{
/// <summary>
/// This class holds instructions about how a single channel
/// is to be diagnosed. The results from these tests will populate the
/// DiagnosticsResults[] object in the IDASCommunication object. The results
/// can then be compared against the hardware specifications for a sensor to
/// determine if the channel is set up correctly before arming and recording.
/// </summary>
public class DiagnosticsActions : IDiagnosticActions
{
/// <summary>
/// Which DAS Channel (CH# WRT entire DAS unit) are these diagnostic test
/// instructions for?
/// </summary>
public int DASChannelNumber { get; set; }
/// <summary>
/// Should we measure the excitation volatge being applied to this sensor?
/// </summary>
public bool MeasureExcitation { get; set; }
/// <summary>
/// Should we measure the sensor's offset from 0? (If measured, the returned offset can
/// be checked against the high and low offset limits that are properties of the
/// AnalogInputDasChannel object corresponding to this sensor.)
/// </summary>
public bool MeasureOffset { get; set; }
/// <summary>
/// should we check the open/closed/low/high nature of a digital input channel?
/// </summary>
public bool CheckDigitalState { get; set; }
public bool MeasureInternalOffset { get; set; }
/// <summary>
/// Should the firmware compensate for the offset from 0 of this sensor?
/// </summary>
public bool RemoveOffset { get; set; }
/// <summary>
/// Should we measure the noise floor as a percentage of full scale readings?
/// </summary>
public bool MeasureNoise { get; set; }
/// <summary>
/// Should an emulated shunt-check be performed on this sensor.
/// </summary>
public bool PerformShuntCheck { get; set; }
/// <summary>
/// should run a squib fire check on channel
/// </summary>
public bool SquibFireCheck { get; set; } = false;
/// <summary>
/// perform a voltage insertion gain check (SLICE Pro)
/// </summary>
public bool PerformVoltageInsertCheck { get; set; }
/// <summary>
/// Should a Calibration signal-check be performed on this sensor.
/// </summary>
public bool PerformCalSignalCheck { get; set; }
/// <summary>
/// Should the resistance of the bridge be measured?
/// </summary>
public bool MeasureBridgeResistance { get; set; }
public DiagnosticsActions()
{
DASChannelNumber = 0;
MeasureExcitation = false;
MeasureOffset = false;
RemoveOffset = false;
MeasureNoise = false;
PerformShuntCheck = false;
PerformCalSignalCheck = false;
PerformVoltageInsertCheck = false;
MeasureInternalOffset = false;
CheckDigitalState = false;
}
public bool AllActionsDisabled()
{
return !MeasureExcitation && !MeasureOffset && !RemoveOffset && !MeasureNoise && !PerformShuntCheck &&
!MeasureBridgeResistance
&& !PerformCalSignalCheck && !PerformVoltageInsertCheck && !MeasureInternalOffset && !SquibFireCheck &&
!CheckDigitalState;
}
public static void SetChannelDiagnosticActions(IDASCommunication unit, IDiagnosticActions[] actions,
bool setInDb)
{
unit.ChannelDiagnostics = actions;
if (!DASFactoryDb.DbWrapper.Connected || !setInDb) { return; }
try
{
Diagnostics.ClearDiagnosticActionsAllChannels(unit.RecordId);
}
catch (Exception ex)
{
APILogger.Log(ex);
}
if (null != actions)
{
foreach (var action in actions)
{
InsertAction(unit.RecordId, action);
}
}
}
private static void InsertAction(int dasRecordId, IDiagnosticActions action)
{
try
{
Diagnostics.InsertDiagnosticAction(dasRecordId,
action.DASChannelNumber,
action.MeasureExcitation,
action.MeasureOffset,
action.CheckDigitalState,
action.MeasureInternalOffset,
action.RemoveOffset,
action.MeasureNoise,
action.PerformShuntCheck,
action.SquibFireCheck,
action.PerformVoltageInsertCheck,
action.PerformCalSignalCheck,
action.MeasureBridgeResistance);
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
}
}