init
This commit is contained in:
@@ -0,0 +1,534 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.ICommunication;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
|
||||
namespace DTS.DASLib.Command.SLICEDB
|
||||
{
|
||||
public abstract class InformationCommands : CommandBase
|
||||
{
|
||||
protected enum Commands
|
||||
{
|
||||
Reserved = 0x00,
|
||||
QuerySerialNumber = 0x01,
|
||||
SetSerialNumber = 0x02,
|
||||
QueryFirmwareVersion = 0x03,
|
||||
QueryTime = 0x04,
|
||||
SetTime = 0x05,
|
||||
QueryDebugLevel = 0x06,
|
||||
SetDebugLevel = 0x07,
|
||||
QueryKernelVersion = 0x08,
|
||||
QueryMSPFirmwareVersion = 0x09,
|
||||
QueryProtocolVersion = 0x0A,
|
||||
QueryCalibrationDaysSince1970_01_01 = 0x0F,
|
||||
SetCalibrationDaysSince1970_01_01 = 0x10,
|
||||
};
|
||||
|
||||
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 override void CommandToString(ref List<List<string>> list)
|
||||
{
|
||||
base.CommandToString(ref list);
|
||||
if (null != recorder)
|
||||
{
|
||||
list[0].Add(recorder.SerialNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class QuerySerialNumber : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QuerySerialNumber; }
|
||||
}
|
||||
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QuerySerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _value;
|
||||
|
||||
/// <summary>
|
||||
/// The serial number of the SLICE DB
|
||||
/// </summary>
|
||||
public string SerialNumber
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Serial Number: {0}", SerialNumber)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SetSerialNumber : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.SetSerialNumber; }
|
||||
}
|
||||
public SetSerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetSerialNumber(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _value;
|
||||
|
||||
/// <summary>
|
||||
/// The serial number of the SLICE DB
|
||||
/// </summary>
|
||||
public string SerialNumber
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
// Allocate parameter array (+1 for terminating null)
|
||||
command.Parameter = new byte[value.Length + 1];
|
||||
command.SetParameter(0, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string>() { string.Format("Serial Number: {0}", SerialNumber) });
|
||||
}
|
||||
|
||||
}
|
||||
public class SetCalibrationDaysSince1970_01_01 : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.SetCalibrationDaysSince1970_01_01; }
|
||||
}
|
||||
public SetCalibrationDaysSince1970_01_01(ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetCalibrationDaysSince1970_01_01(ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _value;
|
||||
|
||||
/// <summary>
|
||||
/// The serial number of the SLICE DB
|
||||
/// </summary>
|
||||
public string CalibrationDaysSince1970_01_01
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
// Allocate parameter array (+1 for terminating null)
|
||||
command.Parameter = new byte[value.Length + 1];
|
||||
command.SetParameter(0, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string>() { string.Format("CalibrationDaysSince1970_01_01: {0}", CalibrationDaysSince1970_01_01) });
|
||||
}
|
||||
|
||||
}
|
||||
public class QueryFirmwareVersion : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryFirmwareVersion; }
|
||||
}
|
||||
|
||||
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _value;
|
||||
|
||||
/// <summary>
|
||||
/// The current firmware version of the SLICE DB.
|
||||
/// </summary>
|
||||
public string FirmwareVersion
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Firmware Version: {0}", FirmwareVersion)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryTime : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryTime; }
|
||||
}
|
||||
|
||||
public QueryTime(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryTime(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private DateTime _value;
|
||||
|
||||
/// <summary>
|
||||
/// The current time according to the SLICE DB.
|
||||
/// </summary>
|
||||
public DateTime CurrentTime
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
_value = new DateTime(1970, 1, 1);
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
const int SecondsPosition = 0;
|
||||
const int MicrosecondsPosition = 4;
|
||||
UInt32 seconds, microseconds;
|
||||
response.GetParameter(SecondsPosition, out seconds);
|
||||
response.GetParameter(MicrosecondsPosition, out microseconds);
|
||||
_value = _value.AddMilliseconds(microseconds / 1000);
|
||||
_value = _value.AddSeconds(seconds);
|
||||
}
|
||||
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Current Time: {0}", CurrentTime.ToLongDateString() + " " + CurrentTime.ToLongTimeString())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SetTime : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.SetTime; }
|
||||
}
|
||||
public SetTime(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetTime(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private DateTime _value;
|
||||
|
||||
/// <summary>
|
||||
/// The current time according to the SLICE DB.
|
||||
/// </summary>
|
||||
public DateTime CurrentTime
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
const int ParameterLength = 8;
|
||||
const int SecondsPosition = 0;
|
||||
const int MicrosecondsPosition = 4;
|
||||
_value = value;
|
||||
DateTime epoch = new DateTime(1970, 1, 1);
|
||||
TimeSpan sinceEpoch = _value - epoch;
|
||||
double dSecondsSinceEpoch = sinceEpoch.TotalSeconds;
|
||||
UInt32 secondsSinceEpoch = (UInt32)dSecondsSinceEpoch;
|
||||
UInt32 microsecondsSinceEpoch = (UInt32)((dSecondsSinceEpoch - secondsSinceEpoch) * 1000000.0 + 0.5);
|
||||
command.Parameter = new byte[ParameterLength];
|
||||
command.SetParameter(SecondsPosition, secondsSinceEpoch);
|
||||
command.SetParameter(MicrosecondsPosition, microsecondsSinceEpoch);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string>() { string.Format("Current Time: {0}", CurrentTime.ToLongDateString() + " " + CurrentTime.ToLongTimeString()) });
|
||||
}
|
||||
}
|
||||
public class QueryProtocolVersion : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryProtocolVersion; }
|
||||
}
|
||||
|
||||
public QueryProtocolVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryProtocolVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private byte _value;
|
||||
|
||||
/// <summary>
|
||||
/// The current protocol version of the SLICE DB.
|
||||
/// </summary>
|
||||
public byte ProtocolVersion
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = 0;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Firmware Version: {0}", ProtocolVersion)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryKernelVersion : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryKernelVersion; }
|
||||
}
|
||||
|
||||
public QueryKernelVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryKernelVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _value;
|
||||
|
||||
/// <summary>
|
||||
/// The current Kernel firmware version of the SLICE DB.
|
||||
/// </summary>
|
||||
public string KernelFirmwareVersion
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Firmware Version: {0}", KernelFirmwareVersion)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//FB 16049 Support ECM Cal date query
|
||||
public class QueryCalibrationDaysSince1970_01_01 : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryCalibrationDaysSince1970_01_01; }
|
||||
}
|
||||
public QueryCalibrationDaysSince1970_01_01(ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryCalibrationDaysSince1970_01_01(ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _value;
|
||||
|
||||
/// <summary>
|
||||
/// The serial number of the SLICE DB
|
||||
/// </summary>
|
||||
public string CalibrationDaysSince1970_01_01
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("QueryCalibrationDaysSince1970_01_01: {0}", CalibrationDaysSince1970_01_01)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryMSPFirmwareVersion : InformationCommands
|
||||
{
|
||||
protected override InformationCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryMSPFirmwareVersion; }
|
||||
}
|
||||
|
||||
public QueryMSPFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryMSPFirmwareVersion(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _value;
|
||||
|
||||
/// <summary>
|
||||
/// The current MSP firmware version of the SLICE DB.
|
||||
/// </summary>
|
||||
public string MSPFirmwareVersion
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Firmware Version: {0}", MSPFirmwareVersion)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user