PMEntity.cs 60 KB

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