PMEntity.cs 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603
  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 PMControlPressureRoutine _pmControlPressureRoutine;
  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. fsm = new StateMachine<PMEntity>(Module.ToString(), (int)PMState.Init, 50);
  389. //Idle
  390. EnterExitTransition((int)PMState.Idle, FnIdle, (int)FSM_MSG.NONE, null);
  391. EnterExitTransition<PMState, FSM_MSG>(PMState.Error, fEnterError, FSM_MSG.NONE, null);
  392. EnterExitTransition<PMState, FSM_MSG>(PMState.ReadyForPick, fnEnterPickReady, FSM_MSG.NONE, fnExitPickReady);
  393. EnterExitTransition<PMState, FSM_MSG>(PMState.ReadyForPlace, fnEnterPlaceReady, FSM_MSG.NONE, fnExitPlaceReady);
  394. EnterExitTransition<PMState, FSM_MSG>(PMState.DropDownReady, fnEnterDropDownReady, FSM_MSG.NONE, fnExitDropDownReady);
  395. EnterExitTransition<PMState, FSM_MSG>(PMState.LiftUpReady, fnEnterLiftUpReady, FSM_MSG.NONE, fnExitLiftUpReady);
  396. //Home
  397. //EnterExitTransition((int)PMState.Homing, FnEnterHome, (int)FSM_MSG.NONE, FnExitHome);
  398. AnyStateTransition(MSG.Error, FnError, PMState.Error);
  399. AnyStateTransition(MSG.Online, FnSetOnline, FSM_STATE.SAME);
  400. AnyStateTransition(MSG.Offline, FnSetOffline, FSM_STATE.SAME);
  401. Transition(PMState.Init, FSM_MSG.TIMER, FnTimeout, PMState.Init);
  402. Transition(PMState.Init, MSG.Home, FnStartHome, PMState.Homing);
  403. Transition(PMState.Error, MSG.Home, FnStartHome, PMState.Homing);
  404. Transition(PMState.Idle, MSG.Home, FnStartHome, PMState.Homing);
  405. Transition(PMState.Homing, MSG.Home, FnStartHome, PMState.Homing);
  406. Transition(PMState.Homing, FSM_MSG.TIMER, FnMonitorHome, PMState.Idle);
  407. Transition(PMState.Idle, FSM_MSG.TIMER, FnIdleTimeout, PMState.Idle);
  408. Transition(PMState.Error, FSM_MSG.TIMER, FnErrorTimeout, PMState.Error);
  409. //Launch DryPump sequence
  410. Transition(PMState.Idle, MSG.LaunchPump, FnLaunchPump, PMState.LaunchingPump);
  411. Transition(PMState.LaunchingPump, FSM_MSG.TIMER, FnLaunchPumpTimeout, PMState.Idle);
  412. Transition(PMState.LaunchingPump, MSG.Abort, FnAbortStartPumping, PMState.Idle);
  413. //Launch TurboPump sequence
  414. Transition(PMState.Idle, MSG.LaunchTurboPump, FnLaunchTurboPump, PMState.LaunchingTurboPump);
  415. Transition(PMState.LaunchingTurboPump, FSM_MSG.TIMER, FnLaunchTurboPumpTimeout, PMState.Idle);
  416. Transition(PMState.LaunchingTurboPump, MSG.Abort, FnAbortStartTurboPumping, PMState.Idle);
  417. //vent sequence
  418. Transition(PMState.Idle, MSG.Vent, FnStartVent, PMState.Venting);
  419. Transition(PMState.Pumping, MSG.Vent, FnVentToPumping, PMState.Venting);
  420. Transition(PMState.Venting, FSM_MSG.TIMER, FnVentTimeout, PMState.Idle);
  421. Transition(PMState.Venting, MSG.Abort, FnAbortVent, PMState.Idle);
  422. //Pump sequence
  423. Transition(PMState.Idle, MSG.Pump, FnStartPumpDown, PMState.Pumping);
  424. Transition(PMState.Venting, MSG.Pump, FnVentToPumping, PMState.Pumping);
  425. Transition(PMState.Pumping, FSM_MSG.TIMER, FnPumpDownTimeout, PMState.Idle);
  426. Transition(PMState.Pumping, MSG.Abort, FnAbortPumping, PMState.Idle);
  427. //Pump Loadlock sequence
  428. Transition(PMState.Idle, MSG.PumpLoadLock, FnStartPumpDownLoadLock, PMState.PumpingLoadLock);
  429. Transition(PMState.VentingLoadLock, MSG.PumpLoadLock, FnVentLoadLockToPumpingLoadLock, PMState.PumpingLoadLock);
  430. Transition(PMState.PumpingLoadLock, FSM_MSG.TIMER, FnPumpDownLoadLockTimeout, PMState.Idle);
  431. Transition(PMState.PumpingLoadLock, MSG.Abort, FnAbortPumpingLoadLock, PMState.Idle);
  432. //Vent Loadlock sequence
  433. Transition(PMState.Idle, MSG.VentLoadLock, FnStartVentLoadlock, PMState.VentingLoadLock);
  434. Transition(PMState.PumpingLoadLock, MSG.VentLoadLock, FnPumpingLoadLockToVentLoadLock, PMState.VentingLoadLock);
  435. Transition(PMState.VentingLoadLock, FSM_MSG.TIMER, FnVentLoadLockTimeout, PMState.Idle);
  436. Transition(PMState.VentingLoadLock, MSG.Abort, FnAbortVentLoadLock, PMState.Idle);
  437. // Purge LoadLock sequence
  438. Transition(PMState.Idle, MSG.PurgeLoadLock, FnStartPurgeLoadlock, PMState.PurgingLoadLock);
  439. Transition(PMState.PurgingLoadLock, FSM_MSG.TIMER, FnPurgeLoadLockTimeout, PMState.Idle);
  440. Transition(PMState.PurgingLoadLock, MSG.Abort, FnAbortPurgeLoadLock, PMState.Idle);
  441. //LoadLock Leak check sequence
  442. Transition(PMState.Idle, MSG.LoadLockLeakCheck, FnStartLoadLockLeakCheck, PMState.LoadLockLeakCheck);
  443. Transition(PMState.LoadLockLeakCheck, FSM_MSG.TIMER, FnLoadLockLeakCheckTimeout, PMState.Idle);
  444. Transition(PMState.LoadLockLeakCheck, MSG.Abort, FnAbortLoadLockLeakCheck, PMState.Idle);
  445. // PM Purge sequence
  446. Transition(PMState.Idle, MSG.CyclePurge, FnStartPurge, PMState.Purging);
  447. Transition(PMState.Purging, FSM_MSG.TIMER, FnPurgeTimeout, PMState.Idle);
  448. Transition(PMState.Purging, MSG.Abort, FnAbortPurge, PMState.Idle);
  449. // PM GasLine Purge sequence
  450. Transition(PMState.Idle, MSG.GasLinePurge, FnStartGasLinePurge, PMState.GasLinePurge);
  451. Transition(PMState.GasLinePurge, FSM_MSG.TIMER, FnGasLinePurgeTimeout, PMState.Idle);
  452. Transition(PMState.GasLinePurge, MSG.Abort, FnAbortGasLinePurge, PMState.Idle);
  453. //PM Leak check sequence
  454. Transition(PMState.Idle, MSG.LeakCheck, FnStartPMLeakCheck, PMState.LeakCheck);
  455. Transition(PMState.LeakCheck, FSM_MSG.TIMER, FnPMLeakCheckTimeout, PMState.Idle);
  456. Transition(PMState.LeakCheck, MSG.Abort, FnAbortPMLeakCheck, PMState.Idle);
  457. //PM GasBox Leak check sequence
  458. Transition(PMState.Idle, MSG.GasLeakCheck, FnStartGasBoxLeakCheck, PMState.GasBoxLeakCheck);
  459. Transition(PMState.GasBoxLeakCheck, FSM_MSG.TIMER, FnGasBoxLeakCheckTimeout, PMState.Idle);
  460. Transition(PMState.GasBoxLeakCheck, MSG.Abort, FnAbortGasBoxLeakCheck, PMState.Idle);
  461. // PlaceWafer from LoadLock Arm sequence
  462. Transition(PMState.Idle, MSG.LLPlace, FnStartLLPlace, PMState.LLPlacing);
  463. Transition(PMState.LLPlacing, FSM_MSG.TIMER, FnLLPlaceTimeout, PMState.Idle);
  464. Transition(PMState.LLPlacing, MSG.Abort, FnAbortLLPlace, PMState.Idle);
  465. // PickWafer to LoadLock Arm sequence
  466. Transition(PMState.Idle, MSG.LLPick, FnStartLLPick, PMState.LLPicking);
  467. Transition(PMState.LLPicking, FSM_MSG.TIMER, FnLLPickTimeout, PMState.Idle);
  468. Transition(PMState.LLPicking, MSG.Abort, FnAbortLLPick, PMState.Idle);
  469. // Process
  470. Transition(PMState.Idle, MSG.RunRecipe, FnRunRecipe, PMState.Processing);
  471. Transition(PMState.Processing, FSM_MSG.TIMER, FnProcessTimeout, PMState.Idle);
  472. Transition(PMState.Processing, MSG.Abort, FnAbortProcess, PMState.Idle);
  473. // Clean
  474. Transition(PMState.Idle, MSG.Clean, FnRunRecipe, PMState.Clean);
  475. Transition(PMState.Clean, FSM_MSG.TIMER, FnProcessTimeout, PMState.Idle);
  476. Transition(PMState.Clean, MSG.Abort, FnAbortProcess, PMState.Idle);
  477. // Gas Flow sequence
  478. Transition(PMState.Idle, MSG.GasFlow, FnStartGasFlow, PMState.GasFlowing);
  479. Transition(PMState.GasFlowing, MSG.GasFlow, FnAbortGasFlow, PMState.Idle);
  480. Transition(PMState.GasFlowing, FSM_MSG.TIMER, FnGasFlowTimeout, PMState.Idle);
  481. Transition(PMState.GasFlowing, MSG.StopGasFlow, FnStopGasFlow, PMState.Idle);
  482. Transition(PMState.GasFlowing, MSG.Abort, FnAbortGasFlow, PMState.Idle);
  483. //RF Power sequence
  484. Transition(PMState.Idle, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  485. Transition(PMState.GasFlowing, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  486. Transition(PMState.RfPowering, FSM_MSG.TIMER, FnRfPowerTimeout, PMState.Idle);
  487. Transition(PMState.RfPowering, MSG.Abort, FnAbortRfPower, PMState.Idle);
  488. //MFC verification
  489. Transition(PMState.Idle, MSG.MFCVerification, FnStartMFCVerification, PMState.MFCVerification);
  490. Transition(PMState.MFCVerification, FSM_MSG.TIMER, FnMFCVerificationTimeout, PMState.Idle);
  491. Transition(PMState.MFCVerification, MSG.Abort, FnAbortMFCVerification, PMState.Idle);
  492. //////////////////////// Exchange Wafer with TM ///////////////////////////////////////////////////////
  493. // Pick Wafer from PM
  494. Transition(PMState.Idle, MSG.PreparePick, FnStartPreparePick, PMState.PreparePick);
  495. Transition(PMState.PreparePick, MSG.Abort, FnAbortPreparePick, PMState.Idle);
  496. Transition(PMState.PreparePick, FSM_MSG.TIMER, FnPreparePickTimeout, PMState.ReadyForPick);
  497. Transition(PMState.PreparePick, MSG.PreparePick, null, PMState.PreparePick);
  498. Transition(PMState.ReadyForPick, MSG.Abort, FnAbortPick, PMState.Idle);
  499. Transition(PMState.ReadyForPick, MSG.DropDownWafer, FnStartDropDownWafer, PMState.DropDownWafer);
  500. Transition(PMState.ReadyForPick, MSG.PreparePick, null, PMState.ReadyForPick);
  501. Transition(PMState.DropDownWafer, FSM_MSG.TIMER, FnDropDownTimeout, PMState.DropDownReady);
  502. Transition(PMState.DropDownReady, MSG.PickReady, FnStartFinishPick, PMState.FinishPick);
  503. Transition(PMState.ReadyForPick, MSG.PickReady, FnStartFinishPick, PMState.FinishPick);
  504. Transition(PMState.FinishPick, FSM_MSG.TIMER, FnFinishPickTimeout, PMState.Idle);
  505. // Place Wafer to PM
  506. Transition(PMState.Idle, MSG.PreparePlace, FnStartPreparePlace, PMState.PreparePlace);
  507. Transition(PMState.PreparePlace, MSG.Abort, FnAbortPreparePlace, PMState.Idle);
  508. Transition(PMState.PreparePlace, FSM_MSG.TIMER, FnPreparePlaceTimeout, PMState.ReadyForPlace);
  509. Transition(PMState.PreparePlace, MSG.PreparePlace, null, PMState.PreparePlace);
  510. Transition(PMState.ReadyForPlace, MSG.LiftUpWafer, FnStartLiftUpWafer, PMState.LiftUpWafer);
  511. Transition(PMState.LiftUpWafer, FSM_MSG.TIMER, FnLiftUpTimeout, PMState.LiftUpReady);
  512. Transition(PMState.LiftUpReady, MSG.PlaceReady, FnStartFinishPlace, PMState.FinishPlace);
  513. Transition(PMState.ReadyForPlace, MSG.PlaceReady, FnStartFinishPlace, PMState.FinishPlace);
  514. Transition(PMState.PreparePlace, MSG.Abort, FnAortPlace, PMState.Idle);
  515. Transition(PMState.ReadyForPlace, MSG.Abort, FnAortPlace, PMState.Idle);
  516. Transition(PMState.ReadyForPlace, MSG.PreparePlace, null, PMState.ReadyForPlace);
  517. Transition(PMState.LiftUpReady, MSG.Abort, FnAortPlace, PMState.Idle);
  518. Transition(PMState.FinishPlace, FSM_MSG.TIMER, FnFinishPlaceTimeout, PMState.Idle);
  519. // Swap Wafer With PM
  520. Transition(PMState.DropDownReady, MSG.PreparePlace, FnStartSwapPlace, PMState.PreparePlace);
  521. Transition(PMState.ReadyForPick, MSG.PreparePlace, FnStartPreparePlace, PMState.PreparePlace);
  522. Transition(PMState.Idle, MSG.PartialPressure, FnStartPartialPressure, PMState.PartialPressureTesting);
  523. Transition(PMState.PartialPressureTesting, FSM_MSG.TIMER, FnPartialPressureTimeout, PMState.Idle);
  524. Transition(PMState.PartialPressureTesting, MSG.Abort, FnAbortPartialPressure, PMState.Idle);
  525. Transition(PMState.Idle, MSG.VATPerformance, FnStartVATPerformance, PMState.VATPerformanceTesting);
  526. Transition(PMState.VATPerformanceTesting, FSM_MSG.TIMER, FnVATPerformanceTimeout, PMState.Idle);
  527. Transition(PMState.VATPerformanceTesting, MSG.Abort, FnAbortVATPerformance, PMState.Idle);
  528. AnyStateTransition(FSM_MSG.TIMER, FnControlPressure, FSM_STATE.SAME);
  529. Running = true;
  530. WaferManager.Instance.SubscribeLocation(Module, 1);
  531. }
  532. protected override bool Init()
  533. {
  534. DATA.Subscribe($"{Module}.FsmState", () => (((PMState)fsm.State)), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  535. DATA.Subscribe($"{Module}.FsmPrevState", () => (((PMState)fsm.PrevState).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  536. DATA.Subscribe($"{Module}.FsmLastMessage", () => (((MSG)fsm.LastMsg).ToString()), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  537. DATA.Subscribe($"{Module}.LoadLockPurge.PurgeCounter", () => _purgeLoadLockRoutine.PurgeCounter, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  538. DATA.Subscribe($"{Module}.PartialPressureCounter", () => _pmPartialPressureRoutine.counter, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  539. DATA.Subscribe($"{Module}.VATPerformanceCounter", () => _pmVATPerformanceRoutine.counter, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  540. DATA.Subscribe($"{Module}.VATPerformanceResult", () => _pmVATPerformanceRoutine?.m_sb.ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  541. DATA.Subscribe($"{Module}.PartialPressureResult", () => _pmPartialPressureRoutine?.m_sb.ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  542. DATA.Subscribe($"{Module}.MFCCalibrationDatas", () => _gasVerificationRoutine?._MFCCalibrationDatas, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  543. DATA.Subscribe($"{Module}.IsIdle", () => IsIdle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  544. DATA.Subscribe($"{Module}.IsAlarm", () => IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  545. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  546. DATA.Subscribe($"{Module}.IsInit", () => IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  547. DATA.Subscribe($"{Module}.IsOnline", () => _isOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  548. DATA.Subscribe($"{Module}.VentingFlag",()=>_ventRoutine.VentingFlag, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  549. //DATA.Subscribe($"{Module}.GetLeakCheckDatas", () => LeakCheckDataRecorder.GetAllLeakCheckData(Module.ToString()));
  550. DATA.Subscribe($"{Module}.CurrentRecipeResult", () => _processRoutine.currentRecipeResult, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  551. DATA.Subscribe($"{Module}.LeakCheck.Step", () => _leakCheckRoutine.CurrentStep, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  552. DATA.Subscribe($"{Module}.GasLeakCheck.Step", () => _gasBoxLeakCheckRoutine.CurrentStep, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  553. DATA.Subscribe($"{Module}.IsInclude", () => IsInclude, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  554. OP.Subscribe($"{Module}.{RtOperation.GasFlow}", (cmd, args) => CheckToPostMessage((int)MSG.GasFlow, args));
  555. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck, args));
  556. OP.Subscribe($"{Module}.{RtOperation.GasLeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.GasLeakCheck, args));
  557. OP.Subscribe($"{Module}.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  558. OP.Subscribe($"{Module}.{RtOperation.StartPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchPump));
  559. OP.Subscribe($"{Module}.{RtOperation.StartTurboPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchTurboPump));
  560. OP.Subscribe($"{Module}.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  561. OP.Subscribe($"{Module}.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.CyclePurge));
  562. OP.Subscribe($"{Module}.{RtOperation.RfPower}", (cmd, args) => CheckToPostMessage((int)MSG.RfPower));
  563. OP.Subscribe($"{Module}.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  564. OP.Subscribe($"{Module}.{RtOperation.VentLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.VentLoadLock));
  565. OP.Subscribe($"{Module}.{RtOperation.PurgeLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PurgeLoadLock));
  566. OP.Subscribe($"{Module}.{RtOperation.PumpLoadLock}", (cmd, args) => CheckToPostMessage((int)MSG.PumpLoadLock));
  567. OP.Subscribe($"{Module}.{RtOperation.Reset}", (cmd, args) => CheckToPostMessage((int)MSG.Reset));
  568. OP.Subscribe($"{Module}.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  569. OP.Subscribe($"{Module}.{RtOperation.LLPick}", (cmd, args) => CheckToPostMessage((int)MSG.LLPick));
  570. OP.Subscribe($"{Module}.{RtOperation.LLPlace}", (cmd, args) => CheckToPostMessage((int)MSG.LLPlace));
  571. OP.Subscribe($"{Module}.{RtOperation.MFCVerification}", (cmd, args) => CheckToPostMessage((int)MSG.MFCVerification, args));
  572. OP.Subscribe($"{Module}.{RtOperation.RunRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RunRecipe, args));
  573. OP.Subscribe($"{Module}.{RtOperation.RunCleanRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.Clean, args));
  574. OP.Subscribe($"{Module}.PartialPressureTest", (cmd, args) => CheckToPostMessage((int)MSG.PartialPressure, args[0], args[1]));
  575. OP.Subscribe($"{Module}.VATPerformanceTest", (cmd, args) => CheckToPostMessage((int)MSG.VATPerformance, args[0], args[1], args[2]));
  576. OP.Subscribe($"{Module}.GasLinePurge", (cmd, args) => CheckToPostMessage((int)MSG.GasLinePurge));
  577. OP.Subscribe($"{Module}.ManualEndStep", (cmd, args) => ManualEndStep() );
  578. OP.Subscribe($"{Module}.{RtOperation.Online}", (cmd, args) => CheckToPostMessage((int)MSG.Online));
  579. OP.Subscribe($"{Module}.{RtOperation.Offline}", (cmd, args) => CheckToPostMessage((int)MSG.Offline));
  580. OP.Subscribe($"{Module}.{RtOperation.PmError}", (cmd, args) => CheckToPostMessage((int)MSG.Error));
  581. OP.Subscribe($"{Module}.{RtOperation.Include}", (cmd, args) => FnSetInclude());
  582. OP.Subscribe($"{Module}.{RtOperation.Exclude}", (cmd, args) => FnSetExclude());
  583. LOG.PMErrorInterrupt += (pmname)=> PMErrorInterrupt(pmname);
  584. return true;
  585. }
  586. private void PMErrorInterrupt(ModuleName pmname)
  587. {
  588. if (pmname == Module)
  589. {
  590. LOG.Write(eEvent.ERR_PM, Module, $"Device Error Happend! {Module} Crash!");
  591. CheckToPostMessage((int)MSG.Error);
  592. }
  593. }
  594. private bool ManualEndStep()
  595. {
  596. _processRoutine.isMaualEndStep = true;
  597. return true;
  598. }
  599. private bool FnIdle(object[] objs)
  600. {
  601. Running = false;
  602. return true;
  603. }
  604. private bool fEnterError(object[] objs)
  605. {
  606. return true;
  607. }
  608. private bool fnEnterPickReady(object[] objs)
  609. {
  610. Status = PMStatus.Ready_For_Pick;
  611. return true;
  612. }
  613. private bool fnExitPickReady(object[] objs)
  614. {
  615. Status = PMStatus.Not_Ready;
  616. return true;
  617. }
  618. private bool fnEnterPlaceReady(object[] objs)
  619. {
  620. Status = PMStatus.Ready_For_Place;
  621. return true;
  622. }
  623. private bool fnExitPlaceReady(object[] objs)
  624. {
  625. Status = PMStatus.Not_Ready;
  626. return true;
  627. }
  628. private bool fnEnterDropDownReady(object[] objs)
  629. {
  630. Status = PMStatus.Exchange_Ready;
  631. return true;
  632. }
  633. private bool fnExitDropDownReady(object[] objs)
  634. {
  635. Status = PMStatus.Not_Ready;
  636. return true;
  637. }
  638. private bool fnEnterLiftUpReady(object[] objs)
  639. {
  640. Status = PMStatus.Exchange_Ready;
  641. return true;
  642. }
  643. private bool fnExitLiftUpReady(object[] objs)
  644. {
  645. Status = PMStatus.Not_Ready;
  646. return true;
  647. }
  648. private bool FnError(object[] objs)
  649. {
  650. Running = false;
  651. _isOnline = false;
  652. //if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  653. // || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  654. // return false;
  655. _chamber.CloseValves();
  656. _chamber.GeneratorPowerOn(false);
  657. _chamber.GeneratorBiasPowerOn(false);
  658. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  659. _chamber.OpenValve(ValveType.TurboPumpPurge, true);
  660. _chamber.OnOffSetESCHV(false);
  661. if (IsProcessing)
  662. {
  663. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  664. }
  665. return true;
  666. }
  667. private bool FnTimeout(object[] objs)
  668. {
  669. _debugRoutine();
  670. return true;
  671. }
  672. private bool FnIdleTimeout(object[] objs)
  673. {
  674. _chamber.CheckIdleInterlock();
  675. //_debugRoutine();
  676. return true;
  677. }
  678. private bool FnErrorTimeout(object[] objs)
  679. {
  680. //_debugRoutine();
  681. return true;
  682. }
  683. private bool FnStartHome(object[] objs)
  684. {
  685. return _home.Start() == RState.Running;
  686. }
  687. private bool FnMonitorHome(object[] objs)
  688. {
  689. RState ret = _home.Monitor();
  690. if (ret == RState.Failed || ret == RState.Timeout)
  691. {
  692. PostMsg(MSG.Error);
  693. return false;
  694. }
  695. return ret == RState.End;
  696. }
  697. private bool FnLaunchPump(object[] param)
  698. {
  699. return _startDryPumpRoutine.Start() == RState.Running;
  700. }
  701. private bool FnLaunchPumpTimeout(object[] param)
  702. {
  703. RState ret = _startDryPumpRoutine.Monitor();
  704. if (ret == RState.Failed || ret == RState.Timeout)
  705. {
  706. PostMsg(MSG.Error);
  707. return false;
  708. }
  709. return ret == RState.End;
  710. }
  711. private bool FnAbortStartPumping(object[] param)
  712. {
  713. _startDryPumpRoutine.Abort();
  714. return true;
  715. }
  716. private bool FnLaunchTurboPump(object[] param)
  717. {
  718. return _startTurboPumpRoutine.Start() == RState.Running;
  719. }
  720. private bool FnLaunchTurboPumpTimeout(object[] param)
  721. {
  722. RState ret = _startTurboPumpRoutine.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 FnAbortStartTurboPumping(object[] param)
  731. {
  732. _startTurboPumpRoutine.Abort();
  733. return true;
  734. }
  735. private bool FnStartVent(object[] param)
  736. {
  737. return _ventRoutine.Start() == RState.Running;
  738. }
  739. private bool FnVentTimeout(object[] param)
  740. {
  741. RState ret = _ventRoutine.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 FnVentToPumping(object[] param)
  750. {
  751. _ventRoutine.Abort();
  752. return true; // FnStartPumpDown(param);
  753. }
  754. private bool FnAbortVent(object[] param)
  755. {
  756. _ventRoutine.Abort();
  757. return true;
  758. }
  759. private bool FnStartPumpDown(object[] param)
  760. {
  761. return _pumpRoutine.Start() == RState.Running;
  762. }
  763. private bool FnPumpDownTimeout(object[] param)
  764. {
  765. RState ret = _pumpRoutine.Monitor();
  766. if (ret == RState.Failed || ret == RState.Timeout)
  767. {
  768. PostMsg(MSG.Error);
  769. return false;
  770. }
  771. return ret == RState.End;
  772. }
  773. private bool FnAbortPumping(object[] param)
  774. {
  775. _pumpRoutine.Abort();
  776. return true;
  777. }
  778. private bool FnStartVentLoadlock(object[] param)
  779. {
  780. return _ventLoadLockRoutine.Start() == RState.Running;
  781. }
  782. private bool FnVentLoadLockTimeout(object[] param)
  783. {
  784. RState ret = _ventLoadLockRoutine.Monitor();
  785. if (ret == RState.Failed || ret == RState.Timeout)
  786. {
  787. PostMsg(MSG.Error);
  788. return false;
  789. }
  790. return ret == RState.End;
  791. }
  792. private bool FnVentLoadLockToPumpingLoadLock(object[] param)
  793. {
  794. _ventLoadLockRoutine.Abort();
  795. return FnStartPumpDownLoadLock(param);
  796. }
  797. private bool FnAbortVentLoadLock(object[] param)
  798. {
  799. _ventLoadLockRoutine.Abort();
  800. return true;
  801. }
  802. private bool FnStartPumpDownLoadLock(object[] param)
  803. {
  804. return _pumpLoadLockRoutine.Start() == RState.Running;
  805. }
  806. private bool FnPumpDownLoadLockTimeout(object[] param)
  807. {
  808. RState ret = _pumpLoadLockRoutine.Monitor();
  809. if (ret == RState.Failed || ret == RState.Timeout)
  810. {
  811. PostMsg(MSG.Error);
  812. return false;
  813. }
  814. return ret == RState.End;
  815. }
  816. private bool FnPumpingToVent(object[] param)
  817. {
  818. _pumpRoutine.Abort();
  819. return FnStartVent(param);
  820. }
  821. private bool FnPumpingLoadLockToVentLoadLock(object[] param)
  822. {
  823. _pumpLoadLockRoutine.Abort();
  824. return FnStartVentLoadlock(param);
  825. }
  826. private bool FnAbortPumpingLoadLock(object[] param)
  827. {
  828. _pumpLoadLockRoutine.Abort();
  829. return true;
  830. }
  831. private bool FnStartPurgeLoadlock(object[] param)
  832. {
  833. return _purgeLoadLockRoutine.Start() == RState.Running;
  834. }
  835. private bool FnPurgeLoadLockTimeout(object[] param)
  836. {
  837. RState ret = _purgeLoadLockRoutine.Monitor();
  838. if (ret == RState.Failed || ret == RState.Timeout)
  839. {
  840. PostMsg(MSG.Error);
  841. return false;
  842. }
  843. return ret == RState.End;
  844. }
  845. private bool FnAbortPurgeLoadLock(object[] param)
  846. {
  847. _purgeLoadLockRoutine.Abort();
  848. return true;
  849. }
  850. private bool FnStartLoadLockLeakCheck(object[] param)
  851. {
  852. return _loadLockLeakCheckRoutine.Start() == RState.Running;
  853. }
  854. private bool FnLoadLockLeakCheckTimeout(object[] param)
  855. {
  856. RState ret = _loadLockLeakCheckRoutine.Monitor();
  857. if (ret == RState.Failed || ret == RState.Timeout)
  858. {
  859. PostMsg(MSG.Error);
  860. return false;
  861. }
  862. return ret == RState.End;
  863. }
  864. private bool FnAbortLoadLockLeakCheck(object[] param)
  865. {
  866. _loadLockLeakCheckRoutine.Abort();
  867. return true;
  868. }
  869. private bool FnStartPurge(object[] param)
  870. {
  871. return _purgeRoutine.Start() == RState.Running;
  872. }
  873. private bool FnPurgeTimeout(object[] param)
  874. {
  875. RState ret = _purgeRoutine.Monitor();
  876. if (ret == RState.Failed || ret == RState.Timeout)
  877. {
  878. PostMsg(MSG.Error);
  879. return false;
  880. }
  881. return ret == RState.End;
  882. }
  883. private bool FnAbortPurge(object[] param)
  884. {
  885. _purgeRoutine.Abort();
  886. return true;
  887. }
  888. private bool FnStartGasLinePurge(object[] param)
  889. {
  890. return _gaslinePurgeRoutine.Start() == RState.Running;
  891. }
  892. private bool FnGasLinePurgeTimeout(object[] param)
  893. {
  894. RState ret = _gaslinePurgeRoutine.Monitor();
  895. if (ret == RState.Failed || ret == RState.Timeout)
  896. {
  897. PostMsg(MSG.Error);
  898. return false;
  899. }
  900. return ret == RState.End;
  901. }
  902. private bool FnAbortGasLinePurge(object[] param)
  903. {
  904. _gaslinePurgeRoutine.Abort();
  905. return true;
  906. }
  907. private bool FnStartPMLeakCheck(object[] param)
  908. {
  909. return _leakCheckRoutine.Start(param) == RState.Running;
  910. }
  911. private bool FnPMLeakCheckTimeout(object[] param)
  912. {
  913. RState ret = _leakCheckRoutine.Monitor();
  914. if (ret == RState.Failed || ret == RState.Timeout)
  915. {
  916. PostMsg(MSG.Error);
  917. return false;
  918. }
  919. return ret == RState.End;
  920. }
  921. private bool FnAbortPMLeakCheck(object[] param)
  922. {
  923. _leakCheckRoutine.Abort();
  924. return true;
  925. }
  926. private bool FnStartGasBoxLeakCheck(object[] param)
  927. {
  928. return _gasBoxLeakCheckRoutine.Start(param) == RState.Running;
  929. }
  930. private bool FnGasBoxLeakCheckTimeout(object[] param)
  931. {
  932. RState ret = _gasBoxLeakCheckRoutine.Monitor();
  933. if (ret == RState.Failed || ret == RState.Timeout)
  934. {
  935. PostMsg(MSG.Error);
  936. return false;
  937. }
  938. return ret == RState.End;
  939. }
  940. private bool FnAbortGasBoxLeakCheck(object[] param)
  941. {
  942. _gasBoxLeakCheckRoutine.Abort();
  943. return true;
  944. }
  945. private bool FnStartLLPlace(object[] param)
  946. {
  947. return _llPlaceRoutine.Start() == RState.Running;
  948. }
  949. private bool FnLLPlaceTimeout(object[] param)
  950. {
  951. RState ret = _llPlaceRoutine.Monitor();
  952. if (ret == RState.Failed || ret == RState.Timeout)
  953. {
  954. PostMsg(MSG.Error);
  955. return false;
  956. }
  957. return ret == RState.End;
  958. }
  959. private bool FnAbortLLPlace(object[] param)
  960. {
  961. _llPlaceRoutine.Abort();
  962. return true;
  963. }
  964. private bool FnStartLLPick(object[] param)
  965. {
  966. return _llPickRoutine.Start() == RState.Running;
  967. }
  968. private bool FnLLPickTimeout(object[] param)
  969. {
  970. RState ret = _llPickRoutine.Monitor();
  971. if (ret == RState.Failed || ret == RState.Timeout)
  972. {
  973. PostMsg(MSG.Error);
  974. return false;
  975. }
  976. return ret == RState.End;
  977. }
  978. private bool FnAbortLLPick(object[] param)
  979. {
  980. _llPickRoutine.Abort();
  981. return true;
  982. }
  983. private bool FnRunRecipe(object[] param)
  984. {
  985. RState ret = _processRoutine.Start(param);
  986. if (ret == RState.Failed || ret == RState.Timeout)
  987. {
  988. PostMsg(MSG.Error);
  989. return false;
  990. }
  991. return ret == RState.Running;
  992. }
  993. private bool FnProcessTimeout(object[] param)
  994. {
  995. _chamber.CheckIdleInterlock();
  996. RState ret = _processRoutine.Monitor();
  997. if (ret == RState.Failed || ret == RState.Timeout)
  998. {
  999. PostMsg(MSG.Error);
  1000. return false;
  1001. }
  1002. if(ret == RState.End)
  1003. {
  1004. _dictRecipeTime[_processRoutine.currentRecipeResult.RecipeName] = fsm.ElapsedTime;
  1005. return true;
  1006. }
  1007. return false;
  1008. }
  1009. private bool FnAbortProcess(object[] param)
  1010. {
  1011. _processRoutine.Abort();
  1012. return true;
  1013. }
  1014. private bool FnStartGasFlow(object[] param)
  1015. {
  1016. return _gasFlowRoutine.Start(param) == RState.Running;
  1017. }
  1018. private bool FnGasFlowTimeout(object[] param)
  1019. {
  1020. RState ret = _gasFlowRoutine.Monitor();
  1021. if (ret == RState.Failed || ret == RState.Timeout)
  1022. {
  1023. PostMsg(MSG.Error);
  1024. return false;
  1025. }
  1026. return ret == RState.End;
  1027. }
  1028. private bool FnStopGasFlow(object[] param)
  1029. {
  1030. _gasFlowRoutine.Abort();
  1031. return true;
  1032. }
  1033. private bool FnAbortGasFlow(object[] param)
  1034. {
  1035. _gasFlowRoutine.Abort();
  1036. return true;
  1037. }
  1038. private bool FnStartRfPower(object[] param)
  1039. {
  1040. return _rfPowerRoutine.Start(param) == RState.Running;
  1041. }
  1042. private bool FnRfPowerTimeout(object[] param)
  1043. {
  1044. RState ret = _rfPowerRoutine.Monitor();
  1045. if (ret == RState.Failed || ret == RState.Timeout)
  1046. {
  1047. PostMsg(MSG.Error);
  1048. return false;
  1049. }
  1050. return ret == RState.End;
  1051. }
  1052. private bool FnAbortRfPower(object[] param)
  1053. {
  1054. _rfPowerRoutine.Abort();
  1055. if(_gasFlowRoutine._gasStatus)
  1056. {
  1057. _gasFlowRoutine.StopFlow();
  1058. }
  1059. return true;
  1060. }
  1061. private bool FnStartMFCVerification(object[] param)
  1062. {
  1063. _gasVerificationRoutine.Init((string)param[0], Convert.ToDouble( param[1]), (int)param[2]);
  1064. return _gasVerificationRoutine.Start(param) == RState.Running;
  1065. }
  1066. private bool FnMFCVerificationTimeout(object[] param)
  1067. {
  1068. RState ret = _gasVerificationRoutine.Monitor();
  1069. if (ret == RState.Failed || ret == RState.Timeout)
  1070. {
  1071. PostMsg(MSG.Error);
  1072. return false;
  1073. }
  1074. return ret == RState.End;
  1075. }
  1076. private bool FnAbortMFCVerification(object[] param)
  1077. {
  1078. _gasVerificationRoutine.Abort();
  1079. return true;
  1080. }
  1081. private bool FnControlPressure(object[] param)
  1082. {
  1083. if (RouteManager.IsATMMode)
  1084. {
  1085. return true;
  1086. }
  1087. if (IsOnline == true && fsm.State!=(int)PMState.Processing && fsm.State!=(int)PMState.Clean)
  1088. {
  1089. if (startControlPressureFlag == true)
  1090. {
  1091. startControlPressureFlag = false;
  1092. if (_chamber.GetPVPosition()<= 0)
  1093. {
  1094. LOG.Write(eEvent.WARN_PM, Module, $"{Module} control pressure fail,due to pendulum valve is not Open");
  1095. return false;
  1096. }
  1097. if (_chamber.IsTurboPumpRunning==false)
  1098. {
  1099. LOG.Write(eEvent.WARN_PM, Module, $"{Module} control pressure fail,due to turbo pump is not Open");
  1100. return false;
  1101. }
  1102. _controlPressureSetPoint = SC.GetValue<int>($"{Module}.ControlPressureSetPoint");
  1103. _controlFlowSetPoint = SC.GetValue<int>($"{Module}.ControlPressureN2FlowSetPoint");
  1104. _chamber.StartControlPressure(_controlPressureSetPoint, _controlFlowSetPoint);
  1105. }
  1106. }
  1107. else
  1108. {
  1109. if (startControlPressureFlag == false)
  1110. {
  1111. _chamber.AbortControlPressure();
  1112. startControlPressureFlag = true;
  1113. }
  1114. }
  1115. return true;
  1116. }
  1117. #region Exchange wafer with TM
  1118. private bool FnStartPreparePick(object[] param)
  1119. {
  1120. if (!_chamber.PreparePick())
  1121. {
  1122. LOG.Write(eEvent.ERR_PM, Module, $"Prepare Pick failed");
  1123. return false;
  1124. }
  1125. return true;
  1126. }
  1127. private bool FnPreparePickTimeout(object[] param)
  1128. {
  1129. // return _chamber.WaferIsDown && IsSlitDoorOpen;
  1130. return _chamber.PreparePickIsOK();
  1131. }
  1132. private bool FnAbortPreparePick(object[] param)
  1133. {
  1134. return true;
  1135. }
  1136. private bool FnStartFinishPick(object[] param)
  1137. {
  1138. //if (!_chamber.SetSlitDoor(false, out string reason))
  1139. //{
  1140. // LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1141. // return false;
  1142. //}
  1143. //return true;
  1144. return _chamber.EndPick();
  1145. }
  1146. private bool FnAbortPick(object[] param)
  1147. {
  1148. return true;
  1149. }
  1150. private bool FnFinishPickTimeout(object[] param)
  1151. {
  1152. //return IsSlitDoorClose;
  1153. return _chamber.EndPickIsOK();
  1154. }
  1155. private bool FnStartDropDownWafer(object[] param)
  1156. {
  1157. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1158. {
  1159. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1160. return false;
  1161. }
  1162. return _chamber.SetLiftPin(MovementPosition.Down, out string _);
  1163. }
  1164. private bool FnDropDownTimeout(object[] param)
  1165. {
  1166. return _chamber.LiftPinIsDown;
  1167. }
  1168. private bool FnStartPreparePlace(object[] param)
  1169. {
  1170. //if (_chamber.ChamberType == JetChamber.Venus || _chamber.ChamberType == JetChamber.Kepler2300)
  1171. //{
  1172. // if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1173. // {
  1174. // LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin down failed:{reason}");
  1175. // return false;
  1176. // }
  1177. //}
  1178. if (!_chamber.PreparePlace())
  1179. {
  1180. LOG.Write(eEvent.ERR_PM, Module, $"Set Wafer Down failed");
  1181. return false;
  1182. }
  1183. //string reason = "";
  1184. //if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1185. //{
  1186. // LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin down failed:{reason}");
  1187. // return false;
  1188. //}
  1189. return true;
  1190. }
  1191. private bool FnPreparePlaceTimeout(object[] param)
  1192. {
  1193. return _chamber.PreparePlaceIsOK();
  1194. }
  1195. private bool FnAbortPreparePlace(object[] param)
  1196. {
  1197. return true;
  1198. }
  1199. private bool FnStartLiftUpWafer(object[] param)
  1200. {
  1201. if (!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  1202. {
  1203. LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Up failed:{reason}");
  1204. return false;
  1205. }
  1206. return true;
  1207. }
  1208. private bool FnLiftUpTimeout(object[] param)
  1209. {
  1210. return _chamber.LiftPinIsUp;
  1211. }
  1212. private bool FnStartFinishPlace(object[] param)
  1213. {
  1214. //if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  1215. //{
  1216. // LOG.Write(eEvent.ERR_PM, Module, $"Set Lift Pin Down failed:{reason}");
  1217. // return false;
  1218. //}
  1219. //if (!_chamber.SetSlitDoor(false, out reason))
  1220. //{
  1221. // LOG.Write(eEvent.ERR_PM, Module, $"Set Slit Door Close failed:{reason}");
  1222. // return false;
  1223. //}
  1224. //return true;
  1225. return _chamber.EndPlace();
  1226. }
  1227. private bool FnAortPlace(object[] param)
  1228. {
  1229. return true;
  1230. }
  1231. private bool FnFinishPlaceTimeout(object[] param)
  1232. {
  1233. //return _chamber.LiftPinIsDown && IsSlitDoorClose;
  1234. return _chamber.EndPlaceIsOK();
  1235. }
  1236. private bool FnStartSwapPlace(object[] param)
  1237. {
  1238. return true;
  1239. }
  1240. private bool FnStartPartialPressure(object[] param)
  1241. {
  1242. return _pmPartialPressureRoutine.Start(param) == RState.Running;
  1243. }
  1244. private bool FnPartialPressureTimeout(object[] param)
  1245. {
  1246. RState ret = _pmPartialPressureRoutine.Monitor();
  1247. if (ret == RState.Failed || ret == RState.Timeout)
  1248. {
  1249. PostMsg(MSG.Error);
  1250. return false;
  1251. }
  1252. return ret == RState.End;
  1253. }
  1254. private bool FnAbortPartialPressure(object[] param)
  1255. {
  1256. _pmPartialPressureRoutine.Abort();
  1257. return true;
  1258. }
  1259. private bool FnStartVATPerformance(object[] param)
  1260. {
  1261. return _pmVATPerformanceRoutine.Start(param) == RState.Running;
  1262. }
  1263. private bool FnVATPerformanceTimeout(object[] param)
  1264. {
  1265. RState ret = _pmVATPerformanceRoutine.Monitor();
  1266. if (ret == RState.Failed || ret == RState.Timeout)
  1267. {
  1268. PostMsg(MSG.Error);
  1269. return false;
  1270. }
  1271. return ret == RState.End;
  1272. }
  1273. private bool FnAbortVATPerformance(object[] param)
  1274. {
  1275. _pmVATPerformanceRoutine.Abort();
  1276. return true;
  1277. }
  1278. #endregion
  1279. private void _debugRoutine()
  1280. {
  1281. int flag = 0;
  1282. // Test Home routine
  1283. if (flag == 1)
  1284. {
  1285. PostMsg(MSG.Home);
  1286. }
  1287. else if (flag == 2)
  1288. {
  1289. PostMsg(MSG.Vent);
  1290. }
  1291. else if (flag == 3)
  1292. {
  1293. PostMsg(MSG.Pump);
  1294. }
  1295. else if(flag == 4)
  1296. {
  1297. PostMsg(MSG.PumpLoadLock);
  1298. }
  1299. else if(flag == 5)
  1300. {
  1301. PostMsg(MSG.VentLoadLock);
  1302. }
  1303. else if(flag == 6)
  1304. {
  1305. PostMsg(MSG.PurgeLoadLock);
  1306. }
  1307. else if(flag == 7)
  1308. {
  1309. PostMsg(MSG.LaunchPump);
  1310. }
  1311. else if(flag == 8)
  1312. {
  1313. PostMsg(MSG.LaunchTurboPump);
  1314. }
  1315. else if(flag == 9)
  1316. {
  1317. PostMsg(MSG.LoadLockLeakCheck);
  1318. }
  1319. else if(flag == 10)
  1320. {
  1321. PostMsg(MSG.CyclePurge);
  1322. }
  1323. else if(flag == 11)
  1324. {
  1325. PostMsg(MSG.GasLinePurge);
  1326. }
  1327. else if(flag == 12)
  1328. {
  1329. PostMsg(MSG.LeakCheck);
  1330. }
  1331. else if(flag == 13)
  1332. {
  1333. PostMsg(MSG.GasLeakCheck);
  1334. }
  1335. else if(flag == 14)
  1336. {
  1337. PostMsg(MSG.LLPlace);
  1338. }
  1339. else if(flag == 15)
  1340. {
  1341. PostMsg(MSG.LLPick);
  1342. }
  1343. else if(flag == 16)
  1344. {
  1345. PostMsg(MSG.RunRecipe, "7777");
  1346. }
  1347. else if(flag == 17)
  1348. {
  1349. PostMsg(MSG.MFCVerification, "MFC2", (double)50, 10);
  1350. }
  1351. }
  1352. }
  1353. }