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 @@
12

View File

@@ -0,0 +1 @@
12

View File

@@ -0,0 +1,384 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DTS.DASLib.Command.Ribeye
{
public class CommandPacket : CommandPacketBase
{
public enum CommandType
{
Reserved = 0x00,
Arm,
Attribute,
Diagnostics,
EventData,
FirmwareUpdate,
Information,
QAandUtility,
Realtime,
};
const int HEADER_SIZE_BYTES = 4;
public string[] Parameter;
byte Checksum = 0;
//public byte[] OriginalBytes;
public CommandPacket()
{
Parameter = new string[0];
ShouldLog = true;
}
public CommandPacket(byte[] Bytes)
{
OriginalBytes = Bytes;
ShouldLog = true;
int ParameterCount = 0;
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
ParameterCount++;
}
}
Parameter = new string[ParameterCount];
int CurrentParameter = 0;
StringBuilder sb = new StringBuilder();
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
Parameter[CurrentParameter] = sb.ToString();
CurrentParameter++;
sb = new StringBuilder();
}
else if ((byte)'\r' != CurrentByte && (byte)'\n' != CurrentByte)
{
sb.Append((char)CurrentByte);
}
}
}
public override PacketState VerifyPacket(byte[] Bytes)
{
if (Bytes == null || '?' == Bytes[0]) // ? is the error indicator
return PacketState.Unknown;
if (Bytes.Length < HEADER_SIZE_BYTES)
return PacketState.TooShort;
// Need to check checksum
if (Bytes[Bytes.Length - 2] == '\r' && Bytes[Bytes.Length - 1] == '\n')
{
return PacketState.OK;
}
else
{
return PacketState.TooShort;
}
}
public override byte[] ToBytes()
{
uint Length;
byte[] CommandBytes;
Length = 0;
foreach (string CurrentParameter in Parameter)
{
if (null != CurrentParameter)
{
Length += (uint)(CurrentParameter.Length + 1);
}
}
Length += (uint)(Checksum.ToString().Length + 2);
CommandBytes = new byte[Length];
int CommandIndex = 0;
foreach (string CurrentParameter in Parameter)
{
foreach (char CurrentChar in CurrentParameter)
{
CommandBytes[CommandIndex] = (byte)CurrentChar;
CommandIndex++;
}
CommandBytes[CommandIndex] = (byte)'#';
CommandIndex++;
}
foreach (char CurrentChar in Checksum.ToString())
{
CommandBytes[CommandIndex] = (byte)CurrentChar;
CommandIndex++;
}
CommandBytes[CommandBytes.Length - 2] = (byte)'\r';
CommandBytes[CommandBytes.Length - 1] = (byte)'\n';
OriginalBytes = CommandBytes;
return CommandBytes;
}
private void ComputeChecksum()
{
Checksum = 0;
foreach (string CurrentParameter in Parameter)
{
foreach (char CurrentCharacter in CurrentParameter)
{
Checksum += (byte)CurrentCharacter;
}
Checksum += (byte)'#';
}
}
public override void ComputeCRCs()
{
ComputeChecksum();
}
private static System.Globalization.CultureInfo InvariantCulture = new System.Globalization.CultureInfo("");
public void GetParameter(int Position, out double Value)
{
Double.TryParse(Parameter[Position], System.Globalization.NumberStyles.Float, InvariantCulture, out Value);
}
public void GetParameter(int Position, out UInt64 Value)
{
UInt64.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out Int64 Value)
{
Int64.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out Int32 Value)
{
Int32.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out UInt32 Value)
{
UInt32.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out Int16 Value)
{
Int16.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out UInt16 Value)
{
UInt16.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out float Value)
{
float.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out string Value)
{
Value = Parameter[Position];
}
public void SetParameter(int Position, double Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, Int64 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, UInt64 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, Int32 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, UInt32 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, Int16 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, UInt16 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, float Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, string Value)
{
Parameter[Position] = Value;
}
public override object ConvertByteToCommandType(byte b)
{
return (CommandType)b;
}
private static UInt16 GlobalSequenceNumber = 0;
private static object GlobalSequenceNumberLock = new object();
public override void GetNextSequenceNumber()
{
lock (GlobalSequenceNumberLock)
{
SequenceNumber = GlobalSequenceNumber;
GlobalSequenceNumber++;
}
}
}
public class DownloadPacket : CommandPacket
{
public byte[] Data;
public DownloadPacket(byte[] Bytes)
{
OriginalBytes = Bytes;
ShouldLog = true;
int ParameterCount = 0;
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
ParameterCount++;
}
if ('\r' == CurrentByte)
{
break;
}
}
Parameter = new string[ParameterCount];
int CurrentParameter = 0;
StringBuilder sb = new StringBuilder();
uint ByteOffset = 0;
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
Parameter[CurrentParameter] = sb.ToString();
CurrentParameter++;
sb = new StringBuilder();
}
else if ((byte)'\n' == CurrentByte)
{
break;
}
else
{
sb.Append((char)CurrentByte);
}
ByteOffset++;
}
ByteOffset++;
uint DataLength = (uint)(Bytes.Length - ByteOffset);
Data = new byte[DataLength];
Array.Copy(Bytes, ByteOffset, Data, 0, DataLength);
}
public static PacketState VerifyPacket(byte[] Bytes, ref uint BytesExpected)
{
if (Bytes == null)
return PacketState.Unknown;
if (0 == BytesExpected)
{
string[] Parameter = new string[3];
uint CurrentParameter = 0;
StringBuilder sb = new StringBuilder();
// Look for initial header
foreach (byte CurrentByte in Bytes)
{
try
{
if ('#' == CurrentByte)
{
Parameter[CurrentParameter] = sb.ToString();
CurrentParameter++;
sb = new StringBuilder();
}
else if ((byte)'\r' == CurrentByte || (byte)'\n' == CurrentByte)
{
break;
}
else
{
sb.Append((char)CurrentByte);
}
}
catch (Exception)
{
return PacketState.Unknown;
}
}
if (3 != CurrentParameter)
{
return PacketState.TooShort;
}
else
{
// Parameter 1 = number of channels
// Parameter 2 = number of samples
// + 1 is for checksum on each sample
// * 2 is for 2 bytes per sample
try
{
BytesExpected = (uint)((UInt16.Parse(Parameter[1]) * 2 + 1) * UInt16.Parse(Parameter[2]) + Bytes.Length);
}
catch (Exception)
{
return PacketState.Unknown;
}
if (Bytes.Length >= BytesExpected)
{
return PacketState.OK;
}
else
{
return PacketState.TooShort;
}
}
}
else
{
if (Bytes.Length >= BytesExpected)
{
return PacketState.OK;
}
else
{
return PacketState.TooShort;
}
}
}
}
}

View File

