PMEntity.cs 55 KB

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