PMEntity.cs 58 KB

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