@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Enums.DASFactory;
using DTS.Common.ICommunication;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class InformationCommands : CommandBase
{
protected enum Commands
{
Reserved = 0x00,
QueryNumberOfLEDs = 0x01,
QueryDataAvailable = 0x02,
QuerySerialNumber = 0x03
};
protected abstract Commands _Command { get; }
protected InformationCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Type = CommandPacket.CommandType.Information;
command.SetCommand((byte)_Command, _Command.ToString());
}
protected InformationCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Type = CommandPacket.CommandType.Information;
command.SetCommand((byte)_Command, _Command.ToString());
}
}
/*
public class QueryProtocolVersion : InformationCommands
{
protected override InformationCommands.Commands _Command
{
get {
}
byte _versionbyte = (byte)0;
public int Version { get { return _versionbyte; } }
public QueryProtocolVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
// this.command.Command = (byte)Commands.QueryProtocolVersion;
}
public QueryProtocolVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
// this.command.Command = (byte)Commands.QueryProtocolVersion;
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
// response.GetParameter(0, out _versionbyte);
}
return CommandReceiveAction.StopReceiving;
}
public override string CommandToString()
{
var sb = new StringBuilder();
return sb.ToString();
}
public override string ResponseToString()
{
var sb = new StringBuilder();
sb.AppendLine();
sb.AppendFormat(" Status: {0}, Version: {1}", ResponseStatus, Version);
return sb.ToString();
}
}
*/
/*
public class QueryFirmwareVersion : InformationCommands
{
string _versionstring = string.Empty;
public string Version { get { return _versionstring; } }
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
// this.command.Command = (byte)Commands.QueryFirmwareVersion;
}
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
// this.command.Command = (byte)Commands.QueryFirmwareVersion;
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
response.GetParameter(0, out _versionstring);
}
return CommandReceiveAction.StopReceiving;
}
public override string CommandToString()
{
var sb = new StringBuilder();
return sb.ToString();
}
public override string ResponseToString()
{
var sb = new StringBuilder();
sb.AppendLine();
sb.AppendFormat(" Status: {0}, Version: {1}", ResponseStatus, Version);
return sb.ToString();
}
}
*/
public class QuerySerialNumber : InformationCommands
{
// note - the existing implementation doesn't set a command for this
// class, so I will preserve that by changing it not to be set
// in the parent class for this one instance
protected override InformationCommands.Commands _Command
{
get { return Commands.QuerySerialNumber; }
}
string _serialnumber = string.Empty;
const string SerialNumberCommand = "SERIAL_NUMBER";
public string SerialNumber { get { return _serialnumber; } }
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Parameter = new string[1];
command.SetParameter(0, SerialNumberCommand);
}
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Parameter = new string[1];
command.SetParameter(0, SerialNumberCommand);
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
try
{
response.GetParameter(1, out _serialnumber);
}
catch (Exception e)
{
e.ToString();
}
}
return CommandReceiveAction.StopReceiving;
}
}
public class QueryNumberOfLEDs : InformationCommands
{
protected override InformationCommands.Commands _Command
{
get { return Commands.QueryNumberOfLEDs; }
}
uint _numberOfLEDs = 0;
const string NumberOfLEDsCommand = "HOW_MANY_LEDS";
public uint NumberOfLEDs { get { return _numberOfLEDs; } }
public QueryNumberOfLEDs(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryNumberOfLEDs(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, NumberOfLEDsCommand);
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
response.GetParameter(1, out _numberOfLEDs);
}
return CommandReceiveAction.StopReceiving;
}
public override void ResponseToString(ref List<List<string>> lines)
{
base.ResponseToString(ref lines);
lines.Add(new List<string>()
{
string.Format("NumberOfLEDs: {0}", NumberOfLEDs)
});
}
}
public class QueryDataAvailable : InformationCommands
{
//a note - I'm preserving the existing code that was using the command
//querynumberofled's - but I'm thinking it probably should have been using
//querydataavailable ...
protected override InformationCommands.Commands _Command
{
get { return Commands.QueryNumberOfLEDs; }
}
float _totalMS = 0;
float _preTriggerMS = 0;
float _postTriggerMS = 0;
const string DumpInfoCommand = "DUMPINFO";
public float TotalMS { get { return _totalMS; } }
public float PreTriggerMS { get { return _preTriggerMS; } }
public float PostTriggerMS { get { return _postTriggerMS; } }
public QueryDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
//is this really the right command? - it doesn't match the name
//this.command.Command = (byte)Commands.QueryNumberOfLEDs;
command.Parameter = new string[1];
command.SetParameter(0, DumpInfoCommand);
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
int NegativePreTriggerMS;
response.GetParameter(1, out NegativePreTriggerMS);
_preTriggerMS = Math.Abs(NegativePreTriggerMS);
response.GetParameter(2, out _postTriggerMS);
_totalMS = _postTriggerMS + _preTriggerMS;
}
return CommandReceiveAction.StopReceiving;
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Ribeye Commands")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ribeye Commands")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d846da1f-f9e7-45a2-a4ac-354b1b06cae1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.06.0081")]
[assembly: AssemblyFileVersion("1.06.0081")]

View File

