PMEntity.cs 58 KB

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