PMEntity.cs 54 KB

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