@@ -0,0 +1,409 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.DASResource;
using DTS.Common.Enums.DASFactory;
using DTS.Common.ICommunication;
using DTS.Common.Utilities.Logging;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class ArmCommands : CommandBase
{
protected enum Commands
{
Reserved = 0x00,
Arm = 0x01,
Disarm = 0x02,
QueryArmAndTriggerStatus = 0x03,
PrepareForDataCollection = 0x04,
DownloadTestData = 0x05,
Trigger = 0x06
};
protected abstract Commands _Command { get; }
protected ArmCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Type = CommandPacket.CommandType.Arm;
command.SetCommand((byte)_Command, _Command.ToString());
}
protected ArmCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Type = CommandPacket.CommandType.Arm;
command.SetCommand((byte)_Command, _Command.ToString());
}
}
public class Arm : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.Arm; }
}
const string ArmCommand = "ARM";
public Arm(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public Arm(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[3];
command.SetParameter(0, ArmCommand);
}
public uint TStopMS
{
set
{
command.SetParameter(1, value);
}
}
public uint TPostMS
{
set
{
command.SetParameter(2, value);
}
}
}
public class QueryArmAndTriggerStatus : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.QueryArmAndTriggerStatus; }
}
string StatusCommand = "S";
public QueryArmAndTriggerStatus(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryArmAndTriggerStatus(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, StatusCommand);
}
public bool IsArmed;
public bool IsRecording;
public bool IsTriggered;
enum StatusCodeEnum { Idle = 0x00, Armed = 0x01, Busy = 0x02, DataAvailable = 0x03 };
protected override CommandReceiveAction WholePackage()
{
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
int StatusCode;
if (response.Parameter.Length == 2)
{
response.GetParameter(1, out StatusCode);
switch ((StatusCodeEnum)StatusCode)
{
case StatusCodeEnum.Idle:
IsArmed = false;
IsRecording = false;
IsTriggered = false;
break;
case StatusCodeEnum.Armed:
IsArmed = true;
IsRecording = true;
IsTriggered = false;
break;
case StatusCodeEnum.Busy:
IsArmed = true;
IsRecording = true;
IsTriggered = true;
break;
case StatusCodeEnum.DataAvailable:
default:
IsArmed = false;
IsRecording = false;
IsTriggered = false;
break;
}
}
else
{
}
}
return CommandReceiveAction.StopReceiving;
}
}
public class Disarm : ArmCommands
{
private const string DISARM_COMMAND = "D";
protected override ArmCommands.Commands _Command
{
get { return Commands.Disarm; }
}
public Disarm(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Parameter = new string[1];
command.SetParameter(0, DISARM_COMMAND);
}
public Disarm(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Parameter = new string[1];
command.SetParameter(0, DISARM_COMMAND);
}
}
public class PrepareForDataCollection : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.PrepareForDataCollection; }
}
string EraseCommand = "ERASE";
public PrepareForDataCollection(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public PrepareForDataCollection(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, EraseCommand);
}
}
public class DownloadTestData : ArmCommands
{
// note - this looks like it's using the wrong command, but that's what the code
// was set up to do already, so I preserved it.
protected override ArmCommands.Commands _Command
{
get { return Commands.QueryArmAndTriggerStatus; }
}
string DownloadCommand = "DUMPBIN";
ushort[] _Data;
public DownloadTestData(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public DownloadTestData(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
//command.Command = (byte)Commands.QueryArmAndTriggerStatus;
command.Parameter = new string[3];
command.SetParameter(0, DownloadCommand);
BytesExpected = 0;
}
public ushort[] Data { get { return _Data; } }
public int StartTimeMS
{
set
{
command.SetParameter(1, value);
}
}
public int StopTimeMS
{
set
{
command.SetParameter(2, value);
}
}
private uint _NumberOfChannels;
public uint NumberOfChannels
{
get
{
return _NumberOfChannels;
}
}
private int ExpectedNumberOfSamples;
private uint BytesExpected;
protected override CommandReceiveAction ReceiveBlockOK(Common.Interface.Communication.ICommunicationReport report)
{
lock (_debuglock)
{
if (-1 != current_thread_id)
{
}
current_thread_id = System.Threading.Thread.CurrentThread.ManagedThreadId;
}
CommandDataBuffer.Enqueue(report.Data);
var tempBuffer = CommandDataBuffer.Dequeue(false);
var pState = DownloadPacket.VerifyPacket(tempBuffer, ref BytesExpected);
switch (pState)
{
case CommandPacket.PacketState.OK:
response = new DownloadPacket(tempBuffer);
CommandReceiveAction ret = WholePackage();
if (IsSynchronous)
{
lock (_debuglock) { current_thread_id = -1; }
SyncEvent.Set();
}
else
{
WholePackagePost();
lock (_debuglock) { current_thread_id = -1; }
}
return ret; // ???
case CommandPacket.PacketState.TooShort:
lock (_debuglock) { current_thread_id = -1; }
return DataTooShort(tempBuffer);
case CommandPacket.PacketState.Unknown:
if (!IsSynchronous)
{
lock (_debuglock) { current_thread_id = -1; }
return DataUnknown(report);
}
SyncEvent.Set();
return CommandReceiveAction.StopReceiving;
default:
// "Slice.CommandBase.ReceiveBlockOK: CommandPacket.VerifyPacket returned unknown value {0}"
lock (_debuglock) { current_thread_id = -1; }
throw new ApplicationException(string.Format(Strings.Slice_CommandBase_ReceiveBlockOK_Err1, pState));
}
}
protected override CommandReceiveAction WholePackagePost()
{
// now send the data to the user
var stat = CommandStatus.Success;
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
var s = (int)response.Status;
APILogger.LogString("QueryEventData.WholePackagePost: reporting failure, status==" + CommandPacket.StatusLabels[s] + " (0x" + s.ToString("X") + ")");
stat = CommandStatus.Failure;
}
var cbReport = new QueryEventDataReport(stat, UserCallbackData);
cbReport.data = new short[_NumberOfChannels][];
for (int i = 0; i < _NumberOfChannels; i++)
GetChannelData(i, out cbReport.data[i]);
return UserCallback(cbReport);
}
public void GetChannelData(int channel, out short[] signedADC)
{
if (channel < 0 || channel > _NumberOfChannels)
{
// "QueryEventData.GetChannelData: Data requested on a channel that wasn't downloaded."
throw new ApplicationException(Strings.QueryEventData_GetChannelData_Err1);
}
short[] rv = new short[ExpectedNumberOfSamples];
for (int i = 0; i < rv.Length; i++)
{
rv[i] = (short)(_Data[i * _NumberOfChannels + channel]);
}
signedADC = rv;
}
protected override CommandReceiveAction WholePackage()
{
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
return CommandReceiveAction.StopReceiving;
}
response.GetParameter(1, out _NumberOfChannels);
response.GetParameter(2, out ExpectedNumberOfSamples);
_Data = new ushort[ExpectedNumberOfSamples * _NumberOfChannels];
byte[] ByteArray = (response as DownloadPacket).Data;
for (int i = 0; i < ExpectedNumberOfSamples * _NumberOfChannels; i++)
{
_Data[i] = (ushort)(ByteArray[2 * i + i / _NumberOfChannels] + (ByteArray[2 * i + 1 + i / _NumberOfChannels] << 8));
}
return CommandReceiveAction.StopReceiving;
}
public class QueryEventDataReport : ICommandReport
{
public object CallbackObject { get; set; }
public CommandStatus Status { get; set; }
public short[][] data { get; set; }
public QueryEventDataReport(CommandStatus _status, object _cbData)
{
Status = _status;
CallbackObject = _cbData;
}
}
}
public class Trigger : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.Trigger; }
}
const string TriggerCommand = "T";
public Trigger(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public Trigger(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, TriggerCommand);
}
}
}

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Diagnostics;
using DTS.Common.ICommunication;
using DTS.DASLib.Utility;
using DTS.Common.Utilities.Logging;
// Steal it for now
using DTS.DASLib.Command;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class CommandBase : AbstractCommandBase
{
protected CommandPacket command { get { return baseCommand as CommandPacket; } set { baseCommand = value; } }
protected CommandPacket response { get { return baseResponse as CommandPacket; } set { baseResponse = value; } }
public CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock) : base(sock)
{
command = new CommandPacket();
}
public CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) : base(sock, TimeoutMillisec)
{
command = new CommandPacket();
}
public override void CommandToString(ref List<List<string>> lines)
{
base.CommandToString(ref lines);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < command.OriginalBytes.Length; i++)
{
if ((char)command.OriginalBytes[i] != '\n' &&
(char)command.OriginalBytes[i] != '\r')
{
sb.AppendFormat("{0}", (char)command.OriginalBytes[i]);
}
}
lines.Add(new List<string>() { sb.ToString() });
}
public override void ResponseToString(ref List<List<string>> lines)
{
base.ResponseToString(ref lines);
if (null == response || null == response.OriginalBytes)
{
lines.Add(new List<string>() { "Empty response!" });
return;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < Math.Min(30, response.OriginalBytes.Length); i++)
{
if ((char)response.OriginalBytes[i] != '\n' &&
(char)response.OriginalBytes[i] != '\r')
{
sb.AppendFormat("{0}", (char)response.OriginalBytes[i]);
}
}
lines.Add(new List<string>() { sb.ToString() });
}
protected override CommandPacketBase GetCommandPacket()
{
return new CommandPacket();
}
protected override CommandPacketBase GetCommandPacket(byte[] buffer)
{
return new CommandPacket(buffer);
}
}
}

