PMEntity.cs 54 KB

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