refactor: 将Framework库和RT、UI放在同一个解决方案中。

This commit is contained in:
SL
2026-06-01 17:48:28 +08:00
parent 1948f4290d
commit b73d39a6b1
4331 changed files with 506148 additions and 49363 deletions
@@ -0,0 +1,119 @@
using MECF.Framework.RT.EquipmentLibrary.Core.Attributes;
using MECF.Framework.RT.EquipmentLibrary.Core.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobotB
{
public class HiwinRobotBStatus : IBitTypeClass
{
#region Constructor
#endregion
#region Properties
/// <summary>
/// 返回是否已接收巨集指令尚未被执行。
/// </summary>
[BitTypeClassProperty(0, "已接收巨集指令尚未被执行")]
public bool IsCommandNotExecuted { get; private set; }
/// <summary>
/// 返回是否正压力传感器被触发。
/// </summary>
[BitTypeClassProperty(1, "正压力传感器被触发")]
public bool IsPosPressureSensorTriggered { get; private set; }
/// <summary>
/// 返回是否负压力传感器被触发。
/// </summary>
[BitTypeClassProperty(2, "负压力传感器被触发")]
public bool IsNegPressureSensorTriggered { get; private set; }
/// <summary>
/// 返回是否电磁阀已被启动。
/// </summary>
[BitTypeClassProperty(3, "电磁阀已被启动")]
public bool IsSolenoidValveTurnedOn { get; private set; }
/// <summary>
/// 返回是否单轴或多轴马达发生错误。
/// </summary>
[BitTypeClassProperty(4, "单轴或多轴马达发生错误", true)]
public bool IsMotorError { get; private set; }
/// <summary>
/// 返回是否单个或多个极限开关被触发。
/// </summary>
[BitTypeClassProperty(5, "单个或多个极限开关被触发", true)]
public bool IsEndLimitTriggered { get; private set; }
/// <summary>
/// 返回是否单个或多个轴伺服马达归零未成功。
/// </summary>
[BitTypeClassProperty(6, "单个或多个轴伺服马达归零未成功", true)]
public bool IsHomingFailed { get; private set; }
/// <summary>
/// 保留位1。
/// </summary>
[BitTypeClassProperty(7, "保留位1")]
public bool Reserved1 { get; private set; }
/// <summary>
/// 返回是否指令正在执行中。
/// </summary>
[BitTypeClassProperty(8, "指令正在执行中")]
public bool IsCommandExecuting { get; private set; }
/// <summary>
/// 返回是否单个或多个轴正在移动中。
/// </summary>
[BitTypeClassProperty(9, "单个或多个轴正在移动中")]
public bool IsMoving { get; private set; }
/// <summary>
/// 返回是否单个或多个马达已被解除励磁。
/// </summary>
[BitTypeClassProperty(10, "单个或多个马达已被解除励磁中", true)]
public bool IsServoOff { get; private set; }
/// <summary>
/// 返回是否已回原点但RW轴未在原点位置。
/// </summary>
[BitTypeClassProperty(11, "已回原点但RW轴未在原点位置", true)]
public bool IsHomedButRWAxis { get; private set; }
/// <summary>
/// 返回是否已回原点并且处于缩回状态。
/// </summary>
[BitTypeClassProperty(12, "已回原点并且处于缩回状态")]
public bool IsHomedAndRetracted { get; private set; }
/// <summary>
/// 保留位2。
/// </summary>
[BitTypeClassProperty(13, "保留位2")]
public bool Reserved2 { get; private set; }
/// <summary>
/// 返回是否控制器返回错误。
/// </summary>
[BitTypeClassProperty(14, "控制器返回错误", true)]
public bool IsControllerError { get; private set; }
/// <summary>
/// 保留位3。
/// </summary>
[BitTypeClassProperty(15, "保留位3")]
public bool Reserved3 { get; private set; }
#endregion
}
}
@@ -0,0 +1,459 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Aitex.Core.RT.Event;
using Aitex.Core.RT.Log;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.RT.SCCore;
using MECF.Framework.Common.CommonData;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.SubstrateTrackings;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobot
{
public class HwinRobotB : HwinRobot
{
public HwinRobotB(string module, string name, string endof = "\r\n") : base(module, name)
{
OP.Subscribe($"{Module}.SetPosition", (string cmd, object[] args) =>
{
MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Picking,
ArmTarget = RobotArm.ArmA,
BladeTarget = "ArmA." + args[0].ToString(),
};
return true;
});
ModuleAssociateStationDic = new Dictionary<string, string>()
{
{$"{ModuleName.LoadLock }", "B" },
{$"{ModuleName.CassBL}", "A"},
{$"{ModuleName.LoadLock }.Pick", "C" },
{$"{ModuleName.LoadLock }.Place", "B" },
};
}
public override void NoteActionCompleted()
{
//Blade1Target = ModuleName.System;
//Blade2Target = ModuleName.System;
CheckToPostMessage((int)RobotMsg.ActionDone);
}
#region Command Functions
public override void RobotPickB(object[] args)
{
if (args.Length >= 2)
{
_lstHandler.Clear();
lock (_locker)
{
_lstHandler.AddLast(new HwinRobotBGETBHandler(this, args[0].ToString(), Convert.ToInt32(args[1])));
}
}
}
public override void RobotPlaceB(object[] args)
{
if (args.Length >= 2)
{
_lstHandler.Clear();
lock (_locker)
{
_lstHandler.AddLast(new HwinRobotBPUTBHandler(this, args[0].ToString(), Convert.ToInt32(args[1])));
}
}
}
public override void SetWaferData(string data)
{
//0:未扫片 1:有 2:没有 3:斜放 4:两片 5:薄片
string errorMessage = "";
int waferCount = 1;
if (CurrentInteractModule == ModuleName.CassBL)
{
waferCount = 8;
}
if (data.Length == 25)//Wafer Cassette
{
for (int i = 0; i < waferCount; i++)
{
string waferStatue = data.Substring(i, 1);
if (waferStatue == "1")
{
if (!WaferManager.Instance.CheckHasTray(CurrentInteractModule, i))
{
WaferManager.Instance.CreateTray(CurrentInteractModule, i);
}
}
else if (waferStatue == "0" || waferStatue == "X")
{
if (WaferManager.Instance.CheckHasTray(CurrentInteractModule, i))
{
WaferManager.Instance.DeleteWafer(CurrentInteractModule, i);
}
}
else
{
if (!WaferManager.Instance.CheckHasTray(CurrentInteractModule, i))
{
WaferManager.Instance.CreateTray(CurrentInteractModule, i,Aitex.Core.Common.TrayStatus.Crossed);
}
errorMessage += $"slot {i + 1} has crossed wafer!" + "\r\n";
}
}
}
else if (data.Length == 1)
{
if (data == "0")
{
if (!WaferManager.Instance.CheckHasTray(ModuleHelper.Converter(Module), 0))
{
WaferManager.Instance.CreateTray(ModuleHelper.Converter(Module), 0);
}
}
else if (data == "1")
{
if (WaferManager.Instance.CheckHasTray(ModuleHelper.Converter(Module), 0))
{
WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 0);
}
}
}
if (!String.IsNullOrEmpty(errorMessage))
{
EV.PostWarningLog(Module, $"Module {CurrentInteractModule} {errorMessage}");
}
}
//internal override bool ParseErrData(string response)
//{
// try
// {
// var errs = new HiwinRobotAggregatedErrors(response).AggregateErrorMessages;
// if (errs != null)
// {
// foreach (var err in errs)
// {
// EV.PostWarningLog(Module, err);
// }
// }
// return true;
// }
// catch (Exception ex)
// {
// return true;
// }
//}
public override void InputA()
{
_lstHandler.Clear();
lock (_locker)
{
_lstHandler.AddLast(new HwinRobotBINPUTHandler(this));
}
}
public override void RobotRsr()
{
_lstHandler.Clear();
lock (_locker)
{
_lstHandler.AddLast(new HwinRobotBRSRHandler(this));
}
}
public override void RobotConnectHomeAll()
{
IsBusy = false;
base.Connection.ForceClear();
_lstHandler.Clear();
lock (_locker)
{
_lstHandler.AddLast(new HwinRobotRespHandler(this));
_lstHandler.AddLast(new HwinRobotRemsHandler(this));
_lstHandler.AddLast(new HwinRobotSVONHandler(this));
_lstHandler.AddLast(new HwinRobotHomeHandler(this, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotBOPTClosePHandler(this));
_lstHandler.AddLast(new HwinRobotBINPUTHandler(this));
_lstHandler.AddLast(new HwinRobotBOPTPHandler(this));
}
}
#endregion
#region Note Functions
public void ContineHome()
{
fAbort(null);
_lstHandler.AddLast(new HwinRobotHomeHandler(this, _scHomeTimeout.IntValue));
}
public override bool ReadParameter(object[] param)
{
IsBusy = true;
return CheckToPostMessage((int)RobotMsg.ReadData, param);
}
protected override bool fStartMapWafer(object[] param)
{
try
{
if (param.Length >= 1)
{
lock (_locker)
{
_lstHandler.AddLast(new HwinRobotMapHandler(this, param[0].ToString(), _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotBRSRHandler(this, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotHomeHandler(this, _scMotionTimeout.IntValue));
}
}
}
catch (Exception ex)
{
LOG.Write(ex);
return false;
}
return true;
}
protected override bool fStartPlaceWafer(object[] param)
{
try
{
//arm, station, slot
if (param.Length >= 3)
{
lock (_locker)
{
if (param[1].ToString() == ModuleName.LoadLock.ToString())
{
/* 1.打开夹爪
* 2.取盘位置低位
* 3.抬升托盘
*/
int _rDistance = SC.GetValue<int>("TrayRobot.PlaceRMoveDistance");
_lstHandler.AddLast(new HwinRobotBOPTPHandler(this, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotMTCSPHandler(this, $"{param[1].ToString()}", "Place", _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotMOVRPHandler(this, _rDistance, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotRETHHandler(this, _scMotionTimeout.IntValue));
//_lstHandler.AddLast(new HwinRobotBOPTClosePHandler(this, _scMotionTimeout.IntValue));
}
else
{
_lstHandler.AddLast(new HwinRobotBPUTBHandler(this, param[1].ToString(), Convert.ToInt32(param[2]), _scMotionTimeout.IntValue));
}
}
}
}
catch (Exception ex)
{
LOG.Write(ex);
return false;
}
return true;
}
//(module, slot)
protected override bool fStartPickWafer(object[] param)
{
try
{
//Load 高位B,Load 低位C
//arm, station, slot
if (param.Length >= 3)
{
lock (_locker)
{
if (param[1].ToString() == ModuleName.LoadLock.ToString())
{
/* 1.打开夹爪
* 2.取盘位置低位
* 3.抬升托盘
* 4.收回
*/
int _rDistance = SC.GetValue<int>("TrayRobot.PickRMoveDistance");
_lstHandler.AddLast(new HwinRobotBOPTPHandler(this, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotMTCSPHandler(this, $"{param[1].ToString()}", "Pick", _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotMOVRGHandler(this, _rDistance, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotRETHHandler(this, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new HwinRobotBOPTClosePHandler(this, _scMotionTimeout.IntValue));
}
else
{
string str = $"{param[1]} {Convert.ToInt32(param[2])}";
_lstHandler.AddLast(new HwinRobotBGETBHandler(this, param[1].ToString(), Convert.ToInt32(param[2]), _scMotionTimeout.IntValue));
}
}
}
}
catch (Exception ex)
{
LOG.Write(ex);
return false;
}
return true;
}
protected override bool fPlaceComplete(object[] param)
{
IsBusy = false;
return true;
}
protected override bool fPickComplete(object[] param)
{
IsBusy = false;
return true;
}
protected override bool fReset(object[] param)
{
_trigError.RST = true;
Connection.SetCommunicationError(false, "");
_trigCommunicationError.RST = true;
_trigRetryConnect.RST = true;
if (_isAlarm)
{
lock (_locker)
{
//_lstHandler.AddLast(new HwinRobotBResetHandler(this));
}
Thread.Sleep(100);
CheckToPostMessage((int)RobotMsg.ActionDone);
}
IsBusy = false;
return true;
}
//[module][slot]
protected override bool fStartExtendForPick(object[] param)
{
try
{
//if (param.Length >= 2)
//{
// lock (_locker)
// {
// _lstHandler.AddLast(new HwinRobotBGETSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 1, _scMotionTimeout.IntValue));
// _lstHandler.AddLast(new HwinRobotBGETSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 2, _scMotionTimeout.IntValue));
// }
//}
}
catch (Exception ex)
{
LOG.Write(ex);
return false;
}
return true;
}
protected override bool fStartExtendForPlace(object[] param)
{
try
{
//if (param.Length >= 2)
//{
// lock (_locker)
// {
// _lstHandler.AddLast(new HwinRobotBPUTSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 1, _scMotionTimeout.IntValue));
// _lstHandler.AddLast(new HwinRobotBPUTSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 2, _scMotionTimeout.IntValue));
// }
//}
}
catch (Exception ex)
{
LOG.Write(ex);
return false;
}
return true;
}
/// <summary>
/// 开始从Pick处缩回
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
protected override bool fStartRetractFromPick(object[] param)
{
try
{
//if (param.Length >= 2)
//{
// lock (_locker)
// {
// _lstHandler.AddLast(new HwinRobotBGETSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 3, _scMotionTimeout.IntValue));
// _lstHandler.AddLast(new HwinRobotBGETSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 4, _scMotionTimeout.IntValue));
// }
//}
}
catch (Exception ex)
{
LOG.Write(ex);
return false;
}
return true;
}
/// <summary>
/// 开始从Place处缩回
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
protected override bool fStartRetractFromPlace(object[] param)
{
try
{
//if (param.Length >= 2)
//{
// lock (_locker)
// {
// _lstHandler.AddLast(new HwinRobotBPUTSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 3, _scMotionTimeout.IntValue));
// _lstHandler.AddLast(new HwinRobotBPUTSPHandler(this, param[0].ToString(), Convert.ToInt32(param[1]), 4, _scMotionTimeout.IntValue));
// }
//}
}
catch (Exception ex)
{
LOG.Write(ex);
return false;
}
return true;
}
#endregion
}
}
@@ -0,0 +1,94 @@
using System.Collections.Generic;
using System.IO.Ports;
using System.Text;
using Aitex.Core.RT.Log;
using MECF.Framework.Common.Communications;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobot
{
public class HwinRobotBMessage : AsciiMessage
{
public string Data { get; set; }
public string ErrorText { get; set; }
}
public class HwinRobotBTCPConnection : TCPPortConnectionBase
{
private bool _isAckMode = false;//should read from config file
public HwinRobotBTCPConnection(string address, string endof)
: base(address, endof, true)
{
}
public override bool SendMessage(string message)
{
return base.SendMessage(message);
}
protected override void ActiveHandlerProceedMessage(MessageBase msg)
{
lock (_lockerActiveHandler)
{
if (_activeHandler != null)
{
if (msg.IsFormatError || !((HwinRobotBHandler)_activeHandler).HasResponse || (_activeHandler.HandleMessage(msg, out bool transactionComplete) && transactionComplete))
{
_activeHandler = null;
}
}
}
}
protected override MessageBase ParseResponse(string rawText)
{
HwinRobotBMessage msg = new HwinRobotBMessage();
msg.RawMessage = rawText;
if (rawText.Length <= 0)
{
LOG.Error($"empty response,");
msg.IsFormatError = true;
return msg;
}
rawText = rawText.Replace("\r", "").Replace("\n", "");
if (rawText.Contains("_ERR"))
{
msg.IsError = true;
var rewTextArray = rawText.Split(' ');
msg.Data = rewTextArray[1];
msg.IsComplete = true;
}
else if (rawText.Contains("_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 if (rawText.Contains("_RDY"))
{
msg.Data = rawText.Replace("_RDY", "");
msg.IsResponse = true;
msg.IsAck = true;
msg.IsComplete = true;
}
else
{
msg.Data = rawText;
msg.IsResponse = true;
}
return msg;
}
}
}
@@ -0,0 +1,797 @@
using Aitex.Sorter.Common;
using MECF.Framework.Common.CommonData;
using MECF.Framework.Common.Communications;
using MECF.Framework.Common.Equipment;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using System.Text;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobort.Errors;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobot
{
public abstract class HwinRobotBHandler : HandlerBase
{
public HwinRobotB Device { get; }
public bool HasResponse { get; set; } = true;
protected string _command;
protected string _parameter;
protected string _target;
protected RobotArmEnum _blade;
protected string _requestResponse = "";
protected HwinRobotBHandler(HwinRobotB 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\n";
}
public override bool HandleMessage(MessageBase msg, out bool transactionComplete)
{
HwinRobotBMessage response = msg as HwinRobotBMessage;
ResponseMessage = msg;
if (response.IsError)
{
Device.NoteError(response.Data);
}
if (response.IsComplete)
{
SetState(EnumHandlerState.Completed);
transactionComplete = true;
return true;
}
if (response.IsResponse)
{
_requestResponse = response.Data;
}
transactionComplete = false;
return false;
}
}
public class HwinRobotBSTATHandler : HwinRobotBHandler
{
// STAT
public HwinRobotBSTATHandler(HwinRobotB device, int timeout = 5)
: base(device, $"STAT")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot STAT Timeout");
return true;
}
if (result.Data == "?")
{
Device.NoteError("Robot STAT Response Error");
return false;
}
if (int.TryParse(result.Data, out var stat))
{
//Wafer位置从机械手和Station之间转换
Device.ParseStatusData(stat);
}
else
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBERRHandler : HwinRobotBHandler
{
// STAT
public HwinRobotBERRHandler(HwinRobotB device, int timeout = 5)
: base(device, $"ERR 0")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot ERR Timeout");
return true;
}
if (result.Data == "?")
{
Device.NoteError("Robot ERR Response Error",false);
return false;
}
if (HiwinRobotAggregatedErrors.IsErrResponse(result.Data, out _))
{
Device.ParseErrData(result.Data);
}
else
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBGETBHandler : HwinRobotBHandler
{
//GETB [module],[slot]
string cModule = "";
public HwinRobotBGETBHandler(HwinRobotB device, string module, int slot, int timeout = 60)
: base(device, $"GETB {device.ModuleAssociateStationDic[module]} {slot + 1}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
cModule = module;
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Picking,
ArmTarget = RobotArm.ArmA,
BladeTarget = module,
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot GETB Timeout");
return true;
}
if (result.Data == ">")
{
Device.GetWaferData();
Device.NotePickCompleted();
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
}
else if (result.Data == "?")
{
Device.NoteError("Robot GETB Response Error");
return true;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBPUTBHandler : HwinRobotBHandler
{
//PUTA [module],[slot]
string cModule = "";
public HwinRobotBPUTBHandler(HwinRobotB device, string module, int slot, int timeout = 60)
: base(device, $"PUTB {device.ModuleAssociateStationDic[module]} {slot + 1}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
cModule = module;
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Placing,
ArmTarget = RobotArm.ArmA,
BladeTarget = module,
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot PUTB Timeout");
return true;
}
if (result.Data == ">")
{
Device.PutWaferData();
Device.NotePlaceCompleted();
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
}
else if (result.Data == "?")
{
Device.NoteError("Robot PUTB Response Error");
return false;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBMapHandler : HwinRobotBHandler
{
//MAP [module]
string cModule = "";
public HwinRobotBMapHandler(HwinRobotB device, string module, int timeout = 60)
: base(device, $"MAP {device.ModuleAssociateStationDic[module].ToLower()}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Picking,
ArmTarget = RobotArm.ArmA,
BladeTarget = module,
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot MAP Timeout");
return true;
}
if (result.Data == ">")
{
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
}
else if (result.Data == "?")
{
Device.NoteError("Robot MAP Response Error");
return false;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBRSRHandler : HwinRobotBHandler
{
//RSR
public HwinRobotBRSRHandler(HwinRobotB device, int timeout = 60)
: base(device, $"RSR")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot RSR Timeout");
return true;
}
if (result.Data.Length > 5 )
{
Device.SetWaferData(result.Data);
}
else if (result.Data == "?")
{
Device.NoteError("Robot RSR Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
Device.NoteActionCompleted();
handled = true;
return true;
}
}
public class HwinRobotBINPUTHandler : HwinRobotBHandler
{
// INPUT A 3
public HwinRobotBINPUTHandler(HwinRobotB device, int timeout = 5)
: base(device, $"INPUT A 6")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot INPUT Timeout");
return true;
}
if (result.Data.Length == 1)
{
Device.SetWaferData(result.Data);
}
else if (result.Data == "?")
{
Device.NoteError("Robot INPUT Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
Device.NoteActionCompleted();
handled = true;
return true;
}
}
public class HwinRobotBRespHandler : HwinRobotBHandler
{
//RESP 确认控制器是否成功建立与主控电脑的通信
public HwinRobotBRespHandler(HwinRobotB device, int timeout = 60)
: base(device, $"RESP")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot RESP Timeout");
return true;
}
if (result.Data == ">")
{
}
else if (result.Data == "?")
{
Device.NoteError("Robot RESP Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBRemsHandler : HwinRobotBHandler
{
//RESP 确认控制器是否成功建立与主控电脑的通信
public HwinRobotBRemsHandler(HwinRobotB device, int timeout = 60)
: base(device, $"REMS")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot REMS Timeout");
return true;
}
if (result.Data == ">")
{
}
else if (result.Data == "?")
{
Device.NoteError("Robot REMS Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBSVONHandler : HwinRobotBHandler
{
//SVON 用以激磁位于机械手臂内之伺服马达
public HwinRobotBSVONHandler(HwinRobotB device, int timeout = 60)
: base(device, $"SVON")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot SVON Timeout");
return true;
}
if (result.Data == ">")
{
}
else if (result.Data == "?")
{
Device.NoteError("Robot SVON Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBHomeHandler : HwinRobotBHandler
{
//HOM
public HwinRobotBHomeHandler(HwinRobotB device, int timeout = 60)
: base(device, $"HOM")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.Both,
BladeTarget = "ArmA.System",
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot HOM Timeout");
return true;
}
if (result.Data == ">")
{
Device.IsBusy = false;
}
else if (result.Data == "?")
{
//Device.ContineHome();
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
//Device.NoteActionCompleted();
return true;
}
}
public class HwinRobotBOPTClosePHandler : HwinRobotBHandler
{
//打开夹爪
public HwinRobotBOPTClosePHandler(HwinRobotB device, int timeout = 60)
: base(device, $"OUTP 1 1")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot OUTP Timeout");
return true;
}
if (result.Data == ">")
{
}
else if (result.Data == "?")
{
return false;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotBOPTPHandler : HwinRobotBHandler
{
//打开夹爪
public HwinRobotBOPTPHandler(HwinRobotB device, int timeout = 60)
: base(device, $"OUTP 1 0")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot OUTP Timeout");
return true;
}
if (result.Data == ">")
{
}
else if (result.Data == "?")
{
return false;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotMTCSPHandler : HwinRobotBHandler
{
//前往位置
public HwinRobotMTCSPHandler(HwinRobotB device, string module,string strAction, int timeout = 60)
: base(device, $"MTCS {device.ModuleAssociateStationDic[$"{module}.{strAction}"].ToUpper()}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = module,
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot MTCS Timeout");
return true;
}
if (result.Data == ">")
{
}
else if (result.Data == "?")
{
return false;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotMOVRPHandler : HwinRobotBHandler
{
//抬升或下降 一定距离
public HwinRobotMOVRPHandler(HwinRobotB device, int rDistance, int timeout = 60)
: base(device, $"MOVR Z {rDistance}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot MOVR Z Timeout");
return true;
}
if (result.Data == ">")
{
Device.PutWaferData();
}
else if (result.Data == "?")
{
Device.NoteError("Robot MOVR Z Response Error");
return false;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotMOVRGHandler : HwinRobotBHandler
{
//抬升或下降 一定距离
public HwinRobotMOVRGHandler(HwinRobotB device, int rDistance, int timeout = 60)
: base(device, $"MOVR Z {rDistance}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot MOVR Z Timeout");
return true;
}
if (result.Data == ">")
{
Device.GetWaferData();
}
else if (result.Data == "?")
{
Device.NoteError("Robot MOVR Z Response Error");
return false;
}
ResponseMessage = msg;
handled = true;
return true;
}
}
public class HwinRobotRETHHandler : HwinRobotBHandler
{
//缩回
public HwinRobotRETHHandler(HwinRobotB device, int timeout = 60)
: base(device, $"RETH")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = "ArmA.System",
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as HwinRobotBMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot RETH Timeout");
return true;
}
if (result.Data == ">")
{
Device.NotePickCompleted();
}
else if (result.Data == "?")
{
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
Device.NoteActionCompleted();
return true;
}
}
}