View File

@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Enums.DASFactory;
using DTS.Common.ICommunication;
using DTS.DASLib.Utility;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class DiagnosticsCommands : CommandBase
{
protected enum Commands
{
Reserved = 0x00,
QueryCurrentPositions = 0x01,
};
protected abstract Commands _Command { get; }
protected DiagnosticsCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Type = CommandPacket.CommandType.Diagnostics;
command.SetCommand((byte)_Command, _Command.ToString());
}
protected DiagnosticsCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Type = CommandPacket.CommandType.Diagnostics;
command.SetCommand((byte)_Command, _Command.ToString());
}
}
public class QueryCurrentPositions : DiagnosticsCommands
{
protected override DiagnosticsCommands.Commands _Command
{
get { return Commands.QueryCurrentPositions; }
}
private int _numChannels = 0;
private float[] _Positions;
const string QueryCurrentPositionsCommand = "CURRENT_POSITIONS";
/// <summary>
/// Read-only property to retrieve the number of stack channels being offset.
/// </summary>
public int NumberOfChannels
{
get { return _numChannels; }
}
/// <summary>
/// The list of stack channels to offset.
/// </summary>
/// <summary>
/// The millivolt value that the channel deflected to with the target deflection applied.
/// </summary>
public float[] Positions { get { return _Positions; } }
public QueryCurrentPositions(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryCurrentPositions(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, QueryCurrentPositionsCommand);
}
protected override CommandReceiveAction WholePackage()
{
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
int NumberOfPositions;
response.GetParameter(1, out NumberOfPositions);
_numChannels = NumberOfPositions;
_Positions = new float[NumberOfPositions];
string PositionString;
response.GetParameter(2, out PositionString);
string[] PositionList = PositionString.Split(',');
// Mask firmware problem
if (PositionList[PositionList.Length - 1].Contains(" "))
{
string[] NewPositionList = new string[PositionList.Length + 1];
for (int CurrentPosition = 0; CurrentPosition < PositionList.Length; CurrentPosition++)
{
NewPositionList[CurrentPosition] = PositionList[CurrentPosition];
}
string[] FinalTwoPositions = PositionList[PositionList.Length - 1].Trim().Split(' ');
NewPositionList[NewPositionList.Length - 2] = FinalTwoPositions[0];
NewPositionList[NewPositionList.Length - 1] = FinalTwoPositions[1];
PositionList = NewPositionList;
}
for (int i = 0; i < NumberOfPositions; i++)
{
_Positions[i] = float.Parse(PositionList[i]);
}
}
return CommandReceiveAction.StopReceiving;
}
}
}

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{53ABD0F3-7D8D-43CD-99D7-06C45246D93E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Ribeye_Commands</RootNamespace>
<AssemblyName>Ribeye Commands</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ArmCommands.cs" />
<Compile Include="CalibrationCommands.cs" />
<Compile Include="CommandBase.cs" />
<Compile Include="CommandPacket.cs" />
<Compile Include="InformationCommands.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\DTS.Common.DASResource\DTS.Common.DASResource.csproj">
<Project>{f621ce48-bb4b-4cfc-a325-9410b721cc44}</Project>
<Name>DTS.Common.DASResource</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.ICommunication\DTS.Common.ICommunication.csproj">
<Project>{f57b954e-a49a-4110-b36c-b5abab3e230b}</Project>
<Name>DTS.Common.ICommunication</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
<Name>DTS.Common.Utilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common\DTS.Common.csproj">
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
<Name>DTS.Common</Name>
</ProjectReference>
<ProjectReference Include="..\ICommand\ICommand.csproj">
<Project>{58E70872-8ACC-4957-BB8E-D3746BCC536D}</Project>
<Name>ICommand</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Design\RibeyeCommandsClassDiagram.cd" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DTS.DASLib.Command.Ribeye.ArmCommands" Collapsed="true">
<Position X="7" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.Arm" Collapsed="true">
<Position X="3.75" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAIAAABAAAAAAgABIAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryArmAndTriggerStatus" Collapsed="true">
<Position X="8.25" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAIAAAAAACAAAABIAAAAAAAAAAAAAAEBAAAQ=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.Disarm" Collapsed="true">
<Position X="12.75" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.PrepareForDataCollection" Collapsed="true">
<Position X="1.5" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAEAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.DownloadTestData" Collapsed="true">
<Position X="6" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAoAAACAgEQAAAAAABBICAAAAABAEQAAEAEAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.Trigger" Collapsed="true">
<Position X="10.5" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAACAABIAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.DiagnosticsCommands" Collapsed="true">
<Position X="21.75" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>CalibrationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryCurrentPositions" Collapsed="true">
<Position X="21.75" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AEAAAAAAAQAAAAAgAAAACBIAAAAAAAAAQAAAAEAAAAA=</HashCode>
<FileName>CalibrationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.CommandBase" Collapsed="true">
<Position X="11.5" Y="1" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAEAAAAAAAAAAAAAAAABAAAQAAAAAAAEAAAAAAEA=</HashCode>
<FileName>CommandBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.CommandPacket" Collapsed="true">
<Position X="0.5" Y="5" Width="1.5" />
<TypeIdentifier>
<HashCode>AIAQAQCAAAAAgAAIAAAAAgAAgAARACAAAgACAAAAAAA=</HashCode>
<FileName>CommandPacket.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.DownloadPacket" Collapsed="true">
<Position X="0.5" Y="6.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAA=</HashCode>
<FileName>CommandPacket.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.InformationCommands" Collapsed="true">
<Position X="17.25" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QuerySerialNumber" Collapsed="true">
<Position X="15" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAEAEAAAQAAAAEAAAAA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryNumberOfLEDs" Collapsed="true">
<Position X="17.25" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>QAIAAAAAAAAAAEAAAAAAABIAAAAAAAAAAAAAAEAAAEA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryDataAvailable" Collapsed="true">
<Position X="19.5" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAIAAAEAACAAAAgAAABIAAAAAAAAAAEAAAFIAAAA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

Binary file not shown.

View File

@@ -0,0 +1,409 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.DASResource;
using DTS.Common.Enums.DASFactory;
using DTS.Common.ICommunication;
using DTS.Common.Utilities.Logging;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class ArmCommands : CommandBase
{
protected enum Commands
{
Reserved = 0x00,
Arm = 0x01,
Disarm = 0x02,
QueryArmAndTriggerStatus = 0x03,
PrepareForDataCollection = 0x04,
DownloadTestData = 0x05,
Trigger = 0x06
};
protected abstract Commands _Command { get; }
protected ArmCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Type = CommandPacket.CommandType.Arm;
command.SetCommand((byte)_Command, _Command.ToString());
}
protected ArmCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Type = CommandPacket.CommandType.Arm;
command.SetCommand((byte)_Command, _Command.ToString());
}
}
public class Arm : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.Arm; }
}
const string ArmCommand = "ARM";
public Arm(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public Arm(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[3];
command.SetParameter(0, ArmCommand);
}
public uint TStopMS
{
set
{
command.SetParameter(1, value);
}
}
public uint TPostMS
{
set
{
command.SetParameter(2, value);
}
}
}
public class QueryArmAndTriggerStatus : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.QueryArmAndTriggerStatus; }
}
string StatusCommand = "S";
public QueryArmAndTriggerStatus(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryArmAndTriggerStatus(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, StatusCommand);
}
public bool IsArmed;
public bool IsRecording;
public bool IsTriggered;
enum StatusCodeEnum { Idle = 0x00, Armed = 0x01, Busy = 0x02, DataAvailable = 0x03 };
protected override CommandReceiveAction WholePackage()
{
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
int StatusCode;
if (response.Parameter.Length == 2)
{
response.GetParameter(1, out StatusCode);
switch ((StatusCodeEnum)StatusCode)
{
case StatusCodeEnum.Idle:
IsArmed = false;
IsRecording = false;
IsTriggered = false;
break;
case StatusCodeEnum.Armed:
IsArmed = true;
IsRecording = true;
IsTriggered = false;
break;
case StatusCodeEnum.Busy:
IsArmed = true;
IsRecording = true;
IsTriggered = true;
break;
case StatusCodeEnum.DataAvailable:
default:
IsArmed = false;
IsRecording = false;
IsTriggered = false;
break;
}
}
else
{
}
}
return CommandReceiveAction.StopReceiving;
}
}
public class Disarm : ArmCommands
{
private const string DISARM_COMMAND = "D";
protected override ArmCommands.Commands _Command
{
get { return Commands.Disarm; }
}
public Disarm(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Parameter = new string[1];
command.SetParameter(0, DISARM_COMMAND);
}
public Disarm(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Parameter = new string[1];
command.SetParameter(0, DISARM_COMMAND);
}
}
public class PrepareForDataCollection : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.PrepareForDataCollection; }
}
string EraseCommand = "ERASE";
public PrepareForDataCollection(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public PrepareForDataCollection(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, EraseCommand);
}
}
public class DownloadTestData : ArmCommands
{
// note - this looks like it's using the wrong command, but that's what the code
// was set up to do already, so I preserved it.
protected override ArmCommands.Commands _Command
{
get { return Commands.QueryArmAndTriggerStatus; }
}
string DownloadCommand = "DUMPBIN";
ushort[] _Data;
public DownloadTestData(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public DownloadTestData(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
//command.Command = (byte)Commands.QueryArmAndTriggerStatus;
command.Parameter = new string[3];
command.SetParameter(0, DownloadCommand);
BytesExpected = 0;
}
public ushort[] Data { get { return _Data; } }
public int StartTimeMS
{
set
{
command.SetParameter(1, value);
}
}
public int StopTimeMS
{
set
{
command.SetParameter(2, value);
}
}
private uint _NumberOfChannels;
public uint NumberOfChannels
{
get
{
return _NumberOfChannels;
}
}
private int ExpectedNumberOfSamples;
private uint BytesExpected;
protected override CommandReceiveAction ReceiveBlockOK(Common.Interface.Communication.ICommunicationReport report)
{
lock (_debuglock)
{
if (-1 != current_thread_id)
{
}
current_thread_id = System.Threading.Thread.CurrentThread.ManagedThreadId;
}
CommandDataBuffer.Enqueue(report.Data);
var tempBuffer = CommandDataBuffer.Dequeue(false);
var pState = DownloadPacket.VerifyPacket(tempBuffer, ref BytesExpected);
switch (pState)
{
case CommandPacket.PacketState.OK:
response = new DownloadPacket(tempBuffer);
CommandReceiveAction ret = WholePackage();
if (IsSynchronous)
{
lock (_debuglock) { current_thread_id = -1; }
SyncEvent.Set();
}
else
{
WholePackagePost();
lock (_debuglock) { current_thread_id = -1; }
}
return ret; // ???
case CommandPacket.PacketState.TooShort:
lock (_debuglock) { current_thread_id = -1; }
return DataTooShort(tempBuffer);
case CommandPacket.PacketState.Unknown:
if (!IsSynchronous)
{
lock (_debuglock) { current_thread_id = -1; }
return DataUnknown(report);
}
SyncEvent.Set();
return CommandReceiveAction.StopReceiving;
default:
// "Slice.CommandBase.ReceiveBlockOK: CommandPacket.VerifyPacket returned unknown value {0}"
lock (_debuglock) { current_thread_id = -1; }
throw new ApplicationException(string.Format(Strings.Slice_CommandBase_ReceiveBlockOK_Err1, pState));
}
}
protected override CommandReceiveAction WholePackagePost()
{
// now send the data to the user
var stat = CommandStatus.Success;
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
var s = (int)response.Status;
APILogger.LogString("QueryEventData.WholePackagePost: reporting failure, status==" + CommandPacket.StatusLabels[s] + " (0x" + s.ToString("X") + ")");
stat = CommandStatus.Failure;
}
var cbReport = new QueryEventDataReport(stat, UserCallbackData);
cbReport.data = new short[_NumberOfChannels][];
for (int i = 0; i < _NumberOfChannels; i++)
GetChannelData(i, out cbReport.data[i]);
return UserCallback(cbReport);
}
public void GetChannelData(int channel, out short[] signedADC)
{
if (channel < 0 || channel > _NumberOfChannels)
{
// "QueryEventData.GetChannelData: Data requested on a channel that wasn't downloaded."
throw new ApplicationException(Strings.QueryEventData_GetChannelData_Err1);
}
short[] rv = new short[ExpectedNumberOfSamples];
for (int i = 0; i < rv.Length; i++)
{
rv[i] = (short)(_Data[i * _NumberOfChannels + channel]);
}
signedADC = rv;
}
protected override CommandReceiveAction WholePackage()
{
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
return CommandReceiveAction.StopReceiving;
}
response.GetParameter(1, out _NumberOfChannels);
response.GetParameter(2, out ExpectedNumberOfSamples);
_Data = new ushort[ExpectedNumberOfSamples * _NumberOfChannels];
byte[] ByteArray = (response as DownloadPacket).Data;
for (int i = 0; i < ExpectedNumberOfSamples * _NumberOfChannels; i++)
{
_Data[i] = (ushort)(ByteArray[2 * i + i / _NumberOfChannels] + (ByteArray[2 * i + 1 + i / _NumberOfChannels] << 8));
}
return CommandReceiveAction.StopReceiving;
}
public class QueryEventDataReport : ICommandReport
{
public object CallbackObject { get; set; }
public CommandStatus Status { get; set; }
public short[][] data { get; set; }
public QueryEventDataReport(CommandStatus _status, object _cbData)
{
Status = _status;
CallbackObject = _cbData;
}
}
}
public class Trigger : ArmCommands
{
protected override ArmCommands.Commands _Command
{
get { return Commands.Trigger; }
}
const string TriggerCommand = "T";
public Trigger(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public Trigger(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, TriggerCommand);
}
}
}

