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 { /// /// While a DAS unit is armed and object of this type in the corresponding /// can be udated to reflect the unit's status at that moment with a call to /// ArmingService.GetArmStatus(...). /// public class ArmStatus : IArmStatusData { /// /// 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 /// public bool ReceivedInvalidModeDuringSetup { get; set; } = false; /// /// clears any flags set or needed for triggercheck /// public void ClearTriggerCheckStatus() { IsTriggered = false; IsArmed = false; IsRecording = false; IsTriggerShorted = false; IsStartShorted = false; } /// /// Is the DAS currently armed? /// public bool IsArmed { get; set; } /// /// Has the DAS sensed a trigger? /// public bool IsTriggered { get; set; } /// /// a little bit distinct from IsTriggered /// in that IsTriggerShorted is only set during TriggerCheck /// while IsTriggered is set in many places /// public bool IsTriggerShorted { get; set; } /// /// indicates that trigger was shorted /// is only set during triggercheck /// public bool IsStartShorted { get; set; } /// /// Is the DAS currently recording sample data? /// public bool IsRecording { get; set; } /// /// Has the DAS faulted? /// public bool IsFaulted { get; set; } /// /// Is the DAS in real time mode? /// public bool IsInRealtime { get; set; } /// /// is the DAS in flash write (G5) /// public bool IsInFlashWrite { get; set; } /// /// used for the times when TDAS ARM STAT READ just doesn't return anything /// public bool IsUndefined { get; set; } /// /// Is the DAS in post test diagnostics /// public bool IsInPostTestDiagnostics { get; set; } /// /// How many seconds are left of recording? /// public double TimeRemainingSeconds { get; set; } /// /// what percentage is complete [flashwrite] /// public double PercentComplete { get; set; } /// /// How many samples total will the DAS be recording this test? /// public ulong TotalSamples { get; set; } /// /// What sample are we currently recording? /// public ulong CurrentSample { get; set; } /// /// At what sample rate are we currently recording? /// public uint SampleRate { get; set; } /// /// What's the current input voltage? /// //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; } } } /// /// What's the current battery voltage (null if no battery)? /// 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; } } } /// /// Which event number is currently being recorded? /// public int? EventNumber { get; set; } //FB 26817 /// /// Max number of events supported by device /// public ushort? MaxEventsPossible { get; set; } public int RecordingMode { get; set; } /// /// optional fault message if there is a fault /// (software will flag some faults and when we do we know what caused it) /// 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; } } } /// /// sets the given status to a given unit, optionally writing to the db /// /// /// /// 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); } } } }