PMEntity.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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 PMStatus
  46. {
  47. Not_Ready,
  48. Ready_For_Pick,
  49. Ready_For_Place,
  50. Exchange_Ready,
  51. }
  52. public enum MSG
  53. {
  54. Home,
  55. Transfer,
  56. PrepareTransfer,
  57. PostTransfer,
  58. Reset,
  59. Abort,
  60. Error,
  61. LaunchPump,
  62. LaunchTurboPump,
  63. Pump,
  64. Vent,
  65. PumpLoadLock,
  66. VentLoadLock,
  67. PurgeLoadLock,
  68. LoadLockLeakCheck,
  69. CyclePurge,
  70. GasLinePurge,
  71. Heat,
  72. TransferHandoff,
  73. StartTransfer,
  74. LeakCheck,
  75. GasLeakCheck,
  76. MoveLiftPin,
  77. MoveGuidePin,
  78. PartialPressure,
  79. VATPerformance,
  80. LLPlace,
  81. LLPick,
  82. Process,
  83. RunRecipe,
  84. PostProcess,
  85. RecipeSkipStep,
  86. RecipeUpdate,
  87. RecipeResume,
  88. RecipePause,
  89. RecipeAbort,
  90. PreProcess,
  91. AutoMode,
  92. ManualMode,
  93. LockLid,
  94. Clean,
  95. Online,
  96. Offline,
  97. GasFlow,
  98. StopGasFlow,
  99. RfPower,
  100. MFCVerification,
  101. // exchange wafer with TM
  102. PreparePick,
  103. PreparePlace,
  104. LiftUpWafer,
  105. DropDownWafer,
  106. PickReady,
  107. PlaceReady,
  108. MaxMsg
  109. }
  110. private readonly JetPM _chamber;
  111. public ModuleName Module { get; }
  112. public PMStatus Status { get; private set; }
  113. public Action<bool, bool> TransferPrepared;
  114. private readonly PMHomeRoutine _home;
  115. private readonly StartDryPumpRoutine _startDryPumpRoutine;
  116. private readonly StartTurboPumpRoutine _startTurboPumpRoutine;
  117. private readonly VentRoutine _ventRoutine;
  118. private readonly PumpDownRoutine _pumpRoutine;
  119. private readonly LoadLockVentRoutine _ventLoadLockRoutine;
  120. private readonly LoadLockPumpRoutine _pumpLoadLockRoutine;
  121. private readonly LoadLockPurgeRoutine _purgeLoadLockRoutine;
  122. private readonly LoadLockLeakCheckRoutine _loadLockLeakCheckRoutine;
  123. private readonly PMPurgeRoutine _purgeRoutine;
  124. private readonly PMGaslinePurgeRoutine _gaslinePurgeRoutine;
  125. private readonly PMLeakCheckRoutine _leakCheckRoutine;
  126. private readonly GasBoxLeakCheckRoutine _gasBoxLeakCheckRoutine;
  127. private readonly LLPlaceRoutine _llPlaceRoutine;
  128. private readonly LLPickRoutine _llPickRoutine;
  129. private readonly PMProcessRoutine _processRoutine;
  130. private readonly GasFlowRoutine _gasFlowRoutine;
  131. private readonly RFPowerSwitchRoutine _rfPowerRoutine;
  132. private readonly PMGasVerificationRoutine _gasVerificationRoutine;
  133. private readonly PMPartialPressureRoutine _pmPartialPressureRoutine;
  134. private readonly PMVATPerformanceRoutine _pmVATPerformanceRoutine;
  135. private AutoFlag _AutoMode;
  136. private bool _isOnline = false;
  137. //private bool _isAlarm;
  138. //private DateTime _pumpStartTime;
  139. //private TimeSpan _pumpElapsedTime;
  140. //private DateTime _rfStartTime;
  141. //private DateTime _tcStartTime;
  142. //private TimeSpan _rfElapsedTime;
  143. //private TimeSpan _tcElapsedTime;
  144. //private MovementPosition _goalLiftPin;
  145. //private ushort _ActivatedActionID;
  146. //private Stopwatch _LifpinSleepTimer;
  147. public bool IsIdle
  148. {
  149. get { return fsm.State == (int)PMState.Idle; }
  150. }
  151. public bool IsError
  152. {
  153. get { return fsm.State == (int)PMState.Error; }
  154. }
  155. public bool IsInit
  156. {
  157. get { return fsm.State == (int)PMState.Init; }
  158. }
  159. public bool IsBusy
  160. {
  161. get { return !IsInit && !IsError && !IsIdle; }
  162. }
  163. public bool IsProcessing
  164. {
  165. get { return fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess; }
  166. }
  167. public bool IsOnline
  168. {
  169. get { return _isOnline; }
  170. }
  171. public bool IsAutoMode => _AutoMode == AutoFlag.Auto;
  172. public bool IsSlitDoorOpen => _chamber.CheckSlitDoorOpen();
  173. public bool IsSlitDoorClose => _chamber.CheckSlitDoorClose();
  174. public bool LiftPinIsDown => _chamber.LiftPinIsDown;
  175. public bool LiftPinIsUp => _chamber.LiftPinIsUp;
  176. public bool Check(int msg, out string reason, object[] objs)
  177. {
  178. reason = "";
  179. return true;
  180. }
  181. //
  182. private bool CheckToPostMessage(int msg, params object[] args)
  183. {
  184. if (!fsm.FindTransition(fsm.State, msg))
  185. {
  186. EV.PostWarningLog(Module.ToString(), eEvent.WARN_State, $"{Module} is in { (PMState)fsm.State} state,can not do {(MSG)msg}");
  187. return false;
  188. }
  189. fsm.PostMsg(msg, args);
  190. return true;
  191. }
  192. public int Invoke(string function, params object[] args)
  193. {
  194. switch (function)
  195. {
  196. case "Home":
  197. CheckToPostMessage((int)MSG.Home);
  198. return (int)MSG.Home;
  199. }
  200. return (int)FSM_MSG.NONE;
  201. }
  202. public bool CheckAcked(int msg)
  203. {
  204. return fsm.CheckExecuted(msg);
  205. }
  206. public bool IsPrepareTransferReady(ModuleName robot, EnumTransferType type, int slot, Hand blade)
  207. {
  208. //if (type == EnumTransferType.Pick)
  209. //{
  210. // return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(_chamber.Module, 0).Size);
  211. //}
  212. //else if (type == EnumTransferType.Place)
  213. //{
  214. // return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(robot, (int)blade).Size);
  215. //}
  216. return false;
  217. }
  218. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  219. {
  220. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString()))
  221. return (int)MSG.PrepareTransfer;
  222. return (int)FSM_MSG.NONE;
  223. }
  224. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp)
  225. {
  226. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp))
  227. return (int)MSG.PrepareTransfer;
  228. return (int)FSM_MSG.NONE;
  229. }
  230. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp, WaferSize size)
  231. {
  232. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp, size))
  233. return (int)MSG.PrepareTransfer;
  234. return (int)FSM_MSG.NONE;
  235. }
  236. public int InvokePostTransfer(ModuleName robot, EnumTransferType type, int slot)
  237. {
  238. if (CheckToPostMessage((int)MSG.PostTransfer, type.ToString()))
  239. return (int)MSG.PostTransfer;
  240. return (int)FSM_MSG.NONE;
  241. }
  242. public int InvokeClean(string recipeName, string waferID, bool withWafer)
  243. {
  244. if (CheckToPostMessage((int)MSG.Clean, recipeName, waferID, withWafer))
  245. {
  246. return (int)MSG.Clean;
  247. }
  248. return (int)FSM_MSG.NONE;
  249. }
  250. public int InvokeProcess(string recipeName, string waferID, bool withWafer)
  251. {
  252. if (CheckToPostMessage((int)MSG.RunRecipe, recipeName, waferID, withWafer))
  253. return (int)MSG.RunRecipe;
  254. return (int)FSM_MSG.NONE;
  255. }
  256. public int InvokePreHeat(float temperature)
  257. {
  258. if (CheckToPostMessage((int)MSG.Heat, (double)temperature))
  259. return (int)MSG.Heat;
  260. return (int)FSM_MSG.NONE;
  261. }
  262. public void InvokeReset()
  263. {
  264. PostMsg((int)MSG.Reset);
  265. }
  266. public void SetAuto()
  267. {
  268. this._AutoMode = AutoFlag.Auto;
  269. }
  270. private bool FnSetManual(object[] param)
  271. {
  272. if (fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess)
  273. {
  274. EV.PostWarningLog(Module.ToString(), $"{Module} is in {(PMState)fsm.State},can not do SetAutoMode");
  275. return false;
  276. }
  277. this._AutoMode = AutoFlag.Manual;
  278. if (IsOnline)
  279. {
  280. EV.PostWarningLog(Module.ToString(), $"{Module} is online,change to offline due to the chamber change to manual mode");
  281. this._isOnline = false;
  282. }
  283. return true;
  284. }
  285. private bool FnSetOnline(object[] param)
  286. {
  287. if (!IsAutoMode)
  288. {
  289. EV.PostWarningLog(Module.ToString(), $"{Module} in manual mode,can not set online.");
  290. return false;
  291. }
  292. if (!_chamber.CheckSlitDoorClose())
  293. {
  294. EV.PostWarningLog(Module.ToString(), $"{Module} slit door is open,can not set online.");
  295. return false;
  296. }
  297. this._isOnline = true;
  298. return true;
  299. }
  300. private bool FnSetOffline(object[] param)
  301. {
  302. this._isOnline = false;
  303. return true;
  304. }
  305. public PMEntity(ModuleName module)
  306. {
  307. Module = module;
  308. _chamber = DEVICE.GetDevice<JetPM>(Module.ToString());
  309. _home = new PMHomeRoutine(_chamber);
  310. _startDryPumpRoutine = new StartDryPumpRoutine(_chamber);
  311. _startTurboPumpRoutine = new StartTurboPumpRoutine(_chamber);
  312. _ventRoutine = new VentRoutine(_chamber);
  313. _pumpRoutine = new PumpDownRoutine(_chamber);
  314. _ventLoadLockRoutine = new LoadLockVentRoutine(_chamber);
  315. _pumpLoadLockRoutine = new LoadLockPumpRoutine(_chamber);
  316. _purgeLoadLockRoutine = new LoadLockPurgeRoutine(_chamber);
  317. _loadLockLeakCheckRoutine = new LoadLockLeakCheckRoutine(_chamber);
  318. _purgeRoutine = new PMPurgeRoutine(_chamber);
  319. _gaslinePurgeRoutine = new PMGaslinePurgeRoutine(_chamber);
  320. _leakCheckRoutine = new PMLeakCheckRoutine(_chamber);
  321. _gasBoxLeakCheckRoutine = new GasBoxLeakCheckRoutine(_chamber);
  322. _llPlaceRoutine = new LLPlaceRoutine(_chamber);
  323. _llPickRoutine = new LLPickRoutine(_chamber, _ventLoadLockRoutine);
  324. _processRoutine = new PMProcessRoutine(_chamber, _pumpRoutine);
  325. _gasFlowRoutine = new GasFlowRoutine(_chamber);
  326. _rfPowerRoutine = new RFPowerSwitchRoutine(_chamber, true);
  327. _gasVerificationRoutine = new PMGasVerificationRoutine(_chamber, _pumpRoutine);
  328. _pmPartialPressureRoutine=new PMPartialPressureRoutine(_chamber);
  329. _pmVATPerformanceRoutine = new PMVATPerformanceRoutine(_chamber);
  330. fsm = new StateMachine<PMEntity>(Module.ToString(), (int)PMState.Init, 50);
  331. //Idle
  332. EnterExitTransition((int)PMState.Idle, FnIdle, (int)FSM_MSG.NONE, null);
  333. EnterExitTransition<PMState, FSM_MSG>(PMState.Error, fEnterError, FSM_MSG.NONE, null);
  334. EnterExitTransition<PMState, FSM_MSG>(PMState.ReadyForPick, fnEnterPickReady, FSM_MSG.NONE, fnExitPickReady);
  335. EnterExitTransition<PMState, FSM_MSG>(PMState.ReadyForPlace, fnEnterPlaceReady, FSM_MSG.NONE, fnExitPlaceReady);
  336. EnterExitTransition<PMState, FSM_MSG>(PMState.DropDownReady, fnEnterDropDownReady, FSM_MSG.NONE, fnExitDropDownReady);
  337. EnterExitTransition<PMState, FSM_MSG>(PMState.LiftUpReady, fnEnterLiftUpReady, FSM_MSG.NONE, fnExitLiftUpReady);
  338. //Home
  339. //EnterExitTransition((int)PMState.Homing, FnEnterHome, (int)FSM_MSG.NONE, FnExitHome);
  340. AnyStateTransition(MSG.Error, FnError, PMState.Error);
  341. Transition(PMState.Init, FSM_MSG.TIMER, FnTimeout, PMState.Init);
  342. Transition(PMState.Init, MSG.Home, FnStartHome, PMState.Homing);
  343. Transition(PMState.Error, MSG.Home, FnStartHome, PMState.Homing);
  344. Transition(PMState.Idle, MSG.Home, FnStartHome, PMState.Homing);
  345. Transition(PMState.Homing, MSG.Home, FnStartHome, PMState.Homing);
  346. Transition(PMState.Homing, FSM_MSG.TIMER, FnMonitorHome, PMState.Idle);
  347. Transition(PMState.Idle, FSM_MSG.TIMER, FnIdleTimeout, PMState.Idle);
  348. Transition(PMState.Error, FSM_MSG.TIMER, FnErrorTimeout, PMState.Error);
  349. //Launch DryPump sequence
  350. Transition(PMState.Idle, MSG.LaunchPump, FnLaunchPump, PMState.LaunchingPump);
  351. Transition(PMState.LaunchingPump, FSM_MSG.TIMER, FnLaunchPumpTimeout, PMState.Idle);
  352. Transition(PMState.LaunchingPump, MSG.Abort, FnAbortStartPumping, PMState.Idle);
  353. //Launch TurboPump sequence
  354. Transition(PMState.Idle, MSG.LaunchTurboPump, FnLaunchTurboPump, PMState.LaunchingTurboPump);
  355. Transition(PMState.LaunchingTurboPump, FSM_MSG.TIMER, FnLaunchTurboPumpTimeout, PMState.Idle);
  356. Transition(PMState.LaunchingTurboPump, MSG.Abort, FnAbortStartTurboPumping, PMState.Idle);
  357. //vent sequence
  358. Transition(PMState.Idle, MSG.Vent, FnStartVent, PMState.Venting);
  359. Transition(PMState.Pumping, MSG.Vent, FnVentToPumping, PMState.Venting);
  360. Transition(PMState.Venting, FSM_MSG.TIMER, FnVentTimeout, PMState.Idle);
  361. Transition(PMState.Venting, MSG.Abort, FnAbortVent, PMState.Idle);
  362. //Pump sequence
  363. Transition(PMState.Idle, MSG.Pump, FnStartPumpDown, PMState.Pumping);
  364. Transition(PMState.Venting, MSG.Pump, FnVentToPumping, PMState.Pumping);
  365. Transition(PMState.Pumping, FSM_MSG.TIMER, FnPumpDownTimeout, PMState.Idle);
  366. Transition(PMState.Pumping, MSG.Abort, FnAbortPumping, PMState.Idle);
  367. //Pump Loadlock sequence
  368. Transition(PMState.Idle, MSG.PumpLoadLock, FnStartPumpDownLoadLock, PMState.PumpingLoadLock);
  369. Transition(PMState.VentingLoadLock, MSG.PumpLoadLock, FnVentLoadLockToPumpingLoadLock, PMState.PumpingLoadLock);
  370. Transition(PMState.PumpingLoadLock, FSM_MSG.TIMER, FnPumpDownLoadLockTimeout, PMState.Idle);
  371. Transition(PMState.PumpingLoadLock, MSG.Abort, FnAbortPumpingLoadLock, PMState.Idle);
  372. //Vent Loadlock sequence
  373. Transition(PMState.Idle, MSG.VentLoadLock, FnStartVentLoadlock, PMState.VentingLoadLock);
  374. Transition(PMState.PumpingLoadLock, MSG.VentLoadLock, FnPumpingLoadLockToVentLoadLock, PMState.VentingLoadLock);
  375. Transition(PMState.VentingLoadLock, FSM_MSG.TIMER, FnVentLoadLockTimeout, PMState.Idle);
  376. Transition(PMState.VentingLoadLock, MSG.Abort, FnAbortVentLoadLock, PMState.Idle);
  377. // Purge LoadLock sequence
  378. Transition(PMState.Idle, MSG.PurgeLoadLock, FnStartPurgeLoadlock, PMState.PurgingLoadLock);
  379. Transition(PMState.PurgingLoadLock, FSM_MSG.TIMER, FnPurgeLoadLockTimeout, PMState.Idle);
  380. Transition(PMState.PurgingLoadLock, MSG.Abort, FnAbortPurgeLoadLock, PMState.Idle);
  381. //LoadLock Leak check sequence
  382. Transition(PMState.Idle, MSG.LoadLockLeakCheck, FnStartLoadLockLeakCheck, PMState.LoadLockLeakCheck);
  383. Transition(PMState.LoadLockLeakCheck, FSM_MSG.TIMER, FnLoadLockLeakCheckTimeout, PMState.Idle);
  384. Transition(PMState.LoadLockLeakCheck, MSG.Abort, FnAbortLoadLockLeakCheck, PMState.Idle);
  385. // PM Purge sequence
  386. Transition(PMState.Idle, MSG.CyclePurge, FnStartPurge, PMState.Purging);
  387. Transition(PMState.Purging, FSM_MSG.TIMER, FnPurgeTimeout, PMState.Idle);
  388. Transition(PMState.Purging, MSG.Abort, FnAbortPurge, PMState.Idle);
  389. // PM GasLine Purge sequence
  390. Transition(PMState.Idle, MSG.GasLinePurge, FnStartGasLinePurge, PMState.GasLinePurge);
  391. Transition(PMState.GasLinePurge, FSM_MSG.TIMER, FnGasLinePurgeTimeout, PMState.Idle);
  392. Transition(PMState.GasLinePurge, MSG.Abort, FnAbortGasLinePurge, PMState.Idle);
  393. //PM Leak check sequence
  394. Transition(PMState.Idle, MSG.LeakCheck, FnStartPMLeakCheck, PMState.LeakCheck);
  395. Transition(PMState.LeakCheck, FSM_MSG.TIMER, FnPMLeakCheckTimeout, PMState.Idle);
  396. Transition(PMState.LeakCheck, MSG.Abort, FnAbortPMLeakCheck, PMState.Idle);
  397. //PM GasBox Leak check sequence
  398. Transition(PMState.Idle, MSG.GasLeakCheck, FnStartGasBoxLeakCheck, PMState.GasBoxLeakCheck);
  399. Transition(PMState.GasBoxLeakCheck, FSM_MSG.TIMER, FnGasBoxLeakCheckTimeout, PMState.Idle);
  400. Transition(PMState.GasBoxLeakCheck, MSG.Abort, FnAbortGasBoxLeakCheck, PMState.Idle);
  401. // PlaceWafer from LoadLock Arm sequence
  402. Transition(PMState.Idle, MSG.LLPlace, FnStartLLPlace, PMState.LLPlacing);
  403. Transition(PMState.LLPlacing, FSM_MSG.TIMER, FnLLPlaceTimeout, PMState.Idle);
  404. Transition(PMState.LLPlacing, MSG.Abort, FnAbortLLPlace, PMState.Idle);
  405. // PickWafer to LoadLock Arm sequence
  406. Transition(PMState.Idle, MSG.LLPick, FnStartLLPick, PMState.LLPicking);
  407. Transition(PMState.LLPicking, FSM_MSG.TIMER, FnLLPickTimeout, PMState.Idle);
  408. Transition(PMState.LLPicking, MSG.Abort, FnAbortLLPick, PMState.Idle);
  409. // Process
  410. Transition(PMState.Idle, MSG.RunRecipe, FnRunRecipe, PMState.Processing);
  411. Transition(PMState.Processing, FSM_MSG.TIMER, FnProcessTimeout, PMState.Idle);
  412. Transition(PMState.Processing, MSG.Abort, FnAbortProcess, PMState.Idle);
  413. // Gas Flow sequence
  414. Transition(PMState.Idle, MSG.GasFlow, FnStartGasFlow, PMState.GasFlowing);
  415. Transition(PMState.GasFlowing, MSG.GasFlow, FnAbortGasFlow, PMState.Idle);
  416. Transition(PMState.GasFlowing, FSM_MSG.TIMER, FnGasFlowTimeout, PMState.Idle);
  417. Transition(PMState.GasFlowing, MSG.StopGasFlow, FnStopGasFlow, PMState.Idle);
  418. Transition(PMState.GasFlowing, MSG.Abort, FnAbortGasFlow, PMState.Idle);
  419. //RF Power sequence
  420. Transition(PMState.Idle, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  421. Transition(PMState.GasFlowing, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  422. Transition(PMState.RfPowering, FSM_MSG.TIMER, FnRfPowerTimeout, PMState.Idle);
  423. Transition(PMState.RfPowering, MSG.Abort, FnAbortRfPower, PMState.Idle);
  424. //MFC verification
  425. Transition(PMState.Idle, MSG.MFCVerification, FnStartMFCVerification, PMState.MFCVerification);
  426. Transition(PMState.MFCVerification, FSM_MSG.TIMER, FnMFCVerificationTimeout, PMState.Idle);
  427. Transition(PMState.MFCVerification, MSG.Abort, FnAbortMFCVerification, PMState.Idle);
  428. //////////////////////// Exchange Wafer with TM ///////////////////////////////////////////////////////
  429. // Pick Wafer from PM
  430. Transition(PMState.Idle, MSG.PreparePick, FnStartPreparePick, PMState.PreparePick);
  431. Transition(PMState.PreparePick, MSG.Abort, FnAbortPreparePick, PMState.Idle);
  432. Transition(PMState.PreparePick, FSM_MSG.TIMER, FnPreparePickTimeout, PMState.ReadyForPick);
  433. Transition(PMState.ReadyForPick, MSG.Abort, FnAbortPick, PMState.Idle);
  434. Transition(PMState.ReadyForPick, MSG.DropDownWafer, FnStartDropDownWafer, PMState.DropDownWafer);
  435. Transition(PMState.DropDownWafer, FSM_MSG.TIMER, FnDropDownTimeout, PMState.DropDownReady);
  436. Transition(PMState.DropDownReady, MSG.PickReady, FnStartFinishPick, PMState.FinishPick);
  437. Transition(PMState.FinishPick, FSM_MSG.TIMER, FnFinishPickTimeout, PMState.Idle);
  438. // Place Wafer to PM
  439. Transition(PMState.Idle, MSG.PreparePlace, FnStartPreparePlace, PMState.PreparePlace);
  440. Transition(PMState.PreparePlace, MSG.Abort, FnAbortPreparePlace, PMState.Idle);
  441. Transition(PMState.PreparePlace, FSM_MSG.TIMER, FnPreparePlaceTimeout, PMState.ReadyForPlace);
  442. Transition(PMState.ReadyForPlace, MSG.LiftUpWafer, FnStartLiftUpWafer, PMState.LiftUpWafer);
  443. Transition(PMState.LiftUpWafer, FSM_MSG.TIMER, FnLiftUpTimeout, PMState.LiftUpReady);
  444. Transition(PMState.LiftUpReady, MSG.PlaceReady, FnStartFinishPlace, PMState.FinishPlace);
  445. Transition(PMState.ReadyForPlace, MSG.Abort, FnAortPlace, PMState.Idle);
  446. Transition(PMState.FinishPlace, FSM_MSG.TIMER, FnFinishPlaceTimeout, PMState.Idle);
  447. // Swap Wafer With PM
  448. Transition(PMState.DropDownReady, MSG.PreparePlace, FnStartSwapPlace, PMState.PreparePlace);
  449. Transition(PMState.Idle, MSG.PartialPressure, (a) =>
  450. {
  451. return _pmPartialPressureRoutine.Start(a) == RState.Running;
  452. }, PMState.PartialPressureTesting);
  453. Transition(PMState.PartialPressureTesting, FSM_MSG.TIMER, (a) =>
  454. {
  455. RState ret = _pmPartialPressureRoutine.Monitor();
  456. if (ret == RState.Failed || ret == RState.Timeout)
  457. {
  458. PostMsg(MSG.Error);
  459. return false;
  460. }
  461. return ret == RState.End;
  462. }, PMState.Idle);
  463. Transition(PMState.PartialPressureTesting, MSG.Abort, (a) =>
  464. {
  465. _pmPartialPressureRoutine.Abort();
  466. return true;
  467. }, PMState.Idle);
  468. Transition(PMState.Idle, MSG.VATPerformance, (a) =>
  469. {
  470. return _pmVATPerformanceRoutine.Start(a) == RState.Running;
  471. }, PMState.VATPerformanceTesting);
  472. Transition(PMState.VATPerformanceTesting, FSM_MSG.TIMER, (a) =>
  473. {
  474. RState ret = _pmVATPerformanceRoutine.Monitor();
  475. if (ret == RState.Failed || ret == RState.Timeout)
  476. {
  477. PostMsg(MSG.Error);
  478. return false;
  479. }
  480. return ret == RState.End;
  481. }, PMState.Idle);
  482. Transition(PMState.VATPerformanceTesting, MSG.Abort, (a) =>
  483. {
  484. _pmVATPerformanceRoutine.Abort();
  485. return true;
  486. }, PMState.Idle);
  487. Running = true;
  488. WaferManager.Instance.SubscribeLocation(Module, 1);
  489. //WaferManager.Instance.SubscribeLocation(ModuleName.LLA, 1);
  490. }
  491. protected override bool Init()
  492. {
  493. DATA.Subscribe($"{Module}.FsmState", () => (((PMState)fsm.State).ToString()));
  494. DATA.Subscribe($"{Module}.FsmPrevState", () => (((PMState)fsm.PrevState).ToString()));
  495. DATA.Subscribe($"{Module}.FsmLastMessage", () => (((MSG)fsm.LastMsg).ToString()));
  496. DATA.Subscribe($"{Module}.LoadLockPurge.PurgeCounter", () => _purgeLoadLockRoutine.PurgeCounter);
  497. DATA.Subscribe($"{Module}.PartialPressureCounter", () => _pmPartialPressureRoutine.counter);
  498. DATA.Subscribe($"{Module}.VATPerformanceCounter", () => _pmVATPerformanceRoutine.counter);
  499. DATA.Subscribe($"{Module}.VATPerformanceResult", () => _pmVATPerformanceRoutine?.m_sb.ToString());
  500. DATA.Subscribe($"{Module}.PartialPressureResult", () => _pmPartialPressureRoutine?.m_sb.ToString());
  501. DATA.Subscribe($"{Module}.IsIdle", () => IsIdle);
  502. DATA.Subscribe($"{Module}.IsAlarm", () => IsError);
  503. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy);
  504. DATA.Subscribe($"{Module}.IsInit", () => IsInit);
  505. OP.Subscribe($"{Module}.{RtOperation.GasFlow}", (cmd, args) => CheckToPostMessage((int)MSG.GasFlow, args));
  506. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck, args));
  507. OP.Subscribe($"{Module}.{RtOperation.GasLeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.GasLeakCheck, args));
  508. OP.Subscribe($"{Module}.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  509. OP.Subscribe($"{Module}.{RtOperation.StartPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchPump));
  510. OP.Subscribe($"{Module}.{RtOperation.StartTurboPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchTurboPump));
  511. OP.Subscribe($"{Module}.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  512. OP.Subscribe($"{Module}.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.CyclePurge));
  513. OP.Subscribe($"{Module}.{RtOperation.RfPower}", (cmd, args) => CheckToPostMessage((int)MSG.RfPower));
  514. OP.Subscribe($"{Module}.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  515. OP.Subscribe($"{Module}.{RtOperation.VentLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.VentLoadLock));
  516. OP.Subscribe($"{Module}.{RtOperation.PurgeLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PurgeLoadLock));
  517. OP.Subscribe($"{Module}.{RtOperation.PumpLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PumpLoadLock));
  518. OP.Subscribe($"{Module}.{RtOperation.Reset}", (cmd, args) => CheckToPostMessage((int)MSG.Reset));
  519. OP.Subscribe($"{Module}.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  520. OP.Subscribe($"{Module}.{RtOperation.LLPick}", (cmd, args) => CheckToPostMessage((int)MSG.LLPick));
  521. OP.Subscribe($"{Module}.{RtOperation.LLPlace}", (cmd, args) => CheckToPostMessage((int)MSG.LLPlace));
  522. OP.Subscribe($"{Module}.{RtOperation.MFCVerification}", (cmd, args) => CheckToPostMessage((int)MSG.MFCVerification, args));
  523. OP.Subscribe($"{Module}.{RtOperation.RunRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RunRecipe, args[0]));
  524. OP.Subscribe($"{Module}.PartialPressureTest", (cmd, args) => CheckToPostMessage((int)MSG.PartialPressure, args[0], args[1]));
  525. OP.Subscribe($"{Module}.VATPerformanceTest", (cmd, args) => CheckToPostMessage((int)MSG.VATPerformance, args[0], args[1], args[2]));
  526. OP.Subscribe($"{Module}.GasLinePurge", (cmd, args) => CheckToPostMessage((int)MSG.GasLinePurge));
  527. return true;
  528. }
  529. private bool FnIdle(object[] objs)
  530. {
  531. Running = false;
  532. return true;
  533. }
  534. private bool fEnterError(object[] objs)
  535. {
  536. return true;
  537. }
  538. private bool fnEnterPickReady(object[] objs)
  539. {
  540. Status = PMStatus.Ready_For_Pick;
  541. return true;
  542. }
  543. private bool fnExitPickReady(object[] objs)
  544. {
  545. Status = PMStatus.Not_Ready;
  546. return true;
  547. }
  548. private bool fnEnterPlaceReady(object[] objs)
  549. {
  550. Status = PMStatus.Ready_For_Place;
  551. return true;
  552. }
  553. private bool fnExitPlaceReady(object[] objs)
  554. {
  555. Status = PMStatus.Not_Ready;
  556. return true;
  557. }
  558. private bool fnEnterDropDownReady(object[] objs)
  559. {
  560. Status = PMStatus.Exchange_Ready;
  561. return true;
  562. }
  563. private bool fnExitDropDownReady(object[] objs)
  564. {
  565. Status = PMStatus.Not_Ready;
  566. return true;
  567. }
  568. private bool fnEnterLiftUpReady(object[] objs)
  569. {
  570. Status = PMStatus.Exchange_Ready;
  571. return true;
  572. }
  573. private bool fnExitLiftUpReady(object[] objs)
  574. {
  575. Status = PMStatus.Not_Ready;
  576. return true;
  577. }
  578. private bool FnError(object[] objs)
  579. {
  580. Running = false;
  581. if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  582. || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  583. return false;
  584. if (IsProcessing)
  585. {
  586. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  587. }
  588. return true;
  589. }
  590. private bool FnTimeout(object[] objs)
  591. {
  592. _debugRoutine();
  593. return true;
  594. }
  595. private bool FnIdleTimeout(object[] objs)
  596. {
  597. _chamber.CheckIdleInterlock();
  598. //_debugRoutine();
  599. return true;
  600. }
  601. private bool FnErrorTimeout(object[] objs)
  602. {
  603. //_debugRoutine();
  604. return true;
  605. }
  606. private bool FnStartHome(object[] objs)
  607. {
  608. return _home.Start() == RState.Running;
  609. }
  610. private bool FnMonitorHome(object[] objs)
  611. {
  612. RState ret = _home.Monitor();
  613. if (ret == RState.Failed || ret == RState.Timeout)
  614. {
  615. PostMsg(MSG.Error);
  616. return false;
  617. }
  618. return ret == RState.End;
  619. }
  620. private bool FnLaunchPump(object[] param)
  621. {
  622. return _startDryPumpRoutine.Start() == RState.Running;
  623. }
  624. private bool FnLaunchPumpTimeout(object[] param)
  625. {
  626. RState ret = _startDryPumpRoutine.Monitor();
  627. if (ret == RState.Failed || ret == RState.Timeout)
  628. {
  629. PostMsg(MSG.Error);
  630. return false;
  631. }
  632. return ret == RState.End;
  633. }
  634. private bool FnAbortStartPumping(object[] param)
  635. {
  636. _startDryPumpRoutine.Abort();
  637. return true;
  638. }
  639. private bool FnLaunchTurboPump(object[] param)
  640. {
  641. return _startTurboPumpRoutine.Start() == RState.Running;
  642. }
  643. private bool FnLaunchTurboPumpTimeout(object[] param)
  644. {
  645. RState ret = _startTurboPumpRoutine.Monitor();
  646. if (ret == RState.Failed || ret == RState.Timeout)
  647. {
  648. PostMsg(MSG.Error);
  649. return false;
  650. }
  651. return ret == RState.End;
  652. }
  653. private bool FnAbortStartTurboPumping(object[] param)
  654. {
  655. _startTurboPumpRoutine.Abort();
  656. return true;
  657. }
  658. private bool FnStartVent(object[] param)
  659. {
  660. return _ventRoutine.Start() == RState.Running;
  661. }
  662. private bool FnVentTimeout(object[] param)
  663. {
  664. RState ret = _ventRoutine.Monitor();
  665. if (ret == RState.Failed || ret == RState.Timeout)
  666. {
  667. PostMsg(MSG.Error);
  668. return false;
  669. }
  670. return ret == RState.End;
  671. }
  672. private bool FnVentToPumping(object[] param)
  673. {
  674. _ventRoutine.Abort();
  675. return true; // FnStartPumpDown(param);
  676. }
  677. private bool FnAbortVent(object[] param)
  678. {
  679. _ventRoutine.Abort();
  680. return true;
  681. }
  682. private bool FnStartPumpDown(object[] param)
  683. {
  684. return _pumpRoutine.Start() == RState.Running;
  685. }
  686. private bool FnPumpDownTimeout(object[] param)
  687. {
  688. RState ret = _pumpRoutine.Monitor();
  689. if (ret == RState.Failed || ret == RState.Timeout)
  690. {
  691. PostMsg(MSG.Error);
  692. return false;
  693. }
  694. return ret == RState.End;
  695. }
  696. private bool FnAbortPumping(object[] param)
  697. {
  698. _pumpRoutine.Abort();
  699. return true;
  700. }
  701. private bool FnStartVentLoadlock(object[] param)
  702. {
  703. return _ventLoadLockRoutine.Start() == RState.Running;
  704. }
  705. private bool FnVentLoadLockTimeout(object[] param)
  706. {
  707. RState ret = _ventLoadLockRoutine.Monitor();
  708. if (ret == RState.Failed || ret == RState.Timeout)
  709. {
  710. PostMsg(MSG.Error);
  711. return false;
  712. }
  713. return ret == RState.End;
  714. }
  715. private bool FnVentLoadLockToPumpingLoadLock(object[] param)
  716. {
  717. _ventLoadLockRoutine.Abort();
  718. return FnStartPumpDownLoadLock(param);
  719. }
  720. private bool FnAbortVentLoadLock(object[] param)
  721. {
  722. _ventLoadLockRoutine.Abort();
  723. return true;
  724. }
  725. private bool FnStartPumpDownLoadLock(object[] param)
  726. {
  727. return _pumpLoadLockRoutine.Start() == RState.Running;
  728. }
  729. private bool FnPumpDownLoadLockTimeout(object[] param)
  730. {
  731. RState ret = _pumpLoadLockRoutine.Monitor();
  732. if (ret == RState.Failed || ret == RState.Timeout)
  733. {
  734. PostMsg(MSG.Error);
  735. return false;
  736. }
  737. return ret == RState.End;
  738. }
  739. private bool FnPumpingToVent(object[] param)
  740. {
  741. _pumpRoutine.Abort();
  742. return FnStartVent(param);
  743. }
  744. private bool FnPumpingLoadLockToVentLoadLock(object[] param)
  745. {
  746. _pumpLoadLockRoutine.Abort();
  747. return FnStartVentLoadlock(param);
  748. }
  749. private bool FnAbortPumpingLoadLock(object[] param)
  750. {
  751. _pumpLoadLockRoutine.Abort();
  752. return true;
  753. }
  754. private bool FnStartPurgeLoadlock(object[] param)
  755. {
  756. return _purgeLoadLockRoutine.Start() == RState.Running;
  757. }
  758. private bool FnPurgeLoadLockTimeout(object[] param)
  759. {
  760. RState ret = _purgeLoadLockRoutine.Monitor();
  761. if (ret == RState.Failed || ret == RState.Timeout)
  762. {
  763. PostMsg(MSG.Error);
  764. return false;
  765. }
  766. return ret == RState.End;
  767. }
  768. private bool FnAbortPurgeLoadLock(object[] param)
  769. {
  770. _purgeLoadLockRoutine.Abort();
  771. return true;
  772. }
  773. private bool FnStartLoadLockLeakCheck(object[] param)
  774. {
  775. return _loadLockLeakCheckRoutine.Start() == RState.Running;
  776. }
  777. private bool FnLoadLockLeakCheckTimeout(object[] param)
  778. {
  779. RState ret = _loadLockLeakCheckRoutine.Monitor();
  780. if (ret == RState.Failed || ret == RState.Timeout)
  781. {
  782. PostMsg(MSG.Error);
  783. return false;
  784. }
  785. return ret == RState.End;
  786. }
  787. private bool FnAbortLoadLockLeakCheck(object[] param)
  788. {
  789. _loadLockLeakCheckRoutine.Abort();
  790. return true;
  791. }
  792. private bool FnStartPurge(object[] param)
  793. {
  794. return _purgeRoutine.Start() == RState.Running;
  795. }
  796. private bool FnPurgeTimeout(object[] param)
  797. {
  798. RState ret = _purgeRoutine.Monitor();
  799. if (ret == RState.Failed || ret == RState.Timeout)
  800. {
  801. PostMsg(MSG.Error);
  802. return false;
  803. }
  804. return ret == RState.End;
  805. }
  806. private bool FnAbortPurge(object[] param)
  807. {
  808. _purgeRoutine.Abort();
  809. return true;
  810. }
  811. private bool FnStartGasLinePurge(object[] param)
  812. {
  813. return _gaslinePurgeRoutine.Start() == RState.Running;
  814. }
  815. private bool FnGasLinePurgeTimeout(object[] param)
  816. {
  817. RState ret = _gaslinePurgeRoutine.Monitor();
  818. if (ret == RState.Failed || ret == RState.Timeout)
  819. {
  820. PostMsg(MSG.Error);
  821. return false;
  822. }
  823. return ret == RState.End;
  824. }
  825. private bool FnAbortGasLinePurge(object[] param)
  826. {
  827. _gaslinePurgeRoutine.Abort();
  828. return true;
  829. }
  830. private bool FnStartPMLeakCheck(object[] param)
  831. {
  832. return _leakCheckRoutine.Start(param) == RState.Running;
  833. }
  834. private bool FnPMLeakCheckTimeout(object[] param)
  835. {
  836. RState ret = _leakCheckRoutine.Monitor();
  837. if (ret == RState.Failed || ret == RState.Timeout)
  838. {
  839. PostMsg(MSG.Error);
  840. return false;
  841. }
  842. return ret == RState.End;
  843. }
  844. private bool FnAbortPMLeakCheck(object[] param)
  845. {
  846. _leakCheckRoutine.Abort();
  847. return true;
  848. }
  849. private bool FnStartGasBoxLeakCheck(object[] param)
  850. {
  851. return _gasBoxLeakCheckRoutine.Start(param) == RState.Running;
  852. }
  853. private bool FnGasBoxLeakCheckTimeout(object[] param)
  854. {
  855. RState ret = _gasBoxLeakCheckRoutine.Monitor();
  856. if (ret == RState.Failed || ret == RState.Timeout)
  857. {
  858. PostMsg(MSG.Error);
  859. return false;
  860. }
  861. return ret == RState.End;
  862. }
  863. private bool FnAbortGasBoxLeakCheck(object[] param)
  864. {
  865. _gasBoxLeakCheckRoutine.Abort();
  866. return true;
  867. }
  868. private bool FnStartLLPlace(object[] param)
  869. {
  870. return _llPlaceRoutine.Start() == RState.Running;
  871. }
  872. private bool FnLLPlaceTimeout(object[] param)
  873. {
  874. RState ret = _llPlaceRoutine.Monitor();
  875. if (ret == RState.Failed || ret == RState.Timeout)
  876. {
  877. PostMsg(MSG.Error);
  878. return false;
  879. }
  880. return ret == RState.End;
  881. }
  882. private bool FnAbortLLPlace(object[] param)
  883. {
  884. _llPlaceRoutine.Abort();
  885. return true;
  886. }
  887. private bool FnStartLLPick(object[] param)
  888. {
  889. return _llPickRoutine.Start() == RState.Running;
  890. }
  891. private bool FnLLPickTimeout(object[] param)
  892. {
  893. RState ret = _llPickRoutine.Monitor();
  894. if (ret == RState.Failed || ret == RState.Timeout)
  895. {
  896. PostMsg(MSG.Error);
  897. return false;
  898. }
  899. return ret == RState.End;
  900. }
  901. private bool FnAbortLLPick(object[] param)
  902. {
  903. _llPickRoutine.Abort();
  904. return true;
  905. }
  906. private bool FnRunRecipe(object[] param)
  907. {
  908. return _processRoutine.Start(param) == RState.Running;
  909. }
  910. private bool FnProcessTimeout(object[] param)
  911. {
  912. _chamber.CheckIdleInterlock();
  913. RState ret = _processRoutine.Monitor();
  914. if (ret == RState.Failed || ret == RState.Timeout)
  915. {
  916. PostMsg(MSG.Error);
  917. return false;
  918. }
  919. return ret == RState.End;
  920. }
  921. private bool FnAbortProcess(object[] param)
  922. {
  923. _processRoutine.Abort();
  924. return true;
  925. }
  926. private bool FnStartGasFlow(object[] param)
  927. {
  928. return _gasFlowRoutine.Start(param) == RState.Running;
  929. }
  930. private bool FnGasFlowTimeout(object[] param)
  931. {
  932. RState ret = _gasFlowRoutine.Monitor();
  933. if (ret == RState.Failed || ret == RState.Timeout)
  934. {
  935. PostMsg(MSG.Error);
  936. return false;
  937. }
  938. return ret == RState.End;
  939. }
  940. private bool FnStopGasFlow(object[] param)
  941. {
  942. _gasFlowRoutine.Abort();
  943. return true;
  944. }
  945. private bool FnAbortGasFlow(object[] param)
  946. {
  947. _gasFlowRoutine.Abort();
  948. return true;
  949. }
  950. private bool FnStartRfPower(object[] param)
  951. {
  952. return _rfPowerRoutine.Start(param) == RState.Running;
  953. }
  954. private bool FnRfPowerTimeout(object[] param)
  955. {
  956. RState ret = _rfPowerRoutine.Monitor();
  957. if (ret == RState.Failed || ret == RState.Timeout)
  958. {
  959. PostMsg(MSG.Error);
  960. return false;
  961. }
  962. return ret == RState.End;
  963. }
  964. private bool FnAbortRfPower(object[] param)
  965. {
  966. _rfPowerRoutine.Abort();
  967. if(_gasFlowRoutine._gasStatus)
  968. {
  969. _gasFlowRoutine.StopFlow();
  970. }
  971. return true;
  972. }
  973. private bool FnStartMFCVerification(object[] param)
  974. {
  975. _gasVerificationRoutine.Init((string)param[0], Convert.ToDouble( param[1]), (int)param[2]);
  976. return _gasVerificationRoutine.Start(param) == RState.Running;
  977. }
  978. private bool FnMFCVerificationTimeout(object[] param)
  979. {
  980. RState ret = _gasVerificationRoutine.Monitor();
  981. if (ret == RState.Failed || ret == RState.Timeout)
  982. {
  983. PostMsg(MSG.Error);
  984. return false;
  985. }
  986. return ret == RState.End;
  987. }
  988. private bool FnAbortMFCVerification(object[] param)
  989. {
  990. _gasVerificationRoutine.Abort();
  991. return true;
  992. }
  993. #region Exchange wafer with TM
  994. private bool FnStartPreparePick(object[] param)
  995. {
  996. if(!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  997. {
  998. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Up failed:{reason}");
  999. return false;
  1000. }
  1001. if(!_chamber.SetSlitDoor(true, out reason))
  1002. {
  1003. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Open failed:{reason}");
  1004. return false;
  1005. }
  1006. return true;
  1007. }
  1008. private bool FnPreparePickTimeout(object[] param)
  1009. {
  1010. return _chamber.LiftPinIsUp && IsSlitDoorOpen;
  1011. }
  1012. private bool FnAbortPreparePick(object[] param)
  1013. {
  1014. return true;
  1015. }
  1016. private bool FnStartFinishPick(object[] param)
  1017. {
  1018. if (!_chamber.SetSlitDoor(false, out string reason))
  1019. {
  1020. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1021. return false;
  1022. }
  1023. return true;
  1024. }
  1025. private bool FnAbortPick(object[] param)
  1026. {
  1027. return true;
  1028. }
  1029. private bool FnFinishPickTimeout(object[] param)
  1030. {
  1031. return IsSlitDoorClose;
  1032. }
  1033. private bool FnStartDropDownWafer(object[] param)
  1034. {
  1035. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1036. {
  1037. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1038. return false;
  1039. }
  1040. return _chamber.SetLiftPin(MovementPosition.Down, out string _);
  1041. }
  1042. private bool FnDropDownTimeout(object[] param)
  1043. {
  1044. return _chamber.LiftPinIsDown;
  1045. }
  1046. private bool FnStartPreparePlace(object[] param)
  1047. {
  1048. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1049. {
  1050. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin down failed:{reason}");
  1051. return false;
  1052. }
  1053. if (!_chamber.SetSlitDoor(true, out reason))
  1054. {
  1055. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Open failed:{reason}");
  1056. return false;
  1057. }
  1058. return true;
  1059. }
  1060. private bool FnPreparePlaceTimeout(object[] param)
  1061. {
  1062. return _chamber.LiftPinIsDown && IsSlitDoorOpen;
  1063. }
  1064. private bool FnAbortPreparePlace(object[] param)
  1065. {
  1066. return true;
  1067. }
  1068. private bool FnStartLiftUpWafer(object[] param)
  1069. {
  1070. if (!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  1071. {
  1072. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Up failed:{reason}");
  1073. return false;
  1074. }
  1075. return true;
  1076. }
  1077. private bool FnLiftUpTimeout(object[] param)
  1078. {
  1079. return _chamber.LiftPinIsUp;
  1080. }
  1081. private bool FnStartFinishPlace(object[] param)
  1082. {
  1083. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1084. {
  1085. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1086. return false;
  1087. }
  1088. if (!_chamber.SetSlitDoor(false, out reason))
  1089. {
  1090. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1091. return false;
  1092. }
  1093. return true;
  1094. }
  1095. private bool FnAortPlace(object[] param)
  1096. {
  1097. return true;
  1098. }
  1099. private bool FnFinishPlaceTimeout(object[] param)
  1100. {
  1101. return _chamber.LiftPinIsDown && IsSlitDoorClose;
  1102. }
  1103. private bool FnStartSwapPlace(object[] param)
  1104. {
  1105. return true;
  1106. }
  1107. #endregion
  1108. private void _debugRoutine()
  1109. {
  1110. int flag = 0;
  1111. // Test Home routine
  1112. if (flag == 1)
  1113. {
  1114. PostMsg(MSG.Home);
  1115. }
  1116. else if (flag == 2)
  1117. {
  1118. PostMsg(MSG.Vent);
  1119. }
  1120. else if (flag == 3)
  1121. {
  1122. PostMsg(MSG.Pump);
  1123. }
  1124. else if(flag == 4)
  1125. {
  1126. PostMsg(MSG.PumpLoadLock);
  1127. }
  1128. else if(flag == 5)
  1129. {
  1130. PostMsg(MSG.VentLoadLock);
  1131. }
  1132. else if(flag == 6)
  1133. {
  1134. PostMsg(MSG.PurgeLoadLock);
  1135. }
  1136. else if(flag == 7)
  1137. {
  1138. PostMsg(MSG.LaunchPump);
  1139. }
  1140. else if(flag == 8)
  1141. {
  1142. PostMsg(MSG.LaunchTurboPump);
  1143. }
  1144. else if(flag == 9)
  1145. {
  1146. PostMsg(MSG.LoadLockLeakCheck);
  1147. }
  1148. else if(flag == 10)
  1149. {
  1150. PostMsg(MSG.CyclePurge);
  1151. }
  1152. else if(flag == 11)
  1153. {
  1154. PostMsg(MSG.GasLinePurge);
  1155. }
  1156. else if(flag == 12)
  1157. {
  1158. PostMsg(MSG.LeakCheck);
  1159. }
  1160. else if(flag == 13)
  1161. {
  1162. PostMsg(MSG.GasLeakCheck);
  1163. }
  1164. else if(flag == 14)
  1165. {
  1166. PostMsg(MSG.LLPlace);
  1167. }
  1168. else if(flag == 15)
  1169. {
  1170. PostMsg(MSG.LLPick);
  1171. }
  1172. else if(flag == 16)
  1173. {
  1174. PostMsg(MSG.RunRecipe, "7777");
  1175. }
  1176. else if(flag == 17)
  1177. {
  1178. PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  1179. }
  1180. }
  1181. }
  1182. }