LLEntity.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. using System;
  2. using Aitex.Core.Util;
  3. using Aitex.Core.RT.Fsm;
  4. using Aitex.Core.RT.Log;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.SubstrateTrackings;
  7. using Venus_RT.Modules.TM;
  8. using Venus_RT.Devices;
  9. using Venus_Core;
  10. using Aitex.Core.RT.DataCenter;
  11. using Aitex.Core.RT.OperationCenter;
  12. using Aitex.Core.RT.Device;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.RT.Event;
  15. using System.Diagnostics;
  16. using System.Linq;
  17. using System.Windows.Interop;
  18. using System.Collections.Generic;
  19. namespace Venus_RT.Modules
  20. {
  21. class LLEntity : Entity, IEntity, IModuleEntity
  22. {
  23. public enum LLStatus
  24. {
  25. Not_Ready,
  26. Ready_For_TM,
  27. Ready_For_EFEM,
  28. }
  29. public enum STATE
  30. {
  31. Unknown,
  32. Init,
  33. Initializing,
  34. Idle,
  35. Error,
  36. Pumping,
  37. Venting,
  38. Purging,
  39. Cooling,
  40. LeakCheck,
  41. Prepare_For_TM,
  42. Prepare_For_EFEM,
  43. Ready_For_TM,
  44. Ready_For_EFEM,
  45. WaitCooling,
  46. AutoCooling,
  47. }
  48. public enum MSG
  49. {
  50. Home,
  51. Online,
  52. Offline,
  53. Pump,
  54. Vent,
  55. AutoPump,
  56. AutoVent,
  57. Purge,
  58. CyclePurge,
  59. LeakCheck,
  60. Prepare_TM,
  61. Prepare_EFEM,
  62. TM_Exchange_Ready,
  63. EFEM_Exchange_Ready,
  64. Error,
  65. Abort,
  66. AutoCooling,
  67. }
  68. public ModuleName Module { get; private set; }
  69. public LLStatus Status { get; private set; }
  70. public bool Check(int msg, out string reason, params object[] args)
  71. {
  72. throw new NotImplementedException();
  73. }
  74. public bool IsIdle
  75. {
  76. get { return fsm.State == (int)STATE.Idle; }
  77. }
  78. public bool IsError
  79. {
  80. get { return fsm.State == (int)STATE.Error; }
  81. }
  82. public bool IsInit
  83. {
  84. get { return fsm.State == (int)STATE.Unknown || fsm.State == (int)STATE.Init; }
  85. }
  86. public bool IsBusy
  87. {
  88. get { return !IsInit && !IsError && !IsIdle; }
  89. }
  90. public bool IsOnline { get; internal set; }
  91. public bool IsInclude
  92. {
  93. get;
  94. private set;
  95. } = true;
  96. public bool IsVac { get { return _JetTM.IsModuleVaccum(Module); } }
  97. public bool IsATM { get { return _JetTM.IsModuleATM(Module); } }
  98. public override int TimeToReady
  99. {
  100. get
  101. {
  102. switch ((STATE)fsm.State)
  103. {
  104. case STATE.Pumping:
  105. case STATE.Venting:
  106. return base.TimeToReady;
  107. }
  108. return int.MaxValue / 2;
  109. }
  110. }
  111. private readonly JetTM _JetTM;
  112. private readonly MFPumpRoutine _pumpingRoutine;
  113. private readonly MFVentRoutine _ventingRoutine;
  114. private readonly MFLeakCheckRoutine _leakCheckRoutine;
  115. private readonly MFPurgeRoutine _purgeRoutine;
  116. private readonly MFCoolingRoutine _coolingRoutine;
  117. private readonly int _slotNumber = 4;
  118. private bool startControlPressureFlag = true;
  119. private int _controlPressureCheckPoint = 100;
  120. private int _controlPressureSetPoint = 90;
  121. private int _controlFlowSetPoint = 90;
  122. private bool _isEnableControlPressure;
  123. private Stopwatch _coolingStopWatch=new Stopwatch();
  124. private double _coolingMFCFlow;
  125. private int _coolingTime;
  126. CoolingStatu[] _coolingStatus;
  127. private bool _coolingFlag = false;
  128. public LLEntity(ModuleName module)
  129. {
  130. Module = module;
  131. _JetTM = DEVICE.GetDevice<JetTM>("TM");
  132. _pumpingRoutine = new MFPumpRoutine(_JetTM, Module);
  133. _ventingRoutine = new MFVentRoutine(_JetTM, Module);
  134. _leakCheckRoutine = new MFLeakCheckRoutine(_JetTM, Module);
  135. _purgeRoutine = new MFPurgeRoutine(_JetTM, Module);
  136. _coolingRoutine=new MFCoolingRoutine(_JetTM, Module);
  137. _slotNumber = SC.GetValue<int>($"{module.ToString()}.SlotNumber");
  138. WaferManager.Instance.SubscribeLocation(Module, _slotNumber);
  139. InitFsmMap();
  140. _coolingStatus=new CoolingStatu[_slotNumber];
  141. for (int i = 0; i < _slotNumber; i++)
  142. {
  143. _coolingStatus[i] = CoolingStatu.Init;
  144. }
  145. GetCoolingInfo();
  146. }
  147. private void GetCoolingInfo()
  148. {
  149. if (RtInstance.ConfigType == ConfigType.Kepler2200)
  150. {
  151. _coolingMFCFlow = SC.GetValue<double>($"{Module.ToString()}.Cooling.MFCFlow");
  152. _coolingTime = SC.GetValue<int>($"{Module.ToString()}.Cooling.CoolingTime");
  153. }
  154. }
  155. protected override bool Init()
  156. {
  157. OP.Subscribe($"{Module}.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  158. OP.Subscribe($"{Module}.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  159. OP.Subscribe($"{Module}.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  160. OP.Subscribe($"{Module}.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.Purge));
  161. OP.Subscribe($"{Module}.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  162. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck));
  163. OP.Subscribe($"{Module}.{RtOperation.Online}", (cmd, args) => CheckToPostMessage((int)MSG.Online));
  164. OP.Subscribe($"{Module}.{RtOperation.Offline}", (cmd, args) => CheckToPostMessage((int)MSG.Offline));
  165. OP.Subscribe($"{Module}.{RtOperation.Include}", (cmd, args) => FnSetInclude());
  166. OP.Subscribe($"{Module}.{RtOperation.Exclude}", (cmd, args) => FnSetExclude());
  167. OP.Subscribe($"{Module}.{RtOperation.ControlPressure}", (cmd, args) => StartControlPressure());
  168. OP.Subscribe($"{Module}.{RtOperation.AbortControlPressure}", (cmd, args) => StopControlPressure());
  169. DATA.Subscribe($"{Module}.FsmState", () => (((STATE)fsm.State).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  170. DATA.Subscribe($"{Module}.FsmPrevState", () => (((PMState)fsm.PrevState).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  171. DATA.Subscribe($"{Module}.FsmLastMessage", () => (((MSG)fsm.LastMsg).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  172. DATA.Subscribe($"{Module}.IsOnline", () => IsOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  173. DATA.Subscribe($"{Module}.IsInclude", () => IsInclude, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  174. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  175. DATA.Subscribe($"{Module}.IsEnableControlPressure", () => _isEnableControlPressure, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  176. DATA.Subscribe($"{Module}.CoolingTime", () => _coolingStopWatch.ElapsedMilliseconds/1000, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  177. return true;
  178. }
  179. private void InitFsmMap()
  180. {
  181. fsm = new StateMachine<LLEntity>(Module.ToString(), (int)STATE.Init, 50);
  182. fsm.EnableRepeatedMsg(true);
  183. EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_TM, fnEnterTMReady, FSM_MSG.NONE, fnExitTMReady);
  184. EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_EFEM, fnEnterEFEMReady, FSM_MSG.NONE, fnExitEFEMReady);
  185. //AnyStateTransition(FSM_MSG.TIMER, fnMonitor, FSM_STATE.SAME);
  186. AnyStateTransition(MSG.Error, fnError, STATE.Error);
  187. AnyStateTransition(MSG.Online, fnOnline, FSM_STATE.SAME);
  188. AnyStateTransition(MSG.Offline, fnOffline, FSM_STATE.SAME);
  189. AnyStateTransition(MSG.Home, fnHome, STATE.Initializing);
  190. // Home
  191. Transition(STATE.Initializing, FSM_MSG.TIMER, fnHoming, STATE.Idle);
  192. Transition(STATE.Idle, FSM_MSG.TIMER, fnMonitor, STATE.Idle);
  193. Transition(STATE.Init, FSM_MSG.TIMER, fnMonitor, STATE.Init);
  194. //vent sequence
  195. Transition(STATE.Idle, MSG.Vent, FnStartVent, STATE.Venting);
  196. Transition(STATE.Venting, FSM_MSG.TIMER, FnVentTimeout, STATE.Idle);
  197. Transition(STATE.Venting, MSG.Abort, FnAbortVent, STATE.Idle);
  198. Transition(STATE.Idle, MSG.AutoCooling, FnStartCooling, STATE.Cooling);
  199. Transition(STATE.Cooling, FSM_MSG.TIMER, FnCoolingTimeout, STATE.Idle);
  200. Transition(STATE.Cooling, MSG.Abort, FnAbortCooling, STATE.Idle);
  201. //Pump sequence
  202. Transition(STATE.Idle, MSG.Pump, FnStartPump, STATE.Pumping);
  203. Transition(STATE.Pumping, FSM_MSG.TIMER, FnPumpTimeout, STATE.Idle);
  204. Transition(STATE.Pumping, MSG.Abort, FnAbortPump, STATE.Idle);
  205. // Purge sequence
  206. Transition(STATE.Idle, MSG.Purge, FnStartPurge, STATE.Purging);
  207. Transition(STATE.Purging, FSM_MSG.TIMER, FnPurgeTimeout, STATE.Idle);
  208. Transition(STATE.Purging, MSG.Abort, FnAbortPurge, STATE.Idle);
  209. // Leak check sequence
  210. Transition(STATE.Idle, MSG.LeakCheck, FnStartLeakCheck, STATE.LeakCheck);
  211. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FnLeakCheckTimeout, STATE.Idle);
  212. Transition(STATE.LeakCheck, MSG.Abort, FnAbortLeakCheck, STATE.Idle);
  213. // Prepare TM Transfer
  214. Transition(STATE.Idle, MSG.Prepare_TM, FnStartPrepareTM, STATE.Prepare_For_TM);
  215. Transition(STATE.Prepare_For_TM, FSM_MSG.TIMER, FnPreparaTMTimeout, STATE.Ready_For_TM);
  216. Transition(STATE.Prepare_For_TM, MSG.Prepare_TM, null, STATE.Prepare_For_TM);
  217. Transition(STATE.Prepare_For_TM, MSG.Abort, FnAbortPreparaTM, STATE.Idle);
  218. Transition(STATE.Ready_For_TM, MSG.TM_Exchange_Ready, FnTMExchange, STATE.Idle);
  219. Transition(STATE.Ready_For_TM, MSG.Prepare_TM, null, STATE.Ready_For_TM);
  220. Transition(STATE.Ready_For_TM, MSG.Abort, null, STATE.Idle);
  221. Transition(STATE.Idle, MSG.AutoVent, FnTryAutoVent, STATE.Venting);
  222. Transition(STATE.Ready_For_TM, MSG.AutoVent, FnTryAutoVent, STATE.Venting);
  223. // Prepare EFEM Transfer
  224. Transition(STATE.Idle, MSG.Prepare_EFEM, FnStartPrepareEFEM, STATE.Prepare_For_EFEM);
  225. Transition(STATE.Prepare_For_EFEM, FSM_MSG.TIMER, FnPrepareEFEMTimeout, STATE.Ready_For_EFEM);
  226. Transition(STATE.Prepare_For_EFEM, MSG.Abort, FnAbortPrepareEFEM, STATE.Idle);
  227. Transition(STATE.Ready_For_EFEM, MSG.EFEM_Exchange_Ready, null, STATE.Idle);
  228. Transition(STATE.Ready_For_EFEM, MSG.Prepare_EFEM, null, STATE.Ready_For_EFEM);
  229. Transition(STATE.Ready_For_EFEM, MSG.Abort, null, STATE.Idle);
  230. Transition(STATE.Ready_For_EFEM, MSG.AutoPump, FnTryAutoPump, STATE.Pumping);
  231. Running = true;
  232. }
  233. public int Invoke(string function, params object[] args)
  234. {
  235. switch (function)
  236. {
  237. case "Home":
  238. case "Vent":
  239. case "Pump":
  240. case "AutoCooling":
  241. if (Enum.TryParse(function, out MSG message))
  242. {
  243. if (CheckToPostMessage((int)message))
  244. return (int)message;
  245. }
  246. break;
  247. }
  248. return (int)FSM_MSG.NONE;
  249. }
  250. public bool CheckAcked(int msg)
  251. {
  252. return fsm.CheckExecuted(msg);
  253. }
  254. public bool CheckToPostMessage(int msg, params object[] args)
  255. {
  256. if (!fsm.FindTransition(fsm.State, msg))
  257. {
  258. LOG.Write(eEvent.WARN_FSM_WARN, Module, $"{Module} is in {(STATE)fsm.State} state,can not do {(MSG)msg}");
  259. return false;
  260. }
  261. Running = true;
  262. fsm.PostMsg(msg, args);
  263. return true;
  264. }
  265. public (int processed, int unprocessed) GetWaferProcessStatus()
  266. {
  267. int processedCount = 0;
  268. int unprocessCount = 0;
  269. for (int i = 0; i < _slotNumber; i++)
  270. {
  271. var wafer = WaferManager.Instance.GetWafer(Module, i);
  272. if (!wafer.IsEmpty)
  273. {
  274. if (wafer.ProcessState == Aitex.Core.Common.EnumWaferProcessStatus.Completed)
  275. {
  276. processedCount++;
  277. }
  278. else
  279. {
  280. unprocessCount++;
  281. }
  282. }
  283. }
  284. return (processedCount, unprocessCount);
  285. }
  286. private bool fnEnterTMReady(object[] param)
  287. {
  288. if (RouteManager.IsATMMode)
  289. {
  290. Status = LLStatus.Ready_For_TM;
  291. return true;
  292. }
  293. StartControlPressure();
  294. Status = LLStatus.Ready_For_TM;
  295. return true;
  296. }
  297. private bool fnExitTMReady(object[] param)
  298. {
  299. if (RouteManager.IsATMMode)
  300. {
  301. Status = LLStatus.Not_Ready;
  302. return true;
  303. }
  304. StopControlPressure();
  305. Status = LLStatus.Not_Ready;
  306. return true;
  307. }
  308. private bool fnEnterEFEMReady(object[] param)
  309. {
  310. Status = LLStatus.Ready_For_EFEM;
  311. return true;
  312. }
  313. private bool fnExitEFEMReady(object[] param)
  314. {
  315. Status = LLStatus.Not_Ready;
  316. return true;
  317. }
  318. private bool fnMonitor(object[] param)
  319. {
  320. _debugRoutine();
  321. return true;
  322. }
  323. private bool fnError(object[] param)
  324. {
  325. IsOnline = false;
  326. return true;
  327. }
  328. private bool fnOnline(object[] param)
  329. {
  330. if (!IsInclude)
  331. {
  332. LOG.Write(eEvent.WARN_LL, Module, $"{Module} is excluded,can not be put online");
  333. return false;
  334. }
  335. IsOnline = true;
  336. return true;
  337. }
  338. private bool fnOffline(object[] param)
  339. {
  340. IsOnline = false;
  341. return true;
  342. }
  343. private bool FnSetInclude()
  344. {
  345. if (IsOnline == true)
  346. {
  347. LOG.Write(eEvent.WARN_LL, Module, $"{Module} is online,can not set Include");
  348. return false;
  349. }
  350. IsInclude = true;
  351. LOG.Write(eEvent.INFO_LL, Module, $"{Module} Set Include Success");
  352. return true;
  353. }
  354. private bool FnSetExclude()
  355. {
  356. if (IsOnline == true)
  357. {
  358. LOG.Write(eEvent.WARN_LL, Module, $"{Module} is online,can not set Exclude");
  359. return false;
  360. }
  361. IsInclude = false;
  362. LOG.Write(eEvent.INFO_LL, Module, $"{Module} Set Exclude Success");
  363. return true;
  364. }
  365. private bool fnAbort(object[] param)
  366. {
  367. return true;
  368. }
  369. private bool fnHome(object[] param)
  370. {
  371. //IsOnline = true;
  372. return true;
  373. }
  374. private bool fnHoming(object[] param)
  375. {
  376. return true;
  377. }
  378. private bool FnStartVent(object[] param)
  379. {
  380. return _ventingRoutine.Start(false) == RState.Running;
  381. }
  382. private bool FnTryAutoVent(object[] param)
  383. {
  384. if (RouteManager.IsATMMode)
  385. {
  386. PostMsg(MSG.TM_Exchange_Ready, false);
  387. return false;
  388. }
  389. _coolingMFCFlow = SC.GetValue<double>($"{Module.ToString()}.Cooling.MFCFlow");
  390. _coolingTime = SC.GetValue<int>($"{Module.ToString()}.Cooling.CoolingTime");
  391. return _ventingRoutine.Start(false) == RState.Running;
  392. }
  393. private bool FnVentTimeout(object[] param)
  394. {
  395. RState ret = _ventingRoutine.Monitor();
  396. if (ret == RState.Failed || ret == RState.Timeout)
  397. {
  398. PostMsg(MSG.Error);
  399. return false;
  400. }
  401. if(ret == RState.End)
  402. {
  403. MarkStateTime();
  404. return true;
  405. }
  406. return false;
  407. }
  408. private bool FnAbortVent(object[] param)
  409. {
  410. _ventingRoutine.Abort();
  411. return true;
  412. }
  413. private bool FnStartPump(object[] param)
  414. {
  415. return _pumpingRoutine.Start() == RState.Running;
  416. }
  417. private bool FnPumpTimeout(object[] param)
  418. {
  419. RState ret = _pumpingRoutine.Monitor();
  420. if (ret == RState.Failed || ret == RState.Timeout)
  421. {
  422. PostMsg(MSG.Error);
  423. return false;
  424. }
  425. if (ret == RState.End)
  426. {
  427. MarkStateTime();
  428. return true;
  429. }
  430. return false;
  431. }
  432. private bool FnAbortPump(object[] param)
  433. {
  434. _pumpingRoutine.Abort();
  435. return true;
  436. }
  437. private bool FnTryAutoPump(object[] param)
  438. {
  439. if (_JetTM.LLPumpStatus != JetTM.LLPumpState.Idle || RouteManager.IsATMMode)
  440. {
  441. PostMsg(MSG.EFEM_Exchange_Ready);
  442. return false;
  443. }
  444. return _pumpingRoutine.Start() == RState.Running;
  445. }
  446. private bool FnStartPurge(object[] param)
  447. {
  448. return _purgeRoutine.Start() == RState.Running;
  449. }
  450. private bool FnPurgeTimeout(object[] param)
  451. {
  452. RState ret = _purgeRoutine.Monitor();
  453. if (ret == RState.Failed || ret == RState.Timeout)
  454. {
  455. PostMsg(MSG.Error);
  456. return false;
  457. }
  458. return ret == RState.End;
  459. }
  460. private bool FnAbortPurge(object[] param)
  461. {
  462. _purgeRoutine.Abort();
  463. return true;
  464. }
  465. private bool FnStartLeakCheck(object[] param)
  466. {
  467. return _leakCheckRoutine.Start() == RState.Running;
  468. }
  469. private bool FnLeakCheckTimeout(object[] param)
  470. {
  471. RState ret = _leakCheckRoutine.Monitor();
  472. if (ret == RState.Failed || ret == RState.Timeout)
  473. {
  474. PostMsg(MSG.Error);
  475. return false;
  476. }
  477. return ret == RState.End;
  478. }
  479. private bool FnAbortLeakCheck(object[] param)
  480. {
  481. _leakCheckRoutine.Abort();
  482. return true;
  483. }
  484. private bool FnStartPrepareTM(object[] param)
  485. {
  486. if (RouteManager.IsATMMode)
  487. return true;
  488. return _pumpingRoutine.Start() == RState.Running;
  489. }
  490. private bool FnPreparaTMTimeout(object[] param)
  491. {
  492. if (RouteManager.IsATMMode)
  493. {
  494. if (fsm.ElapsedTime > 10000)
  495. {
  496. LOG.Write(eEvent.ERR_TM, Module, $"Cannot transfer wafer as {Module} is not ATM.");
  497. PostMsg(MSG.Error);
  498. return true;
  499. }
  500. return _JetTM.IsModuleATM(Module);
  501. }
  502. RState ret = _pumpingRoutine.Monitor();
  503. if (ret == RState.Failed || ret == RState.Timeout)
  504. {
  505. PostMsg(MSG.Error);
  506. return false;
  507. }
  508. return ret == RState.End;
  509. }
  510. private bool FnAbortPreparaTM(object[] param)
  511. {
  512. _pumpingRoutine.Abort();
  513. return true;
  514. }
  515. private bool FnStartPrepareEFEM(object[] param)
  516. {
  517. if (RouteManager.IsATMMode)
  518. return true;
  519. return _ventingRoutine.Start(false) == RState.Running;
  520. }
  521. private bool FnPrepareEFEMTimeout(object[] param)
  522. {
  523. if (RouteManager.IsATMMode)
  524. {
  525. if (fsm.ElapsedTime > 10000)
  526. {
  527. LOG.Write(eEvent.ERR_TM, Module, $"Cannot transfer wafer as {Module} is not ATM.");
  528. PostMsg(MSG.Error);
  529. return true;
  530. }
  531. return _JetTM.IsModuleATM(Module);
  532. }
  533. RState ret = _ventingRoutine.Monitor();
  534. if (ret == RState.Failed || ret == RState.Timeout)
  535. {
  536. PostMsg(MSG.Error);
  537. return false;
  538. }
  539. return ret == RState.End;
  540. //if (ret == RState.End && _coolingFlag)
  541. //{
  542. // //if (_coolingStatus.Any(x => x == CoolingStatu.WaitCooling) && Singleton<RouteManager>.Instance.IsAutoRunning)
  543. // //{
  544. // // PostMsg(MSG.AutoCooling);
  545. // //}
  546. // return true;
  547. //}
  548. //else if (_coolingFlag == false)
  549. //{
  550. // return true;
  551. //}
  552. //else
  553. //{
  554. // return false;
  555. //}
  556. }
  557. private bool FnAbortPrepareEFEM(object[] param)
  558. {
  559. _ventingRoutine.Abort();
  560. return true;
  561. }
  562. private bool StartControlPressure()
  563. {
  564. _isEnableControlPressure = true;
  565. _controlPressureCheckPoint = SC.GetValue<int>($"{Module}.ControlPressureCheckPoint");
  566. _controlPressureSetPoint = SC.GetValue<int>($"{Module}.ControlPressureSetPoint");
  567. _controlFlowSetPoint = SC.GetValue<int>($"{Module}.{Module}_MFC1.DefaultSetPoint");
  568. _JetTM.TurnFastPumpValve(Module, true);
  569. //_JetTM.TurnSoftPumpValve(Module, true);
  570. _JetTM.TurnPurgeValve(Module, true);
  571. _JetTM.TurnN2Valve(true);
  572. if (Module == ModuleName.LLA)
  573. {
  574. _JetTM.SwitchLLAPressureMode(true);
  575. _JetTM.SetLLAPressure((int)_controlPressureSetPoint);
  576. }
  577. else if (Module == ModuleName.LLB)
  578. {
  579. _JetTM.SwitchLLBPressureMode(true);
  580. _JetTM.SetLLBPressure((int)_controlPressureSetPoint);
  581. }
  582. return true;
  583. }
  584. private bool StopControlPressure()
  585. {
  586. _isEnableControlPressure = false;
  587. _JetTM.TurnFastPumpValve(Module, false);
  588. _JetTM.TurnSoftPumpValve(Module, false);
  589. _JetTM.TurnPurgeValve(Module, false);
  590. if (Module == ModuleName.LLA)
  591. {
  592. _JetTM.SwitchLLAPressureMode(false);
  593. _JetTM.SetLLAPressure(0);
  594. }
  595. else if (Module == ModuleName.LLB)
  596. {
  597. _JetTM.SwitchLLBPressureMode(false);
  598. _JetTM.SetLLBPressure(0);
  599. }
  600. return true;
  601. }
  602. private bool FnStartCooling(object[] param)
  603. {
  604. _coolingStopWatch.Restart();
  605. _coolingTime = SC.GetValue<int>($"{Module}.Cooling.CoolingTime") * 1000;
  606. return _ventingRoutine.Start(true) == RState.Running;
  607. }
  608. private bool FnCoolingTimeout(object[] param)
  609. {
  610. RState ret = _ventingRoutine.Monitor();
  611. if (ret == RState.Failed || ret == RState.Timeout)
  612. {
  613. PostMsg(MSG.Error);
  614. _coolingStopWatch.Reset();
  615. return false;
  616. }
  617. if(_coolingStopWatch.ElapsedMilliseconds > _coolingTime && _JetTM.IsModuleATM(Module))
  618. {
  619. MarkStateTime();
  620. _ventingRoutine.Abort();
  621. _coolingStopWatch.Reset();
  622. return true;
  623. }
  624. if (ret == RState.End)
  625. {
  626. _coolingStopWatch.Reset();
  627. return true;
  628. }
  629. else
  630. {
  631. return false;
  632. }
  633. }
  634. private bool FnAbortCooling(object[] param)
  635. {
  636. _ventingRoutine.Abort();
  637. return true;
  638. }
  639. private bool FnTMExchange(object[] param)
  640. {
  641. return true;
  642. }
  643. //private bool FnEFEMExchange(object[] param)
  644. //{
  645. // int slot = (int)param[0];
  646. // _coolingStatus[slot] = CoolingStatu.Init;
  647. // return true;
  648. //}
  649. private void _debugRoutine()
  650. {
  651. int flag = 0;
  652. // Test Home routine
  653. if (flag == 1)
  654. {
  655. PostMsg(MSG.Home);
  656. }
  657. else if (flag == 2)
  658. {
  659. PostMsg(MSG.Vent);
  660. }
  661. else if (flag == 3)
  662. {
  663. PostMsg(MSG.Pump);
  664. }
  665. //else if (flag == 4)
  666. //{
  667. // PostMsg(MSG.PumpLoadLock);
  668. //}
  669. //else if (flag == 5)
  670. //{
  671. // PostMsg(MSG.VentLoadLock);
  672. //}
  673. //else if (flag == 6)
  674. //{
  675. // PostMsg(MSG.PurgeLoadLock);
  676. //}
  677. //else if (flag == 7)
  678. //{
  679. // PostMsg(MSG.LaunchPump);
  680. //}
  681. //else if (flag == 8)
  682. //{
  683. // PostMsg(MSG.LaunchTurboPump);
  684. //}
  685. //else if (flag == 9)
  686. //{
  687. // PostMsg(MSG.LoadLockLeakCheck);
  688. //}
  689. else if (flag == 10)
  690. {
  691. PostMsg(MSG.CyclePurge);
  692. }
  693. //else if (flag == 11)
  694. //{
  695. // PostMsg(MSG.GasLinePurge);
  696. //}
  697. //else if (flag == 12)
  698. //{
  699. // PostMsg(MSG.LeakCheck);
  700. //}
  701. //else if (flag == 13)
  702. //{
  703. // PostMsg(MSG.GasLeakCheck);
  704. //}
  705. //else if (flag == 14)
  706. //{
  707. // PostMsg(MSG.LLPlace);
  708. //}
  709. //else if (flag == 15)
  710. //{
  711. // PostMsg(MSG.LLPick);
  712. //}
  713. //else if (flag == 16)
  714. //{
  715. // PostMsg(MSG.RunRecipe, "7777");
  716. //}
  717. //else if (flag == 17)
  718. //{
  719. // PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  720. //}
  721. }
  722. }
  723. }