1584 lines
57 KiB
C#
1584 lines
57 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DTS.Common.ICommunication;
|
|
using DTS.Common.Utilities.Logging;
|
|
|
|
namespace DTS.DASLib.Command.TDAS
|
|
{
|
|
internal class SerialNumberBroadcastString : CommandString
|
|
{
|
|
protected override string _CommandString => ModuleIndex >= 0 ? $"*{ModuleIndex}?N" : "*?N";
|
|
|
|
protected override string _CommandDescription => ModuleIndex >= 0 ? $"QuerySerialNumber *{ModuleIndex}?N" : "QuerySerialNumber *?N";
|
|
|
|
public int ModuleIndex { get; set; }
|
|
|
|
public SerialNumberBroadcastString(int moduleIndex) { ModuleIndex = moduleIndex; }
|
|
}
|
|
public class QuerySerialNumberBroadcast : CommandBase
|
|
{
|
|
public QuerySerialNumberBroadcast(DTS.Common.Interface.DASFactory.ICommunication sock, int moduleIndex)
|
|
: base(sock)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new SerialNumberBroadcastString(moduleIndex));
|
|
((TDASCommandPacketBase)baseCommand).RackCommand = false;
|
|
((TDASCommandPacketBase)baseCommand).ExpectsData = true;
|
|
}
|
|
public QuerySerialNumberBroadcast(DTS.Common.Interface.DASFactory.ICommunication sock, int moduleIndex, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new SerialNumberBroadcastString(moduleIndex));
|
|
((TDASCommandPacketBase)baseCommand).RackCommand = false;
|
|
((TDASCommandPacketBase)baseCommand).ExpectsData = true;
|
|
}
|
|
public override void ResponseToString(ref List<List<string>> lines)
|
|
{
|
|
CommandToString(ref lines);
|
|
if (null != baseResponse)
|
|
{
|
|
lines.Add(new List<string>(new[] { $"?N {ResponseData}" }));
|
|
}
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
var response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
var s = Encoding.ASCII.GetString(response.ToBytes());
|
|
var command = baseCommand as TDASCommandPacketBase;
|
|
var cs = "?N";
|
|
var start = s.IndexOf(cs);
|
|
var end = s.LastIndexOf("\r\n");
|
|
if (start < end && start >= 0)
|
|
{
|
|
var csLength = cs.Length + 1;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength).TrimStart();
|
|
if (IsErrored())
|
|
{
|
|
throw new InvalidOperationException(_responseData);
|
|
}
|
|
}
|
|
else { _responseData = ""; }
|
|
}
|
|
}
|
|
internal class SerialNumberCommandString : CommandString
|
|
{
|
|
protected override string _CommandString => "?N";
|
|
|
|
protected override string _CommandDescription => "SerialNumber - ?N";
|
|
}
|
|
public class QuerySerialNumber : CommandBase
|
|
{
|
|
public int ModuleIndex
|
|
{
|
|
set
|
|
{
|
|
((TDASCommandPacketBase)baseCommand).RackCommand = false;
|
|
((TDASCommandPacketBase)baseCommand).ModuleIndex = value;
|
|
}
|
|
}
|
|
private string _serialNumber;
|
|
public string SerialNumber => _serialNumber ?? (_serialNumber = ResponseData);
|
|
|
|
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new SerialNumberCommandString());
|
|
}
|
|
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new SerialNumberCommandString());
|
|
}
|
|
public override void ResponseToString(ref List<List<string>> lines)
|
|
{
|
|
CommandToString(ref lines);
|
|
if (null != baseResponse)
|
|
{
|
|
lines.Add(new List<string>(new[] { $"SerialNumber: {SerialNumber}" }));
|
|
}
|
|
}
|
|
}
|
|
internal class FirmwareVersionCommandString : CommandString
|
|
{
|
|
protected override string _CommandString => "?V";
|
|
|
|
protected override string _CommandDescription => "FirmwareVersion - ?V";
|
|
}
|
|
public class QueryFirmwareVersion : CommandBase
|
|
{
|
|
private string _firmwareVersion;
|
|
public string FirmwareVersion
|
|
{
|
|
get
|
|
{
|
|
if (null == _firmwareVersion) { ProcessData(); }
|
|
return _firmwareVersion;
|
|
}
|
|
}
|
|
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new FirmwareVersionCommandString());
|
|
}
|
|
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new FirmwareVersionCommandString());
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
string[] tokens = ResponseData.Split(' ');
|
|
_firmwareVersion = tokens[tokens.Length - 1];
|
|
}
|
|
public override void ResponseToString(ref List<List<string>> lines)
|
|
{
|
|
CommandToString(ref lines);
|
|
if (null != baseResponse)
|
|
{
|
|
lines.Add(new List<string>(new[] { $"FirmwareVersion: {FirmwareVersion}" }));
|
|
}
|
|
}
|
|
}
|
|
internal class QueryModulesCommandString : CommandString
|
|
{
|
|
protected override string _CommandString => "S";
|
|
|
|
protected override string _CommandDescription => "QueryModules - S";
|
|
}
|
|
internal class QueryMaxModulesCommandString : CommandString
|
|
{
|
|
protected override string _CommandString => "?S";
|
|
|
|
protected override string _CommandDescription => "QueryMaxModules - ?S";
|
|
}
|
|
public class QueryModules : CommandBase
|
|
{
|
|
public enum DownloadStatus
|
|
{
|
|
NO_DATA,
|
|
DATA_ALREADY_DOWNLOADED,
|
|
DATA_NOT_DOWNLOADED
|
|
}
|
|
private List<string> _serialNumbers;
|
|
public string[] SerialNumbers
|
|
{
|
|
get
|
|
{
|
|
if (null == _serialNumbers) { ProcessData(); }
|
|
return _serialNumbers.ToArray();
|
|
}
|
|
}
|
|
private List<int> _moduleIndices;
|
|
public int[] ModuleIndices
|
|
{
|
|
get
|
|
{
|
|
if (null == _moduleIndices) { ProcessData(); }
|
|
return _moduleIndices.ToArray();
|
|
}
|
|
}
|
|
private List<string> _firmwareVersions;
|
|
public string[] FirmwareVersions
|
|
{
|
|
get
|
|
{
|
|
if (null == _firmwareVersions) { ProcessData(); }
|
|
return _firmwareVersions.ToArray();
|
|
}
|
|
}
|
|
private List<DownloadStatus> _downloadData = new List<DownloadStatus>();
|
|
public DownloadStatus[] DownloadData
|
|
{
|
|
get
|
|
{
|
|
if (null == _downloadData) { ProcessData(); }
|
|
return _downloadData.ToArray();
|
|
}
|
|
}
|
|
private List<double> _modulePowers = new List<double>();
|
|
public double[] ModuleInputPowers
|
|
{
|
|
get
|
|
{
|
|
if (null == _downloadData) { ProcessData(); }
|
|
return _modulePowers.ToArray();
|
|
}
|
|
}
|
|
|
|
public QueryModules(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new QueryModulesCommandString());
|
|
}
|
|
public QueryModules(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new QueryModulesCommandString());
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
_firmwareVersions = new List<string>();
|
|
_serialNumbers = new List<string>();
|
|
_moduleIndices = new List<int>();
|
|
_downloadData = new List<DownloadStatus>();
|
|
_modulePowers = new List<double>();
|
|
|
|
if (string.IsNullOrEmpty(_responseData)) { return; }
|
|
var lines = ResponseData.Split(' ');
|
|
//1,DM0218,N,11.0135,07E4Y
|
|
foreach (var line in lines)
|
|
{
|
|
var tokens = line.Split(',');
|
|
if (tokens.Length != 5) continue;
|
|
_moduleIndices.Add(int.Parse(tokens[0]));
|
|
_serialNumbers.Add(tokens[1]);
|
|
switch (tokens[2])
|
|
{
|
|
case "Y":
|
|
_downloadData.Add(DownloadStatus.DATA_ALREADY_DOWNLOADED);
|
|
break;
|
|
case "N":
|
|
_downloadData.Add(DownloadStatus.NO_DATA);
|
|
break;
|
|
case "D":
|
|
_downloadData.Add(DownloadStatus.DATA_NOT_DOWNLOADED);
|
|
break;
|
|
default:
|
|
throw new InvalidCastException("invalid download status " + tokens[2]);
|
|
}
|
|
_modulePowers.Add(double.TryParse(tokens[3], System.Globalization.NumberStyles.Any,
|
|
System.Globalization.CultureInfo.InvariantCulture, out double temp)
|
|
? temp
|
|
: 0D);
|
|
_firmwareVersions.Add(tokens[4]);
|
|
}
|
|
}
|
|
}
|
|
public class QueryMaxModules : CommandBase
|
|
{
|
|
public QueryMaxModules(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new QueryMaxModulesCommandString());
|
|
}
|
|
public QueryMaxModules(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
baseCommand = new TDASCommandPacketBase(new QueryMaxModulesCommandString());
|
|
}
|
|
private int _maxModules = 4;
|
|
public int MaxModules => _maxModules;
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
_maxModules = 4;
|
|
base.ProcessData();
|
|
if (string.IsNullOrEmpty(_responseData)) { return; }
|
|
try { _maxModules = Convert.ToInt32(_responseData.Trim(), System.Globalization.CultureInfo.InvariantCulture); }
|
|
catch (Exception ex) { APILogger.Log(ex); }
|
|
}
|
|
}
|
|
internal class DataAvailableCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "Retrieve data available - R?";
|
|
|
|
protected override string _CommandString => "R?";
|
|
|
|
public DataAvailableCommandString()
|
|
{
|
|
RackCommand = true;
|
|
}
|
|
}
|
|
internal class QueryAAFMaxCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "Query AAF max - ?F1";
|
|
|
|
protected override string _CommandString => "?F1";
|
|
|
|
public QueryAAFMaxCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
}
|
|
public class QueryAAFMax : CommandBase
|
|
{
|
|
public int ModuleIndex
|
|
{
|
|
get => ((TDASCommandPacketBase)baseCommand).ModuleIndex;
|
|
set => ((TDASCommandPacketBase)baseCommand).ModuleIndex = value;
|
|
}
|
|
public QueryAAFMax(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new QueryAAFMaxCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public QueryAAFMax(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new QueryAAFMaxCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public uint AAFMax => uint.Parse(ResponseData.Trim());
|
|
}
|
|
public class QueryDataAvailable : CommandBase
|
|
{
|
|
private int _preTriggerSamples;
|
|
public int PreTriggerSamples
|
|
{
|
|
get => _preTriggerSamples;
|
|
set => _preTriggerSamples = Math.Abs(value);
|
|
}
|
|
|
|
private int _postTriggerSamples;
|
|
public int PostTriggerSamples
|
|
{
|
|
get => _postTriggerSamples;
|
|
set => _postTriggerSamples = value;
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get => ((TDASCommandPacketBase)baseCommand).ModuleIndex;
|
|
set => ((TDASCommandPacketBase)baseCommand).ModuleIndex = value;
|
|
}
|
|
public bool IsDownloaded
|
|
{
|
|
get
|
|
{
|
|
if (null != ResponseData && ResponseData.StartsWith("D")) { return true; }
|
|
return null != ResponseData && ResponseData.Contains("TESTTRIG");
|
|
}
|
|
}
|
|
|
|
public int LevelTriggerOffset { get; set; }
|
|
|
|
private string[] _eventCodes;
|
|
public string[] EventCodes
|
|
{
|
|
get
|
|
{
|
|
if (null != _eventCodes) return _eventCodes;
|
|
if (!ResponseData.StartsWith("Y") && !ResponseData.StartsWith("D")) return _eventCodes;
|
|
var tokens = SetupDASRead.SmartSplit(ResponseData);
|
|
|
|
var eventCode = tokens[4];
|
|
if (eventCode.StartsWith("\"")) { eventCode = eventCode.Substring(1, eventCode.Length - 2); }
|
|
_eventCodes = new[] { eventCode };
|
|
int.TryParse(tokens[2], out _postTriggerSamples);
|
|
if (int.TryParse(tokens[1], out int temp)) { PreTriggerSamples = temp; }
|
|
if (int.TryParse(tokens[3], out temp)) { LevelTriggerOffset = temp; }
|
|
return _eventCodes;
|
|
}
|
|
}
|
|
public QueryDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new DataAvailableCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public QueryDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new DataAvailableCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
}
|
|
internal class ClearDataAvailableCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "Clear data available - R? D";
|
|
|
|
protected override string _CommandString => "R? D";
|
|
|
|
public override string GetCommandPortion()
|
|
{
|
|
return "R?";
|
|
}
|
|
public ClearDataAvailableCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
}
|
|
public class ClearDataAvailable : CommandBase
|
|
{
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
|
|
public ClearDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new ClearDataAvailableCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public ClearDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new ClearDataAvailableCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
|
|
public new bool IsErrored { get; private set; }
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
if (null == baseResponse) { return; }
|
|
var s = Encoding.ASCII.GetString(baseResponse.ToBytes());
|
|
if (s.ToLower().Contains("err")) { IsErrored = true; }
|
|
}
|
|
}
|
|
|
|
internal class ARMSTOPNOWCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "ARM STOP NOW";
|
|
|
|
protected override string _CommandString => "ARM STOP NOW";
|
|
|
|
public override string GetCommandPortion()
|
|
{
|
|
return "ARM";
|
|
}
|
|
}
|
|
internal class ARMOFFCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "ARM OFF";
|
|
|
|
protected override string _CommandString => "ARM OFF";
|
|
|
|
public override string GetCommandPortion()
|
|
{
|
|
return "ARM";
|
|
}
|
|
}
|
|
|
|
public class ARMSTOP : CommandBase
|
|
{
|
|
public ARMSTOP(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var cmd = new TDASCommandPacketBase(new ARMSTOPNOWCommandString());
|
|
cmd.RebuildBytes = true;
|
|
baseCommand = cmd;
|
|
|
|
}
|
|
public ARMSTOP(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeOut)
|
|
: base(sock, msTimeOut)
|
|
{
|
|
var cmd = new TDASCommandPacketBase(new ARMSTOPNOWCommandString());
|
|
cmd.RebuildBytes = true;
|
|
baseCommand = cmd;
|
|
}
|
|
}
|
|
public class ARMOFF : CommandBase
|
|
{
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
|
|
public ARMOFF(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var cmd = new TDASCommandPacketBase(new ARMOFFCommandString());
|
|
cmd.RebuildBytes = true;
|
|
baseCommand = cmd;
|
|
|
|
}
|
|
public ARMOFF(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeOut)
|
|
: base(sock, msTimeOut)
|
|
{
|
|
var cmd = new TDASCommandPacketBase(new ARMOFFCommandString());
|
|
cmd.RebuildBytes = true;
|
|
baseCommand = cmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Command string for TDAS rack IDX command, this command retrieves all channel EIDs
|
|
/// </summary>
|
|
internal class IDXCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "IDX ALL";
|
|
protected override string _CommandString => "IDX ALL";
|
|
public IDXCommandString() { RackCommand = true; }
|
|
public override string GetCommandPortion() => "IDX";
|
|
}
|
|
/// <summary>
|
|
/// TDAS Command for a rack IDX command. This is only used for G5 currently as I'm
|
|
/// only aware of G5 supporting it, I'm not aware of required firmware verion (DTM 2023/01/25)
|
|
/// </summary>
|
|
public class RackIDX : CommandBase
|
|
{
|
|
private List<string[]> _ids;
|
|
/// <summary>
|
|
/// list of all ids returned by the command
|
|
/// the first array is by colum, while the second is by ID,
|
|
/// so IDs[0][0] is channel 0 ID 0, and IDs[0][1] is the channel 0, ID 1
|
|
/// </summary>
|
|
public IList<string[]> IDs
|
|
{
|
|
get
|
|
{
|
|
if (null == _ids) { ProcessData(); }
|
|
return _ids;
|
|
}
|
|
}
|
|
public RackIDX(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new IDXCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
public RackIDX(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new IDXCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
if (string.IsNullOrEmpty(_responseData)) { return; }
|
|
_ids = new List<string[]>();
|
|
var channels = GetChannels(ResponseData);
|
|
foreach (var channel in channels)
|
|
{
|
|
var ids = GetIDs(channel);
|
|
if (null != ids) { _ids.Add(ids); }
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// returns all channels from the command response
|
|
/// channels are separated by spaces
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
private string[] GetChannels(string data)
|
|
{
|
|
var tokens = data.Split(new[] { ' ' });
|
|
return tokens;
|
|
}
|
|
/// <summary>
|
|
/// returns all the eids for a channel
|
|
/// ids are separated by a ',' if there are multiple
|
|
/// </summary>
|
|
/// <param name="channel"></param>
|
|
/// <returns></returns>
|
|
private string[] GetIDs(string channel)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(channel)) { return null; }
|
|
if (channel.Equals("OK")) { return null; }
|
|
return channel.Split(new[] { ',' });
|
|
}
|
|
}
|
|
internal class ReadSensorIDsCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "Read Sensor ID";
|
|
|
|
protected override string _CommandString => "READ SENSOR ID";
|
|
|
|
public ReadSensorIDsCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
public override string GetCommandPortion()
|
|
{
|
|
return "READ";
|
|
}
|
|
}
|
|
|
|
public class ReadSensorIDs : CommandBase
|
|
{
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
private List<string> _ids;
|
|
public IList<string> IDs
|
|
{
|
|
get
|
|
{
|
|
if (null == _ids) { ProcessData(); }
|
|
return _ids;
|
|
}
|
|
}
|
|
public ReadSensorIDs(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadSensorIDsCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
public ReadSensorIDs(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadSensorIDsCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
if (string.IsNullOrEmpty(_responseData)) { return; }
|
|
_ids = new List<string>();
|
|
var data = ResponseData.Split(' ');
|
|
for (var i = 2; i < data.Length; i++)//skip SENSOR, ID
|
|
{
|
|
if ("OK" == data[i]) { continue; }
|
|
_ids.Add(data[i]);
|
|
}
|
|
}
|
|
}
|
|
internal class SetupDASReadCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "SETUP DAS READ - SDR";
|
|
|
|
protected override string _CommandString => "SDR";
|
|
|
|
public SetupDASReadCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
}
|
|
|
|
public class SetupDASRead : CommandBase
|
|
{
|
|
|
|
private SetupDASLoad.ARMMode _armMode;
|
|
public SetupDASLoad.ARMMode ArmMode
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _armMode;
|
|
}
|
|
}
|
|
private double _actualSampleRate;
|
|
public double ActualSampleRate
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _actualSampleRate;
|
|
}
|
|
}
|
|
private double _outputRate;
|
|
public double OutputRate
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _outputRate;
|
|
}
|
|
}
|
|
private float _hardwareFilter;
|
|
public float HardwareFilter
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _hardwareFilter;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// warning this information refers to test setup and not actual data recorded,
|
|
/// probably won't R? data for most things
|
|
/// </summary>
|
|
private double _preTriggerTimeInSeconds;
|
|
public double PreTriggerTimeInSeconds
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _preTriggerTimeInSeconds;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// warning this information refers to test setup and not actual data recorded,
|
|
/// probably won't R? data for most things
|
|
/// </summary>
|
|
private double _postTriggerTimeInSeconds;
|
|
public double PostTriggerTimeInSeconds
|
|
{
|
|
get
|
|
{
|
|
//if (null == _postTriggerTimeInSeconds) { ProcessData(); }
|
|
return _postTriggerTimeInSeconds;
|
|
}
|
|
}
|
|
private double _postADWaitTime;
|
|
public double PostADWaitTime
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _postADWaitTime;
|
|
}
|
|
}
|
|
private SetupDASLoad.TriggerTypes _triggerType;
|
|
public SetupDASLoad.TriggerTypes TriggerType
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _triggerType;
|
|
}
|
|
}
|
|
private int _triggerChannel;
|
|
public int TriggerChannel
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _triggerChannel;
|
|
}
|
|
}
|
|
private SetupDASLoad.TriggerModes _triggerMode;
|
|
public SetupDASLoad.TriggerModes TriggerMode
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _triggerMode;
|
|
}
|
|
}
|
|
|
|
private int _triggerLevelADC;
|
|
public int TriggerLevelADC
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _triggerLevelADC;
|
|
}
|
|
}
|
|
private int _numberOfTriggerSamples;
|
|
public int NumberOfTriggerSamples
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _numberOfTriggerSamples;
|
|
}
|
|
}
|
|
|
|
private string _testID;
|
|
public string TestID
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _testID;
|
|
}
|
|
}
|
|
private string _testConfig;
|
|
public string TestConfig
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _testConfig;
|
|
}
|
|
}
|
|
|
|
private enum FIELDS
|
|
{
|
|
ArmMode,
|
|
SampleRate,
|
|
OutputRate,
|
|
HardwareAAFilter,
|
|
PretriggerTimeInSeconds,
|
|
PostTriggerTimeInSeconds,
|
|
PostADWaitTime,
|
|
TriggerType,
|
|
TriggerChannel,
|
|
TriggerMode,
|
|
TriggerLevelADC,
|
|
NumberOfTriggerSamples,
|
|
TestId,
|
|
TestDescription
|
|
}
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
|
|
public SetupDASRead(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new SetupDASReadCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public SetupDASRead(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new SetupDASReadCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public static string[] SmartSplit(string data)
|
|
{
|
|
var values = new List<string>();
|
|
while (data.Length > 0)
|
|
{
|
|
var indexQuote = data.IndexOf('"');
|
|
var indexSpace = data.IndexOf(' ');
|
|
var end = -1;
|
|
if (indexQuote >= 0 && (indexQuote < indexSpace || indexSpace < 0))
|
|
{
|
|
//process quote
|
|
end = data.IndexOf('"', indexQuote + 1) + 1;
|
|
}
|
|
else
|
|
{//process space
|
|
end = indexSpace;
|
|
}
|
|
if (end < 0) { end = data.Length - 1; }
|
|
values.Add(data.Substring(0, end));
|
|
|
|
data = end < data.Length - 1 ? data.Substring(end + 1) : "";
|
|
}
|
|
return values.ToArray();
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
if (null == _responseData) { throw new SystemException("Empty response received"); }
|
|
var tokens = SmartSplit(ResponseData);
|
|
var a = Enum.GetValues(typeof(FIELDS));
|
|
var i = 0;
|
|
foreach (FIELDS field in a)
|
|
{
|
|
var token = tokens[i];
|
|
switch (field)
|
|
{
|
|
case FIELDS.ArmMode:
|
|
_armMode = token.ToUpper() == "TAPE" ? SetupDASLoad.ARMMode.TAPE : SetupDASLoad.ARMMode.WAIT;
|
|
break;
|
|
case FIELDS.HardwareAAFilter:
|
|
_hardwareFilter = float.Parse(token);
|
|
break;
|
|
case FIELDS.NumberOfTriggerSamples:
|
|
_numberOfTriggerSamples = int.Parse(token);
|
|
break;
|
|
case FIELDS.OutputRate:
|
|
_outputRate = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PostADWaitTime:
|
|
_postADWaitTime = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PostTriggerTimeInSeconds:
|
|
_postTriggerTimeInSeconds = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PretriggerTimeInSeconds:
|
|
_preTriggerTimeInSeconds = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.SampleRate:
|
|
_actualSampleRate = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.TestDescription:
|
|
_testConfig = token.Replace("\"", "");
|
|
break;
|
|
case FIELDS.TestId:
|
|
_testID = token.Replace("\"", "");
|
|
break;
|
|
case FIELDS.TriggerChannel:
|
|
_triggerChannel = int.Parse(token);
|
|
break;
|
|
case FIELDS.TriggerLevelADC:
|
|
_triggerLevelADC = int.Parse(token);
|
|
break;
|
|
case FIELDS.TriggerMode:
|
|
_triggerMode = token.ToUpper() == "GT" ? SetupDASLoad.TriggerModes.GT : SetupDASLoad.TriggerModes.LT;
|
|
break;
|
|
case FIELDS.TriggerType:
|
|
_triggerType = token.ToUpper() == "HW" ? SetupDASLoad.TriggerTypes.HW : SetupDASLoad.TriggerTypes.LV;
|
|
break;
|
|
default:
|
|
throw new NotSupportedException("Unknown SDL parameter " + a.ToString());
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
public class SetupDASReadDIM : CommandBase
|
|
{
|
|
private SetupDASLoad.ARMMode _armMode;
|
|
public SetupDASLoad.ARMMode ArmMode
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _armMode;
|
|
}
|
|
}
|
|
private double _actualSampleRate;
|
|
public double ActualSampleRate
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _actualSampleRate;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// warning this information refers to test setup and not actual data recorded,
|
|
/// probably won't R? data for most things
|
|
/// </summary>
|
|
private double _preTriggerTimeInSeconds;
|
|
public double PreTriggerTimeInSeconds
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _preTriggerTimeInSeconds;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// warning this information refers to test setup and not actual data recorded,
|
|
/// probably won't R? data for most things
|
|
/// </summary>
|
|
private double _postTriggerTimeInSeconds;
|
|
public double PostTriggerTimeInSeconds => _postTriggerTimeInSeconds;
|
|
private double _postADWaitTime;
|
|
public double PostADWaitTime
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _postADWaitTime;
|
|
}
|
|
}
|
|
private SetupDASLoad.TriggerTypes _triggerType;
|
|
public SetupDASLoad.TriggerTypes TriggerType
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _triggerType;
|
|
}
|
|
}
|
|
private int _triggerChannel;
|
|
public int TriggerChannel
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _triggerChannel;
|
|
}
|
|
}
|
|
|
|
private int _numberOfTriggerSamples;
|
|
public int NumberOfTriggerSamples
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _numberOfTriggerSamples;
|
|
}
|
|
}
|
|
|
|
private string _testID;
|
|
public string TestID
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _testID;
|
|
}
|
|
}
|
|
private string _testConfig;
|
|
public string TestConfig
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _testConfig;
|
|
}
|
|
}
|
|
|
|
private enum FIELDS
|
|
{
|
|
ArmMode,
|
|
SampleRate,
|
|
PretriggerTimeInSeconds,
|
|
PostTriggerTimeInSeconds,
|
|
PostADWaitTime,
|
|
TriggerType,
|
|
TriggerChannel,
|
|
NumberOfTriggerSamples,
|
|
TestId,
|
|
TestDescription
|
|
}
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
|
|
public SetupDASReadDIM(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new SetupDASReadCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public SetupDASReadDIM(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new SetupDASReadCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public static string[] SmartSplit(string data)
|
|
{
|
|
var values = new List<string>();
|
|
while (data.Length > 0)
|
|
{
|
|
var indexQuote = data.IndexOf('"');
|
|
var indexSpace = data.IndexOf(' ');
|
|
var end = -1;
|
|
if (indexQuote >= 0 && (indexQuote < indexSpace || indexSpace < 0))
|
|
{
|
|
//process quote
|
|
end = data.IndexOf('"', indexQuote + 1) + 1;
|
|
}
|
|
else
|
|
{//process space
|
|
end = indexSpace;
|
|
}
|
|
if (end < 0) { end = data.Length - 1; }
|
|
values.Add(data.Substring(0, end));
|
|
|
|
data = end < data.Length - 1 ? data.Substring(end + 1) : "";
|
|
}
|
|
return values.ToArray();
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
if (null == _responseData) { throw new SystemException("Empty response received"); }
|
|
var tokens = SmartSplit(ResponseData);
|
|
var a = Enum.GetValues(typeof(FIELDS));
|
|
var i = 0;
|
|
foreach (FIELDS field in a)
|
|
{
|
|
var token = tokens[i];
|
|
switch (field)
|
|
{
|
|
case FIELDS.ArmMode:
|
|
if (token.ToUpper() == "TAPE") { _armMode = SetupDASLoad.ARMMode.TAPE; }
|
|
else { _armMode = SetupDASLoad.ARMMode.WAIT; }
|
|
break;
|
|
case FIELDS.NumberOfTriggerSamples:
|
|
_numberOfTriggerSamples = int.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PostADWaitTime:
|
|
_postADWaitTime = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PostTriggerTimeInSeconds:
|
|
_postTriggerTimeInSeconds = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PretriggerTimeInSeconds:
|
|
_preTriggerTimeInSeconds = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.SampleRate:
|
|
_actualSampleRate = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.TestDescription:
|
|
_testConfig = token.Replace("\"", "");
|
|
break;
|
|
case FIELDS.TestId:
|
|
_testID = token.Replace("\"", "");
|
|
break;
|
|
case FIELDS.TriggerChannel:
|
|
_triggerChannel = int.Parse(token);
|
|
break;
|
|
case FIELDS.TriggerType:
|
|
if (token.ToUpper() == "HW") { _triggerType = SetupDASLoad.TriggerTypes.HW; }
|
|
else { _triggerType = SetupDASLoad.TriggerTypes.LV; }
|
|
break;
|
|
default:
|
|
throw new NotSupportedException("Unknown SDL parameter " + a.ToString());
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
internal class QueryCalDateCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "Query CalDate - ?C";
|
|
|
|
protected override string _CommandString => "?C";
|
|
|
|
public QueryCalDateCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
}
|
|
|
|
public class QueryCalDate : CommandBase
|
|
{
|
|
private static readonly char[] DateSeparators = new char[] { '/', '-' };
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
|
|
public QueryCalDate(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new QueryCalDateCommandString());
|
|
//command.RackCommand = true;
|
|
command.RackCommand = false;
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public QueryCalDate(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new QueryCalDateCommandString());
|
|
//command.RackCommand = false;
|
|
command.RackCommand = true;
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
private DateTime _calDate = DateTime.MinValue;
|
|
public DateTime CalDate
|
|
{
|
|
get
|
|
{
|
|
if (DateTime.MinValue != _calDate) return _calDate;
|
|
_calDate = new DateTime(1970, 1, 1);
|
|
try
|
|
{
|
|
var tokens = ResponseData.Split(DateSeparators);
|
|
if (3 == tokens.Length)
|
|
{
|
|
//06/25/13
|
|
if (int.TryParse(tokens[0], out int month)
|
|
&& int.TryParse(tokens[1], out int day)
|
|
&& int.TryParse(tokens[2], out int year))
|
|
{
|
|
if (year > 90 && year < 1000) { year += 1900; }//we have some calibrations in the field from the 199x's potentially according to tim
|
|
else if (year < 1000) { year += 2000; }
|
|
|
|
_calDate = new DateTime(year, month, day);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
APILogger.Log(ex);
|
|
}
|
|
return _calDate;
|
|
}
|
|
}
|
|
}
|
|
internal class QueryMemoryCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "Query Memory - ?M";
|
|
|
|
protected override string _CommandString => "?M";
|
|
|
|
public QueryMemoryCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
}
|
|
public class QueryMemoryCommand : CommandBase
|
|
{
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
|
|
private ulong? _availableRamBytes;
|
|
public ulong AvailableRamBytes
|
|
{
|
|
get
|
|
{
|
|
if (null == _availableRamBytes) { ParseLongs(); }
|
|
return (ulong)_availableRamBytes;
|
|
}
|
|
}
|
|
|
|
private ulong? _totalRamBytes;
|
|
public ulong TotalRamBytes
|
|
{
|
|
get
|
|
{
|
|
if (null == _totalRamBytes) { ParseLongs(); }
|
|
return (ulong)_totalRamBytes;
|
|
}
|
|
}
|
|
private double ParseDouble(string s)
|
|
{
|
|
s = s.Replace("MB", "");
|
|
//this is for TDAS Pro, which returns 16xxx but has 16M available
|
|
var d = double.Parse(s, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
if (d < 1024) //must be in MB
|
|
{
|
|
d *= (1024 * 1024);
|
|
}
|
|
else if (d < 1024 * 1024) //must be in kb?
|
|
{
|
|
d *= 1024;
|
|
}//else must be in bytes already?
|
|
return d;
|
|
}
|
|
private void ParseLongs()
|
|
{
|
|
var tokens = ResponseData.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
if (tokens.Length > 0)
|
|
{
|
|
_totalRamBytes = Convert.ToUInt64(ParseDouble(tokens[0]));
|
|
}
|
|
if (tokens.Length > 1)
|
|
{
|
|
_availableRamBytes = Convert.ToUInt64(ParseDouble(tokens[1]));
|
|
}
|
|
else
|
|
{
|
|
_availableRamBytes = Convert.ToUInt64(TotalRamBytes);
|
|
}
|
|
}
|
|
|
|
public QueryMemoryCommand(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new QueryMemoryCommandString());
|
|
//command.RackCommand = true;
|
|
command.RackCommand = false;
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public QueryMemoryCommand(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new QueryMemoryCommandString());
|
|
//command.RackCommand = false;
|
|
command.RackCommand = true;
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
}
|
|
internal class GetTOMSwitchCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "Get TOM Switch - ARMST";
|
|
|
|
protected override string _CommandString => "TEST ARMST";
|
|
|
|
public GetTOMSwitchCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
public override string GetCommandPortion()
|
|
{
|
|
return "TEST";
|
|
}
|
|
}
|
|
public class GetTOMSwitch : CommandBase
|
|
{
|
|
public enum TomSwitchMode
|
|
{
|
|
Armed,
|
|
Safe,
|
|
Fail
|
|
}
|
|
private TomSwitchMode _switchMode = TomSwitchMode.Armed;
|
|
public TomSwitchMode SwitchMode
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _switchMode;
|
|
}
|
|
}
|
|
private bool _switchFault = false;
|
|
public bool SwitchFault
|
|
{
|
|
get { if (null == _responseData) { ProcessData(); } return _switchFault; }
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get => (baseCommand as TDASCommandPacketBase).ModuleIndex;
|
|
set => (baseCommand as TDASCommandPacketBase).ModuleIndex = value;
|
|
}
|
|
|
|
public GetTOMSwitch(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new GetTOMSwitchCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
public GetTOMSwitch(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new GetTOMSwitchCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
if (null == _responseData) { return; }
|
|
var tokens = ResponseData.Split(' ');
|
|
foreach (var token in tokens)
|
|
{
|
|
var subTokens = token.Split('=');
|
|
if (2 != subTokens.Length) { continue; }
|
|
switch (subTokens[0])
|
|
{
|
|
case "SS":
|
|
{
|
|
var sMode = subTokens[1].ToUpper();
|
|
if (sMode == "SAFE") { _switchMode = TomSwitchMode.Safe; }
|
|
else if (sMode == "ARM") { _switchMode = TomSwitchMode.Armed; }
|
|
else { _switchMode = TomSwitchMode.Fail; }
|
|
}
|
|
break;
|
|
case "SF":
|
|
{
|
|
var sMode = subTokens[1].ToUpper();
|
|
if (sMode == "FLT") { _switchFault = true; }
|
|
else { _switchFault = false; }
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
internal class SetupTOMDASReadCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription => "SETUP DAS READ - SDR (TOM)";
|
|
|
|
protected override string _CommandString => "SDR";
|
|
|
|
public SetupTOMDASReadCommandString()
|
|
{
|
|
RackCommand = false;
|
|
}
|
|
}
|
|
|
|
public class SetupTOMDASRead : CommandBase
|
|
{
|
|
|
|
private SetupDASLoad.ARMMode _armMode;
|
|
public SetupDASLoad.ARMMode ArmMode
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _armMode;
|
|
}
|
|
}
|
|
|
|
private double _actualSampleRate;
|
|
public double ActualSampleRate
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _actualSampleRate;
|
|
}
|
|
}
|
|
private double _outputRate;
|
|
public double OutputRate
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _outputRate;
|
|
}
|
|
}
|
|
private float _hardwareFilter;
|
|
public float HardwareFilter
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _hardwareFilter;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// warning this information refers to test setup and not actual data recorded,
|
|
/// probably won't R? data for most things
|
|
/// </summary>
|
|
private double _preTriggerTimeInSeconds;
|
|
public double PreTriggerTimeInSeconds
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _preTriggerTimeInSeconds;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// warning this information refers to test setup and not actual data recorded,
|
|
/// probably won't R? data for most things
|
|
/// </summary>
|
|
private double _postTriggerTimeInSeconds;
|
|
public double PostTriggerTimeInSeconds => _postTriggerTimeInSeconds;
|
|
private double _postADWaitTime;
|
|
public double PostADWaitTime
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _postADWaitTime;
|
|
}
|
|
}
|
|
private SetupDASLoad.TriggerTypes _triggerType;
|
|
public SetupDASLoad.TriggerTypes TriggerType
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _triggerType;
|
|
}
|
|
}
|
|
|
|
private string _testID;
|
|
public string TestID
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _testID;
|
|
}
|
|
}
|
|
private string _testConfig;
|
|
public string TestConfig
|
|
{
|
|
get
|
|
{
|
|
if (null == _responseData) { ProcessData(); }
|
|
return _testConfig;
|
|
}
|
|
}
|
|
private double _capacitorDischargeFrequence = double.NaN;
|
|
public double CapacitorDischargeFrequency
|
|
{
|
|
get
|
|
{
|
|
if (double.IsNaN(_capacitorDischargeFrequence)) { ProcessData(); }
|
|
return _capacitorDischargeFrequence;
|
|
}
|
|
}
|
|
//SDR: WAIT 10000 0 2000 0.0512 20.0448 10 BUS 81.6993 "FSDFSDF" "AE1F9C0D-E849-47BF-9714-9DA7D12DE461"
|
|
private enum FIELDS
|
|
{
|
|
ArmMode,
|
|
SampleRate,
|
|
OutputRate,
|
|
HardwareAAFilter,
|
|
PretriggerTimeInSeconds,
|
|
PostTriggerTimeInSeconds,
|
|
PostADWaitTime,
|
|
TriggerType,
|
|
CapacitorDischargeFrequency,
|
|
TestId,
|
|
TestDescription
|
|
}
|
|
public int ModuleIndex
|
|
{
|
|
get => ((TDASCommandPacketBase)baseCommand).ModuleIndex;
|
|
set => ((TDASCommandPacketBase)baseCommand).ModuleIndex = value;
|
|
}
|
|
|
|
public SetupTOMDASRead(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
var command = new TDASCommandPacketBase(new SetupTOMDASReadCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
public SetupTOMDASRead(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
var command = new TDASCommandPacketBase(new SetupDASReadCommandString());
|
|
command.RebuildBytes = true;
|
|
baseCommand = command;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
base.ProcessData();
|
|
if (string.IsNullOrEmpty(_responseData)) { return; }
|
|
var tokens = SetupDASRead.SmartSplit(ResponseData);
|
|
var a = Enum.GetValues(typeof(FIELDS));
|
|
var i = 0;
|
|
foreach (FIELDS field in a)
|
|
{
|
|
var token = tokens[i];
|
|
switch (field)
|
|
{
|
|
case FIELDS.ArmMode:
|
|
if (token.ToUpper() == "TAPE") { _armMode = SetupDASLoad.ARMMode.TAPE; }
|
|
else { _armMode = SetupDASLoad.ARMMode.WAIT; }
|
|
break;
|
|
case FIELDS.HardwareAAFilter:
|
|
_hardwareFilter = float.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.OutputRate:
|
|
_outputRate = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PostADWaitTime:
|
|
_postADWaitTime = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PostTriggerTimeInSeconds:
|
|
_postTriggerTimeInSeconds = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.PretriggerTimeInSeconds:
|
|
_preTriggerTimeInSeconds = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.SampleRate:
|
|
_actualSampleRate = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
case FIELDS.TestDescription:
|
|
_testConfig = token.Replace("\"", "");
|
|
break;
|
|
case FIELDS.TestId:
|
|
_testID = token.Replace("\"", "");
|
|
break;
|
|
case FIELDS.TriggerType:
|
|
if (token.ToUpper() == "HW") { _triggerType = SetupDASLoad.TriggerTypes.HW; }
|
|
else if (token.ToUpper() == "BUS") { _triggerType = SetupDASLoad.TriggerTypes.BUS; }
|
|
else { _triggerType = SetupDASLoad.TriggerTypes.LV; }
|
|
break;
|
|
case FIELDS.CapacitorDischargeFrequency:
|
|
_capacitorDischargeFrequence = double.Parse(token, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture);
|
|
break;
|
|
default:
|
|
throw new NotSupportedException("Unknown SDL parameter " + a.ToString());
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
}
|