SIASUNRobot.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. using System;
  2. using System.Collections.Generic;
  3. using Venus_RT.Modules;
  4. using Venus_Core;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  11. using Aitex.Core.RT.Log;
  12. using System.Text.RegularExpressions;
  13. using MECF.Framework.Common.CommonData;
  14. using System.Threading;
  15. namespace Venus_RT.Devices
  16. {
  17. class SIASUNRobot : ITransferRobot
  18. {
  19. enum OPStep
  20. {
  21. Idle,
  22. Home,
  23. Goto,
  24. MoveTo,
  25. CheckLoad_ArmA,
  26. CheckLoad_ArmB,
  27. Pick,
  28. Place,
  29. PickExtend,
  30. PickRetract,
  31. PlaceExtent,
  32. PlaceRetract,
  33. QueryAwc
  34. }
  35. private RState _status;
  36. private bool _IsHomed;
  37. private bool _HasReceiveMsg;
  38. public RState Status { get { return _status; } }
  39. public bool IsHomed { get { return _IsHomed; } }
  40. private double offset_x = 0;
  41. private double offset_y = 0;
  42. public double Offset_X => offset_x;
  43. public double Offset_Y => offset_y;
  44. public double Offset_D => Math.Round(Math.Sqrt(Math.Pow(offset_x, 2) + Math.Pow(offset_y, 2)), 2);//欧式距离 保留后两位
  45. public RobotMoveInfo TMRobotMoveInfo { get { return _robotMoveInfo; } }
  46. private readonly AsyncSocket _socket;
  47. private OPStep _currentOP = OPStep.Idle;
  48. private Dictionary<ModuleName, int> _StationNumbers = new Dictionary<ModuleName, int>();
  49. private readonly int _checkLoadStation = 1;
  50. private RobotMoveInfo _robotMoveInfo = new RobotMoveInfo();
  51. private string Hand2Arm(Hand hand) => hand == Hand.Blade1 ? "B" : "A";
  52. private readonly Regex _rex_check_load = new Regex(@"LOAD\s+(A|B)\s+(\w+)\s*");
  53. private readonly Regex _rex_error_code = new Regex(@"_ERR\s+(\d+)\s*");
  54. private readonly Regex _rex_event_offset = new Regex(@"_EVENT\sROBOT\s[0-9|\s]*.*");
  55. private readonly Regex _rex_event_getoffset = new Regex(@"(?<=_EVENT\sROBOT\s)(.+?)(?=\sB)");
  56. private readonly Regex _rex_query_awc = new Regex(@"WAF_CEN\sRT[-|0-9|\s]*LFT[-|0-9|\s]*OFFSET[-|0-9|\s]*");
  57. private readonly Regex _rex_query_getoffset = new Regex(@"(?<=WAF_CEN\sRT[-|0-9|\s]*LFT[-|0-9|\s]*OFFSET\s)(.*)");
  58. private const string EOF = "\r\n";
  59. public SIASUNRobot()
  60. {
  61. _socket = new AsyncSocket("", EOF);
  62. _socket.Connect(SC.GetStringValue($"TM.IPAddress"));
  63. _socket.OnDataChanged += OnReceiveMessage;
  64. _socket.OnErrorHappened += OnErrorHappen;
  65. _status = RState.Init;
  66. _IsHomed = false;
  67. _StationNumbers[ModuleName.LLA] = SC.GetValue<int>("TM.LLAStationNumber");
  68. _StationNumbers[ModuleName.LLB] = SC.GetValue<int>("TM.LLBStationNumber");
  69. _StationNumbers[ModuleName.PMA] = SC.GetValue<int>("TM.PMAStationNumber");
  70. _StationNumbers[ModuleName.PMB] = SC.GetValue<int>("TM.PMBStationNumber");
  71. _StationNumbers[ModuleName.PMC] = SC.GetValue<int>("TM.PMCStationNumber");
  72. _StationNumbers[ModuleName.PMD] = SC.GetValue<int>("TM.PMDStationNumber");
  73. _StationNumbers[ModuleName.PME] = SC.GetValue<int>("TM.PMEStationNumber");
  74. _StationNumbers[ModuleName.PMF] = SC.GetValue<int>("TM.PMFStationNumber");
  75. _checkLoadStation = SC.GetValue<int>("TM.CheckLoadStation");
  76. }
  77. public bool Home()
  78. {
  79. _status = RState.Running;
  80. _currentOP = OPStep.Home;
  81. return _SendCommand("HOME ALL");
  82. }
  83. public bool Halt()
  84. {
  85. return _SendCommand("HALT");
  86. }
  87. public bool CheckLoad(Hand hand = Hand.Blade1)
  88. {
  89. if (_currentOP != OPStep.Home && _currentOP != OPStep.CheckLoad_ArmA && CheckRobotStatus() == false)
  90. return false;
  91. _currentOP = hand == Hand.Blade2 ? OPStep.CheckLoad_ArmB : OPStep.CheckLoad_ArmA;
  92. _status = RState.Running;
  93. return _SendCommand($"CHECK LOAD {_checkLoadStation} ARM {Hand2Arm(hand)}");
  94. }
  95. public bool QueryAwc()
  96. {
  97. //检查防止状态交叉
  98. if (CheckRobotStatus() == false)
  99. return false;
  100. offset_x = 0;
  101. offset_y = 0;
  102. _currentOP = OPStep.QueryAwc;
  103. _status = RState.Running;
  104. _HasReceiveMsg = false;
  105. return _SendCommand("RQ WAF_CEN DATA");
  106. }
  107. public bool Goto(ModuleName station, int slot, Hand hand)
  108. {
  109. if (CheckRobotStatus() == false)
  110. return false;
  111. _currentOP = OPStep.Goto;
  112. _status = RState.Running;
  113. SetRobotMovingInfo(RobotAction.Rotating, hand, station);
  114. return _SendCommand($"GOTO N {_StationNumbers[station]} R RE Z DOWN SLOT {slot + 1} ARM {Hand2Arm(hand)}");
  115. }
  116. public bool MoveTo(ModuleName stnFrom, ModuleName stnTo, Hand hand)
  117. {
  118. if (CheckRobotStatus() == false)
  119. return false;
  120. _currentOP = OPStep.MoveTo;
  121. _status = RState.Running;
  122. return _SendCommand($"XFER ARM {Hand2Arm(hand)} {_StationNumbers[stnFrom]} {_StationNumbers[stnTo]}");
  123. }
  124. public bool PickExtend(ModuleName chamber, int slot, Hand hand)
  125. {
  126. if (CheckRobotStatus() == false)
  127. return false;
  128. _currentOP = OPStep.PickExtend;
  129. _status = RState.Running;
  130. SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
  131. return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} ENRT NR");
  132. }
  133. public bool PickRetract(ModuleName chamber, int slot, Hand hand)
  134. {
  135. if (CheckRobotStatus() == false)
  136. return false;
  137. _currentOP = OPStep.PickRetract;
  138. _status = RState.Running;
  139. SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
  140. return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} STRT NR");
  141. }
  142. public bool PlaceExtend(ModuleName chamber, int slot, Hand hand)
  143. {
  144. if (CheckRobotStatus() == false)
  145. return false;
  146. _currentOP = OPStep.PlaceExtent;
  147. _status = RState.Running;
  148. SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
  149. return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} ENRT NR");
  150. }
  151. public bool PlaceRetract(ModuleName chamber, int slot, Hand hand)
  152. {
  153. if (CheckRobotStatus() == false)
  154. return false;
  155. _currentOP = OPStep.PlaceExtent;
  156. _status = RState.Running;
  157. SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
  158. return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} STRT NR");
  159. }
  160. public bool Pick(ModuleName station, int slot, Hand hand)
  161. {
  162. if (CheckRobotStatus() == false)
  163. return false;
  164. _currentOP = OPStep.Pick;
  165. _status = RState.Running;
  166. SetRobotMovingInfo(RobotAction.Picking, hand, station);
  167. return _SendCommand($"PICK {_StationNumbers[station]} SLOT {slot + 1} ARM {Hand2Arm(hand)}");
  168. }
  169. public bool Place(ModuleName station, int slot, Hand hand)
  170. {
  171. if (CheckRobotStatus() == false)
  172. return false;
  173. _currentOP = OPStep.Place;
  174. _status = RState.Running;
  175. SetRobotMovingInfo(RobotAction.Placing, hand, station);
  176. return _SendCommand($"PLACE {_StationNumbers[station]} SLOT {slot + 1} ARM {Hand2Arm(hand)}");
  177. }
  178. private bool _SendCommand(string cmd)
  179. {
  180. LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Send Command to SIASUN TM Robot: {cmd}");
  181. return _socket.Write(cmd + EOF);
  182. }
  183. private bool CheckRobotStatus()
  184. {
  185. if (Status == RState.Init)
  186. {
  187. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, "TM Robot is not homed, please home first.");
  188. return false;
  189. }
  190. else if (Status == RState.Running)
  191. {
  192. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, "TM Robot is busy, please wait a minute");
  193. return false;
  194. }
  195. else if (Status == RState.Failed || Status == RState.Timeout)
  196. {
  197. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, "TM Robot has a error, please check and fix the hardware issue and home it");
  198. return false;
  199. }
  200. return true;
  201. }
  202. private void OnReceiveMessage(string RevMsg)
  203. {
  204. LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Receive message from SIASUN TM Robot: {RevMsg}, while {_currentOP}");
  205. if (_rex_error_code.IsMatch(RevMsg))
  206. {
  207. _IsHomed = false;
  208. _status = RState.Failed;
  209. var results = _rex_error_code.Match(RevMsg);
  210. ErrorMessageHandler(results.Groups[1].Value);
  211. return;
  212. }
  213. switch (_currentOP)
  214. {
  215. case OPStep.Goto:
  216. case OPStep.MoveTo:
  217. case OPStep.Pick:
  218. case OPStep.PickExtend:
  219. case OPStep.PickRetract:
  220. case OPStep.Place:
  221. case OPStep.PlaceExtent:
  222. case OPStep.PlaceRetract:
  223. {
  224. if (RevMsg.Trim() == "_RDY" || (RevMsg.Contains("_RDY") && !RevMsg.Contains("_ERR")))
  225. {
  226. _currentOP = OPStep.Idle;
  227. _status = RState.End;
  228. if (RevMsg.Contains("_EVENT"))
  229. {
  230. GetEventMsg(RevMsg);
  231. }
  232. }
  233. else
  234. {
  235. ReportWrongMsg(RevMsg);
  236. }
  237. if (_currentOP != OPStep.PickExtend && _currentOP != OPStep.PlaceExtent)
  238. {
  239. SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.TMRobot);
  240. }
  241. }
  242. break;
  243. case OPStep.Home:
  244. {
  245. if (RevMsg.Trim() == "_RDY")
  246. {
  247. //CheckLoad(Hand.Blade1);
  248. _currentOP = OPStep.Idle;
  249. _status = RState.End;
  250. _IsHomed = true;
  251. }
  252. else
  253. ReportWrongMsg(RevMsg);
  254. }
  255. break;
  256. case OPStep.CheckLoad_ArmA:
  257. {
  258. if (_rex_check_load.IsMatch(RevMsg))
  259. {
  260. GetCheckLoadResult(RevMsg);
  261. CheckLoad(Hand.Blade2);
  262. }
  263. else
  264. ReportWrongMsg(RevMsg);
  265. }
  266. break;
  267. case OPStep.CheckLoad_ArmB:
  268. {
  269. if (_rex_check_load.IsMatch(RevMsg))
  270. {
  271. GetCheckLoadResult(RevMsg);
  272. _currentOP = OPStep.Idle;
  273. _status = RState.End;
  274. _IsHomed = true;
  275. }
  276. }
  277. break;
  278. case OPStep.QueryAwc:
  279. QueryAwcData(RevMsg);
  280. break;
  281. default:
  282. if (!RevMsg.Contains("_EVENT"))
  283. ReportWrongMsg(RevMsg);
  284. else
  285. GetEventMsg(RevMsg);
  286. break;
  287. }
  288. }
  289. private void GetCheckLoadResult(string strRev)
  290. {
  291. Match result = _rex_check_load.Match(strRev);
  292. string Arm = result.Groups[1].Value;
  293. string WaferStatus = result.Groups[2].Value;
  294. if (WaferStatus == "ON")
  295. {
  296. WaferManager.Instance.CreateWafer(ModuleName.TMRobot, Arm == "A" ? 0 : 1, Aitex.Core.Common.WaferStatus.Unknown);
  297. }
  298. }
  299. private void OnErrorHappen(ErrorEventArgs args)
  300. {
  301. Singleton<RouteManager>.Instance.TM.PostMsg(TMEntity.MSG.Error);
  302. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, $"SIASUN TM Robot Error: {args.Reason} while {_currentOP}");
  303. }
  304. private void ReportWrongMsg(string revMsg)
  305. {
  306. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, $"Receive wrong message:{revMsg} while {_currentOP}");
  307. }
  308. private void ErrorMessageHandler(string errCode)
  309. {
  310. int ErrCode;
  311. string ErrorInfo;
  312. if (int.TryParse(errCode, out ErrCode))
  313. {
  314. switch (ErrCode)
  315. {
  316. // 系统及硬件错误信息
  317. case 901:
  318. ErrorInfo = $"_Err {errCode}: 主电柜急停启动";
  319. break;
  320. case 902:
  321. ErrorInfo = $"_Err {errCode}: 示教盒急停启动";
  322. break;
  323. case 862:
  324. ErrorInfo = $"_Err {errCode}: 驱动器 RDY 信号断开";
  325. break;
  326. // 执行错误信息
  327. case 3001:
  328. ErrorInfo = $"_Err {errCode}: 系统发生碰撞,按取消恢复";
  329. break;
  330. case 7300:
  331. ErrorInfo = $"_Err {errCode}: 旋转信号不允许";
  332. break;
  333. case 7301:
  334. ErrorInfo = $"_Err {errCode}: 伸缩信号不允许";
  335. break;
  336. case 2200:
  337. ErrorInfo = $"_Err {errCode}: 输出端口 NO.不存在";
  338. break;
  339. case 3100:
  340. ErrorInfo = $"_Err {errCode}: 关节 N 位置超界";
  341. break;
  342. case 3120:
  343. ErrorInfo = $"_Err {errCode}: 关节 N 速度超界";
  344. break;
  345. case 100:
  346. ErrorInfo = $"_Err {errCode}: 手臂电源上电失败(手臂电源未打开)";
  347. break;
  348. // 通信错误信息
  349. case 7307:
  350. ErrorInfo = $"_Err {errCode}: GOTO 工位号超范围";
  351. break;
  352. case 7308:
  353. ErrorInfo = $"_Err {errCode}: 不支持的传感器类型";
  354. break;
  355. case 7312:
  356. ErrorInfo = $"_Err {errCode}: PICK工位号超范围";
  357. break;
  358. case 7313:
  359. ErrorInfo = $"_Err {errCode}: PLACE工位号超范围";
  360. break;
  361. case 7314:
  362. ErrorInfo = $"_Err {errCode}: XFER工位号超范围";
  363. break;
  364. case 7315:
  365. ErrorInfo = $"_Err {errCode}: REMOVE不支持的IO类型";
  366. break;
  367. case 7316:
  368. ErrorInfo = $"_Err {errCode}: RQ INTLCK不识别的参数";
  369. break;
  370. case 7317:
  371. ErrorInfo = $"_Err {errCode}: RQ IO不识别的参数";
  372. break;
  373. case 7319:
  374. ErrorInfo = $"_Err {errCode}: RQ STN工位号超范围";
  375. break;
  376. case 7320:
  377. ErrorInfo = $"_Err {errCode}: wafre(WAF_SEN)参数未设置";
  378. break;
  379. case 7321:
  380. ErrorInfo = $"_Err {errCode}: wafex(RETRACT_PIN)参数未设置";
  381. break;
  382. case 7322:
  383. ErrorInfo = $"_Err {errCode}: svlv(SBIT_SVLV_SEN)参数未设置";
  384. break;
  385. case 7323:
  386. ErrorInfo = $"_Err {errCode}: ens(EX_ENABLE)参数未设置";
  387. break;
  388. case 7324:
  389. ErrorInfo = $"_Err {errCode}: RQ命令不支持的参数";
  390. break;
  391. case 7325:
  392. ErrorInfo = $"_Err {errCode}: SET INTLOCK WAF_SEN参数错";
  393. break;
  394. case 7326:
  395. ErrorInfo = $"_Err {errCode}: SET INTLOCK RZ参数错";
  396. break;
  397. case 7327:
  398. ErrorInfo = $"_Err {errCode}: SET INTLOCK参数错";
  399. break;
  400. case 7328:
  401. ErrorInfo = $"_Err {errCode}: SET IO ECHO参数错";
  402. break;
  403. case 7329:
  404. ErrorInfo = $"_Err {errCode}: SET IO STATE不支持";
  405. break;
  406. case 7330:
  407. ErrorInfo = $"_Err {errCode}: SET IO不支持的参数";
  408. break;
  409. case 7331:
  410. ErrorInfo = $"_Err {errCode}: SET STN工位号超范围";
  411. break;
  412. case 7332:
  413. ErrorInfo = $"_Err {errCode}: 手臂参数读取错误";
  414. break;
  415. case 7333:
  416. ErrorInfo = $"_Err {errCode}: WAF_SEN不识别的参数";
  417. break;
  418. case 7334:
  419. ErrorInfo = $"_Err {errCode}: SET不支持的传感器类型";
  420. break;
  421. case 7335:
  422. ErrorInfo = $"_Err {errCode}: SET 指令输入不完整";
  423. break;
  424. case 7336:
  425. ErrorInfo = $"_Err {errCode}: STORE IO命令不支持该参数";
  426. break;
  427. case 7337:
  428. ErrorInfo = $"_Err {errCode}: STORE LOAD命令不支持该参数";
  429. break;
  430. case 7338:
  431. ErrorInfo = $"_Err {errCode}: STORE STN指令工位号大于20";
  432. break;
  433. case 7339:
  434. ErrorInfo = $"_Err {errCode}: STORE STN命令手臂参数错误";
  435. break;
  436. case 7340:
  437. ErrorInfo = $"_Err {errCode}: STORE不支持的传感器类型";
  438. break;
  439. case 7341:
  440. ErrorInfo = $"_Err {errCode}: STORE指令输入不完整";
  441. break;
  442. case 7342:
  443. ErrorInfo = $"_Err {errCode}: 无法识别的命令";
  444. break;
  445. case 7343:
  446. ErrorInfo = $"_Err {errCode}: HOME参数未指定";
  447. break;
  448. case 7344:
  449. ErrorInfo = $"_Err {errCode}: GOTO指令R轴参数未指定";
  450. break;
  451. case 7345:
  452. ErrorInfo = $"_Err {errCode}: GOTO指令Z轴参数未指定";
  453. break;
  454. case 7346:
  455. ErrorInfo = $"_Err {errCode}: ARM参数错误";
  456. break;
  457. case 7347:
  458. ErrorInfo = $"_Err {errCode}: GOTO指令未指定参数";
  459. break;
  460. case 7349:
  461. ErrorInfo = $"_Err {errCode}: MOVE指令未指定模式或轴";
  462. break;
  463. case 7350:
  464. ErrorInfo = $"_Err {errCode}: MOVE 指令中字段名字错";
  465. break;
  466. case 7351:
  467. ErrorInfo = $"_Err {errCode}: PICK未指定参数";
  468. break;
  469. case 7352:
  470. ErrorInfo = $"_Err {errCode}: PLACE未指定参数";
  471. break;
  472. case 7353:
  473. ErrorInfo = $"_Err {errCode}: REMOVE未指定参数";
  474. break;
  475. case 7354:
  476. ErrorInfo = $"_Err {errCode}: 指令执行未结束";
  477. break;
  478. case 7355:
  479. ErrorInfo = $"_Err {errCode}: GOTO指令未指定工位号";
  480. break;
  481. case 7356:
  482. ErrorInfo = $"_Err {errCode}: PICK指令未指定工位号";
  483. break;
  484. case 7357:
  485. ErrorInfo = $"_Err {errCode}: PLACE指令未指定工位号";
  486. break;
  487. case 7358:
  488. ErrorInfo = $"_Err {errCode}: ABS未指定数值";
  489. break;
  490. case 7359:
  491. ErrorInfo = $"_Err {errCode}: REL未指定数值";
  492. break;
  493. case 7360:
  494. ErrorInfo = $"_Err {errCode}: 没有指定主程序";
  495. break;
  496. case 7361:
  497. ErrorInfo = $"_Err {errCode}: 当前没有打开作业";
  498. break;
  499. case 7362:
  500. ErrorInfo = $"_Err {errCode}: 当前作业不是主作业";
  501. break;
  502. case 7363:
  503. ErrorInfo = $"_Err {errCode}: ex_ena(EX_ENABLE_SEN)参数未设置";
  504. break;
  505. case 7364:
  506. ErrorInfo = $"_Err {errCode}: stable(STABLE_ SIGNAL)参数未设置";
  507. break;
  508. case 7365:
  509. ErrorInfo = $"_Err {errCode}: VIA参数设置有误";
  510. break;
  511. case 7366:
  512. ErrorInfo = $"_Err {errCode}: 系统处于非启动状态";
  513. break;
  514. case 7367:
  515. ErrorInfo = $"_Err {errCode}: extend(EX_SIGNAL)参数未设置";
  516. break;
  517. case 7368:
  518. ErrorInfo = $"_Err {errCode}: retract(RE_ SIGNAL)参数未设置";
  519. break;
  520. case 7371:
  521. ErrorInfo = $"_Err {errCode}: place动作前:未检测到晶圆";
  522. break;
  523. case 7372:
  524. ErrorInfo = $"_Err {errCode}: pick动作前:检测到晶圆";
  525. break;
  526. case 7373:
  527. ErrorInfo = $"_Err {errCode}: place动作后:检测到晶圆";
  528. break;
  529. case 7374:
  530. ErrorInfo = $"_Err {errCode}: pick动作后:未检测到晶圆";
  531. break;
  532. case 7375:
  533. ErrorInfo = $"_Err {errCode}: 系统未上电或当前不是执行模式";
  534. break;
  535. case 7376:
  536. ErrorInfo = $"_Err {errCode}: 参数中存在非数字";
  537. break;
  538. case 7385:
  539. ErrorInfo = $"_Err {errCode}: 驱动器异常停止";
  540. break;
  541. case 7387:
  542. ErrorInfo = $"_Err {errCode}: 驱动器ID1报警";
  543. break;
  544. case 7388:
  545. ErrorInfo = $"_Err {errCode}: 驱动器ID2报警";
  546. break;
  547. case 7389:
  548. ErrorInfo = $"_Err {errCode}: 驱动器ID3报警";
  549. break;
  550. case 7391:
  551. ErrorInfo = $"_Err {errCode}: AWC工位号超范围";
  552. break;
  553. case 7392:
  554. ErrorInfo = $"_Err {errCode}: 偏差过大AWC报警";
  555. break;
  556. case 7393:
  557. ErrorInfo = $"_Err {errCode}: 标定失败,请重新标定";
  558. break;
  559. case 7398:
  560. ErrorInfo = $"_Err {errCode}: 触发点计算半径有误";
  561. break;
  562. case 7399:
  563. ErrorInfo = $"_Err {errCode}: 驱动器锁存AWC数据个数有误";
  564. break;
  565. case 7401:
  566. ErrorInfo = $"_Err {errCode}: 手指上可能有晶圆";
  567. break;
  568. case 7402:
  569. ErrorInfo = $"_Err {errCode}: 手指上可能无晶圆";
  570. break;
  571. case 7403:
  572. ErrorInfo = $"_Err {errCode}: load当前状态为ON,不正确";
  573. break;
  574. case 7404:
  575. ErrorInfo = $"_Err {errCode}: load当前状态为OFF,不正确";
  576. break;
  577. case 7405:
  578. ErrorInfo = $"_Err {errCode}: 当前slot不存在!";
  579. break;
  580. case 7495:
  581. ErrorInfo = $"_Err {errCode}: ID1码盘反馈错误";
  582. break;
  583. case 7496:
  584. ErrorInfo = $"_Err {errCode}: ID2码盘反馈错误";
  585. break;
  586. case 7497:
  587. ErrorInfo = $"_Err {errCode}: ID3码盘反馈错误";
  588. break;
  589. default:
  590. ErrorInfo = $"_Err {errCode}: 不能识别的错误码";
  591. break;
  592. }
  593. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, ErrorInfo);
  594. }
  595. else
  596. {
  597. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, $"Try Parse the receive error code faild:{errCode}");
  598. }
  599. }
  600. public void SetRobotMovingInfo(RobotAction action, Hand hand, ModuleName target)
  601. {
  602. _robotMoveInfo.Action = action;
  603. _robotMoveInfo.ArmTarget = hand == Hand.Blade1 ? RobotArm.ArmA : (hand == Hand.Both ? RobotArm.Both : RobotArm.ArmB);
  604. _robotMoveInfo.BladeTarget = $"{_robotMoveInfo.ArmTarget}.{target}";
  605. }
  606. private void GetEventMsg(string revMsg)
  607. {
  608. //在包含数据的前提下
  609. switch (_robotMoveInfo.Action)
  610. {
  611. case RobotAction.Picking:
  612. case RobotAction.Placing:
  613. case RobotAction.Extending:
  614. case RobotAction.Retracting:
  615. if (_rex_event_offset.IsMatch(revMsg))
  616. {
  617. //offset_x = _rex_event_getoffset.Match(revMsg).Value.Split(' ')[0];
  618. //offset_y = _rex_event_getoffset.Match(revMsg).Value.Split(' ')[1];
  619. }
  620. break;
  621. default:
  622. break;
  623. }
  624. }
  625. private void QueryAwcData(string revMsg)
  626. {
  627. //不沾包
  628. if (revMsg.Trim() == "_RDY")
  629. {
  630. if (_HasReceiveMsg)
  631. {
  632. _currentOP = OPStep.Idle;
  633. _status = RState.End;
  634. }
  635. else
  636. {
  637. _status = RState.Failed;
  638. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, $"Query Awc failed because not find valided data");
  639. }
  640. }
  641. //单条查询处理
  642. GetAwcMsg(revMsg);
  643. //沾包
  644. if (revMsg.Trim() != "_RDY" && revMsg.Contains("_RDY"))
  645. {
  646. if (!revMsg.Contains("_ERR"))
  647. {
  648. foreach (string msg in revMsg.Split('\n'))
  649. GetAwcMsg(msg);
  650. _currentOP = OPStep.Idle;
  651. _status = RState.End;
  652. }
  653. else
  654. {
  655. foreach (string msg in revMsg.Split('\n'))
  656. if (msg.Contains("_ERR"))
  657. ErrorMessageHandler(_rex_error_code.Match(revMsg.Trim()).Value);
  658. _status = RState.Failed;
  659. }
  660. }
  661. }
  662. private void GetAwcMsg(string revMsg)
  663. {
  664. revMsg = revMsg.Trim();
  665. if (_rex_query_awc.IsMatch(revMsg))
  666. {
  667. _HasReceiveMsg = true;
  668. string offset_r_t = _rex_query_getoffset.Match(revMsg).Value;
  669. //最大仅6位 不超过int范围
  670. int offset_r;
  671. int offset_t;
  672. if (int.TryParse(offset_r_t.Split(' ')[0], out offset_r) && int.TryParse(offset_r_t.Split(' ')[1], out offset_t))
  673. {
  674. // 9/26 新松暂未提供转换公式 暂时使用相关数据
  675. offset_x = offset_r * Math.Cos(offset_t);
  676. offset_y = offset_r * Math.Sin(offset_t);
  677. }
  678. else
  679. {
  680. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, $"TM Robot returned illegal offset data! Raw Data:{revMsg}");
  681. }
  682. }
  683. else if(!_HasReceiveMsg)
  684. {
  685. _status = RState.Failed;
  686. LOG.Write(eEvent.ERR_TM_ROBOT, ModuleName.TMRobot, $"The awc parameter format returned by TM Robot is incorrect! Raw Data:{revMsg}");
  687. }
  688. }
  689. }
  690. }