|
@@ -413,7 +413,7 @@ namespace Venus_RT.Devices
|
|
|
public override bool Initialize()
|
|
|
{
|
|
|
base.Initialize();
|
|
|
- SetPositionManual(50,50);
|
|
|
+ preset(50,50);
|
|
|
if (_serial.Open())
|
|
|
{
|
|
|
_serial.OnBinaryDataChanged += SerialBinaryPortDataReceived;
|
|
@@ -464,10 +464,21 @@ namespace Venus_RT.Devices
|
|
|
});
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+ public void readc1()
|
|
|
+ {
|
|
|
+ byte[] readc1 = new byte[] { 0x0C, 0xF3, 0x00, 0x02, 0x00, 0x01, 0x61, 0x42, 0x79, 0x18, 0x01, 0x37 };
|
|
|
+ _serial.Write(readc1.ToArray());
|
|
|
+ }
|
|
|
+ public void readc2()
|
|
|
+ {
|
|
|
+ byte[] readc1 = new byte[] { 0x0C, 0xF3, 0x00, 0x02, 0x00, 0x01, 0x61, 0x42, 0x79, 0x19, 0x01, 0x38 };
|
|
|
+ _serial.Write(readc1.ToArray());
|
|
|
+ }
|
|
|
public override void Monitor()
|
|
|
{
|
|
|
- ReadPosition(50,50);//0x10 (present mode)CMD 可实现任意模式下只读不设值,0x08(auto then manual)在auto模式下可实现相同功能
|
|
|
+ //ReadPosition(50,50);//0x10 (present mode)CMD 可实现任意模式下只读不设值,0x08(auto then manual)在auto模式下可实现相同功能
|
|
|
+ readc1();
|
|
|
+ readc2();
|
|
|
}
|
|
|
|
|
|
public override void Terminate()
|
|
@@ -476,7 +487,7 @@ namespace Venus_RT.Devices
|
|
|
|
|
|
public override void Reset()
|
|
|
{
|
|
|
- SetPositionManual(50, 50);
|
|
|
+ preset(50, 50);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -505,11 +516,12 @@ namespace Venus_RT.Devices
|
|
|
private void SerialBinaryPortDataReceived(byte[] message)
|
|
|
{
|
|
|
|
|
|
- if (message.Count() < 29)
|
|
|
+ if (message.Count() < 18)
|
|
|
{
|
|
|
string hexString = BitConverter.ToString(message.ToArray()).Replace("-", " ");
|
|
|
- LOG.Write(eEvent.ERR_MATCH, Module, hexString);
|
|
|
- LOG.Write(eEvent.ERR_RF, Module, "收到 Match 数据格式不正确");
|
|
|
+
|
|
|
+ //LOG.Write(eEvent.ERR_MATCH, Module, hexString);
|
|
|
+ //LOG.Write(eEvent.ERR_RF, Module, "收到 Match 数据格式不正确");
|
|
|
|
|
|
}
|
|
|
else
|
|
@@ -517,7 +529,7 @@ namespace Venus_RT.Devices
|
|
|
try
|
|
|
{
|
|
|
buffer.AddRange(message);
|
|
|
- while (buffer.Count >= 29) //至少包含帧头(1字节)、长度(1字节)、其余27字节
|
|
|
+ while (buffer.Count >= 18) //至少包含帧头(1字节)、长度(1字节)、其余27字节
|
|
|
{
|
|
|
//2.1 查找数据头
|
|
|
if (buffer[0] == 0x1D && buffer[1] == 0xE2) //传输数据有帧头,用于判断
|
|
@@ -543,6 +555,19 @@ namespace Venus_RT.Devices
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ else if (buffer[0] == 0x12 && buffer[1] == 0xED)
|
|
|
+ {
|
|
|
+ byte[] ReceiveBytes18 = new byte[18];
|
|
|
+ buffer.CopyTo(0, ReceiveBytes18, 0, 18);
|
|
|
+ if (ReceiveBytes18[10] == 0x79 && ReceiveBytes18[11] == 0x18)
|
|
|
+ {
|
|
|
+ TunePosition1 = BitConverter.ToSingle(new byte[] { ReceiveBytes18[12], ReceiveBytes18[13], ReceiveBytes18[14], ReceiveBytes18[15] }, 0) * 100;
|
|
|
+ }else if (ReceiveBytes18[10] == 0x79 && ReceiveBytes18[11] == 0x19)
|
|
|
+ {
|
|
|
+ TunePosition2 = BitConverter.ToSingle(new byte[] { ReceiveBytes18[12], ReceiveBytes18[13], ReceiveBytes18[14], ReceiveBytes18[15] }, 0) * 100;
|
|
|
+ }
|
|
|
+ buffer.RemoveRange(0, 18);
|
|
|
+ }
|
|
|
else //帧头不正确时,记得清除
|
|
|
{
|
|
|
buffer.Clear();
|
|
@@ -593,7 +618,7 @@ namespace Venus_RT.Devices
|
|
|
baseBytes.AddRange(ackture);
|
|
|
_serial.Write(baseBytes.ToArray());
|
|
|
}
|
|
|
- private void SetPositionManual(float c1val, float c2val)
|
|
|
+ private void preset(float c1val, float c2val)
|
|
|
{
|
|
|
List<byte> Len = new List<byte>() { 0x16, 0xE9 };
|
|
|
List<byte> DstSrc = new List<byte>() { 0x00, 0x02, 0x00, 0x01 };
|
|
@@ -601,7 +626,7 @@ namespace Venus_RT.Devices
|
|
|
byte[] val1Bytes = BitConverter.GetBytes(c1val / 100);
|
|
|
byte[] val2Bytes = BitConverter.GetBytes(c2val / 100);
|
|
|
List<byte> Act = new List<byte>() { 0x00 };
|
|
|
- List<byte> Ctr123 = new List<byte> { 0x01, 0x00, 0x00 };
|
|
|
+ List<byte> Ctr123 = new List<byte> { 0x04, 0x00, 0x00 };
|
|
|
List<byte> baseBytes = new List<byte>() { };
|
|
|
baseBytes.AddRange(Len);
|
|
|
baseBytes.AddRange(DstSrc);
|
|
@@ -623,36 +648,6 @@ namespace Venus_RT.Devices
|
|
|
baseBytes.AddRange(ackture);
|
|
|
_serial.Write(baseBytes.ToArray());
|
|
|
}
|
|
|
- private void ReadPosition(float c1val, float c2val)
|
|
|
- {
|
|
|
- List<byte> Len = new List<byte>() { 0x16, 0xE9 };
|
|
|
- List<byte> DstSrc = new List<byte>() { 0x00, 0x02, 0x00, 0x01 };
|
|
|
- List<byte> Cmd = new List<byte> { 0x60, 0x40 };
|
|
|
- byte[] val1Bytes = BitConverter.GetBytes(c1val / 100);
|
|
|
- byte[] val2Bytes = BitConverter.GetBytes(c2val / 100);
|
|
|
- List<byte> Act = new List<byte>() { 0x00 };
|
|
|
- List<byte> Ctr123 = new List<byte> { 0x08, 0x00, 0x00 };
|
|
|
- List<byte> baseBytes = new List<byte>() { };
|
|
|
- baseBytes.AddRange(Len);
|
|
|
- baseBytes.AddRange(DstSrc);
|
|
|
- baseBytes.AddRange(Cmd);
|
|
|
- baseBytes.AddRange(val1Bytes);
|
|
|
- baseBytes.AddRange(val2Bytes);
|
|
|
- baseBytes.AddRange(Act);
|
|
|
- baseBytes.AddRange(Ctr123);
|
|
|
- int a = 0;
|
|
|
- for (int i = 2; i < baseBytes.Count; i++)
|
|
|
- {
|
|
|
- a += (Int16)baseBytes[i];
|
|
|
- }
|
|
|
- byte[] ackture = new byte[2];
|
|
|
-
|
|
|
- byte[] ackbyte = BitConverter.GetBytes(a);
|
|
|
- ackture[0] = ackbyte[1];
|
|
|
- ackture[1] = ackbyte[0];
|
|
|
- baseBytes.AddRange(ackture);
|
|
|
- _serial.Write(baseBytes.ToArray());
|
|
|
- }
|
|
|
public override bool SetMatchMode(EnumRfMatchTuneMode enumRfMatchTuneMode, out string reason)
|
|
|
{
|
|
|
reason = string.Empty;
|