PMEntity.cs 58 KB

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