PMEntity.cs 54 KB

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