PMEntity.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using Aitex.Core.Common;
  7. using Aitex.Core.RT.DataCenter;
  8. using Aitex.Core.RT.Device;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.Fsm;
  11. using Aitex.Core.RT.OperationCenter;
  12. using Aitex.Core.RT.Routine;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.Util;
  15. using Aitex.Sorter.Common;
  16. using MECF.Framework.Common.DataCenter;
  17. using MECF.Framework.Common.Equipment;
  18. using MECF.Framework.Common.Schedulers;
  19. using MECF.Framework.Common.SubstrateTrackings;
  20. using Venus_Core;
  21. using Venus_RT.Devices;
  22. using Venus_RT.Modules;
  23. using Venus_RT.Modules.PMs;
  24. using MECF.Framework.Common.Routine;
  25. using Aitex.Core.RT.Log;
  26. namespace Venus_RT.Modules.PMs
  27. {
  28. public class RecipeRunningInfo
  29. {
  30. public Guid InnerId { get; set; }
  31. public RecipeHead Head { get; set; }
  32. public List<RecipeStep> RecipeStepList { get; set; }
  33. public string RecipeName { get; set; }
  34. public DateTime BeginTime { get; set; }
  35. public DateTime EndTime { get; set; }
  36. public int StepNumber { get; set; }
  37. public string StepName { get; set; }
  38. public double StepTime { get; set; }
  39. public double StepElapseTime { get; set; }
  40. public double TotalTime { get; set; }
  41. public double TotalElapseTime { get; set; }
  42. }
  43. public class PMEntity : Entity, IModuleEntity
  44. {
  45. public enum MSG
  46. {
  47. Home,
  48. Transfer,
  49. PrepareTransfer,
  50. PostTransfer,
  51. Reset,
  52. Abort,
  53. Error,
  54. LaunchPump,
  55. LaunchTurboPump,
  56. Pump,
  57. Vent,
  58. PumpLoadLock,
  59. VentLoadLock,
  60. PurgeLoadLock,
  61. LoadLockLeakCheck,
  62. CyclePurge,
  63. GasLinePurge,
  64. Heat,
  65. TransferHandoff,
  66. StartTransfer,
  67. LeakCheck,
  68. GasLeakCheck,
  69. MoveLiftPin,
  70. MoveGuidePin,
  71. LLPlace,
  72. LLPick,
  73. Process,
  74. RunRecipe,
  75. PostProcess,
  76. RecipeSkipStep,
  77. RecipeUpdate,
  78. RecipeResume,
  79. RecipePause,
  80. RecipeAbort,
  81. PreProcess,
  82. AutoMode,
  83. ManualMode,
  84. LockLid,
  85. Clean,
  86. Online,
  87. Offline,
  88. GasFlow,
  89. StopGasFlow,
  90. RfPower,
  91. MFCVerification,
  92. MaxMsg
  93. }
  94. private readonly JetPM _chamber;
  95. public ModuleName Module { get; }
  96. public Action<bool, bool> TransferPrepared;
  97. private readonly PMHomeRoutine _home;
  98. private readonly StartDryPumpRoutine _startDryPumpRoutine;
  99. private readonly StartTurboPumpRoutine _startTurboPumpRoutine;
  100. private readonly VentRoutine _ventRoutine;
  101. private readonly PumpDownRoutine _pumpRoutine;
  102. private readonly LoadLockVentRoutine _ventLoadLockRoutine;
  103. private readonly LoadLockPumpRoutine _pumpLoadLockRoutine;
  104. private readonly LoadLockPurgeRoutine _purgeLoadLockRoutine;
  105. private readonly LoadLockLeakCheckRoutine _loadLockLeakCheckRoutine;
  106. private readonly PMPurgeRoutine _purgeRoutine;
  107. private readonly PMGaslinePurgeRoutine _gaslinePurgeRoutine;
  108. private readonly PMLeakCheckRoutine _leakCheckRoutine;
  109. private readonly GasBoxLeakCheckRoutine _gasBoxLeakCheckRoutine;
  110. private readonly LLPlaceRoutine _llPlaceRoutine;
  111. private readonly LLPickRoutine _llPickRoutine;
  112. private readonly PMProcessRoutine _processRoutine;
  113. private readonly GasFlowRoutine _gasFlowRoutine;
  114. private readonly RFPowerSwitchRoutine _rfPowerRoutine;
  115. private readonly PMGasVerificationRoutine _gasVerificationRoutine;
  116. private AutoFlag _AutoMode;
  117. private bool _isOnline = false;
  118. //private bool _isAlarm;
  119. //private DateTime _pumpStartTime;
  120. //private TimeSpan _pumpElapsedTime;
  121. //private DateTime _rfStartTime;
  122. //private DateTime _tcStartTime;
  123. //private TimeSpan _rfElapsedTime;
  124. //private TimeSpan _tcElapsedTime;
  125. //private MovementPosition _goalLiftPin;
  126. //private ushort _ActivatedActionID;
  127. //private Stopwatch _LifpinSleepTimer;
  128. public bool IsIdle
  129. {
  130. get { return fsm.State == (int)PMState.Idle; }
  131. }
  132. public bool IsError
  133. {
  134. get { return fsm.State == (int)PMState.Error; }
  135. }
  136. public bool IsInit
  137. {
  138. get { return fsm.State == (int)PMState.Init; }
  139. }
  140. public bool IsBusy
  141. {
  142. get { return !IsInit && !IsError && !IsIdle; }
  143. }
  144. public bool IsProcessing
  145. {
  146. get { return fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess; }
  147. }
  148. public bool IsOnline
  149. {
  150. get { return _isOnline; }
  151. }
  152. public bool IsAutoMode => _AutoMode == AutoFlag.Auto;
  153. public bool Check(int msg, out string reason, object[] objs)
  154. {
  155. reason = "";
  156. return true;
  157. }
  158. //
  159. private bool CheckToPostMessage(int msg, params object[] args)
  160. {
  161. if (!fsm.FindTransition(fsm.State, msg))
  162. {
  163. EV.PostWarningLog(Module.ToString(), eEvent.WARN_State, $"{Module} is in { (PMState)fsm.State} state,can not do {(MSG)msg}");
  164. return false;
  165. }
  166. fsm.PostMsg(msg, args);
  167. return true;
  168. }
  169. public int Invoke(string function, params object[] args)
  170. {
  171. switch (function)
  172. {
  173. case "Home":
  174. CheckToPostMessage((int)MSG.Home);
  175. return (int)MSG.Home;
  176. }
  177. return (int)FSM_MSG.NONE;
  178. }
  179. public bool CheckAcked(int msg)
  180. {
  181. return fsm.CheckExecuted(msg);
  182. }
  183. public bool IsPrepareTransferReady(ModuleName robot, EnumTransferType type, int slot, Hand blade)
  184. {
  185. //if (type == EnumTransferType.Pick)
  186. //{
  187. // return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(_chamber.Module, 0).Size);
  188. //}
  189. //else if (type == EnumTransferType.Place)
  190. //{
  191. // return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(robot, (int)blade).Size);
  192. //}
  193. return false;
  194. }
  195. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  196. {
  197. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString()))
  198. return (int)MSG.PrepareTransfer;
  199. return (int)FSM_MSG.NONE;
  200. }
  201. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp)
  202. {
  203. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp))
  204. return (int)MSG.PrepareTransfer;
  205. return (int)FSM_MSG.NONE;
  206. }
  207. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp, WaferSize size)
  208. {
  209. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp, size))
  210. return (int)MSG.PrepareTransfer;
  211. return (int)FSM_MSG.NONE;
  212. }
  213. public int InvokePostTransfer(ModuleName robot, EnumTransferType type, int slot)
  214. {
  215. if (CheckToPostMessage((int)MSG.PostTransfer, type.ToString()))
  216. return (int)MSG.PostTransfer;
  217. return (int)FSM_MSG.NONE;
  218. }
  219. public int InvokeClean(string recipeName, string waferID, bool withWafer)
  220. {
  221. if (CheckToPostMessage((int)MSG.Clean, recipeName, waferID, withWafer))
  222. {
  223. return (int)MSG.Clean;
  224. }
  225. return (int)FSM_MSG.NONE;
  226. }
  227. public int InvokeProcess(string recipeName, string waferID, bool withWafer)
  228. {
  229. if (CheckToPostMessage((int)MSG.RunRecipe, recipeName, waferID, withWafer))
  230. return (int)MSG.RunRecipe;
  231. return (int)FSM_MSG.NONE;
  232. }
  233. public int InvokePreHeat(float temperature)
  234. {
  235. if (CheckToPostMessage((int)MSG.Heat, (double)temperature))
  236. return (int)MSG.Heat;
  237. return (int)FSM_MSG.NONE;
  238. }
  239. public void InvokeReset()
  240. {
  241. PostMsg((int)MSG.Reset);
  242. }
  243. public void SetAuto()
  244. {
  245. this._AutoMode = AutoFlag.Auto;
  246. }
  247. private bool FnSetManual(object[] param)
  248. {
  249. if (fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess)
  250. {
  251. EV.PostWarningLog(Module.ToString(), $"{Module} is in {(PMState)fsm.State},can not do SetAutoMode");
  252. return false;
  253. }
  254. this._AutoMode = AutoFlag.Manual;
  255. if (IsOnline)
  256. {
  257. EV.PostWarningLog(Module.ToString(), $"{Module} is online,change to offline due to the chamber change to manual mode");
  258. this._isOnline = false;
  259. }
  260. return true;
  261. }
  262. private bool FnSetOnline(object[] param)
  263. {
  264. if (!IsAutoMode)
  265. {
  266. EV.PostWarningLog(Module.ToString(), $"{Module} in manual mode,can not set online.");
  267. return false;
  268. }
  269. if (!_chamber.CheckSlitDoorClose())
  270. {
  271. EV.PostWarningLog(Module.ToString(), $"{Module} slit door is open,can not set online.");
  272. return false;
  273. }
  274. this._isOnline = true;
  275. return true;
  276. }
  277. private bool FnSetOffline(object[] param)
  278. {
  279. this._isOnline = false;
  280. return true;
  281. }
  282. public PMEntity(ModuleName module)
  283. {
  284. Module = module;
  285. _chamber = DEVICE.GetDevice<JetPM>(Module.ToString());
  286. _home = new PMHomeRoutine(_chamber);
  287. _startDryPumpRoutine = new StartDryPumpRoutine(_chamber);
  288. _startTurboPumpRoutine = new StartTurboPumpRoutine(_chamber);
  289. _ventRoutine = new VentRoutine(_chamber);
  290. _pumpRoutine = new PumpDownRoutine(_chamber);
  291. _ventLoadLockRoutine = new LoadLockVentRoutine(_chamber);
  292. _pumpLoadLockRoutine = new LoadLockPumpRoutine(_chamber);
  293. _purgeLoadLockRoutine = new LoadLockPurgeRoutine(_chamber);
  294. _loadLockLeakCheckRoutine = new LoadLockLeakCheckRoutine(_chamber);
  295. _purgeRoutine = new PMPurgeRoutine(_chamber);
  296. _gaslinePurgeRoutine = new PMGaslinePurgeRoutine(_chamber);
  297. _leakCheckRoutine = new PMLeakCheckRoutine(_chamber);
  298. _gasBoxLeakCheckRoutine = new GasBoxLeakCheckRoutine(_chamber);
  299. _llPlaceRoutine = new LLPlaceRoutine(_chamber);
  300. _llPickRoutine = new LLPickRoutine(_chamber, _ventLoadLockRoutine);
  301. _processRoutine = new PMProcessRoutine(_chamber, _pumpRoutine);
  302. _gasFlowRoutine = new GasFlowRoutine(_chamber);
  303. _rfPowerRoutine = new RFPowerSwitchRoutine(_chamber, true);
  304. _gasVerificationRoutine = new PMGasVerificationRoutine(_chamber);
  305. fsm = new StateMachine<PMEntity>(Module.ToString(), (int)PMState.Init, 50);
  306. //Idle
  307. EnterExitTransition((int)PMState.Idle, FnIdle, (int)FSM_MSG.NONE, null);
  308. EnterExitTransition<PMState, FSM_MSG>(PMState.Error, fEnterError, FSM_MSG.NONE, null);
  309. //Home
  310. //EnterExitTransition((int)PMState.Homing, FnEnterHome, (int)FSM_MSG.NONE, FnExitHome);
  311. AnyStateTransition(MSG.Error, FnError, PMState.Error);
  312. Transition(PMState.Init, FSM_MSG.TIMER, FnTimeout, PMState.Init);
  313. Transition(PMState.Init, MSG.Home, FnStartHome, PMState.Homing);
  314. Transition(PMState.Error, MSG.Home, FnStartHome, PMState.Homing);
  315. Transition(PMState.Idle, MSG.Home, FnStartHome, PMState.Homing);
  316. Transition(PMState.Homing, MSG.Home, FnStartHome, PMState.Homing);
  317. Transition(PMState.Homing, FSM_MSG.TIMER, FnMonitorHome, PMState.Idle);
  318. Transition(PMState.Idle, FSM_MSG.TIMER, FnIdleTimeout, PMState.Idle);
  319. Transition(PMState.Error, FSM_MSG.TIMER, FnErrorTimeout, PMState.Error);
  320. //Launch DryPump sequence
  321. Transition(PMState.Idle, MSG.LaunchPump, FnLaunchPump, PMState.LaunchingPump);
  322. Transition(PMState.LaunchingPump, FSM_MSG.TIMER, FnLaunchPumpTimeout, PMState.Idle);
  323. Transition(PMState.LaunchingPump, MSG.Abort, FnAbortStartPumping, PMState.Idle);
  324. //Launch TurboPump sequence
  325. Transition(PMState.Idle, MSG.LaunchTurboPump, FnLaunchTurboPump, PMState.LaunchingTurboPump);
  326. Transition(PMState.LaunchingTurboPump, FSM_MSG.TIMER, FnLaunchTurboPumpTimeout, PMState.Idle);
  327. Transition(PMState.LaunchingTurboPump, MSG.Abort, FnAbortStartTurboPumping, PMState.Idle);
  328. //vent sequence
  329. Transition(PMState.Idle, MSG.Vent, FnStartVent, PMState.Venting);
  330. Transition(PMState.Pumping, MSG.Vent, FnVentToPumping, PMState.Venting);
  331. Transition(PMState.Venting, FSM_MSG.TIMER, FnVentTimeout, PMState.Idle);
  332. Transition(PMState.Venting, MSG.Abort, FnAbortVent, PMState.Idle);
  333. //Pump sequence
  334. Transition(PMState.Idle, MSG.Pump, FnStartPumpDown, PMState.Pumping);
  335. Transition(PMState.Venting, MSG.Pump, FnVentToPumping, PMState.Pumping);
  336. Transition(PMState.Pumping, FSM_MSG.TIMER, FnPumpDownTimeout, PMState.Idle);
  337. Transition(PMState.Pumping, MSG.Abort, FnAbortPumping, PMState.Idle);
  338. //Pump Loadlock sequence
  339. Transition(PMState.Idle, MSG.PumpLoadLock, FnStartPumpDownLoadLock, PMState.PumpingLoadLock);
  340. Transition(PMState.VentingLoadLock, MSG.PumpLoadLock, FnVentLoadLockToPumpingLoadLock, PMState.PumpingLoadLock);
  341. Transition(PMState.PumpingLoadLock, FSM_MSG.TIMER, FnPumpDownLoadLockTimeout, PMState.Idle);
  342. Transition(PMState.PumpingLoadLock, MSG.Abort, FnAbortPumpingLoadLock, PMState.Idle);
  343. //Vent Loadlock sequence
  344. Transition(PMState.Idle, MSG.VentLoadLock, FnStartVentLoadlock, PMState.VentingLoadLock);
  345. Transition(PMState.PumpingLoadLock, MSG.VentLoadLock, FnPumpingLoadLockToVentLoadLock, PMState.VentingLoadLock);
  346. Transition(PMState.VentingLoadLock, FSM_MSG.TIMER, FnVentLoadLockTimeout, PMState.Idle);
  347. Transition(PMState.VentingLoadLock, MSG.Abort, FnAbortVentLoadLock, PMState.Idle);
  348. // Purge LoadLock sequence
  349. Transition(PMState.Idle, MSG.PurgeLoadLock, FnStartPurgeLoadlock, PMState.PurgingLoadLock);
  350. Transition(PMState.PurgingLoadLock, FSM_MSG.TIMER, FnPurgeLoadLockTimeout, PMState.Idle);
  351. Transition(PMState.PurgingLoadLock, MSG.Abort, FnAbortPurgeLoadLock, PMState.Idle);
  352. //LoadLock Leak check sequence
  353. Transition(PMState.Idle, MSG.LoadLockLeakCheck, FnStartLoadLockLeakCheck, PMState.LoadLockLeakCheck);
  354. Transition(PMState.LoadLockLeakCheck, FSM_MSG.TIMER, FnLoadLockLeakCheckTimeout, PMState.Idle);
  355. Transition(PMState.LoadLockLeakCheck, MSG.Abort, FnAbortLoadLockLeakCheck, PMState.Idle);
  356. // PM Purge sequence
  357. Transition(PMState.Idle, MSG.CyclePurge, FnStartPurge, PMState.Purging);
  358. Transition(PMState.Purging, FSM_MSG.TIMER, FnPurgeTimeout, PMState.Idle);
  359. Transition(PMState.Purging, MSG.Abort, FnAbortPurge, PMState.Idle);
  360. // PM GasLine Purge sequence
  361. Transition(PMState.Idle, MSG.GasLinePurge, FnStartGasLinePurge, PMState.GasLinePurge);
  362. Transition(PMState.GasLinePurge, FSM_MSG.TIMER, FnGasLinePurgeTimeout, PMState.Idle);
  363. Transition(PMState.GasLinePurge, MSG.Abort, FnAbortGasLinePurge, PMState.Idle);
  364. //PM Leak check sequence
  365. Transition(PMState.Idle, MSG.LeakCheck, FnStartPMLeakCheck, PMState.LeakCheck);
  366. Transition(PMState.LeakCheck, FSM_MSG.TIMER, FnPMLeakCheckTimeout, PMState.Idle);
  367. Transition(PMState.LeakCheck, MSG.Abort, FnAbortPMLeakCheck, PMState.Idle);
  368. //PM GasBox Leak check sequence
  369. Transition(PMState.Idle, MSG.GasLeakCheck, FnStartGasBoxLeakCheck, PMState.GasBoxLeakCheck);
  370. Transition(PMState.GasBoxLeakCheck, FSM_MSG.TIMER, FnGasBoxLeakCheckTimeout, PMState.Idle);
  371. Transition(PMState.GasBoxLeakCheck, MSG.Abort, FnAbortGasBoxLeakCheck, PMState.Idle);
  372. // PlaceWafer from LoadLock Arm sequence
  373. Transition(PMState.Idle, MSG.LLPlace, FnStartLLPlace, PMState.LLPlacing);
  374. Transition(PMState.LLPlacing, FSM_MSG.TIMER, FnLLPlaceTimeout, PMState.Idle);
  375. Transition(PMState.LLPlacing, MSG.Abort, FnAbortLLPlace, PMState.Idle);
  376. // PickWafer to LoadLock Arm sequence
  377. Transition(PMState.Idle, MSG.LLPick, FnStartLLPick, PMState.LLPicking);
  378. Transition(PMState.LLPicking, FSM_MSG.TIMER, FnLLPickTimeout, PMState.Idle);
  379. Transition(PMState.LLPicking, MSG.Abort, FnAbortLLPick, PMState.Idle);
  380. // Process
  381. Transition(PMState.Idle, MSG.RunRecipe, FnRunRecipe, PMState.Processing);
  382. Transition(PMState.Processing, FSM_MSG.TIMER, FnProcessTimeout, PMState.Idle);
  383. Transition(PMState.Processing, MSG.Abort, FnAbortProcess, PMState.Idle);
  384. // Gas Flow sequence
  385. Transition(PMState.Idle, MSG.GasFlow, FnStartGasFlow, PMState.GasFlowing);
  386. Transition(PMState.GasFlowing, MSG.GasFlow, FnAbortGasFlow, PMState.Idle);
  387. Transition(PMState.GasFlowing, FSM_MSG.TIMER, FnGasFlowTimeout, PMState.Idle);
  388. Transition(PMState.GasFlowing, MSG.StopGasFlow, FnStopGasFlow, PMState.Idle);
  389. Transition(PMState.GasFlowing, MSG.Abort, FnAbortGasFlow, PMState.Idle);
  390. //RF Power sequence
  391. Transition(PMState.Idle, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  392. Transition(PMState.GasFlowing, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  393. Transition(PMState.RfPowering, FSM_MSG.TIMER, FnRfPowerTimeout, PMState.Idle);
  394. Transition(PMState.RfPowering, MSG.Abort, FnAbortRfPower, PMState.Idle);
  395. //MFC verification
  396. Transition(PMState.Idle, MSG.MFCVerification, FnStartMFCVerification, PMState.MFCVerification);
  397. Transition(PMState.MFCVerification, FSM_MSG.TIMER, FnMFCVerificationTimeout, PMState.Idle);
  398. Transition(PMState.MFCVerification, MSG.Abort, FnAbortMFCVerification, PMState.Idle);
  399. Running = true;
  400. WaferManager.Instance.SubscribeLocation(ModuleName.PMA, 1);
  401. WaferManager.Instance.SubscribeLocation(ModuleName.LLA, 1);
  402. }
  403. protected override bool Init()
  404. {
  405. DATA.Subscribe($"{Module}.FsmState", () => (((PMState)fsm.State).ToString()));
  406. DATA.Subscribe($"{Module}.LoadLockPurge.PurgeCounter", () => _purgeLoadLockRoutine.PurgeCounter);
  407. OP.Subscribe($"{Module}.{RtOperation.GasFlow}", (cmd, args) => CheckToPostMessage((int)MSG.GasFlow, args));
  408. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck, args));
  409. OP.Subscribe($"{Module}.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  410. OP.Subscribe($"{Module}.{RtOperation.StartPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchPump));
  411. OP.Subscribe($"{Module}.{RtOperation.StartTurboPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchTurboPump));
  412. OP.Subscribe($"{Module}.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  413. OP.Subscribe($"{Module}.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.CyclePurge));
  414. OP.Subscribe($"{Module}.{RtOperation.RfPower}", (cmd, args) => CheckToPostMessage((int)MSG.RfPower));
  415. OP.Subscribe($"{Module}.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  416. OP.Subscribe($"{Module}.{RtOperation.VentLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.VentLoadLock));
  417. OP.Subscribe($"{Module}.{RtOperation.PurgeLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PurgeLoadLock));
  418. OP.Subscribe($"{Module}.{RtOperation.PumpLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PumpLoadLock));
  419. OP.Subscribe($"{Module}.{RtOperation.Reset}", (cmd, args) => CheckToPostMessage((int)MSG.Reset));
  420. OP.Subscribe($"{Module}.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  421. OP.Subscribe($"{Module}.{RtOperation.LLPick}", (cmd, args) => CheckToPostMessage((int)MSG.LLPick));
  422. OP.Subscribe($"{Module}.{RtOperation.LLPlace}", (cmd, args) => CheckToPostMessage((int)MSG.LLPlace));
  423. OP.Subscribe($"{Module}.{RtOperation.MFCVerification}", (cmd, args) => CheckToPostMessage((int)MSG.MFCVerification, args[0], args[1], args[2]));
  424. OP.Subscribe($"{Module}.{RtOperation.RunRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RunRecipe, args[0]));
  425. return true;
  426. }
  427. private bool FnIdle(object[] objs)
  428. {
  429. Running = false;
  430. return true;
  431. }
  432. private bool fEnterError(object[] objs)
  433. {
  434. return true;
  435. }
  436. private bool FnError(object[] objs)
  437. {
  438. Running = false;
  439. if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  440. || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  441. return false;
  442. if (IsProcessing)
  443. {
  444. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  445. }
  446. return true;
  447. }
  448. private bool FnTimeout(object[] objs)
  449. {
  450. _debugRoutine();
  451. return true;
  452. }
  453. private bool FnIdleTimeout(object[] objs)
  454. {
  455. _chamber.CheckIdleInterlock();
  456. //_debugRoutine();
  457. return true;
  458. }
  459. private bool FnErrorTimeout(object[] objs)
  460. {
  461. //_debugRoutine();
  462. return true;
  463. }
  464. private bool FnStartHome(object[] objs)
  465. {
  466. return _home.Start() == RState.Running;
  467. }
  468. private bool FnMonitorHome(object[] objs)
  469. {
  470. RState ret = _home.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 FnLaunchPump(object[] param)
  479. {
  480. return _startDryPumpRoutine.Start() == RState.Running;
  481. }
  482. private bool FnLaunchPumpTimeout(object[] param)
  483. {
  484. RState ret = _startDryPumpRoutine.Monitor();
  485. if (ret == RState.Failed || ret == RState.Timeout)
  486. {
  487. PostMsg(MSG.Error);
  488. return false;
  489. }
  490. return ret == RState.End;
  491. }
  492. private bool FnAbortStartPumping(object[] param)
  493. {
  494. _startDryPumpRoutine.Abort();
  495. return true;
  496. }
  497. private bool FnLaunchTurboPump(object[] param)
  498. {
  499. return _startTurboPumpRoutine.Start() == RState.Running;
  500. }
  501. private bool FnLaunchTurboPumpTimeout(object[] param)
  502. {
  503. RState ret = _startTurboPumpRoutine.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 FnAbortStartTurboPumping(object[] param)
  512. {
  513. _startTurboPumpRoutine.Abort();
  514. return true;
  515. }
  516. private bool FnStartVent(object[] param)
  517. {
  518. return _ventRoutine.Start() == RState.Running;
  519. }
  520. private bool FnVentTimeout(object[] param)
  521. {
  522. RState ret = _ventRoutine.Monitor();
  523. if (ret == RState.Failed || ret == RState.Timeout)
  524. {
  525. PostMsg(MSG.Error);
  526. return false;
  527. }
  528. return ret == RState.End;
  529. }
  530. private bool FnVentToPumping(object[] param)
  531. {
  532. _ventRoutine.Abort();
  533. return true; // FnStartPumpDown(param);
  534. }
  535. private bool FnAbortVent(object[] param)
  536. {
  537. _ventRoutine.Abort();
  538. return true;
  539. }
  540. private bool FnStartPumpDown(object[] param)
  541. {
  542. return _pumpRoutine.Start() == RState.Running;
  543. }
  544. private bool FnPumpDownTimeout(object[] param)
  545. {
  546. RState ret = _pumpRoutine.Monitor();
  547. if (ret == RState.Failed || ret == RState.Timeout)
  548. {
  549. PostMsg(MSG.Error);
  550. return false;
  551. }
  552. return ret == RState.End;
  553. }
  554. private bool FnAbortPumping(object[] param)
  555. {
  556. _pumpRoutine.Abort();
  557. return true;
  558. }
  559. private bool FnStartVentLoadlock(object[] param)
  560. {
  561. return _ventLoadLockRoutine.Start() == RState.Running;
  562. }
  563. private bool FnVentLoadLockTimeout(object[] param)
  564. {
  565. RState ret = _ventLoadLockRoutine.Monitor();
  566. if (ret == RState.Failed || ret == RState.Timeout)
  567. {
  568. PostMsg(MSG.Error);
  569. return false;
  570. }
  571. return ret == RState.End;
  572. }
  573. private bool FnVentLoadLockToPumpingLoadLock(object[] param)
  574. {
  575. _ventLoadLockRoutine.Abort();
  576. return FnStartPumpDownLoadLock(param);
  577. }
  578. private bool FnAbortVentLoadLock(object[] param)
  579. {
  580. _ventLoadLockRoutine.Abort();
  581. return true;
  582. }
  583. private bool FnStartPumpDownLoadLock(object[] param)
  584. {
  585. return _pumpLoadLockRoutine.Start() == RState.Running;
  586. }
  587. private bool FnPumpDownLoadLockTimeout(object[] param)
  588. {
  589. RState ret = _pumpLoadLockRoutine.Monitor();
  590. if (ret == RState.Failed || ret == RState.Timeout)
  591. {
  592. PostMsg(MSG.Error);
  593. return false;
  594. }
  595. return ret == RState.End;
  596. }
  597. private bool FnPumpingToVent(object[] param)
  598. {
  599. _pumpRoutine.Abort();
  600. return FnStartVent(param);
  601. }
  602. private bool FnPumpingLoadLockToVentLoadLock(object[] param)
  603. {
  604. _pumpLoadLockRoutine.Abort();
  605. return FnStartVentLoadlock(param);
  606. }
  607. private bool FnAbortPumpingLoadLock(object[] param)
  608. {
  609. _pumpLoadLockRoutine.Abort();
  610. return true;
  611. }
  612. private bool FnStartPurgeLoadlock(object[] param)
  613. {
  614. return _purgeLoadLockRoutine.Start() == RState.Running;
  615. }
  616. private bool FnPurgeLoadLockTimeout(object[] param)
  617. {
  618. RState ret = _purgeLoadLockRoutine.Monitor();
  619. if (ret == RState.Failed || ret == RState.Timeout)
  620. {
  621. PostMsg(MSG.Error);
  622. return false;
  623. }
  624. return ret == RState.End;
  625. }
  626. private bool FnAbortPurgeLoadLock(object[] param)
  627. {
  628. _purgeLoadLockRoutine.Abort();
  629. return true;
  630. }
  631. private bool FnStartLoadLockLeakCheck(object[] param)
  632. {
  633. return _loadLockLeakCheckRoutine.Start() == RState.Running;
  634. }
  635. private bool FnLoadLockLeakCheckTimeout(object[] param)
  636. {
  637. RState ret = _loadLockLeakCheckRoutine.Monitor();
  638. if (ret == RState.Failed || ret == RState.Timeout)
  639. {
  640. PostMsg(MSG.Error);
  641. return false;
  642. }
  643. return ret == RState.End;
  644. }
  645. private bool FnAbortLoadLockLeakCheck(object[] param)
  646. {
  647. _loadLockLeakCheckRoutine.Abort();
  648. return true;
  649. }
  650. private bool FnStartPurge(object[] param)
  651. {
  652. return _purgeRoutine.Start() == RState.Running;
  653. }
  654. private bool FnPurgeTimeout(object[] param)
  655. {
  656. RState ret = _purgeRoutine.Monitor();
  657. if (ret == RState.Failed || ret == RState.Timeout)
  658. {
  659. PostMsg(MSG.Error);
  660. return false;
  661. }
  662. return ret == RState.End;
  663. }
  664. private bool FnAbortPurge(object[] param)
  665. {
  666. _purgeRoutine.Abort();
  667. return true;
  668. }
  669. private bool FnStartGasLinePurge(object[] param)
  670. {
  671. return _gaslinePurgeRoutine.Start() == RState.Running;
  672. }
  673. private bool FnGasLinePurgeTimeout(object[] param)
  674. {
  675. RState ret = _gaslinePurgeRoutine.Monitor();
  676. if (ret == RState.Failed || ret == RState.Timeout)
  677. {
  678. PostMsg(MSG.Error);
  679. return false;
  680. }
  681. return ret == RState.End;
  682. }
  683. private bool FnAbortGasLinePurge(object[] param)
  684. {
  685. _gaslinePurgeRoutine.Abort();
  686. return true;
  687. }
  688. private bool FnStartPMLeakCheck(object[] param)
  689. {
  690. return _leakCheckRoutine.Start() == RState.Running;
  691. }
  692. private bool FnPMLeakCheckTimeout(object[] param)
  693. {
  694. RState ret = _leakCheckRoutine.Monitor();
  695. if (ret == RState.Failed || ret == RState.Timeout)
  696. {
  697. PostMsg(MSG.Error);
  698. return false;
  699. }
  700. return ret == RState.End;
  701. }
  702. private bool FnAbortPMLeakCheck(object[] param)
  703. {
  704. _leakCheckRoutine.Abort();
  705. return true;
  706. }
  707. private bool FnStartGasBoxLeakCheck(object[] param)
  708. {
  709. return _gasBoxLeakCheckRoutine.Start() == RState.Running;
  710. }
  711. private bool FnGasBoxLeakCheckTimeout(object[] param)
  712. {
  713. RState ret = _gasBoxLeakCheckRoutine.Monitor();
  714. if (ret == RState.Failed || ret == RState.Timeout)
  715. {
  716. PostMsg(MSG.Error);
  717. return false;
  718. }
  719. return ret == RState.End;
  720. }
  721. private bool FnAbortGasBoxLeakCheck(object[] param)
  722. {
  723. _gasBoxLeakCheckRoutine.Abort();
  724. return true;
  725. }
  726. private bool FnStartLLPlace(object[] param)
  727. {
  728. return _llPlaceRoutine.Start() == RState.Running;
  729. }
  730. private bool FnLLPlaceTimeout(object[] param)
  731. {
  732. RState ret = _llPlaceRoutine.Monitor();
  733. if (ret == RState.Failed || ret == RState.Timeout)
  734. {
  735. PostMsg(MSG.Error);
  736. return false;
  737. }
  738. return ret == RState.End;
  739. }
  740. private bool FnAbortLLPlace(object[] param)
  741. {
  742. _llPlaceRoutine.Abort();
  743. return true;
  744. }
  745. private bool FnStartLLPick(object[] param)
  746. {
  747. return _llPickRoutine.Start() == RState.Running;
  748. }
  749. private bool FnLLPickTimeout(object[] param)
  750. {
  751. RState ret = _llPickRoutine.Monitor();
  752. if (ret == RState.Failed || ret == RState.Timeout)
  753. {
  754. PostMsg(MSG.Error);
  755. return false;
  756. }
  757. return ret == RState.End;
  758. }
  759. private bool FnAbortLLPick(object[] param)
  760. {
  761. _llPickRoutine.Abort();
  762. return true;
  763. }
  764. private bool FnRunRecipe(object[] param)
  765. {
  766. return _processRoutine.Start(param) == RState.Running;
  767. }
  768. private bool FnProcessTimeout(object[] param)
  769. {
  770. _chamber.CheckIdleInterlock();
  771. RState ret = _processRoutine.Monitor();
  772. if (ret == RState.Failed || ret == RState.Timeout)
  773. {
  774. PostMsg(MSG.Error);
  775. return false;
  776. }
  777. return ret == RState.End;
  778. }
  779. private bool FnAbortProcess(object[] param)
  780. {
  781. _processRoutine.Abort();
  782. return true;
  783. }
  784. private bool FnStartGasFlow(object[] param)
  785. {
  786. return _gasFlowRoutine.Start(param) == RState.Running;
  787. }
  788. private bool FnGasFlowTimeout(object[] param)
  789. {
  790. RState ret = _gasFlowRoutine.Monitor();
  791. if (ret == RState.Failed || ret == RState.Timeout)
  792. {
  793. PostMsg(MSG.Error);
  794. return false;
  795. }
  796. return ret == RState.End;
  797. }
  798. private bool FnStopGasFlow(object[] param)
  799. {
  800. _gasFlowRoutine.Abort();
  801. return true;
  802. }
  803. private bool FnAbortGasFlow(object[] param)
  804. {
  805. _gasFlowRoutine.Abort();
  806. return true;
  807. }
  808. private bool FnStartRfPower(object[] param)
  809. {
  810. return _rfPowerRoutine.Start(param) == RState.Running;
  811. }
  812. private bool FnRfPowerTimeout(object[] param)
  813. {
  814. RState ret = _rfPowerRoutine.Monitor();
  815. if (ret == RState.Failed || ret == RState.Timeout)
  816. {
  817. PostMsg(MSG.Error);
  818. return false;
  819. }
  820. return ret == RState.End;
  821. }
  822. private bool FnAbortRfPower(object[] param)
  823. {
  824. _rfPowerRoutine.Abort();
  825. if(_gasFlowRoutine._gasStatus)
  826. {
  827. _gasFlowRoutine.StopFlow();
  828. }
  829. return true;
  830. }
  831. private bool FnStartMFCVerification(object[] param)
  832. {
  833. _gasVerificationRoutine.Init((string)param[0], (double)param[1], (int)param[2]);
  834. return _gasVerificationRoutine.Start(param) == RState.Running;
  835. }
  836. private bool FnMFCVerificationTimeout(object[] param)
  837. {
  838. RState ret = _gasVerificationRoutine.Monitor();
  839. if (ret == RState.Failed || ret == RState.Timeout)
  840. {
  841. PostMsg(MSG.Error);
  842. return false;
  843. }
  844. return ret == RState.End;
  845. }
  846. private bool FnAbortMFCVerification(object[] param)
  847. {
  848. _gasVerificationRoutine.Abort();
  849. return true;
  850. }
  851. private void _debugRoutine()
  852. {
  853. int flag = 0;
  854. // Test Home routine
  855. if (flag == 1)
  856. {
  857. PostMsg(MSG.Home);
  858. }
  859. else if (flag == 2)
  860. {
  861. PostMsg(MSG.Vent);
  862. }
  863. else if (flag == 3)
  864. {
  865. PostMsg(MSG.Pump);
  866. }
  867. else if(flag == 4)
  868. {
  869. PostMsg(MSG.PumpLoadLock);
  870. }
  871. else if(flag == 5)
  872. {
  873. PostMsg(MSG.VentLoadLock);
  874. }
  875. else if(flag == 6)
  876. {
  877. PostMsg(MSG.PurgeLoadLock);
  878. }
  879. else if(flag == 7)
  880. {
  881. PostMsg(MSG.LaunchPump);
  882. }
  883. else if(flag == 8)
  884. {
  885. PostMsg(MSG.LaunchTurboPump);
  886. }
  887. else if(flag == 9)
  888. {
  889. PostMsg(MSG.LoadLockLeakCheck);
  890. }
  891. else if(flag == 10)
  892. {
  893. PostMsg(MSG.CyclePurge);
  894. }
  895. else if(flag == 11)
  896. {
  897. PostMsg(MSG.GasLinePurge);
  898. }
  899. else if(flag == 12)
  900. {
  901. PostMsg(MSG.LeakCheck);
  902. }
  903. else if(flag == 13)
  904. {
  905. PostMsg(MSG.GasLeakCheck);
  906. }
  907. else if(flag == 14)
  908. {
  909. PostMsg(MSG.LLPlace);
  910. }
  911. else if(flag == 15)
  912. {
  913. PostMsg(MSG.LLPick);
  914. }
  915. else if(flag == 16)
  916. {
  917. PostMsg(MSG.RunRecipe, "7777");
  918. }
  919. else if(flag == 17)
  920. {
  921. PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  922. }
  923. }
  924. }
  925. }