PMEntity.cs 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  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 JetPM _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<JetPM>(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);
  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. //WaferManager.Instance.SubscribeLocation(ModuleName.LLA, 1);
  490. }
  491. protected override bool Init()
  492. {
  493. DATA.Subscribe($"{Module}.FsmState", () => (((PMState)fsm.State).ToString()));
  494. DATA.Subscribe($"{Module}.FsmPrevState", () => (((PMState)fsm.PrevState).ToString()));
  495. DATA.Subscribe($"{Module}.FsmLastMessage", () => (((MSG)fsm.LastMsg).ToString()));
  496. DATA.Subscribe($"{Module}.LoadLockPurge.PurgeCounter", () => _purgeLoadLockRoutine.PurgeCounter);
  497. DATA.Subscribe($"{Module}.PartialPressureCounter", () => _pmPartialPressureRoutine.counter);
  498. DATA.Subscribe($"{Module}.VATPerformanceCounter", () => _pmVATPerformanceRoutine.counter);
  499. DATA.Subscribe($"{Module}.IsIdle", () => IsIdle);
  500. DATA.Subscribe($"{Module}.IsAlarm", () => IsError);
  501. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy);
  502. DATA.Subscribe($"{Module}.IsInit", () => IsInit);
  503. OP.Subscribe($"{Module}.{RtOperation.GasFlow}", (cmd, args) => CheckToPostMessage((int)MSG.GasFlow, args));
  504. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck, args));
  505. OP.Subscribe($"{Module}.{RtOperation.GasLeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.GasLeakCheck, args));
  506. OP.Subscribe($"{Module}.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  507. OP.Subscribe($"{Module}.{RtOperation.StartPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchPump));
  508. OP.Subscribe($"{Module}.{RtOperation.StartTurboPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchTurboPump));
  509. OP.Subscribe($"{Module}.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  510. OP.Subscribe($"{Module}.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.CyclePurge));
  511. OP.Subscribe($"{Module}.{RtOperation.RfPower}", (cmd, args) => CheckToPostMessage((int)MSG.RfPower));
  512. OP.Subscribe($"{Module}.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  513. OP.Subscribe($"{Module}.{RtOperation.VentLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.VentLoadLock));
  514. OP.Subscribe($"{Module}.{RtOperation.PurgeLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PurgeLoadLock));
  515. OP.Subscribe($"{Module}.{RtOperation.PumpLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PumpLoadLock));
  516. OP.Subscribe($"{Module}.{RtOperation.Reset}", (cmd, args) => CheckToPostMessage((int)MSG.Reset));
  517. OP.Subscribe($"{Module}.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  518. OP.Subscribe($"{Module}.{RtOperation.LLPick}", (cmd, args) => CheckToPostMessage((int)MSG.LLPick));
  519. OP.Subscribe($"{Module}.{RtOperation.LLPlace}", (cmd, args) => CheckToPostMessage((int)MSG.LLPlace));
  520. OP.Subscribe($"{Module}.{RtOperation.MFCVerification}", (cmd, args) => CheckToPostMessage((int)MSG.MFCVerification, args));
  521. OP.Subscribe($"{Module}.{RtOperation.RunRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RunRecipe, args[0]));
  522. OP.Subscribe($"{Module}.PartialPressureTest", (cmd, args) => CheckToPostMessage((int)MSG.PartialPressure, args[0], args[1]));
  523. OP.Subscribe($"{Module}.VATPerformanceTest", (cmd, args) => CheckToPostMessage((int)MSG.VATPerformance, args[0], args[1], args[2]));
  524. return true;
  525. }
  526. private bool FnIdle(object[] objs)
  527. {
  528. Running = false;
  529. return true;
  530. }
  531. private bool fEnterError(object[] objs)
  532. {
  533. return true;
  534. }
  535. private bool fnEnterPickReady(object[] objs)
  536. {
  537. Status = PMStatus.Ready_For_Pick;
  538. return true;
  539. }
  540. private bool fnExitPickReady(object[] objs)
  541. {
  542. Status = PMStatus.Not_Ready;
  543. return true;
  544. }
  545. private bool fnEnterPlaceReady(object[] objs)
  546. {
  547. Status = PMStatus.Ready_For_Place;
  548. return true;
  549. }
  550. private bool fnExitPlaceReady(object[] objs)
  551. {
  552. Status = PMStatus.Not_Ready;
  553. return true;
  554. }
  555. private bool fnEnterDropDownReady(object[] objs)
  556. {
  557. Status = PMStatus.Exchange_Ready;
  558. return true;
  559. }
  560. private bool fnExitDropDownReady(object[] objs)
  561. {
  562. Status = PMStatus.Not_Ready;
  563. return true;
  564. }
  565. private bool fnEnterLiftUpReady(object[] objs)
  566. {
  567. Status = PMStatus.Exchange_Ready;
  568. return true;
  569. }
  570. private bool fnExitLiftUpReady(object[] objs)
  571. {
  572. Status = PMStatus.Not_Ready;
  573. return true;
  574. }
  575. private bool FnError(object[] objs)
  576. {
  577. Running = false;
  578. if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  579. || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  580. return false;
  581. if (IsProcessing)
  582. {
  583. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  584. }
  585. return true;
  586. }
  587. private bool FnTimeout(object[] objs)
  588. {
  589. _debugRoutine();
  590. return true;
  591. }
  592. private bool FnIdleTimeout(object[] objs)
  593. {
  594. _chamber.CheckIdleInterlock();
  595. //_debugRoutine();
  596. return true;
  597. }
  598. private bool FnErrorTimeout(object[] objs)
  599. {
  600. //_debugRoutine();
  601. return true;
  602. }
  603. private bool FnStartHome(object[] objs)
  604. {
  605. return _home.Start() == RState.Running;
  606. }
  607. private bool FnMonitorHome(object[] objs)
  608. {
  609. RState ret = _home.Monitor();
  610. if (ret == RState.Failed || ret == RState.Timeout)
  611. {
  612. PostMsg(MSG.Error);
  613. return false;
  614. }
  615. return ret == RState.End;
  616. }
  617. private bool FnLaunchPump(object[] param)
  618. {
  619. return _startDryPumpRoutine.Start() == RState.Running;
  620. }
  621. private bool FnLaunchPumpTimeout(object[] param)
  622. {
  623. RState ret = _startDryPumpRoutine.Monitor();
  624. if (ret == RState.Failed || ret == RState.Timeout)
  625. {
  626. PostMsg(MSG.Error);
  627. return false;
  628. }
  629. return ret == RState.End;
  630. }
  631. private bool FnAbortStartPumping(object[] param)
  632. {
  633. _startDryPumpRoutine.Abort();
  634. return true;
  635. }
  636. private bool FnLaunchTurboPump(object[] param)
  637. {
  638. return _startTurboPumpRoutine.Start() == RState.Running;
  639. }
  640. private bool FnLaunchTurboPumpTimeout(object[] param)
  641. {
  642. RState ret = _startTurboPumpRoutine.Monitor();
  643. if (ret == RState.Failed || ret == RState.Timeout)
  644. {
  645. PostMsg(MSG.Error);
  646. return false;
  647. }
  648. return ret == RState.End;
  649. }
  650. private bool FnAbortStartTurboPumping(object[] param)
  651. {
  652. _startTurboPumpRoutine.Abort();
  653. return true;
  654. }
  655. private bool FnStartVent(object[] param)
  656. {
  657. return _ventRoutine.Start() == RState.Running;
  658. }
  659. private bool FnVentTimeout(object[] param)
  660. {
  661. RState ret = _ventRoutine.Monitor();
  662. if (ret == RState.Failed || ret == RState.Timeout)
  663. {
  664. PostMsg(MSG.Error);
  665. return false;
  666. }
  667. return ret == RState.End;
  668. }
  669. private bool FnVentToPumping(object[] param)
  670. {
  671. _ventRoutine.Abort();
  672. return true; // FnStartPumpDown(param);
  673. }
  674. private bool FnAbortVent(object[] param)
  675. {
  676. _ventRoutine.Abort();
  677. return true;
  678. }
  679. private bool FnStartPumpDown(object[] param)
  680. {
  681. return _pumpRoutine.Start() == RState.Running;
  682. }
  683. private bool FnPumpDownTimeout(object[] param)
  684. {
  685. RState ret = _pumpRoutine.Monitor();
  686. if (ret == RState.Failed || ret == RState.Timeout)
  687. {
  688. PostMsg(MSG.Error);
  689. return false;
  690. }
  691. return ret == RState.End;
  692. }
  693. private bool FnAbortPumping(object[] param)
  694. {
  695. _pumpRoutine.Abort();
  696. return true;
  697. }
  698. private bool FnStartVentLoadlock(object[] param)
  699. {
  700. return _ventLoadLockRoutine.Start() == RState.Running;
  701. }
  702. private bool FnVentLoadLockTimeout(object[] param)
  703. {
  704. RState ret = _ventLoadLockRoutine.Monitor();
  705. if (ret == RState.Failed || ret == RState.Timeout)
  706. {
  707. PostMsg(MSG.Error);
  708. return false;
  709. }
  710. return ret == RState.End;
  711. }
  712. private bool FnVentLoadLockToPumpingLoadLock(object[] param)
  713. {
  714. _ventLoadLockRoutine.Abort();
  715. return FnStartPumpDownLoadLock(param);
  716. }
  717. private bool FnAbortVentLoadLock(object[] param)
  718. {
  719. _ventLoadLockRoutine.Abort();
  720. return true;
  721. }
  722. private bool FnStartPumpDownLoadLock(object[] param)
  723. {
  724. return _pumpLoadLockRoutine.Start() == RState.Running;
  725. }
  726. private bool FnPumpDownLoadLockTimeout(object[] param)
  727. {
  728. RState ret = _pumpLoadLockRoutine.Monitor();
  729. if (ret == RState.Failed || ret == RState.Timeout)
  730. {
  731. PostMsg(MSG.Error);
  732. return false;
  733. }
  734. return ret == RState.End;
  735. }
  736. private bool FnPumpingToVent(object[] param)
  737. {
  738. _pumpRoutine.Abort();
  739. return FnStartVent(param);
  740. }
  741. private bool FnPumpingLoadLockToVentLoadLock(object[] param)
  742. {
  743. _pumpLoadLockRoutine.Abort();
  744. return FnStartVentLoadlock(param);
  745. }
  746. private bool FnAbortPumpingLoadLock(object[] param)
  747. {
  748. _pumpLoadLockRoutine.Abort();
  749. return true;
  750. }
  751. private bool FnStartPurgeLoadlock(object[] param)
  752. {
  753. return _purgeLoadLockRoutine.Start() == RState.Running;
  754. }
  755. private bool FnPurgeLoadLockTimeout(object[] param)
  756. {
  757. RState ret = _purgeLoadLockRoutine.Monitor();
  758. if (ret == RState.Failed || ret == RState.Timeout)
  759. {
  760. PostMsg(MSG.Error);
  761. return false;
  762. }
  763. return ret == RState.End;
  764. }
  765. private bool FnAbortPurgeLoadLock(object[] param)
  766. {
  767. _purgeLoadLockRoutine.Abort();
  768. return true;
  769. }
  770. private bool FnStartLoadLockLeakCheck(object[] param)
  771. {
  772. return _loadLockLeakCheckRoutine.Start() == RState.Running;
  773. }
  774. private bool FnLoadLockLeakCheckTimeout(object[] param)
  775. {
  776. RState ret = _loadLockLeakCheckRoutine.Monitor();
  777. if (ret == RState.Failed || ret == RState.Timeout)
  778. {
  779. PostMsg(MSG.Error);
  780. return false;
  781. }
  782. return ret == RState.End;
  783. }
  784. private bool FnAbortLoadLockLeakCheck(object[] param)
  785. {
  786. _loadLockLeakCheckRoutine.Abort();
  787. return true;
  788. }
  789. private bool FnStartPurge(object[] param)
  790. {
  791. return _purgeRoutine.Start() == RState.Running;
  792. }
  793. private bool FnPurgeTimeout(object[] param)
  794. {
  795. RState ret = _purgeRoutine.Monitor();
  796. if (ret == RState.Failed || ret == RState.Timeout)
  797. {
  798. PostMsg(MSG.Error);
  799. return false;
  800. }
  801. return ret == RState.End;
  802. }
  803. private bool FnAbortPurge(object[] param)
  804. {
  805. _purgeRoutine.Abort();
  806. return true;
  807. }
  808. private bool FnStartGasLinePurge(object[] param)
  809. {
  810. return _gaslinePurgeRoutine.Start() == RState.Running;
  811. }
  812. private bool FnGasLinePurgeTimeout(object[] param)
  813. {
  814. RState ret = _gaslinePurgeRoutine.Monitor();
  815. if (ret == RState.Failed || ret == RState.Timeout)
  816. {
  817. PostMsg(MSG.Error);
  818. return false;
  819. }
  820. return ret == RState.End;
  821. }
  822. private bool FnAbortGasLinePurge(object[] param)
  823. {
  824. _gaslinePurgeRoutine.Abort();
  825. return true;
  826. }
  827. private bool FnStartPMLeakCheck(object[] param)
  828. {
  829. return _leakCheckRoutine.Start(param) == RState.Running;
  830. }
  831. private bool FnPMLeakCheckTimeout(object[] param)
  832. {
  833. RState ret = _leakCheckRoutine.Monitor();
  834. if (ret == RState.Failed || ret == RState.Timeout)
  835. {
  836. PostMsg(MSG.Error);
  837. return false;
  838. }
  839. return ret == RState.End;
  840. }
  841. private bool FnAbortPMLeakCheck(object[] param)
  842. {
  843. _leakCheckRoutine.Abort();
  844. return true;
  845. }
  846. private bool FnStartGasBoxLeakCheck(object[] param)
  847. {
  848. return _gasBoxLeakCheckRoutine.Start(param) == RState.Running;
  849. }
  850. private bool FnGasBoxLeakCheckTimeout(object[] param)
  851. {
  852. RState ret = _gasBoxLeakCheckRoutine.Monitor();
  853. if (ret == RState.Failed || ret == RState.Timeout)
  854. {
  855. PostMsg(MSG.Error);
  856. return false;
  857. }
  858. return ret == RState.End;
  859. }
  860. private bool FnAbortGasBoxLeakCheck(object[] param)
  861. {
  862. _gasBoxLeakCheckRoutine.Abort();
  863. return true;
  864. }
  865. private bool FnStartLLPlace(object[] param)
  866. {
  867. return _llPlaceRoutine.Start() == RState.Running;
  868. }
  869. private bool FnLLPlaceTimeout(object[] param)
  870. {
  871. RState ret = _llPlaceRoutine.Monitor();
  872. if (ret == RState.Failed || ret == RState.Timeout)
  873. {
  874. PostMsg(MSG.Error);
  875. return false;
  876. }
  877. return ret == RState.End;
  878. }
  879. private bool FnAbortLLPlace(object[] param)
  880. {
  881. _llPlaceRoutine.Abort();
  882. return true;
  883. }
  884. private bool FnStartLLPick(object[] param)
  885. {
  886. return _llPickRoutine.Start() == RState.Running;
  887. }
  888. private bool FnLLPickTimeout(object[] param)
  889. {
  890. RState ret = _llPickRoutine.Monitor();
  891. if (ret == RState.Failed || ret == RState.Timeout)
  892. {
  893. PostMsg(MSG.Error);
  894. return false;
  895. }
  896. return ret == RState.End;
  897. }
  898. private bool FnAbortLLPick(object[] param)
  899. {
  900. _llPickRoutine.Abort();
  901. return true;
  902. }
  903. private bool FnRunRecipe(object[] param)
  904. {
  905. return _processRoutine.Start(param) == RState.Running;
  906. }
  907. private bool FnProcessTimeout(object[] param)
  908. {
  909. _chamber.CheckIdleInterlock();
  910. RState ret = _processRoutine.Monitor();
  911. if (ret == RState.Failed || ret == RState.Timeout)
  912. {
  913. PostMsg(MSG.Error);
  914. return false;
  915. }
  916. return ret == RState.End;
  917. }
  918. private bool FnAbortProcess(object[] param)
  919. {
  920. _processRoutine.Abort();
  921. return true;
  922. }
  923. private bool FnStartGasFlow(object[] param)
  924. {
  925. return _gasFlowRoutine.Start(param) == RState.Running;
  926. }
  927. private bool FnGasFlowTimeout(object[] param)
  928. {
  929. RState ret = _gasFlowRoutine.Monitor();
  930. if (ret == RState.Failed || ret == RState.Timeout)
  931. {
  932. PostMsg(MSG.Error);
  933. return false;
  934. }
  935. return ret == RState.End;
  936. }
  937. private bool FnStopGasFlow(object[] param)
  938. {
  939. _gasFlowRoutine.Abort();
  940. return true;
  941. }
  942. private bool FnAbortGasFlow(object[] param)
  943. {
  944. _gasFlowRoutine.Abort();
  945. return true;
  946. }
  947. private bool FnStartRfPower(object[] param)
  948. {
  949. return _rfPowerRoutine.Start(param) == RState.Running;
  950. }
  951. private bool FnRfPowerTimeout(object[] param)
  952. {
  953. RState ret = _rfPowerRoutine.Monitor();
  954. if (ret == RState.Failed || ret == RState.Timeout)
  955. {
  956. PostMsg(MSG.Error);
  957. return false;
  958. }
  959. return ret == RState.End;
  960. }
  961. private bool FnAbortRfPower(object[] param)
  962. {
  963. _rfPowerRoutine.Abort();
  964. if(_gasFlowRoutine._gasStatus)
  965. {
  966. _gasFlowRoutine.StopFlow();
  967. }
  968. return true;
  969. }
  970. private bool FnStartMFCVerification(object[] param)
  971. {
  972. _gasVerificationRoutine.Init((string)param[0], Convert.ToDouble( param[1]), (int)param[2]);
  973. return _gasVerificationRoutine.Start(param) == RState.Running;
  974. }
  975. private bool FnMFCVerificationTimeout(object[] param)
  976. {
  977. RState ret = _gasVerificationRoutine.Monitor();
  978. if (ret == RState.Failed || ret == RState.Timeout)
  979. {
  980. PostMsg(MSG.Error);
  981. return false;
  982. }
  983. return ret == RState.End;
  984. }
  985. private bool FnAbortMFCVerification(object[] param)
  986. {
  987. _gasVerificationRoutine.Abort();
  988. return true;
  989. }
  990. #region Exchange wafer with TM
  991. private bool FnStartPreparePick(object[] param)
  992. {
  993. if(!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  994. {
  995. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Up failed:{reason}");
  996. return false;
  997. }
  998. if(!_chamber.SetSlitDoor(true, out reason))
  999. {
  1000. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Open failed:{reason}");
  1001. return false;
  1002. }
  1003. return true;
  1004. }
  1005. private bool FnPreparePickTimeout(object[] param)
  1006. {
  1007. return _chamber.LiftPinIsUp && IsSlitDoorOpen;
  1008. }
  1009. private bool FnAbortPreparePick(object[] param)
  1010. {
  1011. return true;
  1012. }
  1013. private bool FnStartFinishPick(object[] param)
  1014. {
  1015. if (!_chamber.SetSlitDoor(false, out string reason))
  1016. {
  1017. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1018. return false;
  1019. }
  1020. return true;
  1021. }
  1022. private bool FnAbortPick(object[] param)
  1023. {
  1024. return true;
  1025. }
  1026. private bool FnFinishPickTimeout(object[] param)
  1027. {
  1028. return IsSlitDoorClose;
  1029. }
  1030. private bool FnStartDropDownWafer(object[] param)
  1031. {
  1032. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1033. {
  1034. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1035. return false;
  1036. }
  1037. return _chamber.SetLiftPin(MovementPosition.Down, out string _);
  1038. }
  1039. private bool FnDropDownTimeout(object[] param)
  1040. {
  1041. return _chamber.LiftPinIsDown;
  1042. }
  1043. private bool FnStartPreparePlace(object[] param)
  1044. {
  1045. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1046. {
  1047. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin down failed:{reason}");
  1048. return false;
  1049. }
  1050. if (!_chamber.SetSlitDoor(true, out reason))
  1051. {
  1052. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Open failed:{reason}");
  1053. return false;
  1054. }
  1055. return true;
  1056. }
  1057. private bool FnPreparePlaceTimeout(object[] param)
  1058. {
  1059. return _chamber.LiftPinIsDown && IsSlitDoorOpen;
  1060. }
  1061. private bool FnAbortPreparePlace(object[] param)
  1062. {
  1063. return true;
  1064. }
  1065. private bool FnStartLiftUpWafer(object[] param)
  1066. {
  1067. if (!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  1068. {
  1069. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Up failed:{reason}");
  1070. return false;
  1071. }
  1072. return true;
  1073. }
  1074. private bool FnLiftUpTimeout(object[] param)
  1075. {
  1076. return _chamber.LiftPinIsUp;
  1077. }
  1078. private bool FnStartFinishPlace(object[] param)
  1079. {
  1080. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1081. {
  1082. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1083. return false;
  1084. }
  1085. if (!_chamber.SetSlitDoor(false, out reason))
  1086. {
  1087. LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1088. return false;
  1089. }
  1090. return true;
  1091. }
  1092. private bool FnAortPlace(object[] param)
  1093. {
  1094. return true;
  1095. }
  1096. private bool FnFinishPlaceTimeout(object[] param)
  1097. {
  1098. return _chamber.LiftPinIsDown && IsSlitDoorClose;
  1099. }
  1100. private bool FnStartSwapPlace(object[] param)
  1101. {
  1102. return true;
  1103. }
  1104. #endregion
  1105. private void _debugRoutine()
  1106. {
  1107. int flag = 0;
  1108. // Test Home routine
  1109. if (flag == 1)
  1110. {
  1111. PostMsg(MSG.Home);
  1112. }
  1113. else if (flag == 2)
  1114. {
  1115. PostMsg(MSG.Vent);
  1116. }
  1117. else if (flag == 3)
  1118. {
  1119. PostMsg(MSG.Pump);
  1120. }
  1121. else if(flag == 4)
  1122. {
  1123. PostMsg(MSG.PumpLoadLock);
  1124. }
  1125. else if(flag == 5)
  1126. {
  1127. PostMsg(MSG.VentLoadLock);
  1128. }
  1129. else if(flag == 6)
  1130. {
  1131. PostMsg(MSG.PurgeLoadLock);
  1132. }
  1133. else if(flag == 7)
  1134. {
  1135. PostMsg(MSG.LaunchPump);
  1136. }
  1137. else if(flag == 8)
  1138. {
  1139. PostMsg(MSG.LaunchTurboPump);
  1140. }
  1141. else if(flag == 9)
  1142. {
  1143. PostMsg(MSG.LoadLockLeakCheck);
  1144. }
  1145. else if(flag == 10)
  1146. {
  1147. PostMsg(MSG.CyclePurge);
  1148. }
  1149. else if(flag == 11)
  1150. {
  1151. PostMsg(MSG.GasLinePurge);
  1152. }
  1153. else if(flag == 12)
  1154. {
  1155. PostMsg(MSG.LeakCheck);
  1156. }
  1157. else if(flag == 13)
  1158. {
  1159. PostMsg(MSG.GasLeakCheck);
  1160. }
  1161. else if(flag == 14)
  1162. {
  1163. PostMsg(MSG.LLPlace);
  1164. }
  1165. else if(flag == 15)
  1166. {
  1167. PostMsg(MSG.LLPick);
  1168. }
  1169. else if(flag == 16)
  1170. {
  1171. PostMsg(MSG.RunRecipe, "7777");
  1172. }
  1173. else if(flag == 17)
  1174. {
  1175. PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  1176. }
  1177. }
  1178. }
  1179. }