PMEntity.cs 51 KB

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