SunWayRobot.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. using Aitex.Core.RT.Log;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Sorter.Common;
  4. using MECF.Framework.Common.CommonData;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.SubstrateTrackings;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  8. using System;
  9. using System.Collections.Concurrent;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Text.RegularExpressions;
  14. using System.Threading.Tasks;
  15. using Venus_Core;
  16. using Venus_RT.Devices.VCE;
  17. namespace Venus_RT.Devices.TM
  18. {
  19. public class SunWayRobot : ITransferRobot
  20. {
  21. private readonly AsyncSocket _socket;
  22. private const string EOF = "\n";
  23. private RState _status;
  24. private bool _IsHomed;
  25. private VRStep _currentStep = VRStep.Idle;
  26. private Dictionary<string, int> _StationNumbers = new Dictionary<string, int>();
  27. public RState Status { get { return _status; } }
  28. public bool IsHomed { get { return _IsHomed; } }
  29. private string Hand2Arm(Hand hand) => hand == Hand.Blade2 ? "B" : "A";
  30. //private readonly Regex _rex_check_load = new Regex(@"LOAD\s+(A|B)\s+(\w+)\s*");
  31. private readonly Regex _rex_check_load = new Regex(@"CHECK LOAD\s*");
  32. private readonly Regex _rex_rq_load_A = new Regex(@"LOAD\sA\s.*");
  33. private readonly Regex _rex_rq_load_B = new Regex(@"LOAD\sB\s.*");
  34. private readonly Regex _rex_error_code = new Regex(@"_ERR\s+(\d+)\s*");
  35. private readonly Regex _rex_rq_speed = new Regex(@"MOTIONPARA.*");
  36. private RobotMoveInfo _robotMoveInfo = new RobotMoveInfo();
  37. private string _WithWaferSpeed = "";
  38. private string _NoWaferSpeed = "";
  39. public string WithWaferSpeed => _WithWaferSpeed;
  40. public string NoWaferSpeed => _NoWaferSpeed;
  41. public RobotMoveInfo TMRobotMoveInfo { get { return _robotMoveInfo; } }
  42. public double Offset_X => 0;
  43. public double Offset_Y => 0;
  44. public double Offset_D => 0;
  45. public Dictionary<string, string> _error2msg = new Dictionary<string, string>()
  46. {
  47. {"221" , "手臂选择无效,检查指令中的对应参数" },
  48. {"222" , "无效的 Pan 参数"},
  49. {"305" , "无法识别的命令,检查指令" },
  50. {"309" , "不支持的指令,检查指令" },
  51. {"350" , "解析器错误,堆栈溢出,检查指令" },
  52. {"402" , "槽位参数异常,检查指令中的对应参数" },
  53. {"403" , "Slot编号错误,指令的参数中指定的 Slot 编号超过了有效范围" },
  54. {"407" , "旋转轴超过限位,检查指令中的对应参数" },
  55. {"408" , "伸展轴超过限位,检查指令中的对应参数" },
  56. {"409" , "升降轴超过限位,检查指令中的对应参数" },
  57. {"416" , "无法执行 CheckLoad 操作,检查指令中的对应参数" },
  58. {"417" , "Offset 参数参数超限,检查指令中指定的 offset 值是否在允许范围内" },
  59. {"418" , "AWC 功能检测到误差过大,检查晶圆是否过偏或检查AWC传感器标定参数" },
  60. {"420" , "副臂没有在HOME位置,请检查副臂的位置,可以使用HOME ALL使得所有关节姿态回到HOME位置" },
  61. {"451" , "取片后 AWC校验异常,机械臂取片后缩回时,检测到晶圆偏心过大,或者 AWC 校验失败" },
  62. {"550" , "Station参数超出范围,检查站点配置参数" },
  63. {"551" , "ARM 不在站点,检查当前手臂实际位置与逻辑位置" },
  64. {"560" , "机械臂处于 HALT 状态,拒绝接受新的指令" },
  65. {"561" , "当前机械臂状态机与指令不匹配,当前状态机不满足执行该指令的条件" },
  66. {"600" , "PAligner通讯异常,检查与 PA 的通讯电缆,上电情况等" },
  67. {"603" , "收到急停指令" },
  68. {"608" , "机械臂急停中" },
  69. {"610" , "手持示教器急停按钮按下" },
  70. {"692" , "检测左 PAN 上有片,与逻辑状态不匹配" },
  71. {"693" , "检测右 PAN 上有片,与逻辑状态不匹配" },
  72. {"694" , "检测左 PAN 上无片,与逻辑状态不匹配" },
  73. {"695" , "检测右 PAN 上有片,与逻辑状态不匹配" },
  74. {"700" , "当前手臂有晶圆 ,检查指令动作要求的晶圆状态,与手臂内部存储的晶圆状态是否匹配" },
  75. {"701" , "当前手臂无晶圆,检查指令动作要求的晶圆状态,与手臂内部存储的晶圆状态是否匹配"},
  76. {"711" , "站点互锁错误,检查站点的“允许机械臂进入信号”是否就绪"},
  77. {"721" , "取片失败,检查手臂晶圆状态,或者晶圆检测传感器状态"},
  78. {"722" , "放片失败,检查手臂晶圆状态,或者晶圆检测传感器状态"},
  79. {"771" , "取片时 AWC 传感器检测失败,检查 AWC 传感器状态,或者 AWC 配置相关是否正确"},
  80. {"791" , "查询 AWC 数据失败,未曾执行过 AWC 相关功能的操作"},
  81. {"792" , "AWC 传感器检测失败,检查AWC传感器状态,或者AWC配置相关是否正确"},
  82. {"799" , "放片失败,检查手臂晶圆状态,或者晶圆检测传感器状态"},
  83. {"802" , "伺服报错,伺服提示异常,目前暂时无法读取伺服错误。开机盖可以读到伺服信息。一般整机断电重启。"},
  84. {"803" , "机械臂上电失败,HOME ALL 指令,或者其他上电操作,驱动器未能正常响应上电"},
  85. {"805" , "第1个伺服收敛异常,伺服没有在规定时间内运动到位置,或者停稳。"},
  86. {"806" , "第2个伺服收敛异常,伺服没有在规定时间内运动到位置,或者停稳。"},
  87. {"807" , "第3个伺服收敛异常,伺服没有在规定时间内运动到位置,或者停稳。"},
  88. {"808" , "第4个伺服收敛异常,伺服没有在规定时间内运动到位置,或者停稳。"},
  89. {"1100" , "无法安全回 HOME 操作,检查机械臂是否在安全 HOME 半径内,常见于双臂机械臂,双臂同时伸出超过安全位"},
  90. {"1805" , "当前处于示教器模式,检查示教器档位,一般此时处于 Teach 档位"},
  91. {"13004" , "PA报错,检查 PA 运行状态,PA 扫片结果等"},
  92. };
  93. private BlockingCollection<RobotAnimationData> blockingCollection = new BlockingCollection<RobotAnimationData>();
  94. private ModuleName _module;
  95. public SunWayRobot(ModuleName module)
  96. {
  97. _module = module;
  98. _socket = new AsyncSocket("", EOF);
  99. _socket.Connect(SC.GetStringValue($"{_module}.IPAddress"));
  100. _socket.OnDataChanged += OnReceiveMessage;
  101. _socket.OnErrorHappened += OnErrorHappen;
  102. _status = RState.Init;
  103. _IsHomed = false;
  104. _StationNumbers[ModuleName.VCE1.ToString()] = SC.GetValue<int>($"{_module}.VCE1StationNumber");
  105. _StationNumbers[ModuleName.VCEA.ToString()] = SC.GetValue<int>($"{_module}.VCEAStationNumber");
  106. _StationNumbers[ModuleName.VCEB.ToString()] = SC.GetValue<int>($"{_module}.VCEBStationNumber");
  107. _StationNumbers[ModuleName.Aligner1.ToString()] = SC.GetValue<int>($"{_module}.Aligner1StationNumber");
  108. _StationNumbers[ModuleName.PMA.ToString()] = SC.GetValue<int>($"{_module}.PMAStationNumber");
  109. _StationNumbers[ModuleName.PMB.ToString()] = SC.GetValue<int>($"{_module}.PMBStationNumber");
  110. _StationNumbers[ModuleName.PMC.ToString()] = SC.GetValue<int>($"{_module}.PMCStationNumber");
  111. _StationNumbers[ModuleName.PMD.ToString()] = SC.GetValue<int>($"{_module}.PMDStationNumber");
  112. _StationNumbers["CheckLoad"] = SC.GetValue<int>($"{_module}.CheckStationNumber");
  113. WaferManager.Instance.SubscribeLocation(ModuleName.TMRobot, 2);
  114. Task.Run(() =>
  115. {
  116. foreach (var data in blockingCollection.GetConsumingEnumerable())
  117. {
  118. _robotMoveInfo.Action = data.Action;
  119. _robotMoveInfo.ArmTarget = data.Hand == Hand.Blade1 ? RobotArm.ArmA : (data.Hand == Hand.Both ? RobotArm.Both : RobotArm.ArmB);
  120. _robotMoveInfo.BladeTarget = $"{_robotMoveInfo.ArmTarget}.{data.Target}";
  121. System.Threading.Thread.Sleep(600);
  122. }
  123. });
  124. }
  125. //初始化某个轴
  126. //1.清错
  127. //2.设备上电
  128. //3.各轴按顺序运动
  129. public bool Home()
  130. {
  131. _status = RState.Running;
  132. _currentStep = VRStep.Home;
  133. return _SendCommand("HOME ALL");
  134. }
  135. public bool Halt()
  136. {
  137. _status = RState.Running;
  138. _currentStep = VRStep.Halt;
  139. return _SendCommand("HALT");
  140. }
  141. public bool Release()
  142. {
  143. _status = RState.Running;
  144. _currentStep = VRStep.Release;
  145. return _SendCommand("RELEASE");
  146. }
  147. //public bool MOVE()
  148. //{
  149. //}
  150. public bool Pick(ModuleName station, int slot, Hand hand)
  151. {
  152. if (!CheckRobotStatus())
  153. return false;
  154. _currentStep = VRStep.Pick;
  155. _status = RState.Running;
  156. SetRobotMovingInfo(RobotAction.Picking, hand, station);
  157. return _SendCommand($"PICK {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)}");
  158. }
  159. public bool PickExtend(ModuleName station, int slot, Hand hand)
  160. {
  161. if (!CheckRobotStatus())
  162. return false;
  163. _currentStep = VRStep.PickExtend;
  164. _status = RState.Running;
  165. SetRobotMovingInfo(RobotAction.Extending, hand, station);
  166. return _SendCommand($"PICK {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)} ENRT NR");
  167. }
  168. public bool PickRetract(ModuleName station, int slot, Hand hand)
  169. {
  170. if (!CheckRobotStatus())
  171. return false;
  172. _currentStep = VRStep.PickRetract;
  173. _status = RState.Running;
  174. SetRobotMovingInfo(RobotAction.Retracting, hand, station);
  175. return _SendCommand($"PICK {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)} STRT NR");
  176. }
  177. public bool Place(ModuleName station, int slot, Hand hand)
  178. {
  179. if (!CheckRobotStatus())
  180. return false;
  181. _currentStep = VRStep.Place;
  182. _status = RState.Running;
  183. SetRobotMovingInfo(RobotAction.Placing, hand, station);
  184. return _SendCommand($"PLACE {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)}");
  185. }
  186. public bool PlaceExtend(ModuleName station, int slot, Hand hand)
  187. {
  188. if (!CheckRobotStatus())
  189. return false;
  190. _currentStep = VRStep.Place;
  191. _status = RState.Running;
  192. SetRobotMovingInfo(RobotAction.Extending, hand, station);
  193. return _SendCommand($"PLACE {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)} ENRT NR");
  194. }
  195. public bool PlaceRetract(ModuleName station, int slot, Hand hand)
  196. {
  197. if (!CheckRobotStatus())
  198. return false;
  199. _currentStep = VRStep.Place;
  200. _status = RState.Running;
  201. SetRobotMovingInfo(RobotAction.Retracting, hand, station);
  202. return _SendCommand($"PLACE {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)} STRT NR");
  203. }
  204. public bool Transfer(ModuleName fromstation, ModuleName tostation, Hand hand)
  205. {
  206. if (!CheckRobotStatus())
  207. return false;
  208. _currentStep = VRStep.Xfer;
  209. _status = RState.Running;
  210. return _SendCommand($"XFER ARM {Hand2Arm(hand)} {_StationNumbers[fromstation.ToString()]} {_StationNumbers[tostation.ToString()]}");
  211. }
  212. public bool CheckLoad(Hand hand = Hand.Blade1)
  213. {
  214. if (_currentStep != VRStep.Home && _currentStep != VRStep.CheckLoad_ArmA && !CheckRobotStatus())
  215. return false;
  216. _currentStep = hand == Hand.Blade2 ? VRStep.CheckLoad_ArmB : VRStep.CheckLoad_ArmA;
  217. _status = RState.Running;
  218. string arm = hand == Hand.Blade2 ? "B" : "A";
  219. return _SendCommand($"CHECK LOAD {_StationNumbers["CheckLoad"]} {arm}");
  220. }
  221. public bool QueryAwc()
  222. {
  223. return true;
  224. }
  225. public bool Goto(ModuleName station, int slot, Hand hand)
  226. {
  227. if (!CheckRobotStatus())
  228. return false;
  229. _currentStep = VRStep.Goto;
  230. _status = RState.Running;
  231. SetRobotMovingInfo(RobotAction.Rotating, hand, station);
  232. return _SendCommand($"Goto {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)}");
  233. }
  234. public bool MoveTo(ModuleName stnFrom, ModuleName stnTo, Hand hand)
  235. {
  236. _currentStep = VRStep.Move;
  237. _status = RState.Running;
  238. return _SendCommand($"MOVE R ABS 100 ARM {Hand2Arm(hand)}"); ;
  239. }
  240. public bool PickWithOffset(ModuleName station, int slot, Hand hand, int Roffset, int Toffset)
  241. {
  242. _currentStep = VRStep.Pick;
  243. _status = RState.Running;
  244. SetRobotMovingInfo(RobotAction.Picking, hand, station);
  245. return _SendCommand($"PICK {_StationNumbers[station.ToString()]} ARM {Hand2Arm(hand)} RO {Roffset} TO {Toffset}"); ;
  246. }
  247. public bool ReQueryLoadA()
  248. {
  249. _currentStep = VRStep.ReQueryLoadA;
  250. _status = RState.Running;
  251. return _SendCommand($"RQ LOAD ARM A");
  252. }
  253. public bool ReQueryLoadB()
  254. {
  255. _currentStep = VRStep.ReQueryLoadB;
  256. _status = RState.Running;
  257. return _SendCommand($"RQ LOAD ARM B");
  258. }
  259. public bool SetSpeed(string withwafer, float speed)
  260. {
  261. if (!CheckRobotStatus())
  262. return false;
  263. _currentStep = VRStep.SetSpeed;
  264. _status = RState.Running;
  265. int setspeed = (int)Math.Floor(speed * 10);
  266. return _SendCommand($"SET MOTIONPARA {withwafer} SPDPCT ALL {setspeed.ToString().PadLeft(4, '0')}");
  267. }
  268. public bool SaveSpeed(string withwafer)
  269. {
  270. if (!CheckRobotStatus())
  271. return false;
  272. _currentStep = VRStep.SaveSpeed;
  273. _status = RState.Running;
  274. return _SendCommand($"STORE MOTIONPARA {withwafer} SPDPCT ALL");
  275. }
  276. public bool QuerySpeed(string withwafer)
  277. {
  278. if (!CheckRobotStatus())
  279. return false;
  280. _currentStep = VRStep.RQSpeed;
  281. _status = RState.Running;
  282. //MOTIONPARA {} SPDPCT all x t z
  283. return _SendCommand($"RQ MOTIONPARA {withwafer} SPDPCT ALL");
  284. }
  285. public bool ServeOn(bool IsOn)
  286. {
  287. _currentStep = VRStep.ServeOn;
  288. _status = RState.Running;
  289. if (IsOn)
  290. return _SendCommand($"SET SERVOS ON");
  291. else
  292. return _SendCommand($"SET SERVOS OFF");
  293. }
  294. private bool _SendCommand(string cmd)
  295. {
  296. LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Send Command to TMRobot: {cmd},Connect:{_socket.IsConnected}");
  297. return _socket.Write(cmd + EOF);
  298. }
  299. private bool CheckRobotStatus()
  300. {
  301. if (Status == RState.Init)
  302. {
  303. LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.TMRobot, "TMRobot is not homed, please home first.");
  304. return false;
  305. }
  306. else if (Status == RState.Running)
  307. {
  308. LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.TMRobot, "TMRobot is busy, please wait a minute");
  309. return false;
  310. }
  311. else if (Status == RState.Failed || Status == RState.Timeout)
  312. {
  313. LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.TMRobot, "TMRobot has a error, please check and fix the hardware issue and home it");
  314. return false;
  315. }
  316. return true;
  317. }
  318. private void OnReceiveMessage(string revMsg)
  319. {
  320. string[] ResMsgs = revMsg.Split('\n');
  321. foreach (string revRawMsg in ResMsgs)
  322. {
  323. if (string.IsNullOrWhiteSpace(revRawMsg)) continue;
  324. string RevMsg = revRawMsg.Trim();
  325. LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Receive message from TMRobot: {RevMsg}, while {_currentStep}");
  326. if (_rex_error_code.IsMatch(RevMsg))
  327. {
  328. _IsHomed = false;
  329. _status = RState.Failed;
  330. var results = _rex_error_code.Match(RevMsg);
  331. ErrorMessageHandler(results.Groups[1].Value);
  332. return;
  333. }
  334. switch (_currentStep)
  335. {
  336. case VRStep.Goto:
  337. case VRStep.Halt:
  338. case VRStep.Move:
  339. case VRStep.Xfer:
  340. case VRStep.SetSpeed:
  341. case VRStep.SaveSpeed:
  342. case VRStep.Pick:
  343. case VRStep.PickExtend:
  344. case VRStep.PickRetract:
  345. case VRStep.Place:
  346. case VRStep.PlaceExtend:
  347. case VRStep.PlaceRetract:
  348. {
  349. if (RevMsg.Trim() == "_RDY" || (RevMsg.Contains("_RDY") && !RevMsg.Contains("_ERR")))
  350. {
  351. _currentStep = VRStep.Idle;
  352. _status = RState.End;
  353. }
  354. else
  355. {
  356. ReportWrongMsg(RevMsg);
  357. }
  358. if (_currentStep != VRStep.PickExtend && _currentStep != VRStep.PlaceExtend)
  359. SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.TMRobot);
  360. }
  361. break;
  362. case VRStep.Home:
  363. {
  364. if (RevMsg.Trim() == "_RDY")
  365. {
  366. //CheckLoad(Hand.Blade1);
  367. _currentStep = VRStep.Idle;
  368. _status = RState.End;
  369. _IsHomed = true;
  370. SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.TMRobot);
  371. }
  372. else
  373. ReportWrongMsg(RevMsg);
  374. }
  375. break;
  376. case VRStep.CheckLoad_ArmA:
  377. {
  378. if (_rex_check_load.IsMatch(RevMsg))
  379. {
  380. GetCheckLoadResult(RevMsg);
  381. //CheckLoad(Hand.Blade2);
  382. }
  383. if (RevMsg.Trim() == "_RDY" || (RevMsg.Contains("_RDY") && !RevMsg.Contains("_ERR")))
  384. {
  385. _currentStep = VRStep.Idle;
  386. _status = RState.End;
  387. }
  388. }
  389. break;
  390. case VRStep.CheckLoad_ArmB:
  391. {
  392. if (_rex_check_load.IsMatch(RevMsg))
  393. {
  394. GetCheckLoadResult(RevMsg);
  395. //_currentStep = VRStep.Idle;
  396. //_status = RState.End;
  397. //_IsHomed = true;
  398. }
  399. if (RevMsg.Trim() == "_RDY" || (RevMsg.Contains("_RDY") && !RevMsg.Contains("_ERR")))
  400. {
  401. _currentStep = VRStep.Idle;
  402. _status = RState.End;
  403. }
  404. }
  405. break;
  406. case VRStep.ReQueryLoadA:
  407. if (_rex_rq_load_A.IsMatch(RevMsg))
  408. {
  409. string WaferStatus = RevMsg.Split(' ')[2];
  410. //LOG.Write(eEvent.WARN_DEFAULT_WARN, ModuleName.TMRobot, WaferStatus);
  411. if (WaferStatus.Contains("ON") && WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 0))
  412. {
  413. WaferManager.Instance.CreateWafer(ModuleName.TMRobot, 0, Aitex.Core.Common.WaferStatus.Normal);
  414. }
  415. if (WaferStatus.Contains("OFF"))
  416. {
  417. //LOG.Write(eEvent.WARN_DEFAULT_WARN, ModuleName.TMRobot, "contains off");
  418. WaferManager.Instance.DeleteWafer(ModuleName.TMRobot, 0);
  419. }
  420. }
  421. else
  422. {
  423. if (RevMsg.Trim() == "_RDY" || (RevMsg.Contains("_RDY") && !RevMsg.Contains("_ERR")))
  424. {
  425. _currentStep = VRStep.Idle;
  426. _status = RState.End;
  427. }
  428. else
  429. {
  430. ReportWrongMsg(RevMsg);
  431. }
  432. }
  433. break;
  434. case VRStep.ReQueryLoadB:
  435. if (_rex_rq_load_B.IsMatch(RevMsg))
  436. {
  437. string WaferStatus = RevMsg.Split(' ')[2];
  438. //LOG.Write(eEvent.WARN_DEFAULT_WARN, ModuleName.TMRobot, WaferStatus);
  439. if (WaferStatus.Contains("ON") && WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1))
  440. {
  441. WaferManager.Instance.CreateWafer(ModuleName.TMRobot, 1, Aitex.Core.Common.WaferStatus.Normal);
  442. }
  443. if (WaferStatus.Contains("OFF"))
  444. {
  445. WaferManager.Instance.DeleteWafer(ModuleName.TMRobot, 1);
  446. }
  447. }
  448. else
  449. {
  450. if (RevMsg.Trim() == "_RDY" || (RevMsg.Contains("_RDY") && !RevMsg.Contains("_ERR")))
  451. {
  452. _currentStep = VRStep.Idle;
  453. _status = RState.End;
  454. }
  455. else
  456. {
  457. ReportWrongMsg(RevMsg);
  458. }
  459. }
  460. break;
  461. case VRStep.RQSpeed:
  462. //MOTIONPARA {} SPDPCT all r t z
  463. if (_rex_rq_speed.IsMatch(RevMsg))
  464. {
  465. string[] _msgs = RevMsg.Split(' ');
  466. if (_msgs[1] == "WITHWAFER")
  467. {
  468. _WithWaferSpeed = _msgs[4];
  469. }
  470. if (_msgs[1] == "NOWAFER")
  471. {
  472. _NoWaferSpeed = _msgs[4];
  473. }
  474. if (_msgs[1] == "MIDDLE")
  475. {
  476. _WithWaferSpeed = _msgs[4];
  477. }
  478. }
  479. else
  480. {
  481. if (RevMsg.Trim() == "_RDY" || (RevMsg.Contains("_RDY") && !RevMsg.Contains("_ERR")))
  482. {
  483. _currentStep = VRStep.Idle;
  484. _status = RState.End;
  485. }
  486. else
  487. {
  488. ReportWrongMsg(RevMsg);
  489. }
  490. }
  491. break;
  492. default:
  493. if (!RevMsg.Contains("_EVENT"))
  494. ReportWrongMsg(RevMsg);
  495. break;
  496. }
  497. }
  498. }
  499. private void GetCheckLoadResult(string revMsg)
  500. {
  501. Match result = _rex_check_load.Match(revMsg);
  502. string Arm = result.Groups[1].Value;
  503. string WaferStatus = result.Groups[2].Value;
  504. if (WaferStatus == "ON")
  505. {
  506. WaferManager.Instance.CreateWafer(ModuleName.TMRobot, Arm == "A" ? 0 : 1, Aitex.Core.Common.WaferStatus.Unknown);
  507. }
  508. }
  509. private void ErrorMessageHandler(string errorcode)
  510. {
  511. _status = RState.Failed;
  512. string ErrorInfo;
  513. if (_error2msg.ContainsKey(errorcode))
  514. {
  515. ErrorInfo = _error2msg[errorcode];
  516. LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.TMRobot, ErrorInfo);
  517. }
  518. else
  519. {
  520. LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.TMRobot, $"Dictionary Not Contains error code:{errorcode}");
  521. }
  522. _IsHomed = false;
  523. }
  524. private void OnErrorHappen(ErrorEventArgs args)
  525. {
  526. //Singleton<RouteManager>.Instance.SETM.PostMsg(SETMEntity.MSG.Error);
  527. LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.TMRobot, $"HongHu TMRobot Error: {args.Reason} while {_currentStep}");
  528. }
  529. private void ReportWrongMsg(string revMsg)
  530. {
  531. LOG.Write(eEvent.WARN_DEVICE_INFO, ModuleName.TMRobot, $"Receive wrong message:{revMsg} while {_currentStep}");
  532. }
  533. public void SetRobotMovingInfo(RobotAction action, Hand hand, ModuleName target)
  534. {
  535. //_robotMoveInfo.Action = action;
  536. //_robotMoveInfo.ArmTarget = hand == Hand.Blade1 ? RobotArm.ArmA : (hand == Hand.Both ? RobotArm.Both : RobotArm.ArmB);
  537. //_robotMoveInfo.BladeTarget = $"{_robotMoveInfo.ArmTarget}.{target}";
  538. blockingCollection.Add(new RobotAnimationData(action, hand, target));
  539. }
  540. }
  541. }