View File

@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Enums.DASFactory;
using DTS.Common.ICommunication;
using DTS.DASLib.Utility;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class DiagnosticsCommands : CommandBase
{
protected enum Commands
{
Reserved = 0x00,
QueryCurrentPositions = 0x01,
};
protected abstract Commands _Command { get; }
protected DiagnosticsCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Type = CommandPacket.CommandType.Diagnostics;
command.SetCommand((byte)_Command, _Command.ToString());
}
protected DiagnosticsCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Type = CommandPacket.CommandType.Diagnostics;
command.SetCommand((byte)_Command, _Command.ToString());
}
}
public class QueryCurrentPositions : DiagnosticsCommands
{
protected override DiagnosticsCommands.Commands _Command
{
get { return Commands.QueryCurrentPositions; }
}
private int _numChannels = 0;
private float[] _Positions;
const string QueryCurrentPositionsCommand = "CURRENT_POSITIONS";
/// <summary>
/// Read-only property to retrieve the number of stack channels being offset.
/// </summary>
public int NumberOfChannels
{
get { return _numChannels; }
}
/// <summary>
/// The list of stack channels to offset.
/// </summary>
/// <summary>
/// The millivolt value that the channel deflected to with the target deflection applied.
/// </summary>
public float[] Positions { get { return _Positions; } }
public QueryCurrentPositions(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryCurrentPositions(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, QueryCurrentPositionsCommand);
}
protected override CommandReceiveAction WholePackage()
{
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
int NumberOfPositions;
response.GetParameter(1, out NumberOfPositions);
_numChannels = NumberOfPositions;
_Positions = new float[NumberOfPositions];
string PositionString;
response.GetParameter(2, out PositionString);
string[] PositionList = PositionString.Split(',');
// Mask firmware problem
if (PositionList[PositionList.Length - 1].Contains(" "))
{
string[] NewPositionList = new string[PositionList.Length + 1];
for (int CurrentPosition = 0; CurrentPosition < PositionList.Length; CurrentPosition++)
{
NewPositionList[CurrentPosition] = PositionList[CurrentPosition];
}
string[] FinalTwoPositions = PositionList[PositionList.Length - 1].Trim().Split(' ');
NewPositionList[NewPositionList.Length - 2] = FinalTwoPositions[0];
NewPositionList[NewPositionList.Length - 1] = FinalTwoPositions[1];
PositionList = NewPositionList;
}
for (int i = 0; i < NumberOfPositions; i++)
{
_Positions[i] = float.Parse(PositionList[i]);
}
}
return CommandReceiveAction.StopReceiving;
}
}
}

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Diagnostics;
using DTS.Common.ICommunication;
using DTS.DASLib.Utility;
using DTS.Common.Utilities.Logging;
// Steal it for now
using DTS.DASLib.Command;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class CommandBase : AbstractCommandBase
{
protected CommandPacket command { get { return baseCommand as CommandPacket; } set { baseCommand = value; } }
protected CommandPacket response { get { return baseResponse as CommandPacket; } set { baseResponse = value; } }
public CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock) : base(sock)
{
command = new CommandPacket();
}
public CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) : base(sock, TimeoutMillisec)
{
command = new CommandPacket();
}
public override void CommandToString(ref List<List<string>> lines)
{
base.CommandToString(ref lines);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < command.OriginalBytes.Length; i++)
{
if ((char)command.OriginalBytes[i] != '\n' &&
(char)command.OriginalBytes[i] != '\r')
{
sb.AppendFormat("{0}", (char)command.OriginalBytes[i]);
}
}
lines.Add(new List<string>() { sb.ToString() });
}
public override void ResponseToString(ref List<List<string>> lines)
{
base.ResponseToString(ref lines);
if (null == response || null == response.OriginalBytes)
{
lines.Add(new List<string>() { "Empty response!" });
return;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < Math.Min(30, response.OriginalBytes.Length); i++)
{
if ((char)response.OriginalBytes[i] != '\n' &&
(char)response.OriginalBytes[i] != '\r')
{
sb.AppendFormat("{0}", (char)response.OriginalBytes[i]);
}
}
lines.Add(new List<string>() { sb.ToString() });
}
protected override CommandPacketBase GetCommandPacket()
{
return new CommandPacket();
}
protected override CommandPacketBase GetCommandPacket(byte[] buffer)
{
return new CommandPacket(buffer);
}
}
}

View File

@@ -0,0 +1,384 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DTS.DASLib.Command.Ribeye
{
public class CommandPacket : CommandPacketBase
{
public enum CommandType
{
Reserved = 0x00,
Arm,
Attribute,
Diagnostics,
EventData,
FirmwareUpdate,
Information,
QAandUtility,
Realtime,
};
const int HEADER_SIZE_BYTES = 4;
public string[] Parameter;
byte Checksum = 0;
//public byte[] OriginalBytes;
public CommandPacket()
{
Parameter = new string[0];
ShouldLog = true;
}
public CommandPacket(byte[] Bytes)
{
OriginalBytes = Bytes;
ShouldLog = true;
int ParameterCount = 0;
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
ParameterCount++;
}
}
Parameter = new string[ParameterCount];
int CurrentParameter = 0;
StringBuilder sb = new StringBuilder();
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
Parameter[CurrentParameter] = sb.ToString();
CurrentParameter++;
sb = new StringBuilder();
}
else if ((byte)'\r' != CurrentByte && (byte)'\n' != CurrentByte)
{
sb.Append((char)CurrentByte);
}
}
}
public override PacketState VerifyPacket(byte[] Bytes)
{
if (Bytes == null || '?' == Bytes[0]) // ? is the error indicator
return PacketState.Unknown;
if (Bytes.Length < HEADER_SIZE_BYTES)
return PacketState.TooShort;
// Need to check checksum
if (Bytes[Bytes.Length - 2] == '\r' && Bytes[Bytes.Length - 1] == '\n')
{
return PacketState.OK;
}
else
{
return PacketState.TooShort;
}
}
public override byte[] ToBytes()
{
uint Length;
byte[] CommandBytes;
Length = 0;
foreach (string CurrentParameter in Parameter)
{
if (null != CurrentParameter)
{
Length += (uint)(CurrentParameter.Length + 1);
}
}
Length += (uint)(Checksum.ToString().Length + 2);
CommandBytes = new byte[Length];
int CommandIndex = 0;
foreach (string CurrentParameter in Parameter)
{
foreach (char CurrentChar in CurrentParameter)
{
CommandBytes[CommandIndex] = (byte)CurrentChar;
CommandIndex++;
}
CommandBytes[CommandIndex] = (byte)'#';
CommandIndex++;
}
foreach (char CurrentChar in Checksum.ToString())
{
CommandBytes[CommandIndex] = (byte)CurrentChar;
CommandIndex++;
}
CommandBytes[CommandBytes.Length - 2] = (byte)'\r';
CommandBytes[CommandBytes.Length - 1] = (byte)'\n';
OriginalBytes = CommandBytes;
return CommandBytes;
}
private void ComputeChecksum()
{
Checksum = 0;
foreach (string CurrentParameter in Parameter)
{
foreach (char CurrentCharacter in CurrentParameter)
{
Checksum += (byte)CurrentCharacter;
}
Checksum += (byte)'#';
}
}
public override void ComputeCRCs()
{
ComputeChecksum();
}
private static System.Globalization.CultureInfo InvariantCulture = new System.Globalization.CultureInfo("");
public void GetParameter(int Position, out double Value)
{
Double.TryParse(Parameter[Position], System.Globalization.NumberStyles.Float, InvariantCulture, out Value);
}
public void GetParameter(int Position, out UInt64 Value)
{
UInt64.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out Int64 Value)
{
Int64.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out Int32 Value)
{
Int32.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out UInt32 Value)
{
UInt32.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out Int16 Value)
{
Int16.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out UInt16 Value)
{
UInt16.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out float Value)
{
float.TryParse(Parameter[Position], out Value);
}
public void GetParameter(int Position, out string Value)
{
Value = Parameter[Position];
}
public void SetParameter(int Position, double Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, Int64 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, UInt64 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, Int32 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, UInt32 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, Int16 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, UInt16 Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, float Value)
{
Parameter[Position] = Value.ToString();
}
public void SetParameter(int Position, string Value)
{
Parameter[Position] = Value;
}
public override object ConvertByteToCommandType(byte b)
{
return (CommandType)b;
}
private static UInt16 GlobalSequenceNumber = 0;
private static object GlobalSequenceNumberLock = new object();
public override void GetNextSequenceNumber()
{
lock (GlobalSequenceNumberLock)
{
SequenceNumber = GlobalSequenceNumber;
GlobalSequenceNumber++;
}
}
}
public class DownloadPacket : CommandPacket
{
public byte[] Data;
public DownloadPacket(byte[] Bytes)
{
OriginalBytes = Bytes;
ShouldLog = true;
int ParameterCount = 0;
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
ParameterCount++;
}
if ('\r' == CurrentByte)
{
break;
}
}
Parameter = new string[ParameterCount];
int CurrentParameter = 0;
StringBuilder sb = new StringBuilder();
uint ByteOffset = 0;
foreach (byte CurrentByte in Bytes)
{
if ('#' == CurrentByte)
{
Parameter[CurrentParameter] = sb.ToString();
CurrentParameter++;
sb = new StringBuilder();
}
else if ((byte)'\n' == CurrentByte)
{
break;
}
else
{
sb.Append((char)CurrentByte);
}
ByteOffset++;
}
ByteOffset++;
uint DataLength = (uint)(Bytes.Length - ByteOffset);
Data = new byte[DataLength];
Array.Copy(Bytes, ByteOffset, Data, 0, DataLength);
}
public static PacketState VerifyPacket(byte[] Bytes, ref uint BytesExpected)
{
if (Bytes == null)
return PacketState.Unknown;
if (0 == BytesExpected)
{
string[] Parameter = new string[3];
uint CurrentParameter = 0;
StringBuilder sb = new StringBuilder();
// Look for initial header
foreach (byte CurrentByte in Bytes)
{
try
{
if ('#' == CurrentByte)
{
Parameter[CurrentParameter] = sb.ToString();
CurrentParameter++;
sb = new StringBuilder();
}
else if ((byte)'\r' == CurrentByte || (byte)'\n' == CurrentByte)
{
break;
}
else
{
sb.Append((char)CurrentByte);
}
}
catch (Exception)
{
return PacketState.Unknown;
}
}
if (3 != CurrentParameter)
{
return PacketState.TooShort;
}
else
{
// Parameter 1 = number of channels
// Parameter 2 = number of samples
// + 1 is for checksum on each sample
// * 2 is for 2 bytes per sample
try
{
BytesExpected = (uint)((UInt16.Parse(Parameter[1]) * 2 + 1) * UInt16.Parse(Parameter[2]) + Bytes.Length);
}
catch (Exception)
{
return PacketState.Unknown;
}
if (Bytes.Length >= BytesExpected)
{
return PacketState.OK;
}
else
{
return PacketState.TooShort;
}
}
}
else
{
if (Bytes.Length >= BytesExpected)
{
return PacketState.OK;
}
else
{
return PacketState.TooShort;
}
}
}
}
}

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DTS.DASLib.Command.Ribeye.ArmCommands" Collapsed="true">
<Position X="7" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.Arm" Collapsed="true">
<Position X="3.75" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAIAAABAAAAAAgABIAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryArmAndTriggerStatus" Collapsed="true">
<Position X="8.25" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAIAAAAAACAAAABIAAAAAAAAAAAAAAEBAAAQ=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.Disarm" Collapsed="true">
<Position X="12.75" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.PrepareForDataCollection" Collapsed="true">
<Position X="1.5" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAEAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.DownloadTestData" Collapsed="true">
<Position X="6" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAoAAACAgEQAAAAAABBICAAAAABAEQAAEAEAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.Trigger" Collapsed="true">
<Position X="10.5" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAACAABIAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ArmCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.DiagnosticsCommands" Collapsed="true">
<Position X="21.75" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>CalibrationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryCurrentPositions" Collapsed="true">
<Position X="21.75" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AEAAAAAAAQAAAAAgAAAACBIAAAAAAAAAQAAAAEAAAAA=</HashCode>
<FileName>CalibrationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.CommandBase" Collapsed="true">
<Position X="11.5" Y="1" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAEAAAAAAAAAAAAAAAABAAAQAAAAAAAEAAAAAAEA=</HashCode>
<FileName>CommandBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.CommandPacket" Collapsed="true">
<Position X="0.5" Y="5" Width="1.5" />
<TypeIdentifier>
<HashCode>AIAQAQCAAAAAgAAIAAAAAgAAgAARACAAAgACAAAAAAA=</HashCode>
<FileName>CommandPacket.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.DownloadPacket" Collapsed="true">
<Position X="0.5" Y="6.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAA=</HashCode>
<FileName>CommandPacket.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.InformationCommands" Collapsed="true">
<Position X="17.25" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QuerySerialNumber" Collapsed="true">
<Position X="15" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAEAEAAAQAAAAEAAAAA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryNumberOfLEDs" Collapsed="true">
<Position X="17.25" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>QAIAAAAAAAAAAEAAAAAAABIAAAAAAAAAAAAAAEAAAEA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Ribeye.QueryDataAvailable" Collapsed="true">
<Position X="19.5" Y="4" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAIAAAEAACAAAAgAAABIAAAAAAAAAAEAAAFIAAAA=</HashCode>
<FileName>InformationCommands.cs</FileName>
</TypeIdentifier>
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Enums.DASFactory;
using DTS.Common.ICommunication;
namespace DTS.DASLib.Command.Ribeye
{
public abstract class InformationCommands : CommandBase
{
protected enum Commands
{
Reserved = 0x00,
QueryNumberOfLEDs = 0x01,
QueryDataAvailable = 0x02,
QuerySerialNumber = 0x03
};
protected abstract Commands _Command { get; }
protected InformationCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Type = CommandPacket.CommandType.Information;
command.SetCommand((byte)_Command, _Command.ToString());
}
protected InformationCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Type = CommandPacket.CommandType.Information;
command.SetCommand((byte)_Command, _Command.ToString());
}
}
/*
public class QueryProtocolVersion : InformationCommands
{
protected override InformationCommands.Commands _Command
{
get {
}
byte _versionbyte = (byte)0;
public int Version { get { return _versionbyte; } }
public QueryProtocolVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
// this.command.Command = (byte)Commands.QueryProtocolVersion;
}
public QueryProtocolVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
// this.command.Command = (byte)Commands.QueryProtocolVersion;
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
// response.GetParameter(0, out _versionbyte);
}
return CommandReceiveAction.StopReceiving;
}
public override string CommandToString()
{
var sb = new StringBuilder();
return sb.ToString();
}
public override string ResponseToString()
{
var sb = new StringBuilder();
sb.AppendLine();
sb.AppendFormat(" Status: {0}, Version: {1}", ResponseStatus, Version);
return sb.ToString();
}
}
*/
/*
public class QueryFirmwareVersion : InformationCommands
{
string _versionstring = string.Empty;
public string Version { get { return _versionstring; } }
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
// this.command.Command = (byte)Commands.QueryFirmwareVersion;
}
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
// this.command.Command = (byte)Commands.QueryFirmwareVersion;
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
response.GetParameter(0, out _versionstring);
}
return CommandReceiveAction.StopReceiving;
}
public override string CommandToString()
{
var sb = new StringBuilder();
return sb.ToString();
}
public override string ResponseToString()
{
var sb = new StringBuilder();
sb.AppendLine();
sb.AppendFormat(" Status: {0}, Version: {1}", ResponseStatus, Version);
return sb.ToString();
}
}
*/
public class QuerySerialNumber : InformationCommands
{
// note - the existing implementation doesn't set a command for this
// class, so I will preserve that by changing it not to be set
// in the parent class for this one instance
protected override InformationCommands.Commands _Command
{
get { return Commands.QuerySerialNumber; }
}
string _serialnumber = string.Empty;
const string SerialNumberCommand = "SERIAL_NUMBER";
public string SerialNumber { get { return _serialnumber; } }
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
command.Parameter = new string[1];
command.SetParameter(0, SerialNumberCommand);
}
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
command.Parameter = new string[1];
command.SetParameter(0, SerialNumberCommand);
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
try
{
response.GetParameter(1, out _serialnumber);
}
catch (Exception e)
{
e.ToString();
}
}
return CommandReceiveAction.StopReceiving;
}
}
public class QueryNumberOfLEDs : InformationCommands
{
protected override InformationCommands.Commands _Command
{
get { return Commands.QueryNumberOfLEDs; }
}
uint _numberOfLEDs = 0;
const string NumberOfLEDsCommand = "HOW_MANY_LEDS";
public uint NumberOfLEDs { get { return _numberOfLEDs; } }
public QueryNumberOfLEDs(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryNumberOfLEDs(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
command.Parameter = new string[1];
command.SetParameter(0, NumberOfLEDsCommand);
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
response.GetParameter(1, out _numberOfLEDs);
}
return CommandReceiveAction.StopReceiving;
}
public override void ResponseToString(ref List<List<string>> lines)
{
base.ResponseToString(ref lines);
lines.Add(new List<string>()
{
string.Format("NumberOfLEDs: {0}", NumberOfLEDs)
});
}
}
public class QueryDataAvailable : InformationCommands
{
//a note - I'm preserving the existing code that was using the command
//querynumberofled's - but I'm thinking it probably should have been using
//querydataavailable ...
protected override InformationCommands.Commands _Command
{
get { return Commands.QueryNumberOfLEDs; }
}
float _totalMS = 0;
float _preTriggerMS = 0;
float _postTriggerMS = 0;
const string DumpInfoCommand = "DUMPINFO";
public float TotalMS { get { return _totalMS; } }
public float PreTriggerMS { get { return _preTriggerMS; } }
public float PostTriggerMS { get { return _postTriggerMS; } }
public QueryDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock)
: base(sock)
{
InitializeMembers();
}
public QueryDataAvailable(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
: base(sock, TimeoutMillisec)
{
InitializeMembers();
}
private void InitializeMembers()
{
//is this really the right command? - it doesn't match the name
//this.command.Command = (byte)Commands.QueryNumberOfLEDs;
command.Parameter = new string[1];
command.SetParameter(0, DumpInfoCommand);
}
protected override CommandReceiveAction WholePackage()
{
// we have a whole package
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
{
int NegativePreTriggerMS;
response.GetParameter(1, out NegativePreTriggerMS);
_preTriggerMS = Math.Abs(NegativePreTriggerMS);
response.GetParameter(2, out _postTriggerMS);
_totalMS = _postTriggerMS + _preTriggerMS;
}
return CommandReceiveAction.StopReceiving;
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Ribeye Commands")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ribeye Commands")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d846da1f-f9e7-45a2-a4ac-354b1b06cae1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.06.0081")]
[assembly: AssemblyFileVersion("1.06.0081")]

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{53ABD0F3-7D8D-43CD-99D7-06C45246D93E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Ribeye_Commands</RootNamespace>
<AssemblyName>Ribeye Commands</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ArmCommands.cs" />
<Compile Include="CalibrationCommands.cs" />
<Compile Include="CommandBase.cs" />
<Compile Include="CommandPacket.cs" />
<Compile Include="InformationCommands.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\DTS.Common.DASResource\DTS.Common.DASResource.csproj">
<Project>{f621ce48-bb4b-4cfc-a325-9410b721cc44}</Project>
<Name>DTS.Common.DASResource</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.ICommunication\DTS.Common.ICommunication.csproj">
<Project>{f57b954e-a49a-4110-b36c-b5abab3e230b}</Project>
<Name>DTS.Common.ICommunication</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
<Name>DTS.Common.Utilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common\DTS.Common.csproj">
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
<Name>DTS.Common</Name>
</ProjectReference>
<ProjectReference Include="..\ICommand\ICommand.csproj">
<Project>{58E70872-8ACC-4957-BB8E-D3746BCC536D}</Project>
<Name>ICommand</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Design\RibeyeCommandsClassDiagram.cd" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]