SIASUNRobot.cs 40 KB

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