1629 lines
57 KiB
C#
1629 lines
57 KiB
C#
using DTS.Common.ICommunication;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DTS.DASLib.Command.TDAS
|
|
{
|
|
|
|
public class GenericTDASCommandString : CommandString
|
|
{
|
|
private string genericCommand;
|
|
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "Generic TDAS Command "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return genericCommand; }
|
|
}
|
|
public GenericTDASCommandString(string command)
|
|
{
|
|
genericCommand = command;
|
|
}
|
|
}
|
|
|
|
public class GenericTDASCommand : CommandBase
|
|
{
|
|
private GenericTDASCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as GenericTDASCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private Object _GenericResponse;
|
|
public Object GenericResponse
|
|
{
|
|
get { return _GenericResponse; }
|
|
}
|
|
|
|
public GenericTDASCommand(DTS.Common.Interface.DASFactory.ICommunication sock, string cmd)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new GenericTDASCommandString(cmd));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
command.RackSerialNumber = base.RackSerialNumber;
|
|
}
|
|
public GenericTDASCommand(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout, string cmd)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new GenericTDASCommandString(cmd));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start = s.IndexOf("ERR");
|
|
if (start > -1)
|
|
System.Diagnostics.Debug.Assert(false, "Error found in response of GenericTDASCommand!\n\n"
|
|
+ s);
|
|
start = s.IndexOf(": ");
|
|
int end = s.LastIndexOf("\r\n");
|
|
// this was added for Serial Comm
|
|
_responseData = command.ToCommandString().Remove(command.ToCommandString().Length - 2, 2) + s.Substring(start, end - start);
|
|
_GenericResponse = s.Substring(start, end - start);
|
|
}
|
|
}
|
|
|
|
public class TestCalDACCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "Test Calibration DAC "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "TC"; }
|
|
}
|
|
public TestCalDACCommandString()
|
|
{
|
|
}
|
|
}
|
|
|
|
public class TestCalDAC : CommandBase
|
|
{
|
|
private TestCalDACCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as TestCalDACCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private double _CalDACLow;
|
|
public double CalDACLow
|
|
{
|
|
get { return _CalDACLow; }
|
|
}
|
|
|
|
private double _CalDACHigh;
|
|
public double CalDACHigh
|
|
{
|
|
get { return _CalDACHigh; }
|
|
}
|
|
|
|
private double _CalDACDelta;
|
|
public double CalDACDelta
|
|
{
|
|
get { return _CalDACDelta; }
|
|
}
|
|
|
|
public TestCalDAC(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestCalDACCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestCalDAC(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestCalDACCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start = s.IndexOf("TC:");
|
|
int end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
int csLength = command.GetCommandString(0).Length + 2;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
string[] data = ResponseData.Split(' ');
|
|
|
|
if (0 < data.Length)
|
|
{
|
|
_CalDACLow = Convert.ToDouble(data[0]) * 1000D;
|
|
_CalDACHigh = Convert.ToDouble(data[1]) * 1000D;
|
|
_CalDACDelta = Convert.ToDouble(data[2]) * 1000D;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class TestRailsCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "Test Rails "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "TR"; }
|
|
}
|
|
public TestRailsCommandString()
|
|
{
|
|
}
|
|
}
|
|
|
|
public class TestRails : CommandBase
|
|
{
|
|
|
|
private TestRailsCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as TestRailsCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private double[] _Rails;
|
|
public double[] Rails
|
|
{
|
|
get { return _Rails; }
|
|
}
|
|
|
|
public TestRails(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestRailsCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestRails(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestRailsCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start = s.IndexOf("TR:");
|
|
int end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
int csLength = command.GetCommandString(0).Length + 2;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
string[] data = ResponseData.Split(' ');
|
|
|
|
if (0 < data.Length)
|
|
{
|
|
_Rails = new double[data.Length];
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
_Rails[i] = Convert.ToDouble(data[i]) * 1000D;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public class TestMemoryCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "Test Memory "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "TM"; }
|
|
}
|
|
public TestMemoryCommandString()
|
|
{
|
|
}
|
|
}
|
|
|
|
public class TestMemory : CommandBase
|
|
{
|
|
private TestMemoryCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as TestMemoryCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private string _MemoryTestResult;
|
|
public string MemoryTestResult
|
|
{
|
|
get { return _MemoryTestResult; }
|
|
}
|
|
|
|
public TestMemory(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestMemoryCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestMemory(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestMemoryCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
|
|
// old fw: "NONE|0TM: W P\r\n"
|
|
// new fw: "NONE|0TMW Test Pattern:1 Pass/Fail:P\r\n"
|
|
|
|
int end = s.LastIndexOf("\r\n");
|
|
int start = end - 1;
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
int csLength = command.GetCommandString(0).Length;
|
|
_responseData = s.Substring(start, end - start);
|
|
_MemoryTestResult = _responseData;
|
|
//string[] data = ResponseData.Split(' ');
|
|
|
|
//if (0 < data.Length)
|
|
//{
|
|
// _MemoryTestResult = data[1];
|
|
//}
|
|
}
|
|
}
|
|
|
|
public class TestDiagnoseRunCommandString : CommandString
|
|
{
|
|
public enum TestType
|
|
{
|
|
Pre,
|
|
Post
|
|
}
|
|
private TestType _testType = TestType.Pre;
|
|
public TestType Type { get { return _testType; } set { _testType = value; } }
|
|
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "Test Diagnose Run "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get
|
|
{
|
|
if (_testType == TestType.Pre)
|
|
return "TEST DIAG RUN PRE";
|
|
else
|
|
return "TEST DIAG RUN POST";
|
|
}
|
|
}
|
|
public override byte[] GetParameters()
|
|
{
|
|
switch (Type)
|
|
{
|
|
case TestType.Pre:
|
|
return ASCIIEncoding.ASCII.GetBytes(string.Format(" PRE "));
|
|
case TestType.Post:
|
|
return ASCIIEncoding.ASCII.GetBytes(string.Format(" POST "));
|
|
default:
|
|
throw new NotSupportedException("Unknown Test type " + Type.ToString());
|
|
}
|
|
}
|
|
public TestDiagnoseRunCommandString()
|
|
{
|
|
}
|
|
public TestDiagnoseRunCommandString(TestType type)
|
|
{
|
|
_testType = type;
|
|
}
|
|
}
|
|
public class TestDiagnoseRun : CommandBase
|
|
{
|
|
private TestDiagnoseRunCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as TestDiagnoseRunCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
public bool RackCommand
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).RackCommand; }
|
|
set { (baseCommand as TDASCommandPacketBase).RackCommand = value; _commandString.RackCommand = true; }
|
|
}
|
|
|
|
public TestDiagnoseRun(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseRunCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestDiagnoseRun(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseRunCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
public TestDiagnoseRun(DTS.Common.Interface.DASFactory.ICommunication sock, DTS.DASLib.Command.TDAS.TestDiagnoseRunCommandString.TestType type)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseRunCommandString(type));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start = s.IndexOf("TEST: DIAGNOSTIC RUN");
|
|
int end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
int csLength = command.GetCommandString(0).Length + 4;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
if (ResponseData.IndexOf("ERR") >= 0) { throw new CommandException(CommandErrorReason.InvalidMode, ResponseData); }
|
|
}
|
|
}
|
|
|
|
|
|
public class TestDiagnoseReadCommandString : CommandString
|
|
{
|
|
public enum TestType
|
|
{
|
|
Pre,
|
|
Post
|
|
}
|
|
|
|
private TestType _testType = TestType.Pre;
|
|
public TestType Type { get { return _testType; } set { _testType = value; } }
|
|
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "Test Diagnose Read "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "TEST DIAG READ"; }
|
|
}
|
|
public override byte[] GetParameters()
|
|
{
|
|
switch (Type)
|
|
{
|
|
case TestType.Pre:
|
|
return ASCIIEncoding.ASCII.GetBytes(string.Format(" PRE "));
|
|
case TestType.Post:
|
|
return ASCIIEncoding.ASCII.GetBytes(string.Format(" POST "));
|
|
default:
|
|
throw new NotSupportedException("Unknown Test type " + Type.ToString());
|
|
}
|
|
}
|
|
public TestDiagnoseReadCommandString()
|
|
{
|
|
}
|
|
public TestDiagnoseReadCommandString(TestType type)
|
|
{
|
|
_testType = type;
|
|
}
|
|
}
|
|
|
|
|
|
public class TestDiagnoseRead : CommandBase
|
|
{
|
|
private TestDiagnoseReadCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as TestDiagnoseReadCommandString;
|
|
}
|
|
}
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private double _battery;
|
|
public double Battery
|
|
{
|
|
get { return _battery; }
|
|
set { _battery = value; }
|
|
}
|
|
|
|
private double _posFiveVolts;
|
|
public double PosFiveVolts
|
|
{
|
|
get { return _posFiveVolts; }
|
|
set { _posFiveVolts = value; }
|
|
}
|
|
|
|
private double _negFiveVolts;
|
|
public double NegFiveVolts
|
|
{
|
|
get { return _negFiveVolts; }
|
|
set { _negFiveVolts = value; }
|
|
}
|
|
|
|
private double _posEightVolts;
|
|
public double PosEightVolts
|
|
{
|
|
get { return _posEightVolts; }
|
|
set { _posEightVolts = value; }
|
|
}
|
|
|
|
private double _negEightVolts;
|
|
public double NegEightVolts
|
|
{
|
|
get { return _negEightVolts; }
|
|
set { _negEightVolts = value; }
|
|
}
|
|
|
|
private double _calDAC;
|
|
public double CalDAC
|
|
{
|
|
get { return _calDAC; }
|
|
set { _calDAC = value; }
|
|
}
|
|
|
|
private string _externalMemory;
|
|
public string ExternalMemory
|
|
{
|
|
get { return _externalMemory; }
|
|
set { _externalMemory = value; }
|
|
}
|
|
|
|
public TestDiagnoseRead(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseReadCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestDiagnoseRead(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseReadCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestDiagnoseRead(DTS.Common.Interface.DASFactory.ICommunication sock, DTS.DASLib.Command.TDAS.TestDiagnoseReadCommandString.TestType type)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseReadCommandString(type));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
private enum ResponseFields
|
|
{
|
|
battery = 0,
|
|
posFiveVolts,
|
|
negFiveVolts,
|
|
posEightVolts,
|
|
negEightVolts,
|
|
calDAC,
|
|
ExternalMemory
|
|
}
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start = s.IndexOf("TEST: DIAGNOSTIC READ");
|
|
int end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
int csLength = command.GetCommandString(0).Length + 12;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
string[] data = ResponseData.Split(' ');
|
|
for (int i = 0; i < data.Length; i++)
|
|
{
|
|
ResponseFields field = (ResponseFields)i;
|
|
switch (field)
|
|
{
|
|
case ResponseFields.battery:
|
|
_battery = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.posFiveVolts:
|
|
_posFiveVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.negFiveVolts:
|
|
_negFiveVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.posEightVolts:
|
|
_posEightVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.negEightVolts:
|
|
_negEightVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.calDAC:
|
|
_calDAC = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.ExternalMemory:
|
|
_externalMemory = data[i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public class TestDiagnoseTomRead : CommandBase
|
|
{
|
|
private TestDiagnoseReadCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as TestDiagnoseReadCommandString;
|
|
}
|
|
}
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private double _battery;
|
|
public double Battery
|
|
{
|
|
get { return _battery; }
|
|
set { _battery = value; }
|
|
}
|
|
|
|
private double _APosFiveVolts;
|
|
public double APosFiveVolts
|
|
{
|
|
get { return _APosFiveVolts; }
|
|
set { _APosFiveVolts = value; }
|
|
}
|
|
|
|
private double _ANegFiveVolts;
|
|
public double ANegFiveVolts
|
|
{
|
|
get { return _ANegFiveVolts; }
|
|
set { _ANegFiveVolts = value; }
|
|
}
|
|
|
|
private double _SPosFiveVolts;
|
|
public double SPosFiveVolts
|
|
{
|
|
get { return _SPosFiveVolts; }
|
|
set { _SPosFiveVolts = value; }
|
|
}
|
|
|
|
private double _SNegFiveVolts;
|
|
public double SNegFiveVolts
|
|
{
|
|
get { return _SNegFiveVolts; }
|
|
set { _SNegFiveVolts = value; }
|
|
}
|
|
|
|
private double _BatteryVolts;
|
|
public double BatteryVolts
|
|
{
|
|
get { return _BatteryVolts; }
|
|
set { _BatteryVolts = value; }
|
|
}
|
|
|
|
private double _CapacitorVoltage;
|
|
public double CapacitorVoltage
|
|
{
|
|
get { return _CapacitorVoltage; }
|
|
set { _CapacitorVoltage = value; }
|
|
}
|
|
|
|
private string _externalMemory;
|
|
public string ExternalMemory
|
|
{
|
|
get { return _externalMemory; }
|
|
set { _externalMemory = value; }
|
|
}
|
|
|
|
public TestDiagnoseTomRead(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseReadCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestDiagnoseTomRead(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseReadCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public TestDiagnoseTomRead(DTS.Common.Interface.DASFactory.ICommunication sock, DTS.DASLib.Command.TDAS.TestDiagnoseReadCommandString.TestType type)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new TestDiagnoseReadCommandString(type));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
private enum ResponseFields
|
|
{
|
|
battery = 0,
|
|
APosFiveVolts,
|
|
ANegFiveVolts,
|
|
SPosFiveVolts,
|
|
SNegFiveVolts,
|
|
TenVolts,
|
|
CapacitorVoltage,
|
|
ExternalMemory
|
|
}
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start = s.IndexOf("TEST: DIAGNOSTIC READ");
|
|
int end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
int csLength = command.GetCommandString(0).Length + 12;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
string[] data = ResponseData.Split(' ');
|
|
for (int i = 0; i < data.Length; i++)
|
|
{
|
|
ResponseFields field = (ResponseFields)i;
|
|
switch (field)
|
|
{
|
|
case ResponseFields.battery:
|
|
_battery = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.APosFiveVolts:
|
|
_APosFiveVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.ANegFiveVolts:
|
|
_ANegFiveVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.SPosFiveVolts:
|
|
_SPosFiveVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.SNegFiveVolts:
|
|
_SNegFiveVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.TenVolts:
|
|
_BatteryVolts = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.CapacitorVoltage:
|
|
_CapacitorVoltage = double.Parse(data[i]);
|
|
break;
|
|
case ResponseFields.ExternalMemory:
|
|
_externalMemory = data[i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public class ReadMIFParameterCommandString : CommandString
|
|
{
|
|
private string command;
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "Read MIF '" + command + "' "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return command; }
|
|
}
|
|
public ReadMIFParameterCommandString()
|
|
{
|
|
command = "?N"; // defalt is serial Number
|
|
}
|
|
public ReadMIFParameterCommandString(string cmd)
|
|
{
|
|
command = cmd;
|
|
}
|
|
public ReadMIFParameterCommandString(string cmd, bool isRack)
|
|
{
|
|
command = cmd;
|
|
RackCommand = isRack;
|
|
}
|
|
}
|
|
|
|
public class ReadMIFParameter : CommandBase
|
|
{
|
|
private ReadMIFParameterCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as ReadMIFParameterCommandString;
|
|
}
|
|
}
|
|
|
|
public bool SingleModule
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).SingleModuleCommand; }
|
|
set { (baseCommand as TDASCommandPacketBase).SingleModuleCommand = value; }
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private string _MIF;
|
|
public string MIF
|
|
{
|
|
get { return _MIF; }
|
|
}
|
|
|
|
public ReadMIFParameter(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadMIFParameterCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
command.RackSerialNumber = base.RackSerialNumber;
|
|
}
|
|
public ReadMIFParameter(DTS.Common.Interface.DASFactory.ICommunication sock, string cmd, bool isRack)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadMIFParameterCommandString(cmd, isRack));
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
command.RackSerialNumber = base.RackSerialNumber;
|
|
command.RackCommand = isRack;
|
|
baseCommand = command;
|
|
}
|
|
public ReadMIFParameter(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout, string cmd)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadMIFParameterCommandString(cmd));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
command.RackSerialNumber = base.RackSerialNumber;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start, end, csLength;
|
|
string[] data = null;
|
|
start = end = csLength = 0;
|
|
|
|
if (command.GetCommandString(0).Contains("?GS "))
|
|
{
|
|
// do something here for static gain parameters...
|
|
start = s.IndexOf("GS: ");
|
|
if (start < 0)
|
|
{
|
|
// bad response detected
|
|
start = s.LastIndexOf("\0") + 2;
|
|
end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
_responseData = s.Substring(start, end - start);
|
|
data = ResponseData.Trim().Split(' ');
|
|
}
|
|
else
|
|
{
|
|
end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
_responseData = s.Substring(start, end - start);
|
|
data = ResponseData.Trim().Split(' ');
|
|
}
|
|
}
|
|
else if (command.GetCommandString(0).Contains("FLASH") ||
|
|
command.GetCommandString(0).Contains("fpget"))
|
|
{
|
|
start = command.GetCommandString(0).Contains("FLASH") ? s.IndexOf("FLASH") : s.IndexOf("FPGET");
|
|
if (start < 0)
|
|
{
|
|
// bad response detected
|
|
start = s.LastIndexOf("\0") + 2;
|
|
end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
_responseData = s.Substring(start, end - start);
|
|
data = ResponseData.Trim().Split(' ');
|
|
}
|
|
else
|
|
{
|
|
end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
_responseData = s.Substring(start, end - start);
|
|
data = ResponseData.Trim().Split(' ');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
start = s.IndexOf(command.GetCommandString(0)) + 1;
|
|
_commandString.GetCommandPortion();
|
|
end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
csLength = command.GetCommandString(0).Length;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
//_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
data = ResponseData.Trim().Split(' ');
|
|
}
|
|
|
|
if (0 < data.Length)
|
|
{
|
|
_MIF = ResponseData.Trim();
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ReadEntireMIFCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "?? Query Entire MIF "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "??"; }
|
|
}
|
|
public ReadEntireMIFCommandString()
|
|
{
|
|
}
|
|
}
|
|
|
|
public class ReadEntireMIF : CommandBase
|
|
{
|
|
private ReadEntireMIFCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as ReadEntireMIFCommandString;
|
|
}
|
|
}
|
|
|
|
public bool SingleModule
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).SingleModuleCommand; }
|
|
set { (baseCommand as TDASCommandPacketBase).SingleModuleCommand = value; }
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private Dictionary<string, object> _MIF;
|
|
public Dictionary<string, object> MIF
|
|
{
|
|
get { return _MIF; }
|
|
}
|
|
|
|
public ReadEntireMIF(DTS.Common.Interface.DASFactory.ICommunication sock, int linesExpected)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadEntireMIFCommandString());
|
|
command.ExpectsMultipleLines = true;
|
|
command.LinesExpected = linesExpected;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
public ReadEntireMIF(DTS.Common.Interface.DASFactory.ICommunication sock, int linesExpected, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadEntireMIFCommandString());
|
|
command.ExpectsMultipleLines = true;
|
|
command.LinesExpected = linesExpected;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
|
|
string[] lines = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
|
List<string> Lines = lines.ToList();
|
|
Lines.RemoveAt(0); // remove the response to the command "??:"
|
|
_responseData = s;
|
|
|
|
// do somehting here to fill the dictionary...
|
|
_MIF = new Dictionary<string, object>();
|
|
|
|
foreach (string line in Lines)
|
|
{
|
|
int start = line.IndexOf('?');
|
|
int stop = line.IndexOf(':');
|
|
string cmd = line.Substring(start, stop - start);
|
|
|
|
start = stop + 1;
|
|
stop = line.Length;
|
|
string _value = line.Substring(start, stop - start).Trim();
|
|
|
|
_MIF.Add(cmd, _value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ReadDasExcitationCommandString : CommandString
|
|
{
|
|
private bool isG5;
|
|
|
|
protected override string _CommandDescription
|
|
{
|
|
get
|
|
{
|
|
if (isG5)
|
|
return "TEAI Command ";
|
|
else
|
|
return "TEA Command ";
|
|
}
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get
|
|
{
|
|
if (isG5)
|
|
return "TEAI";
|
|
else
|
|
return "TEA";
|
|
}
|
|
}
|
|
|
|
public ReadDasExcitationCommandString()
|
|
{
|
|
isG5 = false;
|
|
}
|
|
public ReadDasExcitationCommandString(bool G5)
|
|
{
|
|
isG5 = G5;
|
|
}
|
|
}
|
|
|
|
public class ReadDasExcitation : CommandBase
|
|
{
|
|
private ReadDasExcitationCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as ReadDasExcitationCommandString;
|
|
}
|
|
}
|
|
private bool isG5 = false;
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
private float[] _ChannelExcitations;
|
|
public float[] ChannelExcitations
|
|
{
|
|
get { return _ChannelExcitations; }
|
|
}
|
|
|
|
public ReadDasExcitation(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadDasExcitationCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public ReadDasExcitation(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout, bool G5)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadDasExcitationCommandString(G5));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public ReadDasExcitation(DTS.Common.Interface.DASFactory.ICommunication sock, bool G5)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new ReadDasExcitationCommandString(G5));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
isG5 = G5;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start;
|
|
if (isG5)
|
|
start = s.IndexOf("TEAI:");
|
|
else
|
|
start = s.IndexOf("TEA:");
|
|
int end = s.LastIndexOf("\r\n");
|
|
System.Diagnostics.Debug.Assert(start >= 0 && end > start);
|
|
int csLength = command.GetCommandString(0).Length + 2;
|
|
_responseData = s.Substring(start + csLength, end - start - csLength);
|
|
string[] data = ResponseData.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
if (0 < data.Length)
|
|
{
|
|
_ChannelExcitations = new float[data.Length];
|
|
for (int ch = 0; ch < data.Length; ch++)
|
|
_ChannelExcitations[ch] = Convert.ToSingle(data[ch]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public class SetDasExcitationCommandString : CommandString
|
|
{
|
|
private int option;
|
|
|
|
protected override string _CommandDescription
|
|
{
|
|
get
|
|
{
|
|
switch (option)
|
|
{
|
|
case 1: return "E 01234567 11111111 Command ";
|
|
case 2: return "E 01234567 22222222 Command ";
|
|
default: return "E 01234567 11111111 Command ";
|
|
}
|
|
}
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get
|
|
{
|
|
switch (option)
|
|
{
|
|
case 1: return "E 01234567 11111111";
|
|
case 2: return "E 01234567 22222222";
|
|
default: return "E 01234567 11111111";
|
|
}
|
|
}
|
|
}
|
|
|
|
public SetDasExcitationCommandString()
|
|
{
|
|
option = 1;
|
|
}
|
|
public SetDasExcitationCommandString(int opt)
|
|
{
|
|
option = opt;
|
|
}
|
|
}
|
|
|
|
public class SetDasExcitation : CommandBase
|
|
{
|
|
private SetDasExcitationCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as SetDasExcitationCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
public SetDasExcitation(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new SetDasExcitationCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public SetDasExcitation(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout, int opt)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new SetDasExcitationCommandString(opt));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public SetDasExcitation(DTS.Common.Interface.DASFactory.ICommunication sock, int opt)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new SetDasExcitationCommandString(opt));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
}
|
|
}
|
|
|
|
public class BurnMIFCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "?W burnbaby "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "?W burnbaby"; }
|
|
}
|
|
public BurnMIFCommandString()
|
|
{
|
|
}
|
|
}
|
|
|
|
public class BurnMIF : CommandBase
|
|
{
|
|
private bool _BurnSuccessful = false;
|
|
private BurnMIFCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as BurnMIFCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
|
|
public bool BurnSuccessful
|
|
{
|
|
get { return _BurnSuccessful; }
|
|
}
|
|
|
|
public BurnMIF(DTS.Common.Interface.DASFactory.ICommunication sock, int linesExpected)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new BurnMIFCommandString());
|
|
command.ExpectsMultipleLines = true;
|
|
command.LinesExpected = linesExpected;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
command.RackSerialNumber = base.RackSerialNumber;
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
|
|
}
|
|
public BurnMIF(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout, int linesExpected)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new BurnMIFCommandString());
|
|
command.ExpectsMultipleLines = true;
|
|
command.LinesExpected = linesExpected;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
command.RackSerialNumber = base.RackSerialNumber;
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
|
|
string[] lines = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
|
_responseData = s;
|
|
|
|
int start = lines[0].IndexOf("W: OK");
|
|
if (start > -1)
|
|
_BurnSuccessful = true;
|
|
else
|
|
_BurnSuccessful = false;
|
|
}
|
|
}
|
|
|
|
public class SetCalDacCommandString : CommandString
|
|
{
|
|
private int dacSetting;
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "C 0 I " + dacSetting + " "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "C 0 I " + dacSetting; }
|
|
}
|
|
public SetCalDacCommandString(int dacValue)
|
|
{
|
|
dacSetting = dacValue;
|
|
}
|
|
public SetCalDacCommandString()
|
|
{
|
|
dacSetting = DTS.Common.Constants.ADC_MIDPOINT; // Zero
|
|
}
|
|
}
|
|
|
|
public class SetCalDac : CommandBase
|
|
{
|
|
private SetCalDacCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as SetCalDacCommandString;
|
|
}
|
|
}
|
|
|
|
public int ModuleIndex
|
|
{
|
|
get { return (baseCommand as TDASCommandPacketBase).ModuleIndex; }
|
|
set { (baseCommand as TDASCommandPacketBase).ModuleIndex = value; }
|
|
}
|
|
|
|
public SetCalDac(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new SetCalDacCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public SetCalDac(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new SetCalDacCommandString());
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
public SetCalDac(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout, int dacCount)
|
|
: base(sock, msTimeout)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new SetCalDacCommandString(dacCount));
|
|
baseCommand = command;
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
}
|
|
|
|
public bool CheckData()
|
|
{
|
|
ProcessData();
|
|
return true;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
if (null == response) { return; }
|
|
string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
int start = s.IndexOf("W: OK");
|
|
|
|
}
|
|
}
|
|
|
|
public class SetSerialBaudRateCommandString : CommandString
|
|
{
|
|
private SetSerialBaudRate.BaudRates _rateSetting;
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "OSR " + ((int)_rateSetting).ToString() + " "; }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "OSR " + ((int)_rateSetting).ToString(); }
|
|
}
|
|
public SetSerialBaudRateCommandString(SetSerialBaudRate.BaudRates rate)
|
|
{
|
|
_rateSetting = rate;
|
|
}
|
|
public SetSerialBaudRateCommandString()
|
|
{
|
|
_rateSetting = SetSerialBaudRate.BaudRates.Normal;
|
|
}
|
|
}
|
|
|
|
|
|
public class SetSerialBaudRate : CommandBase
|
|
{
|
|
public enum BaudRates : int
|
|
{
|
|
Normal = 38400,
|
|
Download = 115200
|
|
};
|
|
|
|
private BaudRates _Rate = BaudRates.Normal;
|
|
public BaudRates Rate
|
|
{
|
|
get { return _Rate; }
|
|
set { _Rate = value; }
|
|
}
|
|
|
|
//private SetSerialBaudRateCommandString _commandString
|
|
//{
|
|
// get
|
|
// {
|
|
// TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
// return command.GetCommandStringObject(0) as SetSerialBaudRateCommandString;
|
|
// }
|
|
//}
|
|
|
|
public SetSerialBaudRate(DTS.Common.Interface.DASFactory.ICommunication sock, BaudRates rate)
|
|
: base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new SetSerialBaudRateCommandString(rate));
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
baseCommand = command;
|
|
}
|
|
|
|
protected override void ProcessData()
|
|
{
|
|
//TDASCommandPacketBase response = baseResponse as TDASCommandPacketBase;
|
|
//if (null == response) { return; }
|
|
//string s = System.Text.ASCIIEncoding.ASCII.GetString(response.ToBytes());
|
|
}
|
|
}
|
|
|
|
|
|
public class RackLedControlCommandString : CommandString
|
|
{
|
|
protected override string _CommandDescription
|
|
{
|
|
get { return "L " + _Led.ToString() + " " + _LedColor.ToString(); }
|
|
}
|
|
protected override string _CommandString
|
|
{
|
|
get { return "L"; }
|
|
}
|
|
|
|
private RackLedControl.LEDColor _LedColor = RackLedControl.LEDColor.Off;
|
|
public RackLedControl.LEDColor LedColor
|
|
{
|
|
set { _LedColor = value; }
|
|
}
|
|
|
|
private RackLedControl.RackLED _Led = RackLedControl.RackLED.CalFault;
|
|
public RackLedControl.RackLED Led
|
|
{
|
|
set { _Led = value; }
|
|
}
|
|
|
|
public override byte[] GetParameters()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
switch (_Led)
|
|
{
|
|
case RackLedControl.RackLED.ArmEvent:
|
|
sb.Append(" ARM");
|
|
break;
|
|
case RackLedControl.RackLED.BatteryPower:
|
|
sb.Append(" BATT");
|
|
break;
|
|
case RackLedControl.RackLED.CalFault:
|
|
sb.Append(" CAL");
|
|
break;
|
|
case RackLedControl.RackLED.CommAdress:
|
|
sb.Append(" COMM");
|
|
break;
|
|
case RackLedControl.RackLED.RackFault:
|
|
sb.Append(" FAULT");
|
|
break;
|
|
}
|
|
switch (_LedColor)
|
|
{
|
|
case RackLedControl.LEDColor.Green:
|
|
sb.Append(" GRN");
|
|
break;
|
|
case RackLedControl.LEDColor.Yellow:
|
|
sb.Append(" YEL");
|
|
break;
|
|
case RackLedControl.LEDColor.Red:
|
|
sb.Append(" RED");
|
|
break;
|
|
case RackLedControl.LEDColor.Off:
|
|
sb.Append(" OFF");
|
|
break;
|
|
}
|
|
|
|
return ASCIIEncoding.ASCII.GetBytes(sb.ToString());
|
|
}
|
|
|
|
public RackLedControlCommandString() { }
|
|
}
|
|
public class RackLedControl : CommandBase
|
|
{
|
|
public enum LEDColor : int
|
|
{
|
|
Off = 0,
|
|
Red = 1,
|
|
Yellow = 2,
|
|
Green = 3
|
|
};
|
|
|
|
public enum RackLED
|
|
{
|
|
BatteryPower = 0,
|
|
CommAdress = 1,
|
|
CalFault = 2,
|
|
ArmEvent = 3,
|
|
RackFault = 4
|
|
}
|
|
|
|
private RackLedControlCommandString _commandString
|
|
{
|
|
get
|
|
{
|
|
TDASCommandPacketBase command = baseCommand as TDASCommandPacketBase;
|
|
return command.GetCommandStringObject(0) as RackLedControlCommandString;
|
|
}
|
|
}
|
|
|
|
public LEDColor Color
|
|
{
|
|
set { _commandString.LedColor = value; }
|
|
}
|
|
|
|
public RackLED LED
|
|
{
|
|
set { _commandString.Led = value; }
|
|
}
|
|
|
|
public RackLedControl(DTS.Common.Interface.DASFactory.ICommunication sock) : base(sock)
|
|
{
|
|
TDASCommandPacketBase command = new TDASCommandPacketBase(new RackLedControlCommandString());
|
|
command.RebuildBytes = true;
|
|
command.SingleModuleCommand = base.SingleModuleCommand;
|
|
command.RackCommand = true;
|
|
baseCommand = command;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|