首次上传
This commit is contained in:
+692
@@ -0,0 +1,692 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.RT.Log;
|
||||
using Aitex.Core.RT.SCCore;
|
||||
using Aitex.Core.Util;
|
||||
using MECF.Framework.Common.Communications;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Common;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Siasun1500C800C
|
||||
{
|
||||
|
||||
|
||||
public class RobotSiasun1500C800C : TCPSocketDevice, IConnection
|
||||
{
|
||||
public string Address { get; }
|
||||
public bool IsConnected { get; }
|
||||
public bool Connect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Disconnect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public string PortStatus { get; set; } = "Closed";
|
||||
|
||||
private RobotSiasun1500C800CTCPConnection _connection;
|
||||
public RobotSiasun1500C800CTCPConnection Connection
|
||||
{
|
||||
get { return _connection; }
|
||||
}
|
||||
|
||||
private R_TRIG _trigError = new R_TRIG();
|
||||
|
||||
private R_TRIG _trigCommunicationError = new R_TRIG();
|
||||
private R_TRIG _trigRetryConnect = new R_TRIG();
|
||||
|
||||
private PeriodicJob _thread;
|
||||
|
||||
private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
|
||||
private LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
|
||||
|
||||
public List<IOResponse> IOResponseList { get; set; } = new List<IOResponse>();
|
||||
|
||||
|
||||
private object _locker = new object();
|
||||
|
||||
private bool _enableLog;
|
||||
private string _scRoot;
|
||||
public RobotSiasun1500C800C(string module, string name, string scRoot) : base(module, name)
|
||||
{
|
||||
_scRoot = scRoot;
|
||||
}
|
||||
private void ResetPropertiesAndResponses()
|
||||
{
|
||||
LoadAWaferStatus = false;
|
||||
LoadBWaferStatus = false;
|
||||
|
||||
ArmAPosition = null;
|
||||
ArmBPosition = null;
|
||||
IsHalted = false;
|
||||
AllHomed = false;
|
||||
RHomed = false;
|
||||
THomed = false;
|
||||
ZHomed = false;
|
||||
LastPickInfo = null;
|
||||
LastPlaceInfo = null;
|
||||
ArmRetracted = false;
|
||||
|
||||
foreach (var ioResponse in IOResponseList)
|
||||
{
|
||||
ioResponse.ResonseContent = null;
|
||||
ioResponse.ResonseRecievedTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
ResetPropertiesAndResponses();
|
||||
|
||||
if (_connection != null && _connection.IsConnected)
|
||||
return true;
|
||||
|
||||
_enableLog = SC.GetValue<bool>($"{_scRoot}.{Module}.{Name}.EnableLogMessage");
|
||||
string deviceIP = SC.GetStringValue($"{_scRoot}.{Module}.{Name}.DeviceIP");
|
||||
|
||||
_connection = new RobotSiasun1500C800CTCPConnection(deviceIP);
|
||||
_connection.EnableLog(_enableLog);
|
||||
|
||||
if (_connection.Connect())
|
||||
{
|
||||
PortStatus = "Open";
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
PortStatus = "Close";
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} connect failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
_thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private bool OnTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
//return true;
|
||||
_connection.MonitorTimeout();
|
||||
|
||||
if (!_connection.IsConnected || _connection.IsCommunicationError)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.Clear();
|
||||
}
|
||||
|
||||
_trigRetryConnect.CLK = !_connection.IsConnected;
|
||||
if (_trigRetryConnect.Q)
|
||||
{
|
||||
if (!_connection.Connect())
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//_lstHandler.AddLast(new RobotSiasun1500C800CQueryPinHandler(this, _deviceAddress));
|
||||
//_lstHandler.AddLast(new RobotSiasun1500C800CSetCommModeHandler(this, _deviceAddress, EnumRfPowerCommunicationMode.Host));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HandlerBase handler = null;
|
||||
if (!_connection.IsBusy)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_lstHandler.Count == 0)
|
||||
{
|
||||
foreach (var monitorHandler in _lstMonitorHandler)
|
||||
{
|
||||
_lstHandler.AddLast(monitorHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_lstHandler.Count > 0)
|
||||
{
|
||||
handler = _lstHandler.First.Value;
|
||||
|
||||
_lstHandler.RemoveFirst();
|
||||
}
|
||||
}
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
_connection.Execute(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Monitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
//_connection.EnableLog(_enableLog);
|
||||
|
||||
|
||||
_trigCommunicationError.CLK = _connection.IsCommunicationError;
|
||||
if (_trigCommunicationError.Q)
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
_trigError.RST = true;
|
||||
|
||||
_connection.SetCommunicationError(false, "");
|
||||
_trigCommunicationError.RST = true;
|
||||
|
||||
//_enableLog = SC.GetValue<bool>($"{ScBasePath}.{Name}.EnableLogMessage");
|
||||
|
||||
_trigRetryConnect.RST = true;
|
||||
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
public override bool Home(out string reason)
|
||||
{
|
||||
return base.Home(out reason);
|
||||
}
|
||||
|
||||
|
||||
#region Command Functions
|
||||
public void PerformRawCommand(string command, string comandArgument)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CRawCommandHandler(this, command, comandArgument));
|
||||
}
|
||||
}
|
||||
|
||||
public void PerformRawCommand(string command)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CRawCommandHandler(this, command));
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetRobot()
|
||||
{
|
||||
_connection.SendMessage("RESET\r");
|
||||
}
|
||||
public void Goto(GotoArgument gotoArg)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CGotoHandler(this, JsonConvert.SerializeObject(gotoArg)));
|
||||
}
|
||||
}
|
||||
public void Goto(object gotoArg)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CGotoHandler(this, gotoArg.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void SevoOn()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CSevoOnOffHandler(this, true));
|
||||
}
|
||||
}
|
||||
public void SevoOff()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CSevoOnOffHandler(this, false));
|
||||
}
|
||||
}
|
||||
|
||||
public void Halt()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CHaltHandler(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void HomeAxis(string axis)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CHomeAxisHandler(this, axis));
|
||||
}
|
||||
}
|
||||
public void Pick(PickPlaceArgument pickArg)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CPickHandler(this, JsonConvert.SerializeObject(pickArg)));
|
||||
}
|
||||
}
|
||||
public void Pick(object pickArg)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CPickHandler(this, pickArg.ToString()));
|
||||
}
|
||||
}
|
||||
public void Place(PickPlaceArgument placeArg)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CPlaceHandler(this, JsonConvert.SerializeObject(placeArg)));
|
||||
}
|
||||
}
|
||||
public void Place(object placeArg)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CPlaceHandler(this, placeArg.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void Transfer(string arm, string fromStation, string toStation)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CTransferHandler(this, fromStation, toStation,arm));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Transfer(string fromStation, string toStation)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CTransferHandler(this, fromStation, toStation));
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteSetCommEchoCompleted(bool value)
|
||||
{
|
||||
SetCommEchoCompleted = value;
|
||||
}
|
||||
|
||||
public void Retract()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CRetractHandler(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCommunicationEcho(string echoStatus)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CSetCommunicationEchoHandler(this, echoStatus));
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteSetLoadCompleted(bool value)
|
||||
{
|
||||
SetLoadCompleted = value;
|
||||
}
|
||||
|
||||
public void SetLoad(string arm, string status)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new RobotSiasun1500C800CSetLoadHandler(this, arm, status));
|
||||
}
|
||||
}
|
||||
public void MonitorRawCommand(bool isSelected, string command, string comandArgument)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
string msg = comandArgument == null ? $"{command}\r" : $"{command} {comandArgument}\r";
|
||||
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasun1500C800CRawCommandHandler) && handler.SendText == msg);
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new RobotSiasun1500C800CRawCommandHandler(this, command, comandArgument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void MonitorRawCommand(bool isSelected, string command)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
string msg = $"{command}\r";
|
||||
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasun1500C800CRawCommandHandler) && handler.SendText == msg);
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new RobotSiasun1500C800CRawCommandHandler(this, command));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestWaferOnOff(bool isSelected, string load)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasun1500C800CQueryWaferOnOffHandler) && handler.SendText.Contains(" " + load.ToString()));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new RobotSiasun1500C800CQueryWaferOnOffHandler(this, load));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCommEchoStatus(bool echoStatus)
|
||||
{
|
||||
CommEchoOn = echoStatus;
|
||||
}
|
||||
|
||||
public void RequestWaferOnOff(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasun1500C800CQueryWaferOnOffHandler) && handler.SendText == "RQ LOAD\r");
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new RobotSiasun1500C800CQueryWaferOnOffHandler(this, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteWafeCenData(string requestResponse)
|
||||
{
|
||||
WafeCenData = requestResponse;
|
||||
var dataArray = requestResponse.Split(' ');
|
||||
if(dataArray.Length == 15)
|
||||
{
|
||||
Offset_R = dataArray[10];
|
||||
Offset_T = dataArray[11];
|
||||
}
|
||||
else
|
||||
{
|
||||
NoteError("RequestWafeCenData Response Error");
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestCommunicationEcho(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasun1500C800CRequestCommunicationEchoHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new RobotSiasun1500C800CRequestCommunicationEchoHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestWaferCentData(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasun1500C800CRequestWaferCentDataHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new RobotSiasun1500C800CRequestWaferCentDataHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public bool LoadAWaferStatus { get; private set; }
|
||||
public bool LoadBWaferStatus { get; private set; }
|
||||
|
||||
public string ArmAPosition { get; private set; }
|
||||
public string ArmBPosition { get; private set; }
|
||||
public bool IsHalted { get; private set; }
|
||||
public bool AllHomed { get; private set; }
|
||||
public bool RHomed { get; private set; }
|
||||
public bool THomed { get; private set; }
|
||||
public bool ZHomed { get; private set; }
|
||||
|
||||
public string LastPickInfo { get; private set; }
|
||||
public string LastPlaceInfo { get; private set; }
|
||||
public bool ArmRetracted { get; private set; }
|
||||
public string Error { get; private set; }
|
||||
public bool SevoOnOff { get; private set; }
|
||||
public bool CommEchoOn { get; private set; }
|
||||
public bool SetCommEchoCompleted { get; private set; }
|
||||
public bool SetLoadCompleted { get; private set; }
|
||||
public string WafeCenData { get; private set; }
|
||||
public string Offset_R { get; private set; }
|
||||
public string Offset_T { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Note Functions
|
||||
private R_TRIG _trigWarningMessage = new R_TRIG();
|
||||
|
||||
|
||||
|
||||
public void NoteError(string reason)
|
||||
{
|
||||
if(reason != null)
|
||||
{
|
||||
_trigWarningMessage.CLK = true;
|
||||
if (_trigWarningMessage.Q)
|
||||
{
|
||||
EV.PostWarningLog(Module, $"{Module}.{Name} error, {reason}");
|
||||
}
|
||||
Error = reason;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = null;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteArmAPosition(string position)
|
||||
{
|
||||
ArmAPosition = position;
|
||||
}
|
||||
internal void NoteArmBPosition(string position)
|
||||
{
|
||||
ArmBPosition = position;
|
||||
}
|
||||
|
||||
internal void NoteIsHalted(bool isHalted)
|
||||
{
|
||||
IsHalted = isHalted;
|
||||
}
|
||||
internal void NoteSevoOnOff(bool isOn)
|
||||
{
|
||||
SevoOnOff = isOn;
|
||||
}
|
||||
internal void NoteAxisHomed(string parameter)
|
||||
{
|
||||
if (parameter == null || parameter == "ALL")
|
||||
{
|
||||
AllHomed = true;
|
||||
RHomed = true;
|
||||
THomed = true;
|
||||
ZHomed = true;
|
||||
}
|
||||
else if (parameter == "R")
|
||||
RHomed = true;
|
||||
else if (parameter == "T")
|
||||
THomed = true;
|
||||
else if (parameter == "Z")
|
||||
ZHomed = true;
|
||||
else
|
||||
NoteError("Wrong 'HOME' parameter");
|
||||
}
|
||||
|
||||
internal void NoteWafeOnOff(string arm, bool isOn)
|
||||
{
|
||||
if(arm == "A")
|
||||
LoadAWaferStatus = isOn;
|
||||
else
|
||||
LoadBWaferStatus = isOn;
|
||||
}
|
||||
internal void NoteRawCommandInfo(string command, string data)
|
||||
{
|
||||
var curIOResponse = IOResponseList.Find(res => res.SourceCommandName == command);
|
||||
if (curIOResponse != null)
|
||||
{
|
||||
IOResponseList.Remove(curIOResponse);
|
||||
}
|
||||
IOResponseList.Add(new IOResponse() { SourceCommandName = command, ResonseContent = data, ResonseRecievedTime = DateTime.Now });
|
||||
}
|
||||
|
||||
internal void NoteLastPickInfo(string sendText)
|
||||
{
|
||||
LastPickInfo = sendText;
|
||||
}
|
||||
internal void NoteLastPlaceInfo(string sendText)
|
||||
{
|
||||
LastPlaceInfo = sendText;
|
||||
}
|
||||
internal void NoteRetracted(bool retracted)
|
||||
{
|
||||
ArmRetracted = retracted;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
public class GotoArgument
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Station { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string R { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Z { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Slot { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Arm { get; set; }
|
||||
}
|
||||
public class PickPlaceArgument
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Station { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Slot { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Arm { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Step { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Offset { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
using System.IO.Ports;
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Siasun1500C800C
|
||||
{
|
||||
public class RobotSiasun1500C800CMessage : AsciiMessage
|
||||
{
|
||||
public string Data { get; set; }
|
||||
public string ErrorText { get; set; }
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CConnection : SerialPortConnectionBase
|
||||
{
|
||||
private bool _isAckMode = false;//should read from config file
|
||||
|
||||
private string _cachedBuffer = string.Empty;
|
||||
|
||||
public RobotSiasun1500C800CConnection(string portName, int baudRate = 19200, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One)
|
||||
: base(portName, baudRate, dataBits, parity, stopBits, "\r", true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool SendMessage(byte[] message)
|
||||
{
|
||||
return base.SendMessage(message);
|
||||
}
|
||||
|
||||
protected override MessageBase ParseResponse(string rawText)
|
||||
{
|
||||
RobotSiasun1500C800CMessage msg = new RobotSiasun1500C800CMessage();
|
||||
msg.RawMessage = rawText;
|
||||
|
||||
if (rawText.Length <= 0)
|
||||
{
|
||||
LOG.Error($"empty response,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
rawText = rawText.Substring(0, rawText.Length - 1);
|
||||
if (rawText.Contains("_ERR"))
|
||||
{
|
||||
msg.IsError = true;
|
||||
|
||||
var rewTextArray = rawText.Split(' ');
|
||||
msg.Data = rewTextArray[1];
|
||||
}
|
||||
else if (rawText == "_RDY")
|
||||
{
|
||||
msg.Data = rawText;
|
||||
|
||||
if (_isAckMode)
|
||||
{
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
}
|
||||
else if(rawText == "BG_RDY")
|
||||
{
|
||||
if (!_isAckMode)
|
||||
{
|
||||
LOG.Error($"response format check failed, BG_RDY is not valid in Mode 1");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
msg.Data = rawText;
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
msg.Data = rawText;
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CTCPConnection : TCPPortConnectionBase
|
||||
{
|
||||
private bool _isAckMode = false;//should read from config file
|
||||
|
||||
public RobotSiasun1500C800CTCPConnection(string address)
|
||||
: base(address, "\r", true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool SendMessage(string message)
|
||||
{
|
||||
return base.SendMessage(message);
|
||||
}
|
||||
|
||||
protected override MessageBase ParseResponse(string rawText)
|
||||
{
|
||||
RobotSiasun1500C800CMessage msg = new RobotSiasun1500C800CMessage();
|
||||
msg.RawMessage = rawText;
|
||||
|
||||
if (rawText.Length <= 0)
|
||||
{
|
||||
LOG.Error($"empty response,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
rawText = rawText.Substring(0, rawText.Length - 1);
|
||||
if (rawText.Contains("_ERR"))
|
||||
{
|
||||
msg.IsError = true;
|
||||
|
||||
var rewTextArray = rawText.Split(' ');
|
||||
msg.Data = rewTextArray[1];
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
else if (rawText == "_RDY")
|
||||
{
|
||||
msg.Data = rawText;
|
||||
|
||||
if (_isAckMode)
|
||||
{
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
}
|
||||
else if (rawText == "BG_RDY")
|
||||
{
|
||||
if (!_isAckMode)
|
||||
{
|
||||
LOG.Error($"response format check failed, BG_RDY is not valid in Mode 1");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
msg.Data = rawText;
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
msg.Data = rawText;
|
||||
msg.IsResponse = true;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
+478
@@ -0,0 +1,478 @@
|
||||
using MECF.Framework.Common.Communications;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Siasun1500C800C
|
||||
{
|
||||
public abstract class RobotSiasun1500C800CHandler : HandlerBase
|
||||
{
|
||||
public RobotSiasun1500C800C Device { get; }
|
||||
|
||||
protected string _command;
|
||||
protected string _parameter;
|
||||
|
||||
protected string _requestResponse = "";
|
||||
|
||||
protected RobotSiasun1500C800CHandler(RobotSiasun1500C800C device, string command, string parameter = null)
|
||||
: base(BuildMessage(command, parameter))
|
||||
{
|
||||
Device = device;
|
||||
_command = command;
|
||||
_parameter = parameter;
|
||||
Name = command;
|
||||
}
|
||||
private static string BuildMessage( string command, string parameter)
|
||||
{
|
||||
string msg = parameter == null ? $"{command}" : $"{command} {parameter}";
|
||||
|
||||
return msg + "\r";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool transactionComplete)
|
||||
{
|
||||
RobotSiasun1500C800CMessage response = msg as RobotSiasun1500C800CMessage;
|
||||
ResponseMessage = msg;
|
||||
|
||||
if (response.IsError)
|
||||
{
|
||||
Device.NoteError(response.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
}
|
||||
|
||||
if (response.IsComplete)
|
||||
{
|
||||
SetState(EnumHandlerState.Completed);
|
||||
transactionComplete = true;
|
||||
return true;
|
||||
}
|
||||
if(response.IsResponse)
|
||||
{
|
||||
_requestResponse = response.Data;
|
||||
}
|
||||
|
||||
transactionComplete = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CRawCommandHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CRawCommandHandler(RobotSiasun1500C800C device, string command, string parameter = null)
|
||||
: base(device, command, parameter)
|
||||
{
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if(base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
var rawMsg = _requestResponse != null ? _requestResponse + "$" + result.RawMessage : result.RawMessage;
|
||||
Device.NoteRawCommandInfo(_command, rawMsg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CGotoHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CGotoHandler(RobotSiasun1500C800C device, string jsonParameter)
|
||||
: base(device, "GOTO", BuildCommandParameter(jsonParameter))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static string BuildCommandParameter(string jsonParameter)
|
||||
{
|
||||
JObject jsonObject = JObject.Parse(jsonParameter);
|
||||
StringBuilder paraBuilder = new StringBuilder();
|
||||
foreach (var item in jsonObject)
|
||||
{
|
||||
string key = item.Key;
|
||||
if (key == "station")
|
||||
key = "N";
|
||||
|
||||
if (paraBuilder.Length == 0)
|
||||
{
|
||||
paraBuilder.Append(key.ToUpper() + " " + item.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
paraBuilder.Append(" " + key.ToUpper() + " " + item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return paraBuilder.Length > 0 ? paraBuilder.ToString() : null;
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
Device.NoteIsHalted(true);
|
||||
|
||||
if (_parameter.Contains("ARM B"))
|
||||
{
|
||||
string position = _parameter.Replace(" ARM B", "");
|
||||
Device.NoteArmBPosition(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
string position = _parameter;
|
||||
if (_parameter.Contains("ARM A"))
|
||||
{
|
||||
position = _parameter.Replace(" ARM A", "");
|
||||
}
|
||||
Device.NoteArmAPosition(position);
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
public class RobotSiasun1500C800CPickHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CPickHandler(RobotSiasun1500C800C device, string jsonParameter)
|
||||
: base(device, "PICK", BuildCommandParameter(jsonParameter))
|
||||
{
|
||||
}
|
||||
|
||||
//N 2 R EX Z DOWN SLOT 1 ARM A
|
||||
static string BuildCommandParameter(string jsonParameter)
|
||||
{
|
||||
JObject jsonObject = JObject.Parse(jsonParameter);
|
||||
StringBuilder paraBuilder = new StringBuilder();
|
||||
foreach (var item in jsonObject)
|
||||
{
|
||||
if (paraBuilder.Length == 0)
|
||||
{
|
||||
paraBuilder.Append(item.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(item.Key == "Slot" || item.Key == "Arm")
|
||||
paraBuilder.Append(" " + item.Key.ToUpper() + " " + item.Value);
|
||||
else
|
||||
paraBuilder.Append(" " + item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return paraBuilder.Length > 0 ? paraBuilder.ToString() : null;
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
Device.NoteLastPickInfo(SendText);
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CPlaceHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CPlaceHandler(RobotSiasun1500C800C device, string jsonParameter)
|
||||
: base(device, "PLACE", BuildCommandParameter(jsonParameter))
|
||||
{
|
||||
}
|
||||
|
||||
static string BuildCommandParameter(string jsonParameter)
|
||||
{
|
||||
JObject jsonObject = JObject.Parse(jsonParameter);
|
||||
StringBuilder paraBuilder = new StringBuilder();
|
||||
foreach (var item in jsonObject)
|
||||
{
|
||||
if (paraBuilder.Length == 0)
|
||||
{
|
||||
paraBuilder.Append(item.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Key == "Slot" || item.Key == "Arm")
|
||||
paraBuilder.Append(" " + item.Key.ToUpper() + " " + item.Value);
|
||||
else
|
||||
paraBuilder.Append(" " + item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return paraBuilder.Length > 0 ? paraBuilder.ToString() : null;
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
Device.NoteLastPlaceInfo(SendText);
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
public class RobotSiasun1500C800CTransferHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CTransferHandler(RobotSiasun1500C800C device, string fromStation, string toStation, string arm = null)
|
||||
: base(device, "XFER", arm == null? $"{fromStation} {toStation}" : $"ARM {arm} {fromStation} {toStation}")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CRetractHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CRetractHandler(RobotSiasun1500C800C device)
|
||||
: base(device, "RETRACT")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
Device.NoteRetracted(true);
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
public class RobotSiasun1500C800CHaltHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CHaltHandler(RobotSiasun1500C800C device)
|
||||
: base(device, "HALT")
|
||||
{
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteIsHalted(false);
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
Device.NoteIsHalted(true);
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CSetCommunicationEchoHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CSetCommunicationEchoHandler(RobotSiasun1500C800C device, string echoStaus)
|
||||
: base(device, "SET COMM ECHO", echoStaus)
|
||||
{
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteSetCommEchoCompleted(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CSetLoadHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CSetLoadHandler(RobotSiasun1500C800C device, string arm, string status)
|
||||
: base(device, "SET LOAD", arm + " " + status)
|
||||
{
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteSetLoadCompleted(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CSevoOnOffHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CSevoOnOffHandler(RobotSiasun1500C800C device, bool isOn)
|
||||
: base(device, isOn ? "SVON" : "SVOFF")
|
||||
{
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
Device.NoteSevoOnOff(_command == "SVON");
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CHomeAxisHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CHomeAxisHandler(RobotSiasun1500C800C device, string parameter)
|
||||
: base(device, "HOME", parameter)
|
||||
{
|
||||
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
Device.NoteAxisHomed(_parameter);
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CQueryWaferOnOffHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CQueryWaferOnOffHandler(RobotSiasun1500C800C device, string jsonParameter)
|
||||
: base(device, "RQ LOAD", jsonParameter != null ? jsonParameter : "A")
|
||||
{
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
|
||||
if (_parameter != null && _parameter.Contains('B'))
|
||||
{
|
||||
Device.NoteWafeOnOff("B", _requestResponse.Contains("ON"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteWafeOnOff("A", _requestResponse.Contains("ON"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class RobotSiasun1500C800CRequestCommunicationEchoHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CRequestCommunicationEchoHandler(RobotSiasun1500C800C device)
|
||||
: base(device, "RQ COMM ECHO")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
|
||||
Device.NoteCommEchoStatus(_requestResponse.Contains("ON"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class RobotSiasun1500C800CRequestWaferCentDataHandler : RobotSiasun1500C800CHandler
|
||||
{
|
||||
public RobotSiasun1500C800CRequestWaferCentDataHandler(RobotSiasun1500C800C device)
|
||||
: base(device, "RQ WAF_CEN DATA")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as RobotSiasun1500C800CMessage;
|
||||
//WAF_CEN RT value1x value1y value4x value4y LFT value2x value2y value3x value3y offset_r offset_t
|
||||
Device.NoteWafeCenData(_requestResponse);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user