PMEntity.cs 56 KB

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