|
@@ -7,6 +7,7 @@ using Aitex.Core.RT.SCCore;
|
|
|
using Aitex.Core.RT.Tolerance;
|
|
|
using Aitex.Core.UI.Control;
|
|
|
using Aitex.Core.Util;
|
|
|
+using CommunityToolkit.HighPerformance.Buffers;
|
|
|
using MECF.Framework.Common.Communications;
|
|
|
using MECF.Framework.Common.DataCenter;
|
|
|
using MECF.Framework.Common.Device.Bases;
|
|
@@ -16,7 +17,7 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
-using System.Net;
|
|
|
+using System.ServiceModel.Channels;
|
|
|
using Venus_Core;
|
|
|
|
|
|
namespace Venus_RT.Devices
|
|
@@ -24,17 +25,12 @@ namespace Venus_RT.Devices
|
|
|
public class TruPlasmaRF : RfPowerBase
|
|
|
{
|
|
|
private readonly AsyncSerialPort _serial;
|
|
|
- private static byte _ACK = 0x06;
|
|
|
- private static byte ParamRead = 0x01;
|
|
|
- private static byte ParamWrite = 0x02;
|
|
|
- private static byte TelegramError = 0xFE;
|
|
|
- private static byte MessageRead = 0x04;
|
|
|
- private static byte CtllnterfaceAct= 0x05;
|
|
|
-
|
|
|
+ private List<byte> buffer = new List<byte>(4096);
|
|
|
public TruPlasmaRF(ModuleName mod, VenusDevice device) : base(mod.ToString(), device.ToString())
|
|
|
{
|
|
|
+ this.Status = GeneratorStatus.Unknown;
|
|
|
var portNum = SC.GetStringValue(device == VenusDevice.Rf ? $"{mod}.Rf.Port" : $"{mod}.BiasRf.Port");
|
|
|
- _serial = new AsyncSerialPort(portNum, 9600, 8, System.IO.Ports.Parity.None, System.IO.Ports.StopBits.One, "\r\r");
|
|
|
+ _serial = new AsyncSerialPort(portNum, 9600, 8, System.IO.Ports.Parity.None, System.IO.Ports.StopBits.One,"/r", false);
|
|
|
}
|
|
|
public override bool Initialize()
|
|
|
{
|
|
@@ -45,14 +41,15 @@ namespace Venus_RT.Devices
|
|
|
{
|
|
|
_serial.OnBinaryDataChanged += SerialPortDataReceived;
|
|
|
_serial.OnErrorHappened += SerialPortErrorOccurred;
|
|
|
+ ResetCommand();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LOG.Write(eEvent.ERR_RF, Module, "Tru 射频发生器串口无法打开");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
return true;
|
|
|
+
|
|
|
}
|
|
|
public new AITRfData DeviceData =>
|
|
|
new AITRfData
|
|
@@ -67,43 +64,117 @@ namespace Venus_RT.Devices
|
|
|
};
|
|
|
private void SerialPortDataReceived(byte[] rawMessage)
|
|
|
{
|
|
|
-
|
|
|
- LOG.Write(eEvent.INFO_RF, Module, $"RF byte"+rawMessage.ToString());
|
|
|
try
|
|
|
{
|
|
|
- if (rawMessage.Length==1&& rawMessage[1]== 0x06)
|
|
|
+ buffer.AddRange(rawMessage);
|
|
|
+ while (buffer.Count >= 18)
|
|
|
{
|
|
|
+
|
|
|
+ if (buffer[0] == 0x06)
|
|
|
+ {
|
|
|
+
|
|
|
+ byte[] ReceiveBytes = new byte[13];
|
|
|
+ byte[] ReadReceiveBytes = new byte[18];
|
|
|
+
|
|
|
+ buffer.CopyTo(0, ReceiveBytes, 0, 13);
|
|
|
+ buffer.CopyTo(0, ReadReceiveBytes, 0, 18);
|
|
|
+ if ((ReceiveBytes[12] == 0x55)&& (ReceiveBytes[1] == 0xAA))
|
|
|
+ {
|
|
|
+ parsecmd(ReceiveBytes);
|
|
|
+ buffer.RemoveRange(0, 13);
|
|
|
+
|
|
|
+ }
|
|
|
+ else if ((ReadReceiveBytes[17] == 0x55) && (ReceiveBytes[1] == 0xAA))
|
|
|
+ {
|
|
|
+ parsecmd(ReadReceiveBytes);
|
|
|
+ buffer.RemoveRange(0, 18);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ buffer.Clear();
|
|
|
+ LOG.Write(eEvent.ERR_RF, Module, $"rf通讯错误");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+
|
|
|
}
|
|
|
- else if (rawMessage.Length > 1)
|
|
|
+ else
|
|
|
{
|
|
|
- parsecmd(rawMessage);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ buffer.Clear();
|
|
|
LOG.WriteExeption(ex);
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public GeneratorStatus Status { get; set; }
|
|
|
+ private bool GetBitValue(byte value, int bit)
|
|
|
+ {
|
|
|
+ return (value & (byte)Math.Pow(2, bit)) > 0 ? true : false;
|
|
|
+ }
|
|
|
+ public override bool IsPowerOn
|
|
|
+ {
|
|
|
+ get => Status == GeneratorStatus.ON;
|
|
|
+ set { }
|
|
|
}
|
|
|
public void parsecmd(byte[] message)
|
|
|
{
|
|
|
- switch (message[4])
|
|
|
+ try
|
|
|
{
|
|
|
- case 0x01:
|
|
|
- int DataValue = BitConverter.ToInt32(new byte[] { message[10], message[11], message[12], message[13] }, 0);
|
|
|
- ReflectPower = DataValue;
|
|
|
- break;
|
|
|
- case 0x02:
|
|
|
- DataValue = BitConverter.ToInt32(new byte[] { message[10] ,message[11], message[12], message[13] }, 0);
|
|
|
- ForwardPower = DataValue;
|
|
|
- break;
|
|
|
- case 0xFE:
|
|
|
- LOG.Write(eEvent.ERR_RF, Module, "Telegram structure is not correct");
|
|
|
- break;
|
|
|
- default:
|
|
|
-
|
|
|
- break;
|
|
|
+ IsPowerOn = GetBitValue(message[4], 4);
|
|
|
+ if (GetBitValue(message[4], 4))
|
|
|
+ {
|
|
|
+ Status = GeneratorStatus.ON;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Status = GeneratorStatus.OFF;
|
|
|
+
|
|
|
+ }
|
|
|
+ switch (message[5])
|
|
|
+ {
|
|
|
+ case 0x01:
|
|
|
+ if (message.Length == 18 && message[6]==0x14)
|
|
|
+ {
|
|
|
+ int DataValue = BitConverter.ToInt32(new byte[] { message[11], message[12], message[13], message[14] }, 0);
|
|
|
+ ReflectPower = DataValue;
|
|
|
+ }else if (message.Length == 18 && message[6] == 0x12)
|
|
|
+ {
|
|
|
+ int DataValue1 = BitConverter.ToInt32(new byte[] { message[11], message[12], message[13], message[14] }, 0);
|
|
|
+ ForwardPower = DataValue1;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 0x02:
|
|
|
+ break;
|
|
|
+ case 0xFE:
|
|
|
+ LOG.Write(eEvent.ERR_RF, Module, "Telegram structure is not correct");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (message[9])
|
|
|
+ {
|
|
|
+ case 0x26:
|
|
|
+ Status = GeneratorStatus.OFF;
|
|
|
+ IsPowerOn = false;
|
|
|
+ break;
|
|
|
+ case 0x24:
|
|
|
+ LOG.Write(eEvent.ERR_RF, Module, "Telegram structure is not correct");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ catch (Exception ex)
|
|
|
+ { }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -113,27 +184,61 @@ namespace Venus_RT.Devices
|
|
|
}
|
|
|
public override void SetPower(float val)
|
|
|
{
|
|
|
-
|
|
|
- ForwardPower=val;
|
|
|
List<byte> baseBytes = new List<byte>() { 0xAA, 0x02, 0x0B, 0x00, 0x02, 0x06, 0x00, 0x01, 0x00, 0x04 };
|
|
|
byte[] valueBytes = BitConverter.GetBytes((int)val);
|
|
|
baseBytes.AddRange(valueBytes);
|
|
|
baseBytes = CRC16(baseBytes.ToArray());
|
|
|
- baseBytes.Add(0x55);
|
|
|
+ baseBytes.Add(0x55);
|
|
|
_serial.Write(baseBytes.ToArray());
|
|
|
}
|
|
|
-
|
|
|
- public override bool SetPowerOnOff(bool on, out string str)
|
|
|
+ public override void Monitor()
|
|
|
+ {
|
|
|
+ readpi();
|
|
|
+ readpr();
|
|
|
+ }
|
|
|
+ public void getcontrol()
|
|
|
{
|
|
|
+ byte[] getincontrol = new byte[] { 0xAA, 0x02, 0x06, 0x00, 0x05, 0x01, 0x00, 0x00, 0xFF, 0x34, 0x8A, 0x55 };
|
|
|
+ _serial.Write(getincontrol.ToArray());
|
|
|
+ }
|
|
|
+ public void releasecontrol()
|
|
|
+ {
|
|
|
+ byte[] getincontrol = new byte[] { 0xAA, 0x02, 0x06, 0x00, 0x05, 0x02, 0x00, 0x00, 0xFF, 0xE8, 0x11, 0x55 };
|
|
|
+ _serial.Write(getincontrol.ToArray());
|
|
|
+ }
|
|
|
+ public void readpr()
|
|
|
+ {
|
|
|
+ byte[] getincontrol = new byte[] { 0xAA, 0x02, 0x06, 0x00, 0x01, 0x14, 0x00, 0x01, 0xFF, 0xE1, 0x97, 0x55 };
|
|
|
+ _serial.Write(getincontrol.ToArray());
|
|
|
+ }
|
|
|
+ public void readpi()
|
|
|
+ {
|
|
|
+ byte[] getincontrola = new byte[] { 0xAA, 0x02, 0x06, 0x00, 0x01, 0x12, 0x00, 0x01, 0xFF, 0x78, 0xB0, 0x55 };
|
|
|
+ _serial.Write(getincontrola.ToArray());
|
|
|
+ }
|
|
|
+ public void ResetCommand()
|
|
|
+ {
|
|
|
+ LOG.Write(eEvent.ERR_RF, Module, $"Send rest");
|
|
|
+ byte[] getincontrol = new byte[] { 0xAA, 0x02, 0x0B, 0x00, 0x02, 0x4D, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x30, 0x72, 0x55 };
|
|
|
+ _serial.Write(getincontrol.ToArray());
|
|
|
+ }
|
|
|
+ public override void Reset()
|
|
|
+ {
|
|
|
+ byte[] getincontrol = new byte[] { 0xAA, 0x02, 0x0B, 0x00, 0x02, 0x4D, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x30, 0x72, 0x55 };
|
|
|
+ _serial.Write(getincontrol.ToArray());
|
|
|
+ }
|
|
|
+ public override bool SetPowerOnOff(bool on, out string str)
|
|
|
+ {
|
|
|
str = "";
|
|
|
var _chamber = DEVICE.GetDevice<JetPMBase>(Module);
|
|
|
if (on && !_chamber.CheckGeneratorAndHVInterlock(VenusDevice.Rf))
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
+ getcontrol();
|
|
|
List<byte> baseBytes = new List<byte>() { 0xAA, 0x02, 0x0B, 0x00, 0x02, 0x6F, 0x00, 0x01, 0x00, 0x07 };
|
|
|
if (on == true)
|
|
|
- {
|
|
|
+ {
|
|
|
baseBytes.AddRange(new List<byte> { 0x01, 0x00, 0x00, 0x00 });
|
|
|
}
|
|
|
else
|
|
@@ -143,6 +248,10 @@ namespace Venus_RT.Devices
|
|
|
baseBytes = CRC16(baseBytes.ToArray());
|
|
|
baseBytes.Add(0x55);
|
|
|
_serial.Write(baseBytes.ToArray());
|
|
|
+ if (on == false)
|
|
|
+ {
|
|
|
+ releasecontrol();
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
public override void SetPulseMode(bool on)
|
|
@@ -264,14 +373,6 @@ namespace Venus_RT.Devices
|
|
|
private const ushort S3_HEAD_LENGTH = 2;
|
|
|
private readonly DeviceTimer _timerQueryStatus = new DeviceTimer();
|
|
|
private int QUERY_INTERVAL = 1000;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
[Subscription("MatchWorkMode")]
|
|
|
public EnumRfMatchTuneMode WorkMode { get; set; }
|
|
|
public float C1 { get; set; }
|
|
@@ -298,28 +399,8 @@ namespace Venus_RT.Devices
|
|
|
public TruPlasmaMatch(ModuleName mod, VenusDevice device) : base(mod.ToString(), device.ToString())
|
|
|
{
|
|
|
var portNum = SC.GetStringValue($"{mod}.{device}.Port");
|
|
|
-
|
|
|
- _serial = new AsyncSerialPort(portNum, 9600, 8);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SerachCommandList = new List<string>()
|
|
|
- {
|
|
|
- AdTecMatchMessage.READ_POS,
|
|
|
- AdTecMatchMessage.START_QUERY
|
|
|
- };
|
|
|
+ _serial = new AsyncSerialPort(portNum, 9600, 8, System.IO.Ports.Parity.None, System.IO.Ports.StopBits.One, "/r", false);
|
|
|
intervalTime = 100;
|
|
|
- sendDataChangedEvent += TruMatch_sendDataChangedEvent;
|
|
|
- baseStopwatch.Start();
|
|
|
- baseTimer.Enabled = true;
|
|
|
- }
|
|
|
-
|
|
|
- private void TruMatch_sendDataChangedEvent(string obj)
|
|
|
- {
|
|
|
- this.SendCmd(obj);
|
|
|
}
|
|
|
|
|
|
~TruPlasmaMatch()
|
|
@@ -379,38 +460,21 @@ namespace Venus_RT.Devices
|
|
|
SetMatchMode((string)param[0] == "Auto" ? EnumRfMatchTuneMode.Auto : EnumRfMatchTuneMode.Manual, out reason);
|
|
|
return true;
|
|
|
});
|
|
|
-
|
|
|
- _timerQueryStatus.Start(QUERY_INTERVAL);
|
|
|
- this.SendCmd(AdTecMatchMessage.START_QUERY);
|
|
|
-
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public override void Monitor()
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public override void Terminate()
|
|
|
{
|
|
|
- this.SendCmd(AdTecMatchMessage.STOP_QUERY);
|
|
|
}
|
|
|
|
|
|
public override void Reset()
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -421,25 +485,11 @@ namespace Venus_RT.Devices
|
|
|
|
|
|
private void executeMatchPostion(float c1, float c2)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
|
|
|
SetPosition(c1, c2);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
public override void SetMatchPosition(float c1, float c2, out string reason)
|
|
|
{
|
|
|
- float DataValue = BitConverter.ToSingle(new byte[] { 0x9A, 0x99, 0x19,0x3F }, 0);
|
|
|
- byte[] floatAsBytes = BitConverter.GetBytes(DataValue);
|
|
|
- float DataValue1= BitConverter.ToSingle(new byte[] { floatAsBytes[0], floatAsBytes[1], floatAsBytes[2], floatAsBytes[3] }, 0);
|
|
|
-
|
|
|
-
|
|
|
- base.SetMatchPosition(c1, c2, out reason);
|
|
|
-
|
|
|
executeMatchPostion(c1, c2);
|
|
|
|
|
|
reason = "";
|
|
@@ -453,17 +503,17 @@ namespace Venus_RT.Devices
|
|
|
|
|
|
private void SerialBinaryPortDataReceived(byte[] message)
|
|
|
{
|
|
|
- if(message.Count()==0)
|
|
|
+ if (message.Count()<10)
|
|
|
{
|
|
|
LOG.Write(eEvent.ERR_RF, Module, "收到 Match 数据为空");
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (message[0] ==0x1D && message[6]==0x60 && message[7] == 0x00)
|
|
|
+ if (message[0] ==0x1D && message[8]==0x60)
|
|
|
{
|
|
|
- this.TunePosition1 = BitConverter.ToSingle(new byte[] { message[10], message[11], message[12], message[13] }, 0) * 10;
|
|
|
- this.TunePosition2 = BitConverter.ToSingle(new byte[] { message[14], message[15], message[16], message[17] }, 0) * 10;
|
|
|
+ TunePosition1 = BitConverter.ToSingle(new byte[] { message[10], message[11], message[12], message[13] }, 0) * 100;
|
|
|
+ TunePosition2 = BitConverter.ToSingle(new byte[] { message[14], message[15], message[16], message[17] }, 0) * 100;
|
|
|
switch (message[7])
|
|
|
{
|
|
|
case 0x01:
|
|
@@ -477,37 +527,25 @@ namespace Venus_RT.Devices
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private void SerialPortErrorOccurred(string str)
|
|
|
{
|
|
|
LOG.Write(eEvent.ERR_RF, Module, $"AdTec Match error [{str}]");
|
|
|
}
|
|
|
|
|
|
- private void SendCmd(string str)
|
|
|
- {
|
|
|
- _serial?.Write(str + "\r");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
private void SetPosition(float c1val, float c2val)
|
|
|
{
|
|
|
-
|
|
|
List<byte> Len = new List<byte>() { 0x16, 0xE9};
|
|
|
- List<byte> DstSrc = new List<byte>() { 0x00, 0x0A, 0x00, 0x00};
|
|
|
+ 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>() { 0x64 };
|
|
|
- List<byte> Ctr123 = new List<byte> { 0x08, 0x01, 0x80 };
|
|
|
+ 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);
|
|
@@ -516,37 +554,31 @@ namespace Venus_RT.Devices
|
|
|
baseBytes.AddRange(val2Bytes);
|
|
|
baseBytes.AddRange(Act);
|
|
|
baseBytes.AddRange(Ctr123);
|
|
|
- byte ack=0x00;
|
|
|
+ int a = 0;
|
|
|
for (int i=2; i< baseBytes.Count;i++)
|
|
|
{
|
|
|
- ack += baseBytes[i];
|
|
|
+ a+=(Int16)baseBytes[i];
|
|
|
}
|
|
|
- baseBytes.Add(ack);
|
|
|
-
|
|
|
+ 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;
|
|
|
- SetWorkMode(enumRfMatchTuneMode);
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void SetWorkMode(EnumRfMatchTuneMode mode)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void SetPresetMemory(byte gear)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|