init
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
using DASFactoryDb.ARM;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Interface.DASFactory.ARM;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// While a DAS unit is armed and object of this type in the corresponding <see cref="IDASCommunication" />
|
||||
/// can be udated to reflect the unit's status at that moment with a call to
|
||||
/// <see cref="ArmingService.GetArmStatus">ArmingService.GetArmStatus(...)</see>.
|
||||
/// </summary>
|
||||
public class ArmStatus : IArmStatusData
|
||||
{
|
||||
/// <summary>
|
||||
/// returns true if unit received InvalidMode to query commands during initial setup
|
||||
/// 15932 Error when performing test when S6A is streaming
|
||||
/// this is used in some places currently to detect when a unit is streaming
|
||||
/// </summary>
|
||||
public bool ReceivedInvalidModeDuringSetup { get; set; } = false;
|
||||
/// <summary>
|
||||
/// clears any flags set or needed for triggercheck
|
||||
/// </summary>
|
||||
public void ClearTriggerCheckStatus()
|
||||
{
|
||||
IsTriggered = false;
|
||||
IsArmed = false;
|
||||
IsRecording = false;
|
||||
IsTriggerShorted = false;
|
||||
IsStartShorted = false;
|
||||
}
|
||||
public ArmStatus() { }
|
||||
public ArmStatus(IArmStatusData status)
|
||||
{
|
||||
if (null == status) { return; }
|
||||
ReceivedInvalidModeDuringSetup = status.ReceivedInvalidModeDuringSetup;
|
||||
IsArmed = status.IsArmed;
|
||||
IsTriggered = status.IsTriggered;
|
||||
IsFaulted = status.IsFaulted;
|
||||
IsTriggerShorted = status.IsTriggerShorted;
|
||||
IsStartShorted = status.IsStartShorted;
|
||||
IsRecording = status.IsRecording;
|
||||
IsFaulted = status.IsFaulted;
|
||||
IsInRealtime = status.IsInRealtime;
|
||||
IsInFlashWrite = status.IsInFlashWrite;
|
||||
IsUndefined = status.IsUndefined;
|
||||
IsInPostTestDiagnostics = status.IsInPostTestDiagnostics;
|
||||
TimeRemainingSeconds = status.TimeRemainingSeconds;
|
||||
PercentComplete = status.PercentComplete;
|
||||
TotalSamples = status.TotalSamples;
|
||||
CurrentSample = status.CurrentSample;
|
||||
SampleRate = status.SampleRate;
|
||||
InputMilliVolts = status.InputMilliVolts;
|
||||
BatteryMilliVolts = status.BatteryMilliVolts;
|
||||
EventNumber = status.EventNumber;
|
||||
MaxEventsPossible = status.MaxEventsPossible;
|
||||
RecordingMode = status.RecordingMode;
|
||||
FaultMessage = status.FaultMessage;
|
||||
IsRearming = status.IsRearming;
|
||||
HasBeenRecording = status.HasBeenRecording;
|
||||
TimeLeftInArm = status.TimeLeftInArm;
|
||||
}
|
||||
/// <summary>
|
||||
/// Is the DAS currently armed?
|
||||
/// </summary>
|
||||
public bool IsArmed { get; set; }
|
||||
/// <summary>
|
||||
/// Has the DAS sensed a trigger?
|
||||
/// </summary>
|
||||
public bool IsTriggered { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// a little bit distinct from IsTriggered
|
||||
/// in that IsTriggerShorted is only set during TriggerCheck
|
||||
/// while IsTriggered is set in many places
|
||||
/// </summary>
|
||||
public bool IsTriggerShorted { get; set; }
|
||||
/// <summary>
|
||||
/// indicates that trigger was shorted
|
||||
/// is only set during triggercheck
|
||||
/// </summary>
|
||||
public bool IsStartShorted { get; set; }
|
||||
/// <summary>
|
||||
/// Is the DAS currently recording sample data?
|
||||
/// </summary>
|
||||
public bool IsRecording { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Has the DAS faulted?
|
||||
/// </summary>
|
||||
public bool IsFaulted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the DAS in real time mode?
|
||||
/// </summary>
|
||||
public bool IsInRealtime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// is the DAS in flash write (G5)
|
||||
/// </summary>
|
||||
public bool IsInFlashWrite { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// used for the times when TDAS ARM STAT READ just doesn't return anything
|
||||
/// </summary>
|
||||
public bool IsUndefined { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the DAS in post test diagnostics
|
||||
/// </summary>
|
||||
public bool IsInPostTestDiagnostics { get; set; }
|
||||
/// <summary>
|
||||
/// How many seconds are left of recording?
|
||||
/// </summary>
|
||||
public double TimeRemainingSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// what percentage is complete [flashwrite]
|
||||
/// </summary>
|
||||
public double PercentComplete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How many samples total will the DAS be recording this test?
|
||||
/// </summary>
|
||||
public ulong TotalSamples { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// What sample are we currently recording?
|
||||
/// </summary>
|
||||
public ulong CurrentSample { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// At what sample rate are we currently recording?
|
||||
/// </summary>
|
||||
public uint SampleRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// What's the current input voltage?
|
||||
/// </summary>
|
||||
//public double? InputMilliVolts { get; set; }
|
||||
private double? _inputMilliVolts = null;
|
||||
public double? InputMilliVolts
|
||||
{
|
||||
get => _inputMilliVolts;
|
||||
set
|
||||
{
|
||||
if (null == value) { _inputMilliVolts = null; }
|
||||
else
|
||||
{
|
||||
var d = (double)value;
|
||||
if (d > 100000) { d /= 1000; }
|
||||
_inputMilliVolts = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What's the current battery voltage (null if no battery)?
|
||||
/// </summary>
|
||||
private double? _batteryMilliVolts = null;
|
||||
public double? BatteryMilliVolts
|
||||
{
|
||||
get => _batteryMilliVolts;
|
||||
set
|
||||
{
|
||||
if (null == value) { _batteryMilliVolts = null; }
|
||||
else
|
||||
{
|
||||
var d = (double)value;
|
||||
if (d > 100000) { d /= 1000; }
|
||||
_batteryMilliVolts = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Which event number is currently being recorded?
|
||||
/// </summary>
|
||||
public int? EventNumber { get; set; }
|
||||
//FB 26817
|
||||
/// <summary>
|
||||
/// Max number of events supported by device
|
||||
/// </summary>
|
||||
public ushort? MaxEventsPossible { get; set; }
|
||||
public int RecordingMode { get; set; }
|
||||
/// <summary>
|
||||
/// optional fault message if there is a fault
|
||||
/// (software will flag some faults and when we do we know what caused it)
|
||||
/// </summary>
|
||||
public string FaultMessage { get; set; }
|
||||
|
||||
public bool IsRearming { get; set; }
|
||||
|
||||
public bool HasBeenRecording { get; set; }
|
||||
|
||||
private double? _timeLeftInArm = null;
|
||||
public double? TimeLeftInArm
|
||||
{
|
||||
get => _timeLeftInArm;
|
||||
set
|
||||
{
|
||||
if (null == value) { _timeLeftInArm = null; }
|
||||
else
|
||||
{
|
||||
_timeLeftInArm = (double)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// sets the given status to a given unit, optionally writing to the db
|
||||
/// </summary>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="status"></param>
|
||||
/// <param name="bSetInDb"></param>
|
||||
public static void SetArmStatus(IDASCommunication unit, IArmStatusData status, bool bSetInDb)
|
||||
{
|
||||
unit.DASArmStatus = status;
|
||||
if (!DASFactoryDb.DbWrapper.Connected || !bSetInDb) { return; }
|
||||
|
||||
try
|
||||
{
|
||||
ARM.SetArmStatus(unit.RecordId,
|
||||
status.IsArmed,
|
||||
status.IsTriggered,
|
||||
status.IsTriggerShorted,
|
||||
status.IsStartShorted,
|
||||
status.IsRecording,
|
||||
status.IsFaulted,
|
||||
status.IsInRealtime,
|
||||
status.IsInFlashWrite,
|
||||
status.IsUndefined,
|
||||
status.IsInPostTestDiagnostics,
|
||||
status.TimeRemainingSeconds,
|
||||
status.PercentComplete,
|
||||
status.TotalSamples,
|
||||
status.CurrentSample,
|
||||
status.SampleRate,
|
||||
status.InputMilliVolts,
|
||||
status.BatteryMilliVolts,
|
||||
status.EventNumber,
|
||||
status.RecordingMode,
|
||||
status.FaultMessage,
|
||||
status.IsRearming,
|
||||
status.HasBeenRecording,
|
||||
status.TimeLeftInArm);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user