LLEntity.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  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;
  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 int _slotNumber = 4;
  117. private bool startControlPressureFlag = true;
  118. private int _controlPressureCheckPoint = 100;
  119. private int _controlPressureSetPoint = 90;
  120. private int _controlFlowSetPoint = 90;
  121. private bool _isEnableControlPressure;
  122. private Stopwatch _coolingStopWatch=new Stopwatch();
  123. private double _coolingMFCFlow;
  124. private int _coolingTime;
  125. CoolingStatu[] _coolingStatus;
  126. private bool _coolingFlag = false;
  127. public LLEntity(ModuleName module)
  128. {
  129. Module = module;
  130. _JetTM = DEVICE.GetDevice<JetTM>("TM");
  131. _pumpingRoutine = new MFPumpRoutine(_JetTM, Module);
  132. _ventingRoutine = new MFVentRoutine(_JetTM, Module);
  133. _leakCheckRoutine = new MFLeakCheckRoutine(_JetTM, Module);
  134. _purgeRoutine = new MFPurgeRoutine(_JetTM, Module);
  135. _slotNumber = SC.GetValue<int>($"{module.ToString()}.SlotNumber");
  136. WaferManager.Instance.SubscribeLocation(Module, _slotNumber);
  137. InitFsmMap();
  138. _coolingStatus=new CoolingStatu[_slotNumber];
  139. for (int i = 0; i < _slotNumber; i++)
  140. {
  141. _coolingStatus[i] = CoolingStatu.Init;
  142. }
  143. GetCoolingInfo();
  144. }
  145. private void GetCoolingInfo()
  146. {
  147. if (RtInstance.ConfigType == ConfigType.Kepler2200)
  148. {
  149. _coolingMFCFlow = SC.GetValue<double>($"{Module.ToString()}.Cooling.MFCFlow");
  150. _coolingTime = SC.GetValue<int>($"{Module.ToString()}.Cooling.CoolingTime");
  151. }
  152. }
  153. protected override bool Init()
  154. {
  155. OP.Subscribe($"{Module}.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  156. OP.Subscribe($"{Module}.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  157. OP.Subscribe($"{Module}.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  158. OP.Subscribe($"{Module}.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.Purge));
  159. OP.Subscribe($"{Module}.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  160. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck));
  161. OP.Subscribe($"{Module}.{RtOperation.Online}", (cmd, args) => CheckToPostMessage((int)MSG.Online));
  162. OP.Subscribe($"{Module}.{RtOperation.Offline}", (cmd, args) => CheckToPostMessage((int)MSG.Offline));
  163. OP.Subscribe($"{Module}.{RtOperation.Include}", (cmd, args) => FnSetInclude());
  164. OP.Subscribe($"{Module}.{RtOperation.Exclude}", (cmd, args) => FnSetExclude());
  165. OP.Subscribe($"{Module}.{RtOperation.ControlPressure}", (cmd, args) => StartControlPressure());
  166. OP.Subscribe($"{Module}.{RtOperation.AbortControlPressure}", (cmd, args) => StopControlPressure());
  167. DATA.Subscribe($"{Module}.FsmState", () => (((STATE)fsm.State).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  168. DATA.Subscribe($"{Module}.FsmPrevState", () => (((PMState)fsm.PrevState).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  169. DATA.Subscribe($"{Module}.FsmLastMessage", () => (((MSG)fsm.LastMsg).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  170. DATA.Subscribe($"{Module}.IsOnline", () => IsOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  171. DATA.Subscribe($"{Module}.IsInclude", () => IsInclude, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  172. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  173. DATA.Subscribe($"{Module}.IsEnableControlPressure", () => _isEnableControlPressure, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  174. return true;
  175. }
  176. private void InitFsmMap()
  177. {
  178. fsm = new StateMachine<LLEntity>(Module.ToString(), (int)STATE.Init, 50);
  179. fsm.EnableRepeatedMsg(true);
  180. EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_TM, fnEnterTMReady, FSM_MSG.NONE, fnExitTMReady);
  181. EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_EFEM, fnEnterEFEMReady, FSM_MSG.NONE, fnExitEFEMReady);
  182. //AnyStateTransition(FSM_MSG.TIMER, fnMonitor, FSM_STATE.SAME);
  183. AnyStateTransition(MSG.Error, fnError, STATE.Error);
  184. AnyStateTransition(MSG.Online, fnOnline, FSM_STATE.SAME);
  185. AnyStateTransition(MSG.Offline, fnOffline, FSM_STATE.SAME);
  186. AnyStateTransition(MSG.Home, fnHome, STATE.Initializing);
  187. // Home
  188. Transition(STATE.Initializing, FSM_MSG.TIMER, fnHoming, STATE.Idle);
  189. Transition(STATE.Idle, FSM_MSG.TIMER, fnMonitor, STATE.Idle);
  190. Transition(STATE.Init, FSM_MSG.TIMER, fnMonitor, STATE.Init);
  191. //vent sequence
  192. Transition(STATE.Idle, MSG.Vent, FnStartVent, STATE.Venting);
  193. Transition(STATE.Venting, FSM_MSG.TIMER, FnVentTimeout, STATE.Idle);
  194. Transition(STATE.Venting, MSG.Abort, FnAbortVent, STATE.Idle);
  195. //Pump sequence
  196. Transition(STATE.Idle, MSG.Pump, FnStartPump, STATE.Pumping);
  197. Transition(STATE.Pumping, FSM_MSG.TIMER, FnPumpTimeout, STATE.Idle);
  198. Transition(STATE.Pumping, MSG.Abort, FnAbortPump, STATE.Idle);
  199. // Purge sequence
  200. Transition(STATE.Idle, MSG.Purge, FnStartPurge, STATE.Purging);
  201. Transition(STATE.Purging, FSM_MSG.TIMER, FnPurgeTimeout, STATE.Idle);
  202. Transition(STATE.Purging, MSG.Abort, FnAbortPurge, STATE.Idle);
  203. // Leak check sequence
  204. Transition(STATE.Idle, MSG.LeakCheck, FnStartLeakCheck, STATE.LeakCheck);
  205. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FnLeakCheckTimeout, STATE.Idle);
  206. Transition(STATE.LeakCheck, MSG.Abort, FnAbortLeakCheck, STATE.Idle);
  207. // Prepare TM Transfer
  208. Transition(STATE.Idle, MSG.Prepare_TM, FnStartPrepareTM, STATE.Prepare_For_TM);
  209. Transition(STATE.Prepare_For_TM, FSM_MSG.TIMER, FnPreparaTMTimeout, STATE.Ready_For_TM);
  210. Transition(STATE.Prepare_For_TM, MSG.Prepare_TM, null, STATE.Prepare_For_TM);
  211. Transition(STATE.Prepare_For_TM, MSG.Abort, FnAbortPreparaTM, STATE.Idle);
  212. Transition(STATE.Ready_For_TM, MSG.TM_Exchange_Ready, FnTMExchange, STATE.Idle);
  213. Transition(STATE.Ready_For_TM, MSG.Prepare_TM, null, STATE.Ready_For_TM);
  214. Transition(STATE.Ready_For_TM, MSG.Abort, null, STATE.Idle);
  215. Transition(STATE.Idle, MSG.AutoVent, FnTryAutoVent, STATE.Venting);
  216. Transition(STATE.Ready_For_TM, MSG.AutoVent, FnTryAutoVent, STATE.Venting);
  217. // Prepare EFEM Transfer
  218. Transition(STATE.Idle, MSG.Prepare_EFEM, FnStartPrepareEFEM, STATE.Prepare_For_EFEM);
  219. Transition(STATE.Prepare_For_EFEM, FSM_MSG.TIMER, FnPrepareEFEMTimeout, STATE.Ready_For_EFEM);
  220. Transition(STATE.Prepare_For_EFEM, MSG.Abort, FnAbortPrepareEFEM, STATE.Idle);
  221. Transition(STATE.Ready_For_EFEM, MSG.EFEM_Exchange_Ready, null, STATE.Idle);
  222. Transition(STATE.Ready_For_EFEM, MSG.Prepare_EFEM, null, STATE.Ready_For_EFEM);
  223. Transition(STATE.Ready_For_EFEM, MSG.Abort, null, STATE.Idle);
  224. Transition(STATE.Ready_For_EFEM, MSG.AutoPump, FnTryAutoPump, STATE.Pumping);
  225. //Transition(STATE.Ready_For_EFEM, MSG.Transfer_EFEM_SlotInfo, FnEFEMExchange, STATE.Ready_For_EFEM);
  226. //Cooling
  227. //AnyStateTransition(FSM_MSG.TIMER, LLCoolingTimer_Elapsed, FSM_STATE.SAME);
  228. Transition(STATE.Venting, MSG.AutoCooling, FnStartCooling, STATE.Cooling);
  229. //Transition(STATE.Ready_For_EFEM, MSG.AutoCooling, FnStartCooling, STATE.Ready_For_EFEM);
  230. Transition(STATE.Cooling, FSM_MSG.TIMER, FnCoolingTimeout, STATE.Idle);
  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. 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() == 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. return _ventingRoutine.Start() == RState.Running;
  389. }
  390. private bool FnVentTimeout(object[] param)
  391. {
  392. RState ret = _ventingRoutine.Monitor();
  393. if (ret == RState.Failed || ret == RState.Timeout)
  394. {
  395. PostMsg(MSG.Error);
  396. return false;
  397. }
  398. if (IsATM && _coolingFlag && Singleton<RouteManager>.Instance.IsAutoRunning && _coolingTime>0)
  399. {
  400. PostMsg(MSG.AutoCooling);
  401. }
  402. if(ret == RState.End)
  403. {
  404. MarkStateTime();
  405. return true;
  406. }
  407. return false;
  408. }
  409. private bool FnAbortVent(object[] param)
  410. {
  411. _ventingRoutine.Abort();
  412. return true;
  413. }
  414. private bool FnStartPump(object[] param)
  415. {
  416. return _pumpingRoutine.Start() == RState.Running;
  417. }
  418. private bool FnPumpTimeout(object[] param)
  419. {
  420. RState ret = _pumpingRoutine.Monitor();
  421. if (ret == RState.Failed || ret == RState.Timeout)
  422. {
  423. PostMsg(MSG.Error);
  424. return false;
  425. }
  426. if (ret == RState.End)
  427. {
  428. MarkStateTime();
  429. return true;
  430. }
  431. return false;
  432. }
  433. private bool FnAbortPump(object[] param)
  434. {
  435. _pumpingRoutine.Abort();
  436. return true;
  437. }
  438. private bool FnTryAutoPump(object[] param)
  439. {
  440. if (_JetTM.LLPumpStatus != JetTM.LLPumpState.Idle || RouteManager.IsATMMode)
  441. {
  442. PostMsg(MSG.EFEM_Exchange_Ready);
  443. return false;
  444. }
  445. return _pumpingRoutine.Start() == RState.Running;
  446. }
  447. private bool FnStartPurge(object[] param)
  448. {
  449. return _purgeRoutine.Start() == RState.Running;
  450. }
  451. private bool FnPurgeTimeout(object[] param)
  452. {
  453. RState ret = _purgeRoutine.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 FnAbortPurge(object[] param)
  462. {
  463. _purgeRoutine.Abort();
  464. return true;
  465. }
  466. private bool FnStartLeakCheck(object[] param)
  467. {
  468. return _leakCheckRoutine.Start() == RState.Running;
  469. }
  470. private bool FnLeakCheckTimeout(object[] param)
  471. {
  472. RState ret = _leakCheckRoutine.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 FnAbortLeakCheck(object[] param)
  481. {
  482. _leakCheckRoutine.Abort();
  483. return true;
  484. }
  485. private bool FnStartPrepareTM(object[] param)
  486. {
  487. if (RouteManager.IsATMMode)
  488. return true;
  489. return _pumpingRoutine.Start() == RState.Running;
  490. }
  491. private bool FnPreparaTMTimeout(object[] param)
  492. {
  493. if (RouteManager.IsATMMode)
  494. {
  495. if (fsm.ElapsedTime > 10000)
  496. {
  497. LOG.Write(eEvent.ERR_TM, Module, $"Cannot transfer wafer as {Module} is not ATM.");
  498. PostMsg(MSG.Error);
  499. return true;
  500. }
  501. return _JetTM.IsModuleATM(Module);
  502. }
  503. RState ret = _pumpingRoutine.Monitor();
  504. if (ret == RState.Failed || ret == RState.Timeout)
  505. {
  506. PostMsg(MSG.Error);
  507. return false;
  508. }
  509. return ret == RState.End;
  510. }
  511. private bool FnAbortPreparaTM(object[] param)
  512. {
  513. _pumpingRoutine.Abort();
  514. return true;
  515. }
  516. private bool FnStartPrepareEFEM(object[] param)
  517. {
  518. if (RouteManager.IsATMMode)
  519. return true;
  520. return _ventingRoutine.Start() == RState.Running;
  521. }
  522. private bool FnPrepareEFEMTimeout(object[] param)
  523. {
  524. if (RouteManager.IsATMMode)
  525. {
  526. if (fsm.ElapsedTime > 10000)
  527. {
  528. LOG.Write(eEvent.ERR_TM, Module, $"Cannot transfer wafer as {Module} is not ATM.");
  529. PostMsg(MSG.Error);
  530. return true;
  531. }
  532. return _JetTM.IsModuleATM(Module);
  533. }
  534. RState ret = _ventingRoutine.Monitor();
  535. if (ret == RState.Failed || ret == RState.Timeout)
  536. {
  537. PostMsg(MSG.Error);
  538. return false;
  539. }
  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. //_JetTM.TurnN2Valve(false);
  591. if (Module == ModuleName.LLA)
  592. {
  593. _JetTM.SwitchLLAPressureMode(false);
  594. _JetTM.SetLLAPressure(0);
  595. }
  596. else if (Module == ModuleName.LLB)
  597. {
  598. _JetTM.SwitchLLBPressureMode(false);
  599. _JetTM.SetLLBPressure(0);
  600. }
  601. return true;
  602. }
  603. private bool FnStartCooling(object[] param)
  604. {
  605. _coolingMFCFlow = SC.GetValue<double>($"{Module.ToString()}.Cooling.MFCFlow");
  606. _coolingTime = SC.GetValue<int>($"{Module.ToString()}.Cooling.CoolingTime");
  607. _JetTM.TurnPurgeValve(Module, true);
  608. if (Module == ModuleName.LLA)
  609. {
  610. _JetTM.SetLLAFlow((int)_coolingMFCFlow);
  611. }
  612. else if (Module == ModuleName.LLB)
  613. {
  614. _JetTM.SetLLBFlow((int)_coolingMFCFlow);
  615. }
  616. _coolingStopWatch.Restart();
  617. return true;
  618. }
  619. private bool FnStopCooling()
  620. {
  621. _JetTM.TurnPurgeValve(Module, false);
  622. if (Module == ModuleName.LLA)
  623. {
  624. _JetTM.SetLLAFlow(0);
  625. }
  626. else if (Module == ModuleName.LLB)
  627. {
  628. _JetTM.SetLLBFlow(0);
  629. }
  630. return true;
  631. }
  632. private bool FnCoolingTimeout(object[] param)
  633. {
  634. if (_coolingStopWatch.ElapsedMilliseconds > _coolingTime *1000 )
  635. {
  636. _coolingFlag = false;
  637. FnStopCooling();
  638. return true;
  639. }
  640. else
  641. {
  642. return false;
  643. }
  644. }
  645. private bool FnTMExchange(object[] param)
  646. {
  647. var needcooling = (bool)param[0];
  648. _coolingFlag=needcooling;
  649. if (needcooling)
  650. {
  651. PostMsg(MSG.AutoVent);
  652. }
  653. return true;
  654. }
  655. //private bool FnEFEMExchange(object[] param)
  656. //{
  657. // int slot = (int)param[0];
  658. // _coolingStatus[slot] = CoolingStatu.Init;
  659. // return true;
  660. //}
  661. private void _debugRoutine()
  662. {
  663. int flag = 0;
  664. // Test Home routine
  665. if (flag == 1)
  666. {
  667. PostMsg(MSG.Home);
  668. }
  669. else if (flag == 2)
  670. {
  671. PostMsg(MSG.Vent);
  672. }
  673. else if (flag == 3)
  674. {
  675. PostMsg(MSG.Pump);
  676. }
  677. //else if (flag == 4)
  678. //{
  679. // PostMsg(MSG.PumpLoadLock);
  680. //}
  681. //else if (flag == 5)
  682. //{
  683. // PostMsg(MSG.VentLoadLock);
  684. //}
  685. //else if (flag == 6)
  686. //{
  687. // PostMsg(MSG.PurgeLoadLock);
  688. //}
  689. //else if (flag == 7)
  690. //{
  691. // PostMsg(MSG.LaunchPump);
  692. //}
  693. //else if (flag == 8)
  694. //{
  695. // PostMsg(MSG.LaunchTurboPump);
  696. //}
  697. //else if (flag == 9)
  698. //{
  699. // PostMsg(MSG.LoadLockLeakCheck);
  700. //}
  701. else if (flag == 10)
  702. {
  703. PostMsg(MSG.CyclePurge);
  704. }
  705. //else if (flag == 11)
  706. //{
  707. // PostMsg(MSG.GasLinePurge);
  708. //}
  709. //else if (flag == 12)
  710. //{
  711. // PostMsg(MSG.LeakCheck);
  712. //}
  713. //else if (flag == 13)
  714. //{
  715. // PostMsg(MSG.GasLeakCheck);
  716. //}
  717. //else if (flag == 14)
  718. //{
  719. // PostMsg(MSG.LLPlace);
  720. //}
  721. //else if (flag == 15)
  722. //{
  723. // PostMsg(MSG.LLPick);
  724. //}
  725. //else if (flag == 16)
  726. //{
  727. // PostMsg(MSG.RunRecipe, "7777");
  728. //}
  729. //else if (flag == 17)
  730. //{
  731. // PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  732. //}
  733. }
  734. }
  735. }