PMEntity.cs 57 KB

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