LLEntity.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  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. return true;
  177. }
  178. private void InitFsmMap()
  179. {
  180. fsm = new StateMachine<LLEntity>(Module.ToString(), (int)STATE.Init, 50);
  181. fsm.EnableRepeatedMsg(true);
  182. EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_TM, fnEnterTMReady, FSM_MSG.NONE, fnExitTMReady);
  183. EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_EFEM, fnEnterEFEMReady, FSM_MSG.NONE, fnExitEFEMReady);
  184. //AnyStateTransition(FSM_MSG.TIMER, fnMonitor, FSM_STATE.SAME);
  185. AnyStateTransition(MSG.Error, fnError, STATE.Error);
  186. AnyStateTransition(MSG.Online, fnOnline, FSM_STATE.SAME);
  187. AnyStateTransition(MSG.Offline, fnOffline, FSM_STATE.SAME);
  188. AnyStateTransition(MSG.Home, fnHome, STATE.Initializing);
  189. // Home
  190. Transition(STATE.Initializing, FSM_MSG.TIMER, fnHoming, STATE.Idle);
  191. Transition(STATE.Idle, FSM_MSG.TIMER, fnMonitor, STATE.Idle);
  192. Transition(STATE.Init, FSM_MSG.TIMER, fnMonitor, STATE.Init);
  193. //vent sequence
  194. Transition(STATE.Idle, MSG.Vent, FnStartVent, STATE.Venting);
  195. Transition(STATE.Venting, FSM_MSG.TIMER, FnVentTimeout, STATE.Idle);
  196. Transition(STATE.Venting, MSG.Abort, FnAbortVent, STATE.Idle);
  197. Transition(STATE.Idle, MSG.AutoCooling, FnStartCooling, STATE.Cooling);
  198. Transition(STATE.Cooling, FSM_MSG.TIMER, FnCoolingTimeout, STATE.Idle);
  199. Transition(STATE.Cooling, MSG.Abort, FnAbortCooling, STATE.Idle);
  200. //Pump sequence
  201. Transition(STATE.Idle, MSG.Pump, FnStartPump, STATE.Pumping);
  202. Transition(STATE.Pumping, FSM_MSG.TIMER, FnPumpTimeout, STATE.Idle);
  203. Transition(STATE.Pumping, MSG.Abort, FnAbortPump, STATE.Idle);
  204. // Purge sequence
  205. Transition(STATE.Idle, MSG.Purge, FnStartPurge, STATE.Purging);
  206. Transition(STATE.Purging, FSM_MSG.TIMER, FnPurgeTimeout, STATE.Idle);
  207. Transition(STATE.Purging, MSG.Abort, FnAbortPurge, STATE.Idle);
  208. // Leak check sequence
  209. Transition(STATE.Idle, MSG.LeakCheck, FnStartLeakCheck, STATE.LeakCheck);
  210. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FnLeakCheckTimeout, STATE.Idle);
  211. Transition(STATE.LeakCheck, MSG.Abort, FnAbortLeakCheck, STATE.Idle);
  212. // Prepare TM Transfer
  213. Transition(STATE.Idle, MSG.Prepare_TM, FnStartPrepareTM, STATE.Prepare_For_TM);
  214. Transition(STATE.Prepare_For_TM, FSM_MSG.TIMER, FnPreparaTMTimeout, STATE.Ready_For_TM);
  215. Transition(STATE.Prepare_For_TM, MSG.Prepare_TM, null, STATE.Prepare_For_TM);
  216. Transition(STATE.Prepare_For_TM, MSG.Abort, FnAbortPreparaTM, STATE.Idle);
  217. Transition(STATE.Ready_For_TM, MSG.TM_Exchange_Ready, FnTMExchange, STATE.Idle);
  218. Transition(STATE.Ready_For_TM, MSG.Prepare_TM, null, STATE.Ready_For_TM);
  219. Transition(STATE.Ready_For_TM, MSG.Abort, null, STATE.Idle);
  220. Transition(STATE.Idle, MSG.AutoVent, FnTryAutoVent, STATE.Venting);
  221. Transition(STATE.Ready_For_TM, MSG.AutoVent, FnTryAutoVent, STATE.Venting);
  222. // Prepare EFEM Transfer
  223. Transition(STATE.Idle, MSG.Prepare_EFEM, FnStartPrepareEFEM, STATE.Prepare_For_EFEM);
  224. Transition(STATE.Prepare_For_EFEM, FSM_MSG.TIMER, FnPrepareEFEMTimeout, STATE.Ready_For_EFEM);
  225. Transition(STATE.Prepare_For_EFEM, MSG.Abort, FnAbortPrepareEFEM, STATE.Idle);
  226. Transition(STATE.Ready_For_EFEM, MSG.EFEM_Exchange_Ready, null, STATE.Idle);
  227. Transition(STATE.Ready_For_EFEM, MSG.Prepare_EFEM, null, STATE.Ready_For_EFEM);
  228. Transition(STATE.Ready_For_EFEM, MSG.Abort, null, STATE.Idle);
  229. Transition(STATE.Ready_For_EFEM, MSG.AutoPump, FnTryAutoPump, STATE.Pumping);
  230. Running = true;
  231. }
  232. public int Invoke(string function, params object[] args)
  233. {
  234. switch (function)
  235. {
  236. case "Home":
  237. case "Vent":
  238. case "Pump":
  239. case "AutoCooling":
  240. if (Enum.TryParse(function, out MSG message))
  241. {
  242. if (CheckToPostMessage((int)message))
  243. return (int)message;
  244. }
  245. break;
  246. }
  247. return (int)FSM_MSG.NONE;
  248. }
  249. public bool CheckAcked(int msg)
  250. {
  251. return fsm.CheckExecuted(msg);
  252. }
  253. public bool CheckToPostMessage(int msg, params object[] args)
  254. {
  255. if (!fsm.FindTransition(fsm.State, msg))
  256. {
  257. LOG.Write(eEvent.WARN_FSM_WARN, Module, $"{Module} is in {(STATE)fsm.State} state,can not do {(MSG)msg}");
  258. return false;
  259. }
  260. Running = true;
  261. fsm.PostMsg(msg, args);
  262. return true;
  263. }
  264. public (int processed, int unprocessed) GetWaferProcessStatus()
  265. {
  266. int processedCount = 0;
  267. int unprocessCount = 0;
  268. for (int i = 0; i < _slotNumber; i++)
  269. {
  270. var wafer = WaferManager.Instance.GetWafer(Module, i);
  271. if (!wafer.IsEmpty)
  272. {
  273. if (wafer.ProcessState == Aitex.Core.Common.EnumWaferProcessStatus.Completed)
  274. {
  275. processedCount++;
  276. }
  277. else
  278. {
  279. unprocessCount++;
  280. }
  281. }
  282. }
  283. return (processedCount, unprocessCount);
  284. }
  285. private bool fnEnterTMReady(object[] param)
  286. {
  287. if (RouteManager.IsATMMode)
  288. {
  289. Status = LLStatus.Ready_For_TM;
  290. return true;
  291. }
  292. StartControlPressure();
  293. Status = LLStatus.Ready_For_TM;
  294. return true;
  295. }
  296. private bool fnExitTMReady(object[] param)
  297. {
  298. if (RouteManager.IsATMMode)
  299. {
  300. Status = LLStatus.Not_Ready;
  301. return true;
  302. }
  303. StopControlPressure();
  304. Status = LLStatus.Not_Ready;
  305. return true;
  306. }
  307. private bool fnEnterEFEMReady(object[] param)
  308. {
  309. Status = LLStatus.Ready_For_EFEM;
  310. return true;
  311. }
  312. private bool fnExitEFEMReady(object[] param)
  313. {
  314. Status = LLStatus.Not_Ready;
  315. return true;
  316. }
  317. private bool fnMonitor(object[] param)
  318. {
  319. _debugRoutine();
  320. return true;
  321. }
  322. private bool fnError(object[] param)
  323. {
  324. IsOnline = false;
  325. return true;
  326. }
  327. private bool fnOnline(object[] param)
  328. {
  329. if (!IsInclude)
  330. {
  331. LOG.Write(eEvent.WARN_LL, Module, $"{Module} is excluded,can not be put online");
  332. return false;
  333. }
  334. IsOnline = true;
  335. return true;
  336. }
  337. private bool fnOffline(object[] param)
  338. {
  339. IsOnline = false;
  340. return true;
  341. }
  342. private bool FnSetInclude()
  343. {
  344. if (IsOnline == true)
  345. {
  346. LOG.Write(eEvent.WARN_LL, Module, $"{Module} is online,can not set Include");
  347. return false;
  348. }
  349. IsInclude = true;
  350. LOG.Write(eEvent.INFO_LL, Module, $"{Module} Set Include Success");
  351. return true;
  352. }
  353. private bool FnSetExclude()
  354. {
  355. if (IsOnline == true)
  356. {
  357. LOG.Write(eEvent.WARN_LL, Module, $"{Module} is online,can not set Exclude");
  358. return false;
  359. }
  360. IsInclude = false;
  361. LOG.Write(eEvent.INFO_LL, Module, $"{Module} Set Exclude Success");
  362. return true;
  363. }
  364. private bool fnAbort(object[] param)
  365. {
  366. return true;
  367. }
  368. private bool fnHome(object[] param)
  369. {
  370. //IsOnline = true;
  371. return true;
  372. }
  373. private bool fnHoming(object[] param)
  374. {
  375. return true;
  376. }
  377. private bool FnStartVent(object[] param)
  378. {
  379. return _ventingRoutine.Start(false) == RState.Running;
  380. }
  381. private bool FnTryAutoVent(object[] param)
  382. {
  383. if (RouteManager.IsATMMode)
  384. {
  385. PostMsg(MSG.TM_Exchange_Ready, false);
  386. return false;
  387. }
  388. _coolingMFCFlow = SC.GetValue<double>($"{Module.ToString()}.Cooling.MFCFlow");
  389. _coolingTime = SC.GetValue<int>($"{Module.ToString()}.Cooling.CoolingTime");
  390. return _ventingRoutine.Start(false) == RState.Running;
  391. }
  392. private bool FnVentTimeout(object[] param)
  393. {
  394. RState ret = _ventingRoutine.Monitor();
  395. if (ret == RState.Failed || ret == RState.Timeout)
  396. {
  397. PostMsg(MSG.Error);
  398. return false;
  399. }
  400. if(ret == RState.End)
  401. {
  402. MarkStateTime();
  403. return true;
  404. }
  405. return false;
  406. }
  407. private bool FnAbortVent(object[] param)
  408. {
  409. _ventingRoutine.Abort();
  410. return true;
  411. }
  412. private bool FnStartPump(object[] param)
  413. {
  414. return _pumpingRoutine.Start() == RState.Running;
  415. }
  416. private bool FnPumpTimeout(object[] param)
  417. {
  418. RState ret = _pumpingRoutine.Monitor();
  419. if (ret == RState.Failed || ret == RState.Timeout)
  420. {
  421. PostMsg(MSG.Error);
  422. return false;
  423. }
  424. if (ret == RState.End)
  425. {
  426. MarkStateTime();
  427. return true;
  428. }
  429. return false;
  430. }
  431. private bool FnAbortPump(object[] param)
  432. {
  433. _pumpingRoutine.Abort();
  434. return true;
  435. }
  436. private bool FnTryAutoPump(object[] param)
  437. {
  438. if (_JetTM.LLPumpStatus != JetTM.LLPumpState.Idle || RouteManager.IsATMMode)
  439. {
  440. PostMsg(MSG.EFEM_Exchange_Ready);
  441. return false;
  442. }
  443. return _pumpingRoutine.Start() == RState.Running;
  444. }
  445. private bool FnStartPurge(object[] param)
  446. {
  447. return _purgeRoutine.Start() == RState.Running;
  448. }
  449. private bool FnPurgeTimeout(object[] param)
  450. {
  451. RState ret = _purgeRoutine.Monitor();
  452. if (ret == RState.Failed || ret == RState.Timeout)
  453. {
  454. PostMsg(MSG.Error);
  455. return false;
  456. }
  457. return ret == RState.End;
  458. }
  459. private bool FnAbortPurge(object[] param)
  460. {
  461. _purgeRoutine.Abort();
  462. return true;
  463. }
  464. private bool FnStartLeakCheck(object[] param)
  465. {
  466. return _leakCheckRoutine.Start() == RState.Running;
  467. }
  468. private bool FnLeakCheckTimeout(object[] param)
  469. {
  470. RState ret = _leakCheckRoutine.Monitor();
  471. if (ret == RState.Failed || ret == RState.Timeout)
  472. {
  473. PostMsg(MSG.Error);
  474. return false;
  475. }
  476. return ret == RState.End;
  477. }
  478. private bool FnAbortLeakCheck(object[] param)
  479. {
  480. _leakCheckRoutine.Abort();
  481. return true;
  482. }
  483. private bool FnStartPrepareTM(object[] param)
  484. {
  485. if (RouteManager.IsATMMode)
  486. return true;
  487. return _pumpingRoutine.Start() == RState.Running;
  488. }
  489. private bool FnPreparaTMTimeout(object[] param)
  490. {
  491. if (RouteManager.IsATMMode)
  492. {
  493. if (fsm.ElapsedTime > 10000)
  494. {
  495. LOG.Write(eEvent.ERR_TM, Module, $"Cannot transfer wafer as {Module} is not ATM.");
  496. PostMsg(MSG.Error);
  497. return true;
  498. }
  499. return _JetTM.IsModuleATM(Module);
  500. }
  501. RState ret = _pumpingRoutine.Monitor();
  502. if (ret == RState.Failed || ret == RState.Timeout)
  503. {
  504. PostMsg(MSG.Error);
  505. return false;
  506. }
  507. return ret == RState.End;
  508. }
  509. private bool FnAbortPreparaTM(object[] param)
  510. {
  511. _pumpingRoutine.Abort();
  512. return true;
  513. }
  514. private bool FnStartPrepareEFEM(object[] param)
  515. {
  516. if (RouteManager.IsATMMode)
  517. return true;
  518. return _ventingRoutine.Start(false) == RState.Running;
  519. }
  520. private bool FnPrepareEFEMTimeout(object[] param)
  521. {
  522. if (RouteManager.IsATMMode)
  523. {
  524. if (fsm.ElapsedTime > 10000)
  525. {
  526. LOG.Write(eEvent.ERR_TM, Module, $"Cannot transfer wafer as {Module} is not ATM.");
  527. PostMsg(MSG.Error);
  528. return true;
  529. }
  530. return _JetTM.IsModuleATM(Module);
  531. }
  532. RState ret = _ventingRoutine.Monitor();
  533. if (ret == RState.Failed || ret == RState.Timeout)
  534. {
  535. PostMsg(MSG.Error);
  536. return false;
  537. }
  538. return ret == RState.End;
  539. //if (ret == RState.End && _coolingFlag)
  540. //{
  541. // //if (_coolingStatus.Any(x => x == CoolingStatu.WaitCooling) && Singleton<RouteManager>.Instance.IsAutoRunning)
  542. // //{
  543. // // PostMsg(MSG.AutoCooling);
  544. // //}
  545. // return true;
  546. //}
  547. //else if (_coolingFlag == false)
  548. //{
  549. // return true;
  550. //}
  551. //else
  552. //{
  553. // return false;
  554. //}
  555. }
  556. private bool FnAbortPrepareEFEM(object[] param)
  557. {
  558. _ventingRoutine.Abort();
  559. return true;
  560. }
  561. private bool StartControlPressure()
  562. {
  563. _isEnableControlPressure = true;
  564. _controlPressureCheckPoint = SC.GetValue<int>($"{Module}.ControlPressureCheckPoint");
  565. _controlPressureSetPoint = SC.GetValue<int>($"{Module}.ControlPressureSetPoint");
  566. _controlFlowSetPoint = SC.GetValue<int>($"{Module}.{Module}_MFC1.DefaultSetPoint");
  567. _JetTM.TurnFastPumpValve(Module, true);
  568. //_JetTM.TurnSoftPumpValve(Module, true);
  569. _JetTM.TurnPurgeValve(Module, true);
  570. _JetTM.TurnN2Valve(true);
  571. if (Module == ModuleName.LLA)
  572. {
  573. _JetTM.SwitchLLAPressureMode(true);
  574. _JetTM.SetLLAPressure((int)_controlPressureSetPoint);
  575. }
  576. else if (Module == ModuleName.LLB)
  577. {
  578. _JetTM.SwitchLLBPressureMode(true);
  579. _JetTM.SetLLBPressure((int)_controlPressureSetPoint);
  580. }
  581. return true;
  582. }
  583. private bool StopControlPressure()
  584. {
  585. _isEnableControlPressure = false;
  586. _JetTM.TurnFastPumpValve(Module, false);
  587. _JetTM.TurnSoftPumpValve(Module, false);
  588. _JetTM.TurnPurgeValve(Module, false);
  589. if (Module == ModuleName.LLA)
  590. {
  591. _JetTM.SwitchLLAPressureMode(false);
  592. _JetTM.SetLLAPressure(0);
  593. }
  594. else if (Module == ModuleName.LLB)
  595. {
  596. _JetTM.SwitchLLBPressureMode(false);
  597. _JetTM.SetLLBPressure(0);
  598. }
  599. return true;
  600. }
  601. private bool FnStartCooling(object[] param)
  602. {
  603. _coolingStopWatch.Restart();
  604. _coolingTime = SC.GetValue<int>($"{Module}.Cooling.CoolingTime") * 1000;
  605. return _ventingRoutine.Start(true) == RState.Running;
  606. }
  607. private bool FnCoolingTimeout(object[] param)
  608. {
  609. RState ret = _ventingRoutine.Monitor();
  610. if (ret == RState.Failed || ret == RState.Timeout)
  611. {
  612. PostMsg(MSG.Error);
  613. return false;
  614. }
  615. if(_coolingStopWatch.ElapsedMilliseconds > _coolingTime && _JetTM.IsModuleATM(Module))
  616. {
  617. MarkStateTime();
  618. _ventingRoutine.Abort();
  619. return true;
  620. }
  621. return ret == RState.End;
  622. }
  623. private bool FnAbortCooling(object[] param)
  624. {
  625. _ventingRoutine.Abort();
  626. return true;
  627. }
  628. private bool FnTMExchange(object[] param)
  629. {
  630. return true;
  631. }
  632. //private bool FnEFEMExchange(object[] param)
  633. //{
  634. // int slot = (int)param[0];
  635. // _coolingStatus[slot] = CoolingStatu.Init;
  636. // return true;
  637. //}
  638. private void _debugRoutine()
  639. {
  640. int flag = 0;
  641. // Test Home routine
  642. if (flag == 1)
  643. {
  644. PostMsg(MSG.Home);
  645. }
  646. else if (flag == 2)
  647. {
  648. PostMsg(MSG.Vent);
  649. }
  650. else if (flag == 3)
  651. {
  652. PostMsg(MSG.Pump);
  653. }
  654. //else if (flag == 4)
  655. //{
  656. // PostMsg(MSG.PumpLoadLock);
  657. //}
  658. //else if (flag == 5)
  659. //{
  660. // PostMsg(MSG.VentLoadLock);
  661. //}
  662. //else if (flag == 6)
  663. //{
  664. // PostMsg(MSG.PurgeLoadLock);
  665. //}
  666. //else if (flag == 7)
  667. //{
  668. // PostMsg(MSG.LaunchPump);
  669. //}
  670. //else if (flag == 8)
  671. //{
  672. // PostMsg(MSG.LaunchTurboPump);
  673. //}
  674. //else if (flag == 9)
  675. //{
  676. // PostMsg(MSG.LoadLockLeakCheck);
  677. //}
  678. else if (flag == 10)
  679. {
  680. PostMsg(MSG.CyclePurge);
  681. }
  682. //else if (flag == 11)
  683. //{
  684. // PostMsg(MSG.GasLinePurge);
  685. //}
  686. //else if (flag == 12)
  687. //{
  688. // PostMsg(MSG.LeakCheck);
  689. //}
  690. //else if (flag == 13)
  691. //{
  692. // PostMsg(MSG.GasLeakCheck);
  693. //}
  694. //else if (flag == 14)
  695. //{
  696. // PostMsg(MSG.LLPlace);
  697. //}
  698. //else if (flag == 15)
  699. //{
  700. // PostMsg(MSG.LLPick);
  701. //}
  702. //else if (flag == 16)
  703. //{
  704. // PostMsg(MSG.RunRecipe, "7777");
  705. //}
  706. //else if (flag == 17)
  707. //{
  708. // PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  709. //}
  710. }
  711. }
  712. }