PMEntity.cs 54 KB

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