PMEntity.cs 58 KB

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