PMEntity.cs 58 KB

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