init
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
|
||||
namespace DTS.DASLib.Service
|
||||
{
|
||||
public class TriggerCheckResult : ITriggerCheckResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Is the status good on the DAS?
|
||||
/// </summary>
|
||||
public bool IsStatusGood { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the start record line currently active on the DAS?
|
||||
/// </summary>
|
||||
public bool IsStartRecordActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Has the start record line been active at any point after arm?
|
||||
/// </summary>
|
||||
public bool HasStartRecordBeenActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the trigger currently active?
|
||||
/// </summary>
|
||||
public bool IsTriggered { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Has the trigger line been active at any point after arm?
|
||||
/// </summary>
|
||||
public bool HasTriggered { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Classes.Sensors;
|
||||
|
||||
namespace DTS.DASLib.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for storing/applying Streaming output settings as a channel
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class StreamOutputDASChannel : OutputDASChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// CTOR to populate a channel's owning module and channel WRT that module. Calls
|
||||
/// base class CTOR.
|
||||
/// </summary>
|
||||
/// <param name="owner">Module that contains this channel.</param>
|
||||
/// <param name="channelNumber">ChannelNumber of this channel WRT owning module.</param>
|
||||
public StreamOutputDASChannel(DASModule owner, int channelNumber)
|
||||
: base(owner, channelNumber)
|
||||
{
|
||||
}
|
||||
|
||||
public StreamOutputDASChannel()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Serial number of the sensor.
|
||||
/// </summary>
|
||||
public string SerialNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the hardware channel
|
||||
/// </summary>
|
||||
public string HardwareChannelName { get; set; }
|
||||
|
||||
public string UDPProfileName { get; set; } = UDPStreamProfile.CH10_ANALOG_2HDR.ToString();
|
||||
public ushort UDPTimeChannelId { get; set; }
|
||||
public ushort UDPDataChannelId { get; set; }
|
||||
public ushort IRIGTimeDataPacketIntervalMs { get; set; }
|
||||
/// <summary>
|
||||
/// time between sending TMATS information while streaming
|
||||
/// http://manuscript.dts.local/f/cases/29987/Add-CG-DP-TMATS-interval-UI-support
|
||||
/// </summary>
|
||||
public ushort TMATSIntervalMs { get; set; } = StreamOutputRecord.DEFAULT_TMATS_INTERVAL_MS;
|
||||
public string UDPAddress { get; set; } = string.Empty;
|
||||
public uint[] UDPTmNSConfig { get; set; } = new uint[8];
|
||||
|
||||
/// <summary>
|
||||
/// If the channel has a serial number in the SerialNumber field, it is "Configured".
|
||||
/// </summary>
|
||||
public override bool IsConfigured()
|
||||
{
|
||||
return !string.IsNullOrEmpty(SerialNumber);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Stream{ModuleChannelNumber}";
|
||||
}
|
||||
public override void WriteXml(XmlWriter writer)
|
||||
{
|
||||
base.WriteXml(writer);
|
||||
|
||||
// SerialNumber
|
||||
XMLHelper.PutString(writer, "SerialNumber", SerialNumber);
|
||||
XMLHelper.PutString(writer, "HardwareChannelName", HardwareChannelName);
|
||||
XMLHelper.PutString(writer, "UDPProfileName", UDPProfileName);
|
||||
XMLHelper.PutString(writer, "UDPTimeChannelId", UDPTimeChannelId.ToString());
|
||||
XMLHelper.PutString(writer, "UDPDataChannelId", UDPDataChannelId.ToString());
|
||||
XMLHelper.PutString(writer, "IRIGTimeDataPacketIntervalMs", IRIGTimeDataPacketIntervalMs.ToString());
|
||||
XMLHelper.PutString(writer, TMATS_INTERVAL_MS_TAG, TMATSIntervalMs.ToString());
|
||||
XMLHelper.PutString(writer, "UDPAddress", UDPAddress.ToString());
|
||||
XMLHelper.PutString(writer, "UDPTmNSConfig", ArrayToString.ArrayObjectToString(UDPTmNSConfig));
|
||||
}
|
||||
private const string SERIALNUMBER_TAG = "SerialNumber";
|
||||
private const string HARDWARECHANNELNAME_TAG = "HardwareChannelName";
|
||||
private const string UDPPROFILENAME_TAG = "UDPProfileName";
|
||||
private const string UDPTIMECHANNELID_TAG = "UDPTimeChannelId";
|
||||
private const string UDPDATACHANNELID_TAG = "UDPDataChannelId";
|
||||
private const string IRIGTIMEDATAPACKETINTERVALMS_TAG = "IRIGTimeDataPacketIntervalMs";
|
||||
private const string UDPADDRESS_TAG = "UDPAddress";
|
||||
private const string UDPTMNSCONFIG_TAG = "UDPTmNSConfig";
|
||||
private const string TMATS_INTERVAL_MS_TAG = "TMATSIntervalMs";
|
||||
protected override void HandleElement(XmlReader reader)
|
||||
{
|
||||
base.HandleElement(reader);
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
{
|
||||
var value = string.Empty;
|
||||
switch (reader.Name)
|
||||
{
|
||||
case SERIALNUMBER_TAG:
|
||||
SerialNumber = XMLHelper.GetString(reader);
|
||||
break;
|
||||
case HARDWARECHANNELNAME_TAG:
|
||||
HardwareChannelName = XMLHelper.GetString(reader);
|
||||
break;
|
||||
case UDPPROFILENAME_TAG:
|
||||
UDPProfileName = XMLHelper.GetString(reader);
|
||||
break;
|
||||
case UDPTIMECHANNELID_TAG:
|
||||
UDPTimeChannelId = Convert.ToUInt16(XMLHelper.GetInt(reader));
|
||||
break;
|
||||
case UDPDATACHANNELID_TAG:
|
||||
UDPDataChannelId = Convert.ToUInt16(XMLHelper.GetInt(reader));
|
||||
break;
|
||||
case IRIGTIMEDATAPACKETINTERVALMS_TAG:
|
||||
IRIGTimeDataPacketIntervalMs = Convert.ToUInt16(XMLHelper.GetInt(reader));
|
||||
break;
|
||||
case UDPADDRESS_TAG:
|
||||
UDPAddress = XMLHelper.GetString(reader);
|
||||
break;
|
||||
case UDPTMNSCONFIG_TAG:
|
||||
UDPTmNSConfig = ArrayToString.StringToUIntArray(XMLHelper.GetString(reader));
|
||||
break;
|
||||
case TMATS_INTERVAL_MS_TAG:
|
||||
TMATSIntervalMs = Convert.ToUInt16(XMLHelper.GetInt(reader));
|
||||
break;
|
||||
default:
|
||||
// let child handle it
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public enum State
|
||||
{
|
||||
Prepare,
|
||||
HardwareDiscovery,
|
||||
HardwareDiscoveryStart,
|
||||
Configure,
|
||||
ConfigureStart,
|
||||
Diagnose,
|
||||
Realtime,
|
||||
Arming,
|
||||
Arm,
|
||||
Download,
|
||||
RealtimeStart,
|
||||
DownloadStart
|
||||
}
|
||||
|
||||
public class States
|
||||
{
|
||||
private static readonly States instance = new States();
|
||||
private Dictionary<State, IDASState> _statesDict = new Dictionary<State, IDASState>();
|
||||
private Dictionary<State, IDASStateWithSelector> _statesSelectableDict = new Dictionary<State, IDASStateWithSelector>();
|
||||
|
||||
// Explicit static constructor to tell C# compiler
|
||||
// not to mark type as beforefieldinit
|
||||
// https://csharpindepth.com/articles/singleton
|
||||
static States()
|
||||
{
|
||||
}
|
||||
|
||||
public IDASState Prepare { get => _statesDict[State.Prepare]; }
|
||||
public IDASState HardwareDiscovery { get => _statesDict[State.HardwareDiscovery]; }
|
||||
public IDASStateWithSelector HardwareDiscoveryStart { get => _statesSelectableDict[State.HardwareDiscoveryStart]; }
|
||||
public IDASState Download { get => _statesDict[State.Download]; }
|
||||
public IDASStateWithSelector DownloadStart { get => _statesSelectableDict[State.DownloadStart]; }
|
||||
public IDASStateWithSelector Diagnose { get => _statesSelectableDict[State.Diagnose]; }
|
||||
public IDASStateWithSelector Configure { get => _statesSelectableDict[State.Configure]; }
|
||||
public IDASState Arming { get => _statesDict[State.Arming]; }
|
||||
public IDASState Arm { get => _statesDict[State.Arm]; }
|
||||
public IDASState Realtime { get => _statesDict[State.Realtime]; }
|
||||
public IDASStateWithSelector RealtimeStart { get => _statesSelectableDict[State.RealtimeStart]; }
|
||||
public IDASStateWithSelector ConfigureStart
|
||||
{
|
||||
get => _statesSelectableDict[State.ConfigureStart];
|
||||
}
|
||||
|
||||
public static void SetDASFactory(IDASFactory dasFactory)
|
||||
{
|
||||
foreach (var enumState in Instance._statesDict)
|
||||
{
|
||||
enumState.Value.DASFactory = dasFactory;
|
||||
}
|
||||
|
||||
foreach (var enumState in Instance._statesSelectableDict)
|
||||
{
|
||||
enumState.Value.DASFactory = dasFactory;
|
||||
}
|
||||
}
|
||||
private States()
|
||||
{
|
||||
AddState(State.Prepare, new Prepare());
|
||||
AddState(State.HardwareDiscovery, new HardwareDiscovery());
|
||||
AddState(State.HardwareDiscoveryStart, new HardwareDiscoveryStart());
|
||||
AddState(State.Configure, new Configure());
|
||||
AddState(State.Download, new Download());
|
||||
AddState(State.Diagnose, new Diagnose());
|
||||
AddState(State.Arming, new Arming());
|
||||
AddState(State.Arm, new Arm());
|
||||
AddState(State.Realtime, new Realtime());
|
||||
AddState(State.ConfigureStart, new ConfigureStart());
|
||||
AddState(State.RealtimeStart, new RealtimeStart());
|
||||
AddState(State.DownloadStart, new DownloadStart());
|
||||
}
|
||||
private void AddState<T>(State state, T dasState)
|
||||
{
|
||||
if (dasState is IDASStateWithSelector)
|
||||
{
|
||||
_statesSelectableDict.Add(state, (IDASStateWithSelector)dasState);
|
||||
return;
|
||||
}
|
||||
_statesDict.Add(state, (IDASState)dasState);
|
||||
}
|
||||
public IDASState GetIDASState(State state)
|
||||
{
|
||||
if (_statesDict.ContainsKey(state))
|
||||
{
|
||||
return _statesDict[state];
|
||||
}
|
||||
if (_statesSelectableDict.ContainsKey(state))
|
||||
{
|
||||
return _statesSelectableDict[state];
|
||||
}
|
||||
throw new InvalidOperationException("Undefined State");
|
||||
}
|
||||
|
||||
public static States Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user