PMEntity.cs 53 KB

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