SIASUNRobot.cs 31 KB

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