PMEntity.cs 58 KB

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