TMEntity.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.RT.Fsm;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.Util;
  6. using Venus_Core;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using Venus_RT.Devices;
  11. using Venus_RT.Modules.TM;
  12. using Aitex.Core.RT.DataCenter;
  13. using Aitex.Core.RT.OperationCenter;
  14. using MECF.Framework.Common.Schedulers;
  15. using MECF.Framework.Common.CommonData;
  16. using Aitex.Core.RT.Device;
  17. namespace Venus_RT.Modules
  18. {
  19. class TMEntity : Entity, IModuleEntity
  20. {
  21. public enum STATE
  22. {
  23. Unknown,
  24. Init,
  25. Initializing,
  26. Idle,
  27. Error,
  28. Pumping,
  29. Venting,
  30. Purging,
  31. Leakchecking,
  32. Picking,
  33. Placing,
  34. Swaping,
  35. PMPicking,
  36. PMPlacing,
  37. PMSwaping,
  38. Aligning,
  39. Mapping,
  40. Extending,
  41. Retracting,
  42. Swapping,
  43. Gotoing,
  44. }
  45. public enum MSG
  46. {
  47. Home,
  48. Online,
  49. Offline,
  50. Pump,
  51. Vent,
  52. Purge,
  53. CyclePurge,
  54. LeakCheck,
  55. Pick,
  56. Place,
  57. Swap,
  58. DoublePick,
  59. DoublePlace,
  60. DoubleSwap,
  61. PMPick,
  62. PMPlace,
  63. PMSwap,
  64. Extend,
  65. Retract,
  66. TMCycle,
  67. Error,
  68. Abort,
  69. }
  70. public bool IsIdle
  71. {
  72. get { return fsm.State == (int)STATE.Idle; }
  73. }
  74. public bool IsError
  75. {
  76. get { return fsm.State == (int)STATE.Error; }
  77. }
  78. public bool IsInit
  79. {
  80. get { return fsm.State == (int)STATE.Unknown || fsm.State == (int)STATE.Init; }
  81. }
  82. public bool IsBusy
  83. {
  84. get { return !IsInit && !IsError && !IsIdle; }
  85. }
  86. public bool IsLLSlitDoorClosed(ModuleName ll) => ll == ModuleName.LLA ? _tm.IsLLAESlitDoorClosed : _tm.IsLLBESlitDoorClosed;
  87. public bool IsLLSlitDoorOpen(ModuleName ll) => ll == ModuleName.LLA ? _tm.IsLLAESlitDoorOpen : _tm.IsLLBESlitDoorOpen;
  88. public bool IsOnline { get; internal set; }
  89. public bool IsTMVac => _tm.IsTMVac;
  90. public bool IsTMATM => _tm.IsTMATM;
  91. public double TMPressure { get { return _tm.TMPressure; } }
  92. private readonly JetTM _tm;
  93. private readonly ITransferRobot _robot;
  94. private readonly MFHomeRoutine _homeRoutine;
  95. private readonly MFPumpRoutine _pumpingRoutine;
  96. private readonly MFVentRoutine _ventingRoutine;
  97. private readonly MFLeakCheckRoutine _leakCheckRoutine;
  98. private readonly MFPurgeRoutine _purgeRoutine;
  99. private readonly MFPickRoutine _pickRoutine;
  100. private readonly MFPlaceRoutine _placeRoutine;
  101. private readonly MFSwapRoutine _swapRoutine;
  102. private readonly MFPMPickRoutine _pmPickRoutine;
  103. private readonly MFPMPlaceRoutine _pmPlaceRoutine;
  104. private readonly MFPMSwapRoutine _pmSwapRoutine;
  105. private readonly MFPMRetractRoutine _pmRetractRoutine;
  106. private readonly MFPMExtendRoutine _pmExtendRoutine;
  107. public TMEntity()
  108. {
  109. //_tm = Singleton<JetTM>.Instance;
  110. _tm = DEVICE.GetDevice<JetTM>("TM");
  111. _robot = new SIASUNRobot();
  112. _homeRoutine = new MFHomeRoutine(_tm, _robot);
  113. _pickRoutine = new MFPickRoutine(_tm, _robot);
  114. _placeRoutine = new MFPlaceRoutine(_tm, _robot);
  115. _swapRoutine = new MFSwapRoutine(_tm, _robot);
  116. _pmPickRoutine = new MFPMPickRoutine(_tm, _robot);
  117. _pmPlaceRoutine = new MFPMPlaceRoutine(_tm, _robot);
  118. _pmSwapRoutine = new MFPMSwapRoutine(_tm, _robot);
  119. _pumpingRoutine = new MFPumpRoutine(_tm, ModuleName.TM);
  120. _ventingRoutine = new MFVentRoutine(_tm, ModuleName.TM);
  121. _leakCheckRoutine = new MFLeakCheckRoutine(_tm, ModuleName.TM);
  122. _purgeRoutine = new MFPurgeRoutine(_tm, ModuleName.TM);
  123. _pmRetractRoutine = new MFPMRetractRoutine(_tm, _robot);
  124. _pmExtendRoutine = new MFPMExtendRoutine(_tm, _robot);
  125. WaferManager.Instance.SubscribeLocation(ModuleName.TMRobot, 2);
  126. InitFsmMap();
  127. }
  128. protected override bool Init()
  129. {
  130. OP.Subscribe("TM.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  131. OP.Subscribe($"TM.{RtOperation.LLPick}", (cmd, args) => CheckToPostMessage((int)MSG.Pick, args));
  132. OP.Subscribe($"TM.{RtOperation.LLPlace}", (cmd, args) => CheckToPostMessage((int)MSG.Place, args));
  133. OP.Subscribe($"TM.{RtOperation.PMPick}", (cmd, args) => CheckToPostMessage((int)MSG.PMPick, args));
  134. OP.Subscribe($"TM.{RtOperation.PMPlace}", (cmd, args) => CheckToPostMessage((int)MSG.PMPlace, args));
  135. OP.Subscribe($"TM.{RtOperation.Extend}", (cmd, args) => CheckToPostMessage((int)MSG.Extend, args));
  136. OP.Subscribe($"TM.{RtOperation.Retract}", (cmd, args) => CheckToPostMessage((int)MSG.Retract, args));
  137. OP.Subscribe($"TM.{RtOperation.Cycle}", (cmd, args) => CheckToPostMessage((int)MSG.Swap, args));
  138. //OP.Subscribe($"TM.{RtOperation.LLPlace}", (cmd, args) => CheckToPostMessage((int)MSG.Place, args));
  139. OP.Subscribe($"TM.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  140. OP.Subscribe($"TM.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  141. OP.Subscribe($"TM.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck));
  142. OP.Subscribe($"TM.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.Purge));
  143. OP.Subscribe($"TM.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  144. DATA.Subscribe("TM.FsmState", () => (((STATE)fsm.State).ToString()));
  145. DATA.Subscribe("TM.FsmPrevState", () => (((PMState)fsm.PrevState).ToString()));
  146. DATA.Subscribe("TM.FsmLastMessage", () => (((MSG)fsm.LastMsg).ToString()));
  147. DATA.Subscribe("TM.RobotMoveAction", () => _robot.TMRobotMoveInfo);
  148. DATA.Subscribe("TM.RobotMoveAction.ArmTarget", () => _robot.TMRobotMoveInfo.ArmTarget.ToString()) ;
  149. DATA.Subscribe("TM.RobotMoveAction.BladeTarget", () => _robot.TMRobotMoveInfo.BladeTarget);
  150. DATA.Subscribe("TM.RobotMoveAction.RobotAction", () => _robot.TMRobotMoveInfo.Action.ToString());
  151. return true;
  152. }
  153. private void InitFsmMap()
  154. {
  155. fsm = new StateMachine<TMEntity>("TM", (int)STATE.Init, 50);
  156. //AnyStateTransition(FSM_MSG.TIMER, fnMonitor, FSM_STATE.SAME);
  157. AnyStateTransition(MSG.Error, fnError, STATE.Error);
  158. AnyStateTransition(MSG.Online, fnOnline, FSM_STATE.SAME);
  159. AnyStateTransition(MSG.Offline, fnOffline, FSM_STATE.SAME);
  160. AnyStateTransition(MSG.Home, fnHome, STATE.Initializing);
  161. // Home
  162. Transition(STATE.Initializing, FSM_MSG.TIMER, fnHoming, STATE.Idle);
  163. Transition(STATE.Idle, FSM_MSG.TIMER, fnMonitor, STATE.Idle);
  164. Transition(STATE.Init, FSM_MSG.TIMER, fnMonitor, STATE.Init);
  165. // Vent sequence
  166. Transition(STATE.Idle, MSG.Vent, FnStartVent, STATE.Venting);
  167. Transition(STATE.Venting, FSM_MSG.TIMER, FnVentTimeout, STATE.Idle);
  168. Transition(STATE.Venting, MSG.Abort, FnAbortVent, STATE.Idle);
  169. // Pump sequence
  170. Transition(STATE.Idle, MSG.Pump, FnStartPump, STATE.Pumping);
  171. Transition(STATE.Pumping, FSM_MSG.TIMER, FnPumpTimeout, STATE.Idle);
  172. Transition(STATE.Pumping, MSG.Abort, FnAbortPump, STATE.Idle);
  173. // Purge sequence
  174. Transition(STATE.Idle, MSG.Purge, FnStartPurge, STATE.Purging);
  175. Transition(STATE.Purging, FSM_MSG.TIMER, FnPurgeTimeout, STATE.Idle);
  176. Transition(STATE.Purging, MSG.Abort, FnAbortPurge, STATE.Idle);
  177. // Leak check sequence
  178. Transition(STATE.Idle, MSG.LeakCheck, FnStartLeakCheck, STATE.Leakchecking);
  179. Transition(STATE.Leakchecking, FSM_MSG.TIMER, FnLeakCheckTimeout, STATE.Idle);
  180. Transition(STATE.Leakchecking, MSG.Abort, FnAbortLeakCheck, STATE.Idle);
  181. // Pick wafer from LL sequence
  182. Transition(STATE.Idle, MSG.Pick, FnStartPick, STATE.Picking);
  183. Transition(STATE.Picking, FSM_MSG.TIMER, FnPickTimeout, STATE.Idle);
  184. Transition(STATE.Picking, MSG.Abort, FnAbortPick, STATE.Idle);
  185. // Place wafer to LL sequence
  186. Transition(STATE.Idle, MSG.Place, FnStartPlace, STATE.Placing);
  187. Transition(STATE.Placing, FSM_MSG.TIMER, FnPlaceTimeout, STATE.Idle);
  188. Transition(STATE.Placing, MSG.Abort, FnAbortPlace, STATE.Idle);
  189. // Swap wafer with LL sequence
  190. Transition(STATE.Idle, MSG.Swap, FnStartSwap, STATE.Swaping);
  191. Transition(STATE.Swaping, FSM_MSG.TIMER, FnSwapTimeout, STATE.Idle);
  192. Transition(STATE.Swaping, MSG.Abort, FnAbortSwap, STATE.Idle);
  193. // Pick wafer from PM sequence
  194. Transition(STATE.Idle, MSG.PMPick, FnStartPMPick, STATE.PMPicking);
  195. Transition(STATE.PMPicking, FSM_MSG.TIMER, FnPMPickTimeout, STATE.Idle);
  196. Transition(STATE.PMPicking, MSG.Abort, FnAbortPMPick, STATE.Idle);
  197. // Place wafer to PM sequence
  198. Transition(STATE.Idle, MSG.PMPlace, FnStartPMPlace, STATE.PMPlacing);
  199. Transition(STATE.PMPlacing, FSM_MSG.TIMER, FnPMPlaceTimeout, STATE.Idle);
  200. Transition(STATE.PMPlacing, MSG.Abort, FnAbortPMPlace, STATE.Idle);
  201. // Swap wafer with PM sequence
  202. Transition(STATE.Idle, MSG.PMSwap, FnStartPMSwap, STATE.PMSwaping);
  203. Transition(STATE.PMSwaping, FSM_MSG.TIMER, FnPMSwapTimeout, STATE.Idle);
  204. Transition(STATE.PMSwaping, MSG.Abort, FnAbortPMSwap, STATE.Idle);
  205. //Retract
  206. Transition(STATE.Idle, MSG.Retract, FnStartRetract, STATE.Retracting);
  207. Transition(STATE.Retracting, FSM_MSG.TIMER, FnRetract, STATE.Idle);
  208. Transition(STATE.Retracting, MSG.Abort, FnAbortRetract, STATE.Idle);
  209. //Extend
  210. Transition(STATE.Idle, MSG.Extend, FnStartExtend, STATE.Extending);
  211. Transition(STATE.Extending, FSM_MSG.TIMER, FnExtend, STATE.Idle);
  212. Transition(STATE.Extending, MSG.Abort, FnAbortExtend, STATE.Idle);
  213. //Transition(RtState.Init, MSG.TMCycle, FsmStartTMCycle, RtState.TMCycle);
  214. //Transition(RtState.TMCycle, FSM_MSG.TIMER, FsmMonitorTMCycle, RtState.Idle);
  215. Running = true;
  216. }
  217. private bool fnMonitor(object[] param)
  218. {
  219. _debugRoutine();
  220. return true;
  221. }
  222. private bool fnError(object[] param)
  223. {
  224. IsOnline = false;
  225. return true;
  226. }
  227. private bool fnOnline(object[] param)
  228. {
  229. return true;
  230. }
  231. private bool fnOffline(object[] param)
  232. {
  233. IsOnline = false;
  234. return true;
  235. }
  236. private bool fnAbort(object[] param)
  237. {
  238. _robot.Halt();
  239. return true;
  240. }
  241. private bool fnHome(object[] param)
  242. {
  243. return _homeRoutine.Start() == RState.Running;
  244. }
  245. private bool fnHoming(object[] param)
  246. {
  247. RState ret = _homeRoutine.Monitor();
  248. if (ret == RState.Failed || ret == RState.Timeout)
  249. {
  250. PostMsg(MSG.Error);
  251. return false;
  252. }
  253. return ret == RState.End;
  254. }
  255. private bool FnStartVent(object[] param)
  256. {
  257. return _ventingRoutine.Start() == RState.Running ;
  258. }
  259. private bool FnVentTimeout(object[] param)
  260. {
  261. RState ret = _ventingRoutine.Monitor();
  262. if (ret == RState.Failed || ret == RState.Timeout)
  263. {
  264. _ventingRoutine.Abort();
  265. PostMsg(MSG.Error);
  266. return false;
  267. }
  268. return ret == RState.End;
  269. }
  270. private bool FnAbortVent(object[] param)
  271. {
  272. _ventingRoutine.Abort();
  273. return true;
  274. }
  275. private bool FnStartPump(object[] param)
  276. {
  277. return _pumpingRoutine.Start() == RState.Running;
  278. }
  279. private bool FnPumpTimeout(object[] param)
  280. {
  281. RState ret = _pumpingRoutine.Monitor();
  282. if (ret == RState.Failed || ret == RState.Timeout)
  283. {
  284. _pumpingRoutine.Abort();
  285. PostMsg(MSG.Error);
  286. return false;
  287. }
  288. return ret == RState.End;
  289. }
  290. private bool FnAbortPump(object[] param)
  291. {
  292. _pumpingRoutine.Abort();
  293. return true;
  294. }
  295. private bool FnStartPurge(object[] param)
  296. {
  297. return _purgeRoutine.Start() == RState.Running;
  298. }
  299. private bool FnPurgeTimeout(object[] param)
  300. {
  301. RState ret = _purgeRoutine.Monitor();
  302. if (ret == RState.Failed || ret == RState.Timeout)
  303. {
  304. PostMsg(MSG.Error);
  305. return false;
  306. }
  307. return ret == RState.End;
  308. }
  309. private bool FnAbortPurge(object[] param)
  310. {
  311. _purgeRoutine.Abort();
  312. return true;
  313. }
  314. private bool FnStartLeakCheck(object[] param)
  315. {
  316. return _leakCheckRoutine.Start() == RState.Running;
  317. }
  318. private bool FnLeakCheckTimeout(object[] param)
  319. {
  320. RState ret = _leakCheckRoutine.Monitor();
  321. if (ret == RState.Failed || ret == RState.Timeout)
  322. {
  323. PostMsg(MSG.Error);
  324. return false;
  325. }
  326. return ret == RState.End;
  327. }
  328. private bool FnAbortLeakCheck(object[] param)
  329. {
  330. _leakCheckRoutine.Abort();
  331. return true;
  332. }
  333. private bool FnStartPick(object[] param)
  334. {
  335. return _pickRoutine.Start(param) == RState.Running;
  336. }
  337. private bool FnPickTimeout(object[] param)
  338. {
  339. RState ret = _pickRoutine.Monitor();
  340. if (ret == RState.Failed || ret == RState.Timeout)
  341. {
  342. PostMsg(MSG.Error);
  343. return false;
  344. }
  345. return ret == RState.End;
  346. }
  347. private bool FnAbortPick(object[] param)
  348. {
  349. _pickRoutine.Abort();
  350. return true;
  351. }
  352. private bool FnStartPlace(object[] param)
  353. {
  354. return _placeRoutine.Start(param) == RState.Running;
  355. }
  356. private bool FnPlaceTimeout(object[] param)
  357. {
  358. RState ret = _placeRoutine.Monitor();
  359. if (ret == RState.Failed || ret == RState.Timeout)
  360. {
  361. PostMsg(MSG.Error);
  362. return false;
  363. }
  364. return ret == RState.End;
  365. }
  366. private bool FnAbortPlace(object[] param)
  367. {
  368. _placeRoutine.Abort();
  369. return true;
  370. }
  371. private bool FnStartSwap(object[] param)
  372. {
  373. return _swapRoutine.Start(param) == RState.Running;
  374. }
  375. private bool FnSwapTimeout(object[] param)
  376. {
  377. RState ret = _swapRoutine.Monitor();
  378. if (ret == RState.Failed || ret == RState.Timeout)
  379. {
  380. PostMsg(MSG.Error);
  381. return false;
  382. }
  383. return ret == RState.End;
  384. }
  385. private bool FnAbortSwap(object[] param)
  386. {
  387. _swapRoutine.Abort();
  388. return true;
  389. }
  390. private bool FnStartPMPick(object[] param)
  391. {
  392. return _pmPickRoutine.Start(param) == RState.Running;
  393. }
  394. private bool FnPMPickTimeout(object[] param)
  395. {
  396. RState ret = _pmPickRoutine.Monitor();
  397. if (ret == RState.Failed || ret == RState.Timeout)
  398. {
  399. PostMsg(MSG.Error);
  400. return false;
  401. }
  402. return ret == RState.End;
  403. }
  404. private bool FnAbortPMPick(object[] param)
  405. {
  406. _pmPickRoutine.Abort();
  407. return true;
  408. }
  409. private bool FnStartPMPlace(object[] param)
  410. {
  411. return _pmPlaceRoutine.Start(param) == RState.Running;
  412. }
  413. private bool FnPMPlaceTimeout(object[] param)
  414. {
  415. RState ret = _pmPlaceRoutine.Monitor();
  416. if (ret == RState.Failed || ret == RState.Timeout)
  417. {
  418. PostMsg(MSG.Error);
  419. return false;
  420. }
  421. return ret == RState.End;
  422. }
  423. private bool FnAbortPMPlace(object[] param)
  424. {
  425. _pmPlaceRoutine.Abort();
  426. return true;
  427. }
  428. private bool FnStartPMSwap(object[] param)
  429. {
  430. return _pmSwapRoutine.Start(param) == RState.Running;
  431. }
  432. private bool FnPMSwapTimeout(object[] param)
  433. {
  434. RState ret = _pmSwapRoutine.Monitor();
  435. if (ret == RState.Failed || ret == RState.Timeout)
  436. {
  437. PostMsg(MSG.Error);
  438. return false;
  439. }
  440. return ret == RState.End;
  441. }
  442. private bool FnAbortPMSwap(object[] param)
  443. {
  444. _pmSwapRoutine.Abort();
  445. return true;
  446. }
  447. private bool FnStartRetract(object[] param)
  448. {
  449. return _pmRetractRoutine.Start(param) == RState.Running;
  450. }
  451. private bool FnRetract(object[] param)
  452. {
  453. RState ret = _pmRetractRoutine.Monitor();
  454. if (ret == RState.Failed || ret == RState.Timeout)
  455. {
  456. PostMsg(MSG.Error);
  457. return false;
  458. }
  459. return ret == RState.End;
  460. }
  461. private bool FnAbortRetract(object[] param)
  462. {
  463. _pmRetractRoutine.Abort();
  464. return true;
  465. }
  466. private bool FnStartExtend(object[] param)
  467. {
  468. return _pmExtendRoutine.Start(param) == RState.Running;
  469. }
  470. private bool FnExtend(object[] param)
  471. {
  472. RState ret = _pmExtendRoutine.Monitor();
  473. if (ret == RState.Failed || ret == RState.Timeout)
  474. {
  475. PostMsg(MSG.Error);
  476. return false;
  477. }
  478. return ret == RState.End;
  479. }
  480. private bool FnAbortExtend(object[] param)
  481. {
  482. _pmExtendRoutine.Abort();
  483. return true;
  484. }
  485. public bool Check(int msg, out string reason, params object[] args)
  486. {
  487. reason = "";
  488. return true;
  489. }
  490. public int Invoke(string function, params object[] args)
  491. {
  492. switch (function)
  493. {
  494. case "Home":
  495. CheckToPostMessage((int)MSG.Home);
  496. return (int)MSG.Home;
  497. }
  498. return (int)FSM_MSG.NONE;
  499. }
  500. public bool CheckAcked(int msg)
  501. {
  502. return fsm.CheckExecuted(msg);
  503. }
  504. public bool CheckToPostMessage(int msg, params object[] args)
  505. {
  506. if (!fsm.FindTransition(fsm.State, msg))
  507. {
  508. LOG.Write(eEvent.WARN_FSM_WARN, ModuleName.TM, $"TM is in {(STATE)fsm.State} state,can not do {(MSG)msg}");
  509. return false;
  510. }
  511. Running = true;
  512. fsm.PostMsg(msg, args);
  513. return true;
  514. }
  515. public bool TurnEFEMSlitDoor(ModuleName loadlock, bool open, out string reason)
  516. {
  517. return _tm.TurnEFEMSlitDoor(loadlock, open, out reason);
  518. }
  519. //private bool FsmStartTMCycle(object[] objs)
  520. //{
  521. // return _TMCycle.Start(objs) == RState.Running;
  522. //}
  523. //private bool FsmMonitorTMCycle(object[] objs)
  524. //{
  525. // RState ret = _TMCycle.Monitor();
  526. // if (ret == RState.Failed || ret == RState.Timeout)
  527. // {
  528. // PostMsg(MSG.Error);
  529. // return false;
  530. // }
  531. // return ret == RState.End;
  532. //}
  533. private void _debugRoutine()
  534. {
  535. int flag = 0;
  536. // Test Home routine
  537. if (flag == 1)
  538. {
  539. PostMsg(MSG.Home);
  540. }
  541. else if (flag == 2)
  542. {
  543. PostMsg(MSG.Vent);
  544. }
  545. else if (flag == 3)
  546. {
  547. PostMsg(MSG.Pump);
  548. }
  549. else if(flag == 4)
  550. {
  551. PostMsg(MSG.Pick, ModuleName.LLA, 0, 0);
  552. }
  553. else if(flag == 5)
  554. {
  555. PostMsg(MSG.Place, ModuleName.LLA, 0, 0);
  556. }
  557. else if(flag == 6)
  558. {
  559. Queue<MoveItem> items = new Queue<MoveItem>();
  560. items.Enqueue(new MoveItem(ModuleName.TMRobot, 0, ModuleName.LLA, 0, Hand.Blade1));
  561. items.Enqueue(new MoveItem(ModuleName.TMRobot, 1, ModuleName.LLA, 1, Hand.Blade2));
  562. items.Enqueue(new MoveItem(ModuleName.LLA, 0, ModuleName.TMRobot, 0, Hand.Blade1));
  563. items.Enqueue(new MoveItem(ModuleName.LLA, 1, ModuleName.TMRobot, 1, Hand.Blade2));
  564. PostMsg(MSG.Swap,items);
  565. }
  566. else if(flag == 7)
  567. {
  568. PostMsg(MSG.PMPick, ModuleName.PMA, 0, 0);
  569. }
  570. else if(flag == 8)
  571. {
  572. PostMsg(MSG.PMPlace, ModuleName.PMA, 0, 0);
  573. }
  574. else if(flag == 9)
  575. {
  576. PostMsg(MSG.PMSwap, ModuleName.PMA, 0, 0, 0, 0);
  577. }
  578. //else if (flag == 4)
  579. //{
  580. // PostMsg(MSG.PumpLoadLock);
  581. //}
  582. //else if (flag == 5)
  583. //{
  584. // PostMsg(MSG.VentLoadLock);
  585. //}
  586. //else if (flag == 6)
  587. //{
  588. // PostMsg(MSG.PurgeLoadLock);
  589. //}
  590. //else if (flag == 7)
  591. //{
  592. // PostMsg(MSG.LaunchPump);
  593. //}
  594. //else if (flag == 8)
  595. //{
  596. // PostMsg(MSG.LaunchTurboPump);
  597. //}
  598. //else if (flag == 9)
  599. //{
  600. // PostMsg(MSG.LoadLockLeakCheck);
  601. //}
  602. //else if (flag == 10)
  603. //{
  604. // PostMsg(MSG.CyclePurge);
  605. //}
  606. //else if (flag == 11)
  607. //{
  608. // PostMsg(MSG.GasLinePurge);
  609. //}
  610. //else if (flag == 12)
  611. //{
  612. // PostMsg(MSG.LeakCheck);
  613. //}
  614. //else if (flag == 13)
  615. //{
  616. // PostMsg(MSG.GasLeakCheck);
  617. //}
  618. //else if (flag == 14)
  619. //{
  620. // PostMsg(MSG.LLPlace);
  621. //}
  622. //else if (flag == 15)
  623. //{
  624. // PostMsg(MSG.LLPick);
  625. //}
  626. //else if (flag == 16)
  627. //{
  628. // PostMsg(MSG.RunRecipe, "7777");
  629. //}
  630. //else if (flag == 17)
  631. //{
  632. // PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  633. //}
  634. }
  635. }
  636. }