PMEntity.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  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 JetPMBase _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<JetPMBase>(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. }
  490. protected override bool Init()
  491. {
  492. DATA.Subscribe($"{Module}.FsmState", () => (((PMState)fsm.State)));
  493. DATA.Subscribe($"{Module}.FsmPrevState", () => (((PMState)fsm.PrevState).ToString()));
  494. DATA.Subscribe($"{Module}.FsmLastMessage", () => (((MSG)fsm.LastMsg).ToString()));
  495. DATA.Subscribe($"{Module}.LoadLockPurge.PurgeCounter", () => _purgeLoadLockRoutine.PurgeCounter);
  496. DATA.Subscribe($"{Module}.PartialPressureCounter", () => _pmPartialPressureRoutine.counter);
  497. DATA.Subscribe($"{Module}.VATPerformanceCounter", () => _pmVATPerformanceRoutine.counter);
  498. DATA.Subscribe($"{Module}.VATPerformanceResult", () => _pmVATPerformanceRoutine?.m_sb.ToString());
  499. DATA.Subscribe($"{Module}.PartialPressureResult", () => _pmPartialPressureRoutine?.m_sb.ToString());
  500. DATA.Subscribe($"{Module}.IsIdle", () => IsIdle);
  501. DATA.Subscribe($"{Module}.IsAlarm", () => IsError);
  502. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy);
  503. DATA.Subscribe($"{Module}.IsInit", () => IsInit);
  504. DATA.Subscribe($"{Module}.CurrentRecipeResult", () => _processRoutine.currentRecipeResult);
  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. OP.Subscribe($"{Module}.ManualEndStep", (cmd, args) => ManualEndStep() );
  528. return true;
  529. }
  530. private bool ManualEndStep()
  531. {
  532. _processRoutine.isMaualEndStep = true;
  533. return true;
  534. }
  535. private bool FnIdle(object[] objs)
  536. {
  537. Running = false;
  538. return true;
  539. }
  540. private bool fEnterError(object[] objs)
  541. {
  542. return true;
  543. }
  544. private bool fnEnterPickReady(object[] objs)
  545. {
  546. Status = PMStatus.Ready_For_Pick;
  547. return true;
  548. }
  549. private bool fnExitPickReady(object[] objs)
  550. {
  551. Status = PMStatus.Not_Ready;
  552. return true;
  553. }
  554. private bool fnEnterPlaceReady(object[] objs)
  555. {
  556. Status = PMStatus.Ready_For_Place;
  557. return true;
  558. }
  559. private bool fnExitPlaceReady(object[] objs)
  560. {
  561. Status = PMStatus.Not_Ready;
  562. return true;
  563. }
  564. private bool fnEnterDropDownReady(object[] objs)
  565. {
  566. Status = PMStatus.Exchange_Ready;
  567. return true;
  568. }
  569. private bool fnExitDropDownReady(object[] objs)
  570. {
  571. Status = PMStatus.Not_Ready;
  572. return true;
  573. }
  574. private bool fnEnterLiftUpReady(object[] objs)
  575. {
  576. Status = PMStatus.Exchange_Ready;
  577. return true;
  578. }
  579. private bool fnExitLiftUpReady(object[] objs)
  580. {
  581. Status = PMStatus.Not_Ready;
  582. return true;
  583. }
  584. private bool FnError(object[] objs)
  585. {
  586. Running = false;
  587. //if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  588. // || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  589. // return false;
  590. _chamber.CloseValves();
  591. _chamber.GeneratorPowerOn(false);
  592. _chamber.GeneratorBiasPowerOn(false);
  593. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  594. _chamber.OpenValve(ValveType.TurboPumpPurge, true);
  595. if (IsProcessing)
  596. {
  597. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  598. }
  599. return true;
  600. }
  601. private bool FnTimeout(object[] objs)
  602. {
  603. _debugRoutine();
  604. return true;
  605. }
  606. private bool FnIdleTimeout(object[] objs)
  607. {
  608. _chamber.CheckIdleInterlock();
  609. //_debugRoutine();
  610. return true;
  611. }
  612. private bool FnErrorTimeout(object[] objs)
  613. {
  614. //_debugRoutine();
  615. return true;
  616. }
  617. private bool FnStartHome(object[] objs)
  618. {
  619. return _home.Start() == RState.Running;
  620. }
  621. private bool FnMonitorHome(object[] objs)
  622. {
  623. RState ret = _home.Monitor();
  624. if (ret == RState.Failed || ret == RState.Timeout)
  625. {
  626. PostMsg(MSG.Error);
  627. return false;
  628. }
  629. return ret == RState.End;
  630. }
  631. private bool FnLaunchPump(object[] param)
  632. {
  633. return _startDryPumpRoutine.Start() == RState.Running;
  634. }
  635. private bool FnLaunchPumpTimeout(object[] param)
  636. {
  637. RState ret = _startDryPumpRoutine.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 FnAbortStartPumping(object[] param)
  646. {
  647. _startDryPumpRoutine.Abort();
  648. return true;
  649. }
  650. private bool FnLaunchTurboPump(object[] param)
  651. {
  652. return _startTurboPumpRoutine.Start() == RState.Running;
  653. }
  654. private bool FnLaunchTurboPumpTimeout(object[] param)
  655. {
  656. RState ret = _startTurboPumpRoutine.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 FnAbortStartTurboPumping(object[] param)
  665. {
  666. _startTurboPumpRoutine.Abort();
  667. return true;
  668. }
  669. private bool FnStartVent(object[] param)
  670. {
  671. return _ventRoutine.Start() == RState.Running;
  672. }
  673. private bool FnVentTimeout(object[] param)
  674. {
  675. RState ret = _ventRoutine.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 FnVentToPumping(object[] param)
  684. {
  685. _ventRoutine.Abort();
  686. return true; // FnStartPumpDown(param);
  687. }
  688. private bool FnAbortVent(object[] param)
  689. {
  690. _ventRoutine.Abort();
  691. return true;
  692. }
  693. private bool FnStartPumpDown(object[] param)
  694. {
  695. return _pumpRoutine.Start() == RState.Running;
  696. }
  697. private bool FnPumpDownTimeout(object[] param)
  698. {
  699. RState ret = _pumpRoutine.Monitor();
  700. if (ret == RState.Failed || ret == RState.Timeout)
  701. {
  702. PostMsg(MSG.Error);
  703. return false;
  704. }
  705. return ret == RState.End;
  706. }
  707. private bool FnAbortPumping(object[] param)
  708. {
  709. _pumpRoutine.Abort();
  710. return true;
  711. }
  712. private bool FnStartVentLoadlock(object[] param)
  713. {
  714. return _ventLoadLockRoutine.Start() == RState.Running;
  715. }
  716. private bool FnVentLoadLockTimeout(object[] param)
  717. {
  718. RState ret = _ventLoadLockRoutine.Monitor();
  719. if (ret == RState.Failed || ret == RState.Timeout)
  720. {
  721. PostMsg(MSG.Error);
  722. return false;
  723. }
  724. return ret == RState.End;
  725. }
  726. private bool FnVentLoadLockToPumpingLoadLock(object[] param)
  727. {
  728. _ventLoadLockRoutine.Abort();
  729. return FnStartPumpDownLoadLock(param);
  730. }
  731. private bool FnAbortVentLoadLock(object[] param)
  732. {
  733. _ventLoadLockRoutine.Abort();
  734. return true;
  735. }
  736. private bool FnStartPumpDownLoadLock(object[] param)
  737. {
  738. return _pumpLoadLockRoutine.Start() == RState.Running;
  739. }
  740. private bool FnPumpDownLoadLockTimeout(object[] param)
  741. {
  742. RState ret = _pumpLoadLockRoutine.Monitor();
  743. if (ret == RState.Failed || ret == RState.Timeout)
  744. {
  745. PostMsg(MSG.Error);
  746. return false;
  747. }
  748. return ret == RState.End;
  749. }
  750. private bool FnPumpingToVent(object[] param)
  751. {
  752. _pumpRoutine.Abort();
  753. return FnStartVent(param);
  754. }
  755. private bool FnPumpingLoadLockToVentLoadLock(object[] param)
  756. {
  757. _pumpLoadLockRoutine.Abort();
  758. return FnStartVentLoadlock(param);
  759. }
  760. private bool FnAbortPumpingLoadLock(object[] param)
  761. {
  762. _pumpLoadLockRoutine.Abort();
  763. return true;
  764. }
  765. private bool FnStartPurgeLoadlock(object[] param)
  766. {
  767. return _purgeLoadLockRoutine.Start() == RState.Running;
  768. }
  769. private bool FnPurgeLoadLockTimeout(object[] param)
  770. {
  771. RState ret = _purgeLoadLockRoutine.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 FnAbortPurgeLoadLock(object[] param)
  780. {
  781. _purgeLoadLockRoutine.Abort();
  782. return true;
  783. }
  784. private bool FnStartLoadLockLeakCheck(object[] param)
  785. {
  786. return _loadLockLeakCheckRoutine.Start() == RState.Running;
  787. }
  788. private bool FnLoadLockLeakCheckTimeout(object[] param)
  789. {
  790. RState ret = _loadLockLeakCheckRoutine.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 FnAbortLoadLockLeakCheck(object[] param)
  799. {
  800. _loadLockLeakCheckRoutine.Abort();
  801. return true;
  802. }
  803. private bool FnStartPurge(object[] param)
  804. {
  805. return _purgeRoutine.Start() == RState.Running;
  806. }
  807. private bool FnPurgeTimeout(object[] param)
  808. {
  809. RState ret = _purgeRoutine.Monitor();
  810. if (ret == RState.Failed || ret == RState.Timeout)
  811. {
  812. PostMsg(MSG.Error);
  813. return false;
  814. }
  815. return ret == RState.End;
  816. }
  817. private bool FnAbortPurge(object[] param)
  818. {
  819. _purgeRoutine.Abort();
  820. return true;
  821. }
  822. private bool FnStartGasLinePurge(object[] param)
  823. {
  824. return _gaslinePurgeRoutine.Start() == RState.Running;
  825. }
  826. private bool FnGasLinePurgeTimeout(object[] param)
  827. {
  828. RState ret = _gaslinePurgeRoutine.Monitor();
  829. if (ret == RState.Failed || ret == RState.Timeout)
  830. {
  831. PostMsg(MSG.Error);
  832. return false;
  833. }
  834. return ret == RState.End;
  835. }
  836. private bool FnAbortGasLinePurge(object[] param)
  837. {
  838. _gaslinePurgeRoutine.Abort();
  839. return true;
  840. }
  841. private bool FnStartPMLeakCheck(object[] param)
  842. {
  843. return _leakCheckRoutine.Start(param) == RState.Running;
  844. }
  845. private bool FnPMLeakCheckTimeout(object[] param)
  846. {
  847. RState ret = _leakCheckRoutine.Monitor();
  848. if (ret == RState.Failed || ret == RState.Timeout)
  849. {
  850. PostMsg(MSG.Error);
  851. return false;
  852. }
  853. return ret == RState.End;
  854. }
  855. private bool FnAbortPMLeakCheck(object[] param)
  856. {
  857. _leakCheckRoutine.Abort();
  858. return true;
  859. }
  860. private bool FnStartGasBoxLeakCheck(object[] param)
  861. {
  862. return _gasBoxLeakCheckRoutine.Start(param) == RState.Running;
  863. }
  864. private bool FnGasBoxLeakCheckTimeout(object[] param)
  865. {
  866. RState ret = _gasBoxLeakCheckRoutine.Monitor();
  867. if (ret == RState.Failed || ret == RState.Timeout)
  868. {
  869. PostMsg(MSG.Error);
  870. return false;
  871. }
  872. return ret == RState.End;
  873. }
  874. private bool FnAbortGasBoxLeakCheck(object[] param)
  875. {
  876. _gasBoxLeakCheckRoutine.Abort();
  877. return true;
  878. }
  879. private bool FnStartLLPlace(object[] param)
  880. {
  881. return _llPlaceRoutine.Start() == RState.Running;
  882. }
  883. private bool FnLLPlaceTimeout(object[] param)
  884. {
  885. RState ret = _llPlaceRoutine.Monitor();
  886. if (ret == RState.Failed || ret == RState.Timeout)
  887. {
  888. PostMsg(MSG.Error);
  889. return false;
  890. }
  891. return ret == RState.End;
  892. }
  893. private bool FnAbortLLPlace(object[] param)
  894. {
  895. _llPlaceRoutine.Abort();
  896. return true;
  897. }
  898. private bool FnStartLLPick(object[] param)
  899. {
  900. return _llPickRoutine.Start() == RState.Running;
  901. }
  902. private bool FnLLPickTimeout(object[] param)
  903. {
  904. RState ret = _llPickRoutine.Monitor();
  905. if (ret == RState.Failed || ret == RState.Timeout)
  906. {
  907. PostMsg(MSG.Error);
  908. return false;
  909. }
  910. return ret == RState.End;
  911. }
  912. private bool FnAbortLLPick(object[] param)
  913. {
  914. _llPickRoutine.Abort();
  915. return true;
  916. }
  917. private bool FnRunRecipe(object[] param)
  918. {
  919. //if(_processRoutine.Start(param) == RState.Running)
  920. return _processRoutine.Start(param) == RState.Running;
  921. }
  922. private bool FnProcessTimeout(object[] param)
  923. {
  924. _chamber.CheckIdleInterlock();
  925. RState ret = _processRoutine.Monitor();
  926. if (ret == RState.Failed || ret == RState.Timeout)
  927. {
  928. PostMsg(MSG.Error);
  929. return false;
  930. }
  931. return ret == RState.End;
  932. }
  933. private bool FnAbortProcess(object[] param)
  934. {
  935. _processRoutine.Abort();
  936. return true;
  937. }
  938. private bool FnStartGasFlow(object[] param)
  939. {
  940. return _gasFlowRoutine.Start(param) == RState.Running;
  941. }
  942. private bool FnGasFlowTimeout(object[] param)
  943. {
  944. RState ret = _gasFlowRoutine.Monitor();
  945. if (ret == RState.Failed || ret == RState.Timeout)
  946. {
  947. PostMsg(MSG.Error);
  948. return false;
  949. }
  950. return ret == RState.End;
  951. }
  952. private bool FnStopGasFlow(object[] param)
  953. {
  954. _gasFlowRoutine.Abort();
  955. return true;
  956. }
  957. private bool FnAbortGasFlow(object[] param)
  958. {
  959. _gasFlowRoutine.Abort();
  960. return true;
  961. }
  962. private bool FnStartRfPower(object[] param)
  963. {
  964. return _rfPowerRoutine.Start(param) == RState.Running;
  965. }
  966. private bool FnRfPowerTimeout(object[] param)
  967. {
  968. RState ret = _rfPowerRoutine.Monitor();
  969. if (ret == RState.Failed || ret == RState.Timeout)
  970. {
  971. PostMsg(MSG.Error);
  972. return false;
  973. }
  974. return ret == RState.End;
  975. }
  976. private bool FnAbortRfPower(object[] param)
  977. {
  978. _rfPowerRoutine.Abort();
  979. if(_gasFlowRoutine._gasStatus)
  980. {
  981. _gasFlowRoutine.StopFlow();
  982. }
  983. return true;
  984. }
  985. private bool FnStartMFCVerification(object[] param)
  986. {
  987. _gasVerificationRoutine.Init((string)param[0], Convert.ToDouble( param[1]), (int)param[2]);
  988. return _gasVerificationRoutine.Start(param) == RState.Running;
  989. }
  990. private bool FnMFCVerificationTimeout(object[] param)
  991. {
  992. RState ret = _gasVerificationRoutine.Monitor();
  993. if (ret == RState.Failed || ret == RState.Timeout)
  994. {
  995. PostMsg(MSG.Error);
  996. return false;
  997. }
  998. return ret == RState.End;
  999. }
  1000. private bool FnAbortMFCVerification(object[] param)
  1001. {
  1002. _gasVerificationRoutine.Abort();
  1003. return true;
  1004. }
  1005. #region Exchange wafer with TM
  1006. private bool FnStartPreparePick(object[] param)
  1007. {
  1008. if(!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  1009. {
  1010. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Up failed:{reason}");
  1011. return false;
  1012. }
  1013. if(!_chamber.SetSlitDoor(true, out reason))
  1014. {
  1015. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Open failed:{reason}");
  1016. return false;
  1017. }
  1018. return true;
  1019. }
  1020. private bool FnPreparePickTimeout(object[] param)
  1021. {
  1022. return _chamber.LiftPinIsUp && IsSlitDoorOpen;
  1023. }
  1024. private bool FnAbortPreparePick(object[] param)
  1025. {
  1026. return true;
  1027. }
  1028. private bool FnStartFinishPick(object[] param)
  1029. {
  1030. if (!_chamber.SetSlitDoor(false, out string reason))
  1031. {
  1032. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1033. return false;
  1034. }
  1035. return true;
  1036. }
  1037. private bool FnAbortPick(object[] param)
  1038. {
  1039. return true;
  1040. }
  1041. private bool FnFinishPickTimeout(object[] param)
  1042. {
  1043. return IsSlitDoorClose;
  1044. }
  1045. private bool FnStartDropDownWafer(object[] param)
  1046. {
  1047. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1048. {
  1049. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1050. return false;
  1051. }
  1052. return _chamber.SetLiftPin(MovementPosition.Down, out string _);
  1053. }
  1054. private bool FnDropDownTimeout(object[] param)
  1055. {
  1056. return _chamber.LiftPinIsDown;
  1057. }
  1058. private bool FnStartPreparePlace(object[] param)
  1059. {
  1060. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1061. {
  1062. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin down failed:{reason}");
  1063. return false;
  1064. }
  1065. if (!_chamber.SetSlitDoor(true, out reason))
  1066. {
  1067. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Open failed:{reason}");
  1068. return false;
  1069. }
  1070. return true;
  1071. }
  1072. private bool FnPreparePlaceTimeout(object[] param)
  1073. {
  1074. return _chamber.LiftPinIsDown && IsSlitDoorOpen;
  1075. }
  1076. private bool FnAbortPreparePlace(object[] param)
  1077. {
  1078. return true;
  1079. }
  1080. private bool FnStartLiftUpWafer(object[] param)
  1081. {
  1082. if (!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  1083. {
  1084. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Up failed:{reason}");
  1085. return false;
  1086. }
  1087. return true;
  1088. }
  1089. private bool FnLiftUpTimeout(object[] param)
  1090. {
  1091. return _chamber.LiftPinIsUp;
  1092. }
  1093. private bool FnStartFinishPlace(object[] param)
  1094. {
  1095. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1096. {
  1097. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1098. return false;
  1099. }
  1100. if (!_chamber.SetSlitDoor(false, out reason))
  1101. {
  1102. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1103. return false;
  1104. }
  1105. return true;
  1106. }
  1107. private bool FnAortPlace(object[] param)
  1108. {
  1109. return true;
  1110. }
  1111. private bool FnFinishPlaceTimeout(object[] param)
  1112. {
  1113. return _chamber.LiftPinIsDown && IsSlitDoorClose;
  1114. }
  1115. private bool FnStartSwapPlace(object[] param)
  1116. {
  1117. return true;
  1118. }
  1119. #endregion
  1120. private void _debugRoutine()
  1121. {
  1122. int flag = 0;
  1123. // Test Home routine
  1124. if (flag == 1)
  1125. {
  1126. PostMsg(MSG.Home);
  1127. }
  1128. else if (flag == 2)
  1129. {
  1130. PostMsg(MSG.Vent);
  1131. }
  1132. else if (flag == 3)
  1133. {
  1134. PostMsg(MSG.Pump);
  1135. }
  1136. else if(flag == 4)
  1137. {
  1138. PostMsg(MSG.PumpLoadLock);
  1139. }
  1140. else if(flag == 5)
  1141. {
  1142. PostMsg(MSG.VentLoadLock);
  1143. }
  1144. else if(flag == 6)
  1145. {
  1146. PostMsg(MSG.PurgeLoadLock);
  1147. }
  1148. else if(flag == 7)
  1149. {
  1150. PostMsg(MSG.LaunchPump);
  1151. }
  1152. else if(flag == 8)
  1153. {
  1154. PostMsg(MSG.LaunchTurboPump);
  1155. }
  1156. else if(flag == 9)
  1157. {
  1158. PostMsg(MSG.LoadLockLeakCheck);
  1159. }
  1160. else if(flag == 10)
  1161. {
  1162. PostMsg(MSG.CyclePurge);
  1163. }
  1164. else if(flag == 11)
  1165. {
  1166. PostMsg(MSG.GasLinePurge);
  1167. }
  1168. else if(flag == 12)
  1169. {
  1170. PostMsg(MSG.LeakCheck);
  1171. }
  1172. else if(flag == 13)
  1173. {
  1174. PostMsg(MSG.GasLeakCheck);
  1175. }
  1176. else if(flag == 14)
  1177. {
  1178. PostMsg(MSG.LLPlace);
  1179. }
  1180. else if(flag == 15)
  1181. {
  1182. PostMsg(MSG.LLPick);
  1183. }
  1184. else if(flag == 16)
  1185. {
  1186. PostMsg(MSG.RunRecipe, "7777");
  1187. }
  1188. else if(flag == 17)
  1189. {
  1190. PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  1191. }
  1192. }
  1193. }
  1194. }