LLEntity.cs 27 KB

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