HAtmHandler.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536
  1. using Aitex.Core.RT.Event;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.SCCore;
  4. using Aitex.Sorter.Common;
  5. using MECF.Framework.Common.Communications;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Text.RegularExpressions;
  14. using System.Threading;
  15. using System.Threading.Tasks;
  16. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.HineAutomation
  17. {
  18. public abstract class HAtmHandler : HandlerBase
  19. {
  20. protected ModuleName _target;
  21. protected int _slot;
  22. protected const string EOT = "\r\n";
  23. protected bool _isBackground;
  24. protected bool _isSimulator;
  25. public bool IsBackground { get { return _isBackground; } }
  26. protected bool _hasResponse;
  27. public bool HasResponse { get { return _hasResponse; } }
  28. public HAtmRobot RobotDevice { get; }
  29. public ModuleName Target => _target;
  30. public int Slot => _slot;
  31. protected HAtmHandler(Robot robot)
  32. : base("")
  33. {
  34. RobotDevice = (HAtmRobot)robot;
  35. _isSimulator = SC.GetValue<bool>("System.IsSimulatorMode");
  36. }
  37. public virtual string Package(params object[] args)
  38. {
  39. return "";
  40. }
  41. public virtual void Update()
  42. {
  43. }
  44. public override bool HandleMessage(MessageBase msg, out bool handled)
  45. {
  46. ResponseMessage = msg;
  47. handled = true;
  48. return true;
  49. }
  50. public string GetBladeTarget(ModuleName target, int slot)
  51. {
  52. string bladeTarget = "";
  53. var from = "";
  54. var level = "";
  55. {
  56. int cassette = 180;
  57. int cooling = 110;
  58. int pm = 55;
  59. if (Math.Abs(RobotDevice.RotateReqPos - cassette) < 10)
  60. {
  61. from = $"{ModuleName.LoadLock}";
  62. }
  63. if (Math.Abs(RobotDevice.RotateReqPos - cooling) < 10)
  64. {
  65. from = $"{ModuleName.Cooling}";
  66. }
  67. if (Math.Abs(RobotDevice.RotateReqPos - pm) < 10)
  68. {
  69. from = $"{ModuleName.PM}";
  70. }
  71. if (Math.Abs(RobotDevice.RotateReqPos) < 10)
  72. {
  73. from = $"{ModuleHelper.Converter(RobotDevice.Name)}";
  74. }
  75. }
  76. {
  77. //int pm = 1600;
  78. //int cool = 2628;
  79. if (RobotDevice.ZActPos < 15000)
  80. {
  81. if(slot < 8)
  82. {
  83. level = "low,low";
  84. }
  85. else if(slot > 15)
  86. {
  87. level = "low,high";
  88. }
  89. else
  90. {
  91. level = "low,medium";
  92. }
  93. }
  94. else if(RobotDevice.ZActPos > 30000)
  95. {
  96. if (slot < 8)
  97. {
  98. level = "high,low";
  99. }
  100. else if (slot > 15)
  101. {
  102. level = "high,high";
  103. }
  104. else
  105. {
  106. level = "high,medium";
  107. }
  108. }
  109. else
  110. {
  111. if (slot < 8)
  112. {
  113. level = "medium,low";
  114. }
  115. else if (slot > 15)
  116. {
  117. level = "medium,high";
  118. }
  119. else
  120. {
  121. level = "medium,medium";
  122. }
  123. }
  124. }
  125. bladeTarget = $"{from}.{level}";
  126. return bladeTarget;
  127. }
  128. }
  129. public class HomeHandler : HAtmHandler
  130. {
  131. private const string Category = "HM";
  132. public HomeHandler(Robot robot)
  133. : base(robot)
  134. {
  135. Name = "Home";
  136. _isBackground = false;
  137. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  138. //if(_isSimulator)
  139. UpdateBefore();
  140. }
  141. public override string Package(params object[] args)
  142. {
  143. //A,HM<CR><LF>
  144. return string.Format($"A,HM{EOT}");
  145. }
  146. private void UpdateBefore()
  147. {
  148. RobotDevice.Blade1Target = ModuleHelper.Converter(RobotDevice.Name);
  149. //RobotDevice.CmdBladeTarget = $"{ModuleHelper.Converter(RobotDevice.Name)}.Retract";
  150. RobotDevice.CmdBlade1Extend = "0";
  151. }
  152. public override bool HandleMessage(MessageBase msg, out bool handled)
  153. {
  154. // X,HM<CR><LF>
  155. handled = false;
  156. var result = msg as HAtmMessage;
  157. if (!result.IsResponse) return true;
  158. if (result.IsFormatError || result.Category != Category)
  159. {
  160. RobotDevice.SetError(result.Data);
  161. return true;
  162. }
  163. ResponseMessage = msg;
  164. handled = true;
  165. return true;
  166. }
  167. }
  168. public class AbortHandler : HAtmHandler
  169. {
  170. public AbortHandler(Robot robot)
  171. : base(robot)
  172. {
  173. Name = "Abort";
  174. _isBackground = false;
  175. _hasResponse = false;
  176. }
  177. public override string Package(params object[] args)
  178. {
  179. return string.Format($"D{EOT}");
  180. }
  181. }
  182. public class ResetHandler : HAtmHandler
  183. {
  184. private const string Category = "ER";
  185. public ResetHandler(Robot robot)
  186. : base(robot)
  187. {
  188. Name = "Reset";
  189. _isBackground = false;
  190. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  191. }
  192. public override string Package(params object[] args)
  193. {
  194. return string.Format($"S,ER{EOT}");
  195. }
  196. public override bool HandleMessage(MessageBase msg, out bool handled)
  197. {
  198. // X,ER<CR><LF>
  199. handled = false;
  200. var result = msg as HAtmMessage;
  201. if (!result.IsResponse) return true;
  202. if (result.IsFormatError || result.Category != Category)
  203. {
  204. RobotDevice.SetError(result.Data);
  205. return true;
  206. }
  207. ResponseMessage = msg;
  208. handled = true;
  209. return true;
  210. }
  211. }
  212. public class PickHandler : HAtmHandler
  213. {
  214. private int _thetaAxis;
  215. private int _zAxis;
  216. private Hand blade;
  217. private const string Category = "PK";
  218. public PickHandler(Robot robot, ModuleName target, int slot = 0)
  219. : base(robot)
  220. {
  221. Name = "Pick";
  222. _thetaAxis = RobotConvertor.Chamber2ThetaAxisPosition(target);
  223. _zAxis = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  224. _slot = slot;
  225. _target = target;
  226. blade = Hand.Blade1;
  227. _isBackground = false;
  228. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  229. //if (_isSimulator)
  230. UpdateBefore();
  231. }
  232. public override string Package(params object[] args)
  233. {
  234. //A,PK[,tt,zz,at]<CR><LF>
  235. return string.Format("A,PK,{0:D2},{1:D2}{2}",
  236. _thetaAxis,
  237. _zAxis,
  238. EOT);
  239. }
  240. private void UpdateBefore()
  241. {
  242. RobotDevice.Blade1Target = _target;
  243. //RobotDevice.CmdBladeTarget = $"{GetBladeTarget(_target, _slot)}.Picking";
  244. RobotDevice.CmdBladeTarget = $"{_target}.Picking";
  245. RobotDevice.CmdBlade1Extend = "1";
  246. //if (!_isSimulator)
  247. // WaferManager.Instance.WaferMoved(_target, _slot, ModuleHelper.Converter(RobotDevice.Name), (int)blade);
  248. }
  249. public override void Update()
  250. {
  251. //if (_isSimulator)
  252. //{
  253. // WaferManager.Instance.WaferMoved(_target, _slot, ModuleHelper.Converter(RobotDevice.Name), (int)blade);
  254. // RobotDevice.CmdBladeTarget = $"{_target}.Retract";
  255. //}
  256. //else
  257. {
  258. if(WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(RobotDevice.Name), (int)blade) && WaferManager.Instance.CheckHasWafer(_target, _slot))
  259. {
  260. WaferManager.Instance.WaferMoved(_target, _slot, ModuleHelper.Converter(RobotDevice.Name), (int)blade);
  261. LOG.Info("Wafer move in handler");
  262. }
  263. }
  264. RobotDevice.Blade1Target = ModuleHelper.Converter(RobotDevice.Name);
  265. }
  266. public override bool HandleMessage(MessageBase msg, out bool handled)
  267. {
  268. // X,PK<CR><LF>
  269. handled = false;
  270. var result = msg as HAtmMessage;
  271. if (!result.IsResponse) return true;
  272. if (result.IsFormatError || result.Category != Category)
  273. {
  274. RobotDevice.SetError(result.Data);
  275. return true;
  276. }
  277. ResponseMessage = msg;
  278. handled = true;
  279. return true;
  280. }
  281. }
  282. public class GotoHandler : HAtmHandler
  283. {
  284. private int _thetaAxis;
  285. private int _zAxis;
  286. private Hand blade;
  287. private bool _isPick;
  288. private const string Category = "GO";
  289. private string _up;
  290. public GotoHandler(Robot robot, ModuleName target, int slot = 0, bool isPick = true, bool isUp = true)
  291. : base(robot)
  292. {
  293. Name = "goto";
  294. _thetaAxis = RobotConvertor.Chamber2ThetaAxisPosition(target);
  295. _zAxis = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  296. _slot = slot;
  297. _target = target;
  298. blade = Hand.Blade1;
  299. _isPick = isPick;
  300. _up = isUp ? "U" : "D";
  301. _isBackground = false;
  302. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  303. //if (_isSimulator)
  304. UpdateBefore();
  305. }
  306. public override string Package(params object[] args)
  307. {
  308. //A,GO[,rr,tt,zzb]<CR><LF>
  309. return string.Format("A,GO,EX,{0:D2},{1:D2}{2}{3}",
  310. _thetaAxis,
  311. _zAxis,
  312. _up,
  313. EOT);
  314. }
  315. private void UpdateBefore()
  316. {
  317. RobotDevice.Blade1Target = _target;
  318. //RobotDevice.CmdBladeTarget = $"{_target}.{(_isPick ? "Picking" : "Placing")}";
  319. //RobotDevice.CmdBladeTarget = $"{GetBladeTarget(_target, _slot)}.Extend";
  320. RobotDevice.CmdBladeTarget = $"{_target}.Extend";
  321. RobotDevice.CmdBlade1Extend = "1";
  322. }
  323. public override void Update()
  324. {
  325. if (!_isPick)
  326. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(RobotDevice.Name), (int)blade, _target, _slot);
  327. }
  328. public override bool HandleMessage(MessageBase msg, out bool handled)
  329. {
  330. // X,GO<CR><LF>
  331. handled = false;
  332. var result = msg as HAtmMessage;
  333. if (!result.IsResponse) return true;
  334. if (result.IsFormatError || result.Category != Category)
  335. {
  336. RobotDevice.SetError(result.Data);
  337. return true;
  338. }
  339. ResponseMessage = msg;
  340. handled = true;
  341. return true;
  342. }
  343. }
  344. public class ZAxisMoveHandler : HAtmHandler
  345. {
  346. private int _zAxis;
  347. private Hand blade;
  348. private const string Category = "GZ";
  349. private string _up;
  350. private bool _isUp;
  351. public ZAxisMoveHandler(Robot robot, ModuleName target, int slot, bool isUp)
  352. : base(robot)
  353. {
  354. Name = "goto";
  355. _zAxis = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  356. _slot = slot;
  357. _target = target;
  358. blade = Hand.Blade1;
  359. _up = isUp ? "U" : "D";
  360. _isUp = isUp;
  361. _isBackground = false;
  362. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  363. //if (_isSimulator)
  364. UpdateBefore();
  365. }
  366. public override string Package(params object[] args)
  367. {
  368. //A,GZ[,zzb]<CR><LF>
  369. return string.Format("A,GZ,{0:D2}{1}{2}",
  370. _zAxis,
  371. _up,
  372. EOT);
  373. }
  374. private void UpdateBefore()
  375. {
  376. }
  377. public override void Update()
  378. {
  379. }
  380. public override bool HandleMessage(MessageBase msg, out bool handled)
  381. {
  382. // X,GZ<CR><LF>
  383. handled = false;
  384. var result = msg as HAtmMessage;
  385. if (!result.IsResponse) return true;
  386. if (result.IsFormatError || result.Category != Category)
  387. {
  388. RobotDevice.SetError(result.Data);
  389. return true;
  390. }
  391. ResponseMessage = msg;
  392. handled = true;
  393. return true;
  394. }
  395. }
  396. public class PlaceRetractHandler : HAtmHandler
  397. {
  398. private int _thetaAxis;
  399. private int _zAxis;
  400. //private Hand blade;
  401. private const string Category = "GO";
  402. public PlaceRetractHandler(Robot robot, ModuleName target, int slot = 0)
  403. : base(robot)
  404. {
  405. Name = "PlaceRetract";
  406. _thetaAxis = RobotConvertor.Chamber2ThetaAxisPosition(target);
  407. _zAxis = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  408. _slot = slot;
  409. _target = target;
  410. //blade = Hand.Blade1;
  411. _isBackground = false;
  412. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  413. //if (_isSimulator)
  414. UpdateBefore();
  415. }
  416. public override string Package(params object[] args)
  417. {
  418. //A,GO[,rr,tt,zzb]<CR><LF>
  419. return string.Format("A,GO,RE,{0:D2},{1:D2}U{2}",
  420. _thetaAxis,
  421. _zAxis,
  422. EOT);
  423. }
  424. private void UpdateBefore()
  425. {
  426. RobotDevice.Blade1Target = ModuleHelper.Converter(RobotDevice.Name);
  427. RobotDevice.CmdBladeTarget = $"{_target}.PlaceRetract";
  428. RobotDevice.CmdBlade1Extend = "0";
  429. }
  430. public override void Update()
  431. {
  432. //WaferManager.Instance.WaferMoved(ModuleHelper.Converter(RobotDevice.Name), (int)blade, _target, _slot);
  433. //if (_isSimulator)
  434. {
  435. //RobotDevice.Blade1Target = ModuleHelper.Converter(RobotDevice.Name);
  436. //RobotDevice.CmdBladeTarget = $"{_target}.Retract";
  437. //RobotDevice.CmdBlade1Extend = "0";
  438. }
  439. }
  440. public override bool HandleMessage(MessageBase msg, out bool handled)
  441. {
  442. // X,GO<CR><LF>
  443. handled = false;
  444. var result = msg as HAtmMessage;
  445. if (!result.IsResponse) return true;
  446. if (result.IsFormatError || result.Category != Category)
  447. {
  448. RobotDevice.SetError(result.Data);
  449. return true;
  450. }
  451. ResponseMessage = msg;
  452. handled = true;
  453. return true;
  454. }
  455. }
  456. public class PickRetractHandler : HAtmHandler
  457. {
  458. private int _thetaAxis;
  459. private int _zAxis;
  460. private Hand blade;
  461. private const string Category = "GO";
  462. private bool _isNeedWaferMove;
  463. public PickRetractHandler(Robot robot, ModuleName target, int slot = 0, bool isNeedWaferMove = true)
  464. : base(robot)
  465. {
  466. Name = "PickRetract";
  467. _thetaAxis = RobotConvertor.Chamber2ThetaAxisPosition(target);
  468. _zAxis = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  469. _slot = slot;
  470. _target = target;
  471. blade = Hand.Blade1;
  472. _isNeedWaferMove = isNeedWaferMove;
  473. _isBackground = false;
  474. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  475. //if (_isSimulator)
  476. UpdateBefore();
  477. }
  478. public override string Package(params object[] args)
  479. {
  480. //A,GO[,rr,tt,zzb]<CR><LF>
  481. return string.Format("A,GO,RE,{0:D2},{1:D2}U{2}",
  482. _thetaAxis,
  483. _zAxis,
  484. EOT);
  485. }
  486. private void UpdateBefore()
  487. {
  488. if(_isNeedWaferMove)
  489. WaferManager.Instance.WaferMoved(_target, _slot, ModuleHelper.Converter(RobotDevice.Name), (int)blade);
  490. RobotDevice.Blade1Target = ModuleHelper.Converter(RobotDevice.Name);
  491. RobotDevice.CmdBladeTarget = $"{_target}.PickRetract";
  492. RobotDevice.CmdBlade1Extend = "0";
  493. }
  494. public override void Update()
  495. {
  496. //WaferManager.Instance.WaferMoved(_target, _slot, ModuleHelper.Converter(RobotDevice.Name), (int)blade);
  497. //if (_isSimulator)
  498. {
  499. //RobotDevice.Blade1Target = ModuleHelper.Converter(RobotDevice.Name);
  500. //RobotDevice.CmdBladeTarget = $"{_target}.Retract";
  501. //RobotDevice.CmdBlade1Extend = "0";
  502. }
  503. }
  504. public override bool HandleMessage(MessageBase msg, out bool handled)
  505. {
  506. // X,GO<CR><LF>
  507. handled = false;
  508. var result = msg as HAtmMessage;
  509. if (!result.IsResponse) return true;
  510. if (result.IsFormatError || result.Category != Category)
  511. {
  512. RobotDevice.SetError(result.Data);
  513. return true;
  514. }
  515. ResponseMessage = msg;
  516. handled = true;
  517. return true;
  518. }
  519. }
  520. public class PlaceHandler : HAtmHandler
  521. {
  522. private int _thetaAxis;
  523. private int _zAxis;
  524. private Hand blade;
  525. private const string Category = "PL";
  526. public PlaceHandler(Robot robot, ModuleName target, int slot = 0)
  527. : base(robot)
  528. {
  529. Name = "Place";
  530. _thetaAxis = RobotConvertor.Chamber2ThetaAxisPosition(target);
  531. _zAxis = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  532. _slot = slot;
  533. _target = target;
  534. blade = Hand.Blade1;
  535. _isBackground = false;
  536. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  537. //if (_isSimulator)
  538. UpdateBefore();
  539. }
  540. public override string Package(params object[] args)
  541. {
  542. //A,PL[,tt,zz,at]<CR><LF>
  543. return string.Format("A,PL,{0:D2},{1:D2}{2}",
  544. _thetaAxis,
  545. _zAxis,
  546. EOT);
  547. }
  548. private void UpdateBefore()
  549. {
  550. RobotDevice.Blade1Target = _target;
  551. //RobotDevice.CmdBladeTarget = $"{GetBladeTarget(_target, _slot)}.Placing";
  552. RobotDevice.CmdBladeTarget = $"{_target}.Placing";
  553. RobotDevice.CmdBlade1Extend = "1";
  554. }
  555. public override void Update()
  556. {
  557. if(WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(RobotDevice.Name), (int)blade) && WaferManager.Instance.CheckNoWafer(_target, _slot))
  558. {
  559. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(RobotDevice.Name), (int)blade, _target, _slot);
  560. LOG.Info("Wafer move in handler");
  561. }
  562. //if (_isSimulator)
  563. //{
  564. // RobotDevice.CmdBladeTarget = $"{_target}.Retract";
  565. //}
  566. RobotDevice.Blade1Target = ModuleHelper.Converter(RobotDevice.Name);
  567. }
  568. public override bool HandleMessage(MessageBase msg, out bool handled)
  569. {
  570. // X,PL<CR><LF>
  571. handled = false;
  572. var result = msg as HAtmMessage;
  573. if (!result.IsResponse) return true;
  574. if (result.IsFormatError || result.Category != Category)
  575. {
  576. RobotDevice.SetError(result.Data);
  577. return true;
  578. }
  579. ResponseMessage = msg;
  580. handled = true;
  581. return true;
  582. }
  583. }
  584. public class VacuumOnHandler : HAtmHandler
  585. {
  586. private const string Category = "VY";
  587. public VacuumOnHandler(Robot robot)
  588. : base(robot)
  589. {
  590. Name = "vacuum on";
  591. _isBackground = false;
  592. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  593. }
  594. public override string Package(params object[] args)
  595. {
  596. //A,VY<CR><LF>
  597. return string.Format("A,VY{0}",
  598. EOT);
  599. }
  600. private void UpdateBefore()
  601. {
  602. }
  603. public override void Update()
  604. {
  605. }
  606. public override bool HandleMessage(MessageBase msg, out bool handled)
  607. {
  608. // X,VY<CR><LF>
  609. handled = false;
  610. var result = msg as HAtmMessage;
  611. if (!result.IsResponse) return true;
  612. if (result.IsFormatError || result.Category != Category)
  613. {
  614. RobotDevice.SetError(result.Data);
  615. return true;
  616. }
  617. ResponseMessage = msg;
  618. handled = true;
  619. return true;
  620. }
  621. }
  622. public class VacuumOffHandler : HAtmHandler
  623. {
  624. private const string Category = "VN";
  625. public VacuumOffHandler(Robot robot)
  626. : base(robot)
  627. {
  628. Name = "vacuum off";
  629. _isBackground = false;
  630. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  631. }
  632. public override string Package(params object[] args)
  633. {
  634. //A,VN<CR><LF>
  635. return string.Format("A,VN{0}",
  636. EOT);
  637. }
  638. private void UpdateBefore()
  639. {
  640. }
  641. public override void Update()
  642. {
  643. }
  644. public override bool HandleMessage(MessageBase msg, out bool handled)
  645. {
  646. // X,VN<CR><LF>
  647. handled = false;
  648. var result = msg as HAtmMessage;
  649. if (!result.IsResponse) return true;
  650. if (result.IsFormatError || result.Category != Category)
  651. {
  652. RobotDevice.SetError(result.Data);
  653. return true;
  654. }
  655. ResponseMessage = msg;
  656. handled = true;
  657. return true;
  658. }
  659. }
  660. public class SetThetaSpeedHandler : HAtmHandler
  661. {
  662. private int _speed;
  663. private int _acceleration;
  664. private const string Category = "MH";
  665. public SetThetaSpeedHandler(Robot robot, int speed, int acceleration)
  666. : base(robot)
  667. {
  668. Name = "set speed";
  669. _isBackground = false;
  670. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  671. _speed = speed;
  672. _acceleration = acceleration;
  673. }
  674. public override string Package(params object[] args)
  675. {
  676. //S,MH,a,xx,yy<CR><LF>
  677. //xx = Percentage of maximum allowed acceleration.
  678. //yy = Percentage of maximum allowed speed
  679. //a T(Theta) or Z(Up/ Down), or R(Reach)
  680. var command = "S,MH,T," + _speed.ToString("D2") + "," + _acceleration.ToString("D2");
  681. return string.Format("{0}{1}", command,
  682. EOT);
  683. }
  684. private void UpdateBefore()
  685. {
  686. }
  687. public override void Update()
  688. {
  689. }
  690. public override bool HandleMessage(MessageBase msg, out bool handled)
  691. {
  692. // X,MH<CR><LF>
  693. handled = false;
  694. var result = msg as HAtmMessage;
  695. if (!result.IsResponse) return true;
  696. if (result.IsFormatError || result.Category != Category)
  697. {
  698. RobotDevice.SetError(result.Data);
  699. return true;
  700. }
  701. ResponseMessage = msg;
  702. handled = true;
  703. return true;
  704. }
  705. }
  706. public class SetReachSpeedHandler : HAtmHandler
  707. {
  708. private int _speed;
  709. private int _acceleration;
  710. private const string Category = "MH";
  711. public SetReachSpeedHandler(Robot robot, int speed, int acceleration)
  712. : base(robot)
  713. {
  714. Name = "set speed";
  715. _isBackground = false;
  716. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  717. _speed = speed;
  718. _acceleration = acceleration;
  719. }
  720. public override string Package(params object[] args)
  721. {
  722. //S,MH,a,xx,yy<CR><LF>
  723. //xx = Percentage of maximum allowed acceleration.
  724. //yy = Percentage of maximum allowed speed
  725. //a T(Theta) or Z(Up/ Down), or R(Reach)
  726. var command = "S,MH,R," + _speed.ToString("D2") + "," + _acceleration.ToString("D2");
  727. return string.Format("{0}{1}", command,
  728. EOT);
  729. }
  730. private void UpdateBefore()
  731. {
  732. }
  733. public override void Update()
  734. {
  735. }
  736. public override bool HandleMessage(MessageBase msg, out bool handled)
  737. {
  738. // X,MH<CR><LF>
  739. handled = false;
  740. var result = msg as HAtmMessage;
  741. if (!result.IsResponse) return true;
  742. if (result.IsFormatError || result.Category != Category)
  743. {
  744. RobotDevice.SetError(result.Data);
  745. return true;
  746. }
  747. ResponseMessage = msg;
  748. handled = true;
  749. return true;
  750. }
  751. }
  752. public class QueryAllAxisStatusHandler : HAtmHandler
  753. {
  754. private const string Retract = "RE";
  755. private const string Up = "U";
  756. private const string Category = "AA";
  757. //private bool _isUp;
  758. public QueryAllAxisStatusHandler(Robot robot)
  759. : base(robot)
  760. {
  761. Name = "QueryAllAxisStatus";
  762. _isBackground = false;
  763. _hasResponse = true;
  764. }
  765. public override string Package(params object[] args)
  766. {
  767. //R,AA <CR> <LF>
  768. return string.Format($"R,AA{EOT}");
  769. }
  770. public override bool HandleMessage(MessageBase msg, out bool handled)
  771. {
  772. //aabbccd X,AA,RE0000d
  773. //aa = RE(Radial Axis Retract0 or EX(Extended)
  774. //bb = Theta Axis Address Position (01-15)
  775. //cc = Z Axis Address Position (01-99)
  776. //d = U(Up) or D(Dn)
  777. handled = false;
  778. var result = msg as HAtmMessage;
  779. if (!result.IsResponse) return true;
  780. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length < 1 || result.MessagePart[0].Length != 7)
  781. {
  782. RobotDevice.SetError(result.Data);
  783. return true;
  784. }
  785. ResponseMessage = msg;
  786. string aa = result.MessagePart[0].Substring(0, 2);
  787. string bb = result.MessagePart[0].Substring(2, 2);
  788. string cc = result.MessagePart[0].Substring(4, 2);
  789. string d = result.MessagePart[0].Substring(6, 1);
  790. if (aa == Retract)
  791. RobotDevice.IsRetract = true;
  792. else
  793. RobotDevice.IsRetract = false;
  794. int.TryParse(bb, out int thetaAxisAddressPosition);
  795. RobotDevice.ThetaAxisAddressPosition = thetaAxisAddressPosition;
  796. int.TryParse(cc, out int zAxisAddressPosition);
  797. RobotDevice.ZAxisAddressPosition = zAxisAddressPosition;
  798. if (d.ToUpper() == Up)
  799. RobotDevice.IsUp = true;
  800. else
  801. RobotDevice.IsUp = false;
  802. handled = true;
  803. return true;
  804. }
  805. }
  806. public class QueryThetaAxisStatusHandler : HAtmHandler
  807. {
  808. private const string Retract = "RE";
  809. private const string Up = "U";
  810. private const string Category = "TA";
  811. private const string Busy = "B";
  812. private const string Referenced = "R";
  813. //private bool _isUp;
  814. public QueryThetaAxisStatusHandler(Robot robot)
  815. : base(robot)
  816. {
  817. Name = "QueryThetaAxisStatus";
  818. _isBackground = false;
  819. _hasResponse = true;
  820. }
  821. public override string Package(params object[] args)
  822. {
  823. //R,TA <CR> <LF>
  824. return string.Format($"R,TA{EOT}");
  825. }
  826. public override bool HandleMessage(MessageBase msg, out bool handled)
  827. {
  828. //X,TA,abccdde<CR><LF>
  829. //a = B (Busy) or R (Ready)
  830. //b = R (Referenced) or U (Unreferenced)
  831. //cc = Current Position
  832. //dd = Command Address Position
  833. //e = X (Overcurrent Latch Set) or (Not Set)
  834. handled = false;
  835. var result = msg as HAtmMessage;
  836. if (!result.IsResponse) return true;
  837. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length < 1 || result.MessagePart[0].Length < 7)
  838. {
  839. RobotDevice.SetError(result.Data);
  840. return true;
  841. }
  842. ResponseMessage = msg;
  843. string a = result.MessagePart[0].Substring(0, 1);
  844. string b = result.MessagePart[0].Substring(1, 1);
  845. string cc = result.MessagePart[0].Substring(2, 2);
  846. string dd = result.MessagePart[0].Substring(4, 2);
  847. string e = result.MessagePart[0].Substring(6, 1);
  848. if (a == Busy)
  849. RobotDevice.IsThetaBusy = true;
  850. else
  851. RobotDevice.IsThetaBusy = false;
  852. if (RobotDevice.IsHomed)
  853. {
  854. RobotDevice.IsRotationAxisUnreferencedTrig.CLK = b.ToUpper() == "U";
  855. if (RobotDevice.IsRotationAxisUnreferencedTrig.Q)
  856. {
  857. EV.PostAlarmLog(RobotDevice.Module, "Rotation axis is unreferenced, please repair it");
  858. }
  859. }
  860. handled = true;
  861. return true;
  862. }
  863. }
  864. public class QueryZAxisStatusHandler : HAtmHandler
  865. {
  866. private const string Retract = "RE";
  867. private const string Up = "U";
  868. private const string Category = "ZA";
  869. private const string Busy = "B";
  870. private const string Referenced = "R";
  871. //private bool _isUp;
  872. public QueryZAxisStatusHandler(Robot robot)
  873. : base(robot)
  874. {
  875. Name = "QueryZAxisStatus";
  876. _isBackground = false;
  877. _hasResponse = true;
  878. }
  879. public override string Package(params object[] args)
  880. {
  881. //R,ZA <CR> <LF>
  882. return string.Format($"R,ZA{EOT}");
  883. }
  884. public override bool HandleMessage(MessageBase msg, out bool handled)
  885. {
  886. //X,TA,abccdde<CR><LF>
  887. //X,ZA,abccdeefg<CR><LF>
  888. //a = B (Busy) or R (Ready)
  889. //b = R (Referenced) or U (Unreferenced)
  890. //cc = Current Position
  891. //dd = Command Address Position
  892. //e = X (Overcurrent Latch Set) or (Not Set)
  893. //f U(Up) or D(Down) Command
  894. //g = X (Overcurrent Latch Set) or (Space) (Not Set)
  895. handled = false;
  896. var result = msg as HAtmMessage;
  897. if (!result.IsResponse) return true;
  898. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length < 1 || result.MessagePart[0].Length < 9)
  899. {
  900. RobotDevice.SetError(result.Data);
  901. return true;
  902. }
  903. ResponseMessage = msg;
  904. string a = result.MessagePart[0].Substring(0, 1);
  905. string b = result.MessagePart[0].Substring(1, 1);
  906. string cc = result.MessagePart[0].Substring(2, 2);
  907. string dd = result.MessagePart[0].Substring(4, 2);
  908. string e = result.MessagePart[0].Substring(6, 1);
  909. string f = result.MessagePart[0].Substring(7, 1);
  910. string g = result.MessagePart[0].Substring(8, 1);
  911. if (a == Busy)
  912. RobotDevice.IsZBusy = true;
  913. else
  914. RobotDevice.IsZBusy = false;
  915. if (RobotDevice.IsHomed)
  916. {
  917. RobotDevice.IsZAxisUnreferencedTrig.CLK = b.ToUpper() == "U";
  918. if (RobotDevice.IsZAxisUnreferencedTrig.Q)
  919. {
  920. EV.PostAlarmLog(RobotDevice.Module, "Z axis is unreferenced, please repair it");
  921. }
  922. }
  923. handled = true;
  924. return true;
  925. }
  926. }
  927. public class QueryRadialAxisStatusHandler : HAtmHandler
  928. {
  929. private const string Retract = "RE";
  930. private const string Up = "U";
  931. private const string Category = "RA";
  932. private const string Busy = "B";
  933. private const string Referenced = "R";
  934. //private bool _isUp;
  935. public QueryRadialAxisStatusHandler(Robot robot)
  936. : base(robot)
  937. {
  938. Name = "QueryRadialAxisStatus";
  939. _isBackground = false;
  940. _hasResponse = true;
  941. }
  942. public override string Package(params object[] args)
  943. {
  944. //R,RA <CR> <LF>
  945. return string.Format($"R,RA{EOT}");
  946. }
  947. public override bool HandleMessage(MessageBase msg, out bool handled)
  948. {
  949. //X,RA,abccdde<CR><LF>
  950. //a = B (Busy) or R (Ready)
  951. //b = R (Referenced) or U (Unreferenced)
  952. //cc = Current Position(RE = retract, EX = extend)
  953. //dd = Command Address Position(RE = retract, EX = extend)
  954. //e = X (Overcurrent Latch Set) or (Not Set)
  955. handled = false;
  956. var result = msg as HAtmMessage;
  957. if (!result.IsResponse) return true;
  958. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length < 1 || result.MessagePart[0].Length < 7)
  959. {
  960. RobotDevice.SetError(result.Data);
  961. return true;
  962. }
  963. ResponseMessage = msg;
  964. string a = result.MessagePart[0].Substring(0, 1);
  965. string b = result.MessagePart[0].Substring(1, 1);
  966. string cc = result.MessagePart[0].Substring(2, 2);
  967. string dd = result.MessagePart[0].Substring(4, 2);
  968. string e = result.MessagePart[0].Substring(6, 1);
  969. if (a == Busy)
  970. RobotDevice.IsRadialBusy = true;
  971. else
  972. RobotDevice.IsRadialBusy = false;
  973. if (cc == Retract)
  974. RobotDevice.IsRetract = true;
  975. else
  976. RobotDevice.IsRetract = false;
  977. if(RobotDevice.IsHomed)
  978. {
  979. RobotDevice.IsExtensionAxisUnreferencedTrig.CLK = b.ToUpper() == "U";
  980. if (RobotDevice.IsExtensionAxisUnreferencedTrig.Q)
  981. {
  982. EV.PostAlarmLog(RobotDevice.Module, "Extension axis is unreferenced, please repair it");
  983. }
  984. }
  985. handled = true;
  986. return true;
  987. }
  988. }
  989. public class QueryErrorHandler : HAtmHandler
  990. {
  991. private const string Category = "ER";
  992. public QueryErrorHandler(Robot robot)
  993. : base(robot)
  994. {
  995. Name = "QueryError";
  996. _isBackground = false;
  997. _hasResponse = true;
  998. }
  999. public override string Package(params object[] args)
  1000. {
  1001. //R,ER <CR> <LF>
  1002. return string.Format("R,ER{0}", EOT);
  1003. }
  1004. public override bool HandleMessage(MessageBase msg, out bool handled)
  1005. {
  1006. //aa,bb,…..zz X,ER,OK
  1007. //aa = first error code
  1008. //bb = second error code
  1009. //etc… All current error codes will be returned.
  1010. handled = false;
  1011. var result = msg as HAtmMessage;
  1012. if (!result.IsResponse) return true;
  1013. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length < 1)
  1014. {
  1015. RobotDevice.SetError(result.Data);
  1016. return true;
  1017. }
  1018. if(result.MessagePart[0] == "OK")
  1019. {
  1020. return true;
  1021. }
  1022. ResponseMessage = msg;
  1023. string error = string.Join(",", result.MessagePart);
  1024. EV.PostAlarmLog(RobotDevice.Name, $"{RobotDevice.Name} error, error code({error}):{(RobotDevice.ErrorCodeReference.ContainsKey(error) ? RobotDevice.ErrorCodeReference[error] : "")}");
  1025. handled = true;
  1026. return true;
  1027. }
  1028. }
  1029. public class QueryOperationalStatusHandler : HAtmHandler
  1030. {
  1031. private const string Error = "E";
  1032. private const string Busy = "B";
  1033. private const string Referenced = "R";
  1034. private const string DataValid = "V";
  1035. private const string LastCommandSuccessful = "S";
  1036. private const string WaferPresent = "Y";
  1037. private const string OvercurrentShutdownPresent = "X";
  1038. private const string CassettePortChange = "C";
  1039. private const string Category = "OS";
  1040. public QueryOperationalStatusHandler(Robot robot)
  1041. : base(robot)
  1042. {
  1043. Name = "QueryOperationalStatus";
  1044. _isBackground = false;
  1045. _hasResponse = true;
  1046. }
  1047. public override string Package(params object[] args)
  1048. {
  1049. //R,OS <CR> <LF>
  1050. return string.Format($"R,OS{EOT}");
  1051. }
  1052. public override bool HandleMessage(MessageBase msg, out bool handled)
  1053. {
  1054. //abcdeeffgghijkl "X,OS, RRVHM UN C"
  1055. //a = E (Error Present) or space (No Error Present)
  1056. //b = B (Busy) or R (Ready)
  1057. //c = R (All Axes Referenced) or space (Not All Referenced)
  1058. //d = V (Data Valid) or space (Data Not Valid)
  1059. //ee = Last/Current Action Category
  1060. //ff = Theta Address of High Level Command
  1061. //gg = Z-Address of High Level Command
  1062. //h = S (Last Command Successful) or U (Unsuccessful)
  1063. //I = Y (Wafer Present on End Effector) or N (Not Present)
  1064. //J = X (Overcurrent Shutdown Present) or space (Not Present)
  1065. //K = C (Cassette Port Change) or space (no change)
  1066. //L = Mapping sensor status
  1067. handled = false;
  1068. var result = msg as HAtmMessage;
  1069. if (!result.IsResponse) return true;
  1070. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length < 1 ||
  1071. (result.MessagePart[0].Length != 14 && result.MessagePart[0].Length != 15))
  1072. {
  1073. RobotDevice.SetError(result.RawMessage );
  1074. return true;
  1075. }
  1076. ResponseMessage = msg;
  1077. string a = result.MessagePart[0].Substring(0, 1);
  1078. string b = result.MessagePart[0].Substring(1, 1);
  1079. string c = result.MessagePart[0].Substring(2, 1);
  1080. string d = result.MessagePart[0].Substring(3, 1);
  1081. string ee = result.MessagePart[0].Substring(4, 2);
  1082. string ff = result.MessagePart[0].Substring(6, 2);
  1083. string gg = result.MessagePart[0].Substring(8, 2);
  1084. string h = result.MessagePart[0].Substring(10, 1);
  1085. string i = result.MessagePart[0].Substring(11, 1);
  1086. string j = result.MessagePart[0].Substring(12, 1);
  1087. string k = result.MessagePart[0].Substring(13, 1);
  1088. string l = string.Empty;
  1089. if (result.MessagePart[0].Length > 14)
  1090. l = result.MessagePart[0].Substring(14, 1);
  1091. if (a == Error)
  1092. RobotDevice.SetError($"{result.RawMessage}");
  1093. if (b == Busy)
  1094. RobotDevice.IsBusy = true;
  1095. else
  1096. RobotDevice.IsBusy = false; ;
  1097. if (i == WaferPresent)
  1098. RobotDevice.WaferPresentOnBlade1 = true;
  1099. else
  1100. RobotDevice.WaferPresentOnBlade1 = false;
  1101. handled = true;
  1102. return true;
  1103. }
  1104. }
  1105. public class QueryPositionHandler : HAtmHandler
  1106. {
  1107. private const string Category = "GP";
  1108. public QueryPositionHandler(Robot robot)
  1109. : base(robot)
  1110. {
  1111. Name = "QueryPosition";
  1112. _isBackground = false;
  1113. _hasResponse = true;
  1114. }
  1115. public override string Package(params object[] args)
  1116. {
  1117. //R,GP <CR> <LF>
  1118. return string.Format($"R,GP{EOT}");
  1119. }
  1120. public override bool HandleMessage(MessageBase msg, out bool handled)
  1121. {
  1122. //X,GP,0,11118,1149,0,11118,1149<CR><LF>
  1123. handled = false;
  1124. var result = msg as HAtmMessage;
  1125. if (!result.IsResponse) return true;
  1126. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length != 6)
  1127. {
  1128. RobotDevice.SetError(result.Data);
  1129. return true;
  1130. }
  1131. ResponseMessage = msg;
  1132. string rReqPos = result.MessagePart[0];//retract
  1133. string tReqPos = result.MessagePart[1];//rotate
  1134. string zReqPos = result.MessagePart[2];//z
  1135. string rActPos = result.MessagePart[3];
  1136. string tActPos = result.MessagePart[4];
  1137. string zActPos = result.MessagePart[5];
  1138. handled = true;
  1139. int.TryParse(rReqPos, out int pos);
  1140. RobotDevice.RetractReqPos = pos;
  1141. int.TryParse(tReqPos, out pos);
  1142. RobotDevice.RotateReqPos = pos/100;//deg
  1143. int.TryParse(zReqPos, out pos);
  1144. RobotDevice.ZReqPos = pos;
  1145. return true;
  1146. }
  1147. }
  1148. public class QuerySpeedHandler : HAtmHandler
  1149. {
  1150. private const string Category = "SS";
  1151. public QuerySpeedHandler(Robot robot)
  1152. : base(robot)
  1153. {
  1154. Name = "QuerySpeed";
  1155. _isBackground = false;
  1156. _hasResponse = true;
  1157. }
  1158. public override string Package(params object[] args)
  1159. {
  1160. //R,SS <CR> <LF>
  1161. return string.Format($"R,SS{EOT}");
  1162. }
  1163. public override bool HandleMessage(MessageBase msg, out bool handled)
  1164. {
  1165. // X,SS,rAccel,rVel, tAccel, tVel, zAccel, zVel<CR><LF>
  1166. handled = false;
  1167. var result = msg as HAtmMessage;
  1168. if (!result.IsResponse) return true;
  1169. if (result.IsFormatError || result.Category != Category || result.MessagePart.Length != 6)
  1170. {
  1171. RobotDevice.SetError(result.Data);
  1172. return true;
  1173. }
  1174. ResponseMessage = msg;
  1175. string rAccel = result.MessagePart[0];
  1176. string rVel = result.MessagePart[1];
  1177. string tAccel = result.MessagePart[2];
  1178. string tVel = result.MessagePart[3];
  1179. string zAccel = result.MessagePart[4];
  1180. string zVel = result.MessagePart[5];
  1181. handled = true;
  1182. return true;
  1183. }
  1184. }
  1185. public class SetCommandResponseHandler : HAtmHandler
  1186. {
  1187. private const string Category = "RR";
  1188. public SetCommandResponseHandler(Robot robot)
  1189. : base(robot)
  1190. {
  1191. Name = "SetCommandResponse";
  1192. _isBackground = false;
  1193. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  1194. }
  1195. public override string Package(params object[] args)
  1196. {
  1197. //S,RR <CR> <LF>
  1198. return string.Format($"S,{Category},Y{EOT}");
  1199. }
  1200. public override bool HandleMessage(MessageBase msg, out bool handled)
  1201. {
  1202. // X,RR<CR><LF>
  1203. handled = false;
  1204. var result = msg as HAtmMessage;
  1205. if (!result.IsResponse) return true;
  1206. if (result.IsFormatError || result.Category != Category)
  1207. {
  1208. RobotDevice.SetError(result.Data);
  1209. return true;
  1210. }
  1211. ResponseMessage = msg;
  1212. handled = true;
  1213. return true;
  1214. }
  1215. }
  1216. public class QueryWaferMapHandler : HAtmHandler
  1217. {
  1218. private const string Category = "MP";
  1219. private int _thetaAxis;
  1220. public QueryWaferMapHandler(Robot robot, ModuleName target)
  1221. : base(robot)
  1222. {
  1223. Name = "QueryWaferMap";
  1224. _thetaAxis = RobotConvertor.Chamber2ThetaAxisPosition(target);
  1225. _isBackground = false;
  1226. _hasResponse = true;
  1227. }
  1228. public override string Package(params object[] args)
  1229. {
  1230. //R,MP,tt<CR><LF>
  1231. return string.Format("R,MP,{0:D2}{1}",
  1232. _thetaAxis,
  1233. EOT);
  1234. }
  1235. public override bool HandleMessage(MessageBase msg, out bool handled)
  1236. {
  1237. //X,MP,tt,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<CR><LF>
  1238. //0= No wafer
  1239. //1= wafer present
  1240. //2=double wafer
  1241. //X=cross slotted wafer
  1242. handled = false;
  1243. var result = msg as HAtmMessage;
  1244. if (!result.IsResponse) return true;
  1245. if (result.IsFormatError || result.Category != Category || result.MessagePart == null && result.MessagePart.Length < 2)
  1246. {
  1247. RobotDevice.SetError(result.Data);
  1248. return true;
  1249. }
  1250. RobotDevice.SlotMap = string.Empty;
  1251. foreach(var item in result.MessagePart[1])
  1252. {
  1253. RobotDevice.SlotMap += item;
  1254. }
  1255. ResponseMessage = msg;
  1256. handled = true;
  1257. return true;
  1258. }
  1259. }
  1260. public class WaferMapHandler : HAtmHandler
  1261. {
  1262. private const string Category = "MP";
  1263. private int _thetaAxis;
  1264. public WaferMapHandler(Robot robot, ModuleName target)
  1265. : base(robot)
  1266. {
  1267. Name = "WaferMap";
  1268. _thetaAxis = RobotConvertor.Chamber2ThetaAxisPosition(target);
  1269. _isBackground = false;
  1270. _hasResponse = SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse");
  1271. }
  1272. public override string Package(params object[] args)
  1273. {
  1274. //A,MP,tt<CR><LF>
  1275. return string.Format("A,MP,{0:D2}{1}",
  1276. _thetaAxis,
  1277. EOT);
  1278. }
  1279. public override bool HandleMessage(MessageBase msg, out bool handled)
  1280. {
  1281. //X,MP,tt<CR><LF>
  1282. handled = false;
  1283. var result = msg as HAtmMessage;
  1284. if (!result.IsResponse) return true;
  1285. if (result.IsFormatError || result.Category != Category)
  1286. {
  1287. RobotDevice.SetError(result.Data);
  1288. return true;
  1289. }
  1290. ResponseMessage = msg;
  1291. handled = true;
  1292. return true;
  1293. }
  1294. }
  1295. }