SIASUNRobot.cs 31 KB

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