This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,224 @@
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;
}
/// <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);
}
}
}
}

View File

@@ -0,0 +1,377 @@
using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using DTS.Common.Enums.DASFactory;
using DTS.Common.Enums.Sensors;
using DTS.Common.Interface.DASFactory.Config;
using DTS.Common.Utilities.Logging;
namespace DTS.DASLib.Service
{
/// <inheritdoc />
/// <summary>
/// Base class for all DAS channels.
/// </summary>
[Serializable]
public class DASChannel : IDASChannel, IXmlSerializable // (subset of sensor class)
{
public string SetupEID { get; set; } = string.Empty;
public string DataCollectionEID { get; set; } = string.Empty;
public DFConstantsAndEnums.ConfigMode ConfigurationMode { get; set; }
/// <summary>
/// whether the channel should be put in Diagnostics mode or not
/// </summary>
public bool DiagnosticsMode { get; set; }
/// <summary>
/// Channel number with respect to it's containing module <see cref="OwningModule"/>
/// </summary>
public int ModuleChannelNumber { get; set; }
public int AbsoluteDisplayOrder { get; set; } = 1;
public double UnitConverision { get; set; } = 1D;
public bool AtCapacity { get; set; } = false;
public double CapacityOutputIsBasedOn { get; set; } = 1D;
public SensorConstants.SensUnits SensitivityUnits { get; set; } =
SensorConstants.SensUnits.NONE;
/// <summary>
/// A link back to the Module that contains this channel.
/// </summary>
[XmlIgnore]
public DASModule OwningModule { get; set; }
/// <summary>
/// The "stack channel number" of this channel with respect to the owning
/// DAS (0 based).
/// </summary>
public byte Number
{
get
{
try
{
return OwningModule.OwningDAS.DASInfo.MapModuleArrayIndexAndChannelNum2DASChannel(OwningModule.ModuleArrayIndex, ModuleChannelNumber);
}
catch (Exception ex)
{
throw new ApplicationException("encountered problem getting " + GetType().FullName + ".Number property value", ex);
}
}
}
/// <summary>
/// Array of (string, byte[]) for EID
/// </summary>
[XmlIgnore]
public IEID[] IDs { get; set; }
/// <summary>
/// time stamp of this event
/// </summary>
public DateTime EventStartTime { get; set; }
/// <summary>
/// <see cref="bool"/> value indicating whether or not this channel has registered a level trigger.
/// </summary>
public bool LevelTriggerSeen { get; set; }
public string IsoChannelName { get; set; }
public string ChannelGroupName { get; set; }
public string UserCode { get; set; }
public string UserChannelName { get; set; }
public string LinearSensorCalibration { get; set; }
/// <summary>
/// the number of samples to qualify over
/// </summary>
public int QualificationSamples { get; set; }
///// <summary>
///// Number of samples that T0 on DASes that did not directly experience the level trigger must be shifted
///// to time align with this channel's directly level triggered T0. A null value indicates that this channel
///// did not directly receive a level trigger.
///// </summary>
public int? LevelTriggerT0AdjustmentSamples { get; set; }
public override string ToString()
{
return ModuleChannelNumber.ToString();
}
/// <summary>
/// Is this channel configured? 'Configured' means a sensor is connected and/or there is
/// information in the containg device's ConfigData object, put there with a call to
/// ConfigureService.Configure(...) in the API.
/// </summary>
/// <returns>True if it is configured, False otherwise.</returns>
public virtual bool IsConfigured()
{
return false;
}
/// <summary>
/// CTOR to populate a channel's owning module and channel WRT that module.
/// </summary>
/// <param name="owner">Module that contains this channel.</param>
/// <param name="channelNumber">ChannelNumber of this channel WRT owning module.</param>
public DASChannel(DASModule owner, int channelNumber)
{
ConfigurationMode = DFConstantsAndEnums.ConfigMode.Normal;
ModuleChannelNumber = channelNumber;
OwningModule = owner;
IDs = null;
EventStartTime = DateTime.Now;
DiagnosticsMode = false;
}
public DASChannel()
{
}
public virtual void WriteElementStart(XmlWriter writer)
{
writer.WriteStartElement("DASChannel");
//writer.WriteStartAttribute("type", "xsi");
var tgt = GetType();
writer.WriteAttributeString("xsi", "type", null, tgt.Name);
}
public virtual void WriteElementEnd(XmlWriter writer)
{
writer.WriteEndElement();
}
public virtual void WriteXmlCRC32(XmlWriter writer)
{
// ConfigurationMode
XMLHelper.PutString(writer, "ConfigurationMode", ConfigurationMode.ToString());
// ModuleChannelNumber
XMLHelper.PutInt(writer, "ModuleChannelNumber", ModuleChannelNumber);
XMLHelper.PutInt(writer, "AbsoluteDisplayOrder", AbsoluteDisplayOrder);
XMLHelper.PutBool(writer, "DiagnosticsMode", DiagnosticsMode);
XMLHelper.PutDouble(writer, "UnitConversion", UnitConverision);
// EventStartTime
//XMLHelper.PutString(writer, "EventStartTime", EventStartTime.ToString("o", XMLHelper.InvariantCulture));
}
public virtual void WriteXml(XmlWriter writer)
{
// ConfigurationMode
XMLHelper.PutString(writer, "ConfigurationMode", ConfigurationMode.ToString());
// ModuleChannelNumber
XMLHelper.PutInt(writer, "ModuleChannelNumber", ModuleChannelNumber);
XMLHelper.PutInt(writer, "AbsoluteDisplayOrder", AbsoluteDisplayOrder);
// EventStartTime
XMLHelper.PutString(writer, "EventStartTime", EventStartTime.ToString("o", XMLHelper.InvariantCulture));
//XMLHelper.PutString(writer, "QualificationSamples", QualificationSamples.ToString());
XMLHelper.PutInt(writer, "QualificationSamples", QualificationSamples);
XMLHelper.PutBool(writer, "DiagnosticsMode", DiagnosticsMode);
XMLHelper.PutDouble(writer, "UnitConversion", UnitConverision);
XMLHelper.PutBool(writer, "AtCapacity", AtCapacity);
XMLHelper.PutDouble(writer, "CapacityOutputIsBasedOn", CapacityOutputIsBasedOn);
XMLHelper.PutString(writer, "SensitivityUnits", SensitivityUnits.ToString());
XMLHelper.PutString(writer, "IsoChannelName", IsoChannelName);
XMLHelper.PutString(writer, "UserCode", UserCode);
XMLHelper.PutString(writer, "UserChannelName", UserChannelName);
XMLHelper.PutString(writer, "LinearSensorCalibration", LinearSensorCalibration);
if (!string.IsNullOrEmpty(UserValue1))
{
XMLHelper.PutString(writer, "UserValue1", UserValue1);
}
if (!string.IsNullOrEmpty(UserValue2))
{
XMLHelper.PutString(writer, "UserValue2", UserValue2);
}
if (!string.IsNullOrEmpty(UserValue3))
{
XMLHelper.PutString(writer, "UserValue3", UserValue3);
}
if (!string.IsNullOrEmpty(SetupEID))
{
XMLHelper.PutString(writer, SETUPEID_TAG, SetupEID);
}
if (!string.IsNullOrEmpty(DataCollectionEID))
{
XMLHelper.PutString(writer, DATACOLLECTIONEID_TAG, DataCollectionEID);
}
}
private const string CONFIGUARATIONMODE_TAG = "ConfigurationMode";
private const string MODULECHANNELNUMBER_TAG = "ModuleChannelNumber";
private const string EVENTSTARTTIME_TAG = "EventStartTime";
private const string QUALIFICATIONSAMPLES_TAG = "QualificationSamples";
private const string DIAGNOSTICSMODE_TAG = "DiagnosticsMode";
private const string ABSOLUTEDISPLAYORDER_TAG = "AbsoluteDisplayOrder";
private const string UNITCONVERSION_TAG = "UnitConversion";
private const string ATCAPACITY_TAG = "AtCapacity";
private const string LINEARSENSORCALIBRATION_TAG = "LinearSensorCalibration";
private const string USERCHANNELNAME_TAG = "UserChannelName";
private const string USERCODE_TAG = "UserCode";
private const string ISOCHANNELNAME_TAG = "IsoChannelName";
private const string CAPACITYOUTPUTISBASEDON_TAG = "CapacityOutputIsBasedOn";
private const string SENSITIVITYUNITS_TAG = "SensitivityUnits";
private const string USERVALUE1_TAG = "UserValue1";
private const string USERVALUE2_TAG = "UserValue2";
private const string USERVALUE3_TAG = "UserValue3";
private const string SETUPEID_TAG = "SetupEID";
private const string DATACOLLECTIONEID_TAG = "DataCollectionEID";
protected virtual void HandleElement(XmlReader reader)
{
switch (reader.Name)
{
case CONFIGUARATIONMODE_TAG:
var confMode = XMLHelper.GetString(reader);
ConfigurationMode = (DFConstantsAndEnums.ConfigMode)Enum.Parse(typeof(DFConstantsAndEnums.ConfigMode), confMode);
break;
case MODULECHANNELNUMBER_TAG:
ModuleChannelNumber = XMLHelper.GetInt(reader);
break;
case EVENTSTARTTIME_TAG:
var est = XMLHelper.GetString(reader);
EventStartTime = DateTime.Parse(est);
break;
case QUALIFICATIONSAMPLES_TAG:
QualificationSamples = XMLHelper.GetInt(reader);
break;
case DIAGNOSTICSMODE_TAG:
DiagnosticsMode = XMLHelper.GetBool(reader);
break;
case ABSOLUTEDISPLAYORDER_TAG:
AbsoluteDisplayOrder = XMLHelper.TryGetInt(reader, 1);
break;
case UNITCONVERSION_TAG:
UnitConverision = XMLHelper.TryGetDouble(reader, 1D);
break;
case ATCAPACITY_TAG:
try { AtCapacity = XMLHelper.GetBool(reader); }
catch (Exception) { }
break;
case LINEARSENSORCALIBRATION_TAG:
LinearSensorCalibration = XMLHelper.GetString(reader);
break;
case USERCHANNELNAME_TAG:
UserChannelName = XMLHelper.GetString(reader);
break;
case USERCODE_TAG:
UserCode = XMLHelper.GetString(reader);
break;
case ISOCHANNELNAME_TAG:
IsoChannelName = XMLHelper.GetString(reader);
break;
case CAPACITYOUTPUTISBASEDON_TAG:
CapacityOutputIsBasedOn = XMLHelper.TryGetDouble(reader, 1D);
break;
case SENSITIVITYUNITS_TAG:
var su = XMLHelper.GetString(reader);
SensitivityUnits = (SensorConstants.SensUnits)Enum.Parse(typeof(SensorConstants.SensUnits), su);
break;
case USERVALUE1_TAG:
UserValue1 = XMLHelper.TryGetString(reader, "");
break;
case USERVALUE2_TAG:
UserValue2 = XMLHelper.TryGetString(reader, "");
break;
case USERVALUE3_TAG:
UserValue3 = XMLHelper.TryGetString(reader, "");
break;
case SETUPEID_TAG:
try { SetupEID = XMLHelper.GetString(reader); }
catch(Exception ex) { APILogger.Log(ex); }
break;
case DATACOLLECTIONEID_TAG:
try { DataCollectionEID = XMLHelper.GetString(reader); }
catch (Exception ex) { APILogger.Log(ex); }
break;
default:
// let child handle it
return;
}
}
public virtual void ReadXml(XmlReader reader)
{
// it must be an Element
if (reader.NodeType != XmlNodeType.Element)
{
throw new XmlException("DASChannel.ReadXml: Unknown input: " + reader.NodeType.ToString());
}
// skip our start tag
if (reader.Name == "DASChannel")
{
reader.Read();
}
// try to find our data
do
{
if (reader.NodeType == XmlNodeType.Element)
{
HandleElement(reader);
}
if (!reader.Read())
{
break;
}
} while (!(reader.Name.Equals("DASChannel") && reader.NodeType == XmlNodeType.EndElement));
// we're going to end with an EndElement, so clean up
if (reader.Name.Equals("DASChannel") && reader.NodeType == XmlNodeType.EndElement)
{
reader.Read();
}
}
/// <summary>
/// returns true if the channel is re-programable [can be switched from IEPE to analog]
/// </summary>
/// <returns></returns>
public bool CanReProgram()
{
if (null == OwningModule) { return false; }
if (null == OwningModule.OwningDAS) { return false; }
if (null == OwningModule.OwningDAS.DASInfo) { return false; }
if (null == OwningModule.OwningDAS.DASInfo.Modules) { return false; }
if (0 == OwningModule.OwningDAS.DASInfo.Modules.Length)
{
return false;
}
return OwningModule.OwningDAS.DASInfo.Modules[0].IsProgrammable;
}
public XmlSchema GetSchema()
{
return null;
}
public const int DEFAULT_ID_TYPE = 0;
public const int BRIDGE_ID_TYPE = 1;
public const int IEPE_ID_TYPE = 2;
public const int BRIDGE_G5_ID_TYPE = 3;
public int IdType { get; set; } = DEFAULT_ID_TYPE;
public string UserValue1 { get; set; } = "";
public string UserValue2 { get; set; } = "";
public string UserValue3 { get; set; } = "";
}
}