PMEntity.cs 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Fsm;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Aitex.Core.RT.Routine;
  8. using Aitex.Core.RT.SCCore;
  9. using Aitex.Core.Util;
  10. using MECF.Framework.Common.DataCenter;
  11. using MECF.Framework.Common.Equipment;
  12. using MECF.Framework.Common.Schedulers;
  13. using MECF.Framework.Common.SubstrateTrackings;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Threading;
  17. using VirgoCommon;
  18. using VirgoRT.Devices;
  19. using VirgoRT.Modules;
  20. using VirgoRT.Modules.PMs;
  21. namespace VirgoRT.Module
  22. {
  23. public class RecipeRunningInfo
  24. {
  25. public Guid InnerId { get; set; }
  26. public RecipeHead Head { get; set; }
  27. public List<RecipeStep> RecipeStepList { get; set; }
  28. public string RecipeName { get; set; }
  29. public DateTime BeginTime { get; set; }
  30. public DateTime EndTime { get; set; }
  31. public int StepNumber { get; set; }
  32. public string StepName { get; set; }
  33. public double StepTime { get; set; }
  34. public double StepElapseTime { get; set; }
  35. public double TotalTime { get; set; }
  36. public double TotalElapseTime { get; set; }
  37. }
  38. public class PMEntity : Entity, IModuleEntity
  39. {
  40. public enum MSG
  41. {
  42. Home,
  43. Transfer,
  44. PrepareTransfer,
  45. PostTransfer,
  46. Reset,
  47. Abort,
  48. Error,
  49. LaunchPump,
  50. Pump,
  51. Vent,
  52. CyclePurge,
  53. Heat,
  54. TransferHandoff,
  55. StartTransfer,
  56. LeakCheck,
  57. DeleteLeakCheck,
  58. MoveLiftPin,
  59. MoveGuidePin,
  60. MFCVerification,
  61. AllMFCVerification,
  62. Clean,
  63. CleanReady,
  64. Process,
  65. RunRecipe,
  66. PostProcess,
  67. RecipeSkipStep,
  68. RecipeUpdate,
  69. RecipeResume,
  70. RecipePause,
  71. RecipeAbort,
  72. PreProcess,
  73. AutoMode,
  74. ManualMode,
  75. LockLid,
  76. OpenSlitDoor,
  77. CloseSlitDoor,
  78. Online,
  79. Offline,
  80. GasFlow,
  81. StopGasFlow,
  82. RfPower,
  83. MaxMsg
  84. }
  85. // ----------------------------Fields--------------------------
  86. //
  87. private int _bigWafer = 0;
  88. private int _midWafer = 0;
  89. private int _smallWafer = 0;
  90. private StatsDataItem _statProcessedWafer;
  91. private StatsDataItemRFAndPump _statRfOnTime;
  92. private StatsDataItemRFAndPump _statPumpOnTime;
  93. private readonly JetPM _chamber;
  94. private string _processStatus;
  95. private DateTime _recipeStartTime;
  96. //routine
  97. private readonly VentRoutine _ventRoutine;
  98. private readonly PumpDownRoutine _pumpRoutine;
  99. private readonly StartPumpRoutine _startPumpRoutine;
  100. private readonly TemperatureControlRoutine _temperatureControlRoutine;
  101. private readonly GasFlowRoutine _gasFlowRoutine;
  102. private readonly RfPowerRoutine _rfPowerRoutine;
  103. private readonly CyclePurgeRoutine _cyclePurgeRoutine;
  104. private readonly CleanRoutine _cleanRoutine;
  105. private readonly ProcessRoutine _processRoutine;
  106. private readonly PreProcessRoutine _preProcessRoutine;
  107. private readonly PostProcessRoutine _postProcessRoutine;
  108. private readonly LeakCheckRoutine _leakCheckRoutine;
  109. private readonly PMPrepareTransferRoutine _prepareTrans;
  110. private readonly PMPostTransferRoutine _postTrans;
  111. private readonly PMHomeRoutine _home;
  112. private readonly PMMfcVerificationRoutine _mfcVerification;
  113. private readonly PMAllMfcVerificationRoutine _allMfcVerification;
  114. private AutoFlag _AutoMode;
  115. private bool _isOnline;
  116. private bool _isAlarm;
  117. private DateTime _pumpStartTime;
  118. private TimeSpan _pumpElapsedTime;
  119. private DateTime _rfStartTime;
  120. private DateTime _tcStartTime;
  121. private TimeSpan _rfElapsedTime;
  122. private TimeSpan _tcElapsedTime;
  123. private MovementPosition _goalLiftPin;
  124. private ushort _ActivatedActionID;
  125. // --------------------------Properties------------------------
  126. //
  127. public ModuleName Module { get; }
  128. public Action<bool, bool> TransferPrepared;
  129. public bool IsIdle
  130. {
  131. get { return fsm.State == (int)PMState.Idle; }
  132. }
  133. public bool IsError
  134. {
  135. get { return fsm.State == (int)PMState.Error; }
  136. }
  137. public bool IsAutoMode => _AutoMode == AutoFlag.Auto;
  138. public RecipeRunningInfo RecipeRunningInfo
  139. {
  140. get
  141. {
  142. return _recipeRunningInfo;
  143. }
  144. }
  145. public int Invoke(string function, params object[] args)
  146. {
  147. switch (function)
  148. {
  149. case "Home":
  150. CheckToPostMessage((int)MSG.Home);
  151. return (int)MSG.Home;
  152. }
  153. return (int)FSM_MSG.NONE;
  154. }
  155. public bool CheckAcked(int msg)
  156. {
  157. return fsm.CheckExecuted(msg);
  158. }
  159. public bool IsInit
  160. {
  161. get { return fsm.State == (int)PMState.Init; }
  162. }
  163. public bool IsBusy
  164. {
  165. get { return !IsInit && !IsError && !IsIdle; }
  166. }
  167. public bool IsProcessing
  168. {
  169. get { return fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess; }
  170. }
  171. private DateTime _leakCheckStartTime;
  172. private TimeSpan _leakCheckElapsedTime;
  173. private string LeakCheckElapseTime
  174. {
  175. get
  176. {
  177. if ((fsm.State == (int)PMState.LeakCheck))
  178. _leakCheckElapsedTime = DateTime.Now - _leakCheckStartTime;
  179. return string.Format("{0}:{1}:{2}", ((int)_leakCheckElapsedTime.TotalHours).ToString("00"),
  180. _leakCheckElapsedTime.Minutes.ToString("00"), _leakCheckElapsedTime.Seconds.ToString("00"));
  181. }
  182. }
  183. private string PumpTime
  184. {
  185. get
  186. {
  187. if ((fsm.State == (int)PMState.Pumping) || (fsm.State == (int)PMState.PreProcess))
  188. _pumpElapsedTime = DateTime.Now - _pumpStartTime;
  189. return string.Format("{0}:{1}:{2}", ((int)_pumpElapsedTime.TotalHours).ToString("00"),
  190. _pumpElapsedTime.Minutes.ToString("00"), _pumpElapsedTime.Seconds.ToString("00"));
  191. }
  192. }
  193. private int StepNo
  194. {
  195. get
  196. {
  197. if ((fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  198. {
  199. return _processRoutine.CurStepNum + 1;
  200. }
  201. return 0;
  202. }
  203. }
  204. private int RecipeSteps
  205. {
  206. get
  207. {
  208. if ((fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  209. {
  210. return _preProcessRoutine.CurrentRecipeStepList.Count;
  211. }
  212. return 0;
  213. }
  214. }
  215. private string RecipeStepName
  216. {
  217. get
  218. {
  219. if ((fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  220. {
  221. return _processRoutine.CurStepComment;
  222. }
  223. return null;
  224. }
  225. }
  226. private double LeakRate
  227. {
  228. get { return _leakCheckRoutine.LeakRate; }
  229. }
  230. private string RecipeName
  231. {
  232. get
  233. {
  234. if ((fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  235. {
  236. return _preProcessRoutine.CurrentRecipeRunningName.Split('\\')[1];
  237. }
  238. return null;
  239. }
  240. }
  241. private string RFTime
  242. {
  243. get
  244. {
  245. if (fsm.State == (int)PMState.RfPowering)
  246. _rfElapsedTime = DateTime.Now - _rfStartTime;
  247. return $"{((int)_rfElapsedTime.TotalHours).ToString("00")}:{_rfElapsedTime.Minutes.ToString("00")}:{_rfElapsedTime.Seconds.ToString("00")}";
  248. }
  249. }
  250. private string TCTime
  251. {
  252. get
  253. {
  254. if (fsm.State == (int)PMState.Heating)
  255. _tcElapsedTime = DateTime.Now - _tcStartTime;
  256. return $"{((int)_tcElapsedTime.TotalHours).ToString("00")}:{_tcElapsedTime.Minutes.ToString("00")}:{_tcElapsedTime.Seconds.ToString("00")}";
  257. }
  258. }
  259. private TimeSpan _recipeElapsedTime;
  260. public string RecipeElapsedTime
  261. {
  262. get
  263. {
  264. if (fsm.State == (int)PMState.LoadProcessRecipe || fsm.State == (int)PMState.PreProcess
  265. || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess)
  266. _recipeElapsedTime = DateTime.Now - _recipeStartTime;
  267. return string.Format("{0}:{1}:{2}", ((int)_recipeElapsedTime.TotalHours).ToString("00"),
  268. _recipeElapsedTime.Minutes.ToString("00"), _recipeElapsedTime.Seconds.ToString("00"));
  269. }
  270. }
  271. public double RecipeTotalElapsedSeconds
  272. {
  273. get
  274. {
  275. if (fsm.State == (int)PMState.LoadProcessRecipe || fsm.State == (int)PMState.PreProcess
  276. || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess)
  277. _recipeElapsedTime = DateTime.Now - _recipeStartTime;
  278. return _recipeElapsedTime.TotalSeconds;
  279. }
  280. }
  281. public bool IsOnline
  282. {
  283. get { return _isOnline; }
  284. }
  285. private RecipeRunningInfo _recipeRunningInfo = new RecipeRunningInfo();
  286. // --------------------------Constructor-----------------------
  287. //
  288. public PMEntity(ModuleName module)
  289. {
  290. this.Module = module;
  291. //_chamber = new JetPM(ModuleHelper.Converter(Name));
  292. _smallWafer = SC.GetValue<int>($"System.SmallWafer");
  293. _midWafer = SC.GetValue<int>($"System.MidWafer");
  294. _bigWafer = SC.GetValue<int>($"System.BigWafer");
  295. _chamber = DEVICE.GetDevice<JetPM>(Module.ToString());
  296. _isAlarm = false;
  297. LeakCheckResultManager.Instance.Initialize(Module.ToString());
  298. fsm = new StateMachine<PMEntity>(Module.ToString(), (int)PMState.Init, 50);
  299. _ventRoutine = new VentRoutine(_chamber);
  300. _pumpRoutine = new PumpDownRoutine(_chamber);
  301. _startPumpRoutine = new StartPumpRoutine(_chamber);
  302. _temperatureControlRoutine = new TemperatureControlRoutine(_chamber);
  303. _prepareTrans = new PMPrepareTransferRoutine(_chamber, _ventRoutine);
  304. _postTrans = new PMPostTransferRoutine(_chamber);
  305. _gasFlowRoutine = new GasFlowRoutine(_chamber);
  306. _rfPowerRoutine = new RfPowerRoutine(_chamber, true);
  307. _cyclePurgeRoutine = new CyclePurgeRoutine(_chamber);
  308. _leakCheckRoutine = new LeakCheckRoutine(_chamber, _pumpRoutine);
  309. _cleanRoutine = new CleanRoutine(_chamber);
  310. _preProcessRoutine = new PreProcessRoutine(_chamber, _pumpRoutine);
  311. _processRoutine = new ProcessRoutine(_chamber);
  312. _postProcessRoutine = new PostProcessRoutine(_chamber, _ventRoutine);
  313. _home = new PMHomeRoutine(_chamber);
  314. _mfcVerification = new PMMfcVerificationRoutine(_chamber, _pumpRoutine);
  315. _allMfcVerification = new PMAllMfcVerificationRoutine(_chamber, _pumpRoutine);
  316. //Idle
  317. EnterExitTransition((int)PMState.Idle, FnIdle, (int)FSM_MSG.NONE, null);
  318. EnterExitTransition<PMState, FSM_MSG>(PMState.Error, fEnterError, FSM_MSG.NONE, null);
  319. //Error
  320. Transition(PMState.Init, MSG.Error, FnError, PMState.Error);
  321. Transition(PMState.Error, MSG.Reset, FnReset, PMState.Idle);
  322. //AnyStateTransition(MSG.Error, FnError, PMState.Error);
  323. AnyStateTransition(FSM_MSG.WARNING, fWarning, FSM_STATE.SAME);
  324. AnyStateTransition((int)FSM_MSG.ALARM, fAlarm, (int)PMState.Error);
  325. AnyStateTransition(MSG.AutoMode, FnSetAuto, FSM_STATE.SAME);
  326. AnyStateTransition(MSG.ManualMode, FnSetManual, FSM_STATE.SAME);
  327. AnyStateTransition(MSG.Online, FnSetOnline, FSM_STATE.SAME);
  328. AnyStateTransition(MSG.Offline, FnSetOffline, FSM_STATE.SAME);
  329. //Home
  330. EnterExitTransition((int)PMState.Homing, FnEnterHome, (int)FSM_MSG.NONE, FnExitHome);
  331. Transition(PMState.Init, MSG.Home, FnStartHome, PMState.Homing);
  332. Transition(PMState.Error, MSG.Home, FnStartHome, PMState.Homing);
  333. Transition(PMState.Idle, MSG.Home, FnStartHome, PMState.Homing);
  334. Transition(PMState.Homing, FSM_MSG.TIMER, FnMonitorHome, PMState.Idle);
  335. Transition(PMState.Homing, MSG.Error, null, PMState.Init);
  336. Transition(PMState.Homing, MSG.Abort, FnAbortTask, PMState.Init);
  337. // Gas Flow sequence
  338. Transition(PMState.Idle, MSG.GasFlow, FnStartGasFlow, PMState.GasFlowing);
  339. Transition(PMState.GasFlowing, MSG.GasFlow, FnStartGasFlow, PMState.GasFlowing);
  340. Transition(PMState.GasFlowing, FSM_MSG.TIMER, FnGasFlowTimeout, PMState.Idle);
  341. Transition(PMState.GasFlowing, MSG.StopGasFlow, FnStopGasFlow, PMState.Idle);
  342. Transition(PMState.GasFlowing, MSG.Abort, FnAbortGasFlow, PMState.Idle);
  343. //RF Power sequence
  344. Transition(PMState.Idle, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  345. Transition(PMState.GasFlowing, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  346. Transition(PMState.RfPowering, FSM_MSG.TIMER, FnRfPowerTimeout, PMState.Idle);
  347. Transition(PMState.RfPowering, MSG.Abort, FnAbortRfPower, PMState.Idle);
  348. // Heat substrate
  349. Transition(PMState.Idle, MSG.Heat, FnHeat, PMState.Heating);
  350. Transition(PMState.Heating, FSM_MSG.TIMER, FnHeatTimeout, PMState.Idle);
  351. Transition(PMState.Heating, MSG.Abort, FnAbortHeating, PMState.Idle);
  352. //Launch Pump sequence
  353. Transition(PMState.Idle, MSG.LaunchPump, FnLaunchPump, PMState.LaunchingPump);
  354. Transition(PMState.LaunchingPump, FSM_MSG.TIMER, FnLaunchPumpTimeout, PMState.Idle);
  355. Transition(PMState.LaunchingPump, MSG.Abort, FnAbortStartPumping, PMState.Idle);
  356. //Pump sequence
  357. Transition(PMState.Idle, MSG.Pump, FnStartPumpDown, PMState.Pumping);
  358. Transition(PMState.Venting, MSG.Pump, FnVentToPumping, PMState.Pumping);
  359. Transition(PMState.Pumping, FSM_MSG.TIMER, FnPumpDownTimeout, PMState.Idle);
  360. Transition(PMState.Pumping, MSG.Abort, FnAbortPumping, PMState.Idle);
  361. //vent sequence
  362. Transition(PMState.Idle, MSG.Vent, FnStartVent, PMState.Venting);
  363. Transition(PMState.Pumping, MSG.Vent, FnPumpingToVent, PMState.Venting);
  364. Transition(PMState.Venting, FSM_MSG.TIMER, FnVentTimeout, PMState.Idle);
  365. Transition(PMState.Venting, MSG.Abort, FnAbortVent, PMState.Idle);
  366. // Purge sequence
  367. Transition(PMState.Idle, MSG.CyclePurge, FnStartPurge, PMState.Purging);
  368. Transition(PMState.Purging, FSM_MSG.TIMER, FnPurgeTimeout, PMState.Idle);
  369. Transition(PMState.Purging, MSG.Abort, FnAbortPurge, PMState.Idle);
  370. //Leak check sequence
  371. Transition(PMState.Idle, MSG.LeakCheck, FnStartLeakCheck, PMState.LeakCheck);
  372. Transition(PMState.Idle, MSG.DeleteLeakCheck, FnDeleteLeakCheck, PMState.Idle);
  373. Transition(PMState.LeakCheck, FSM_MSG.TIMER, FnLeakCheckTimeout, PMState.Idle);
  374. Transition(PMState.LeakCheck, MSG.Abort, FnAbortLeakCheck, PMState.Idle);
  375. //MFC verification
  376. Transition(PMState.Idle, MSG.MFCVerification, FnStartMFCVerification, PMState.MFCVerification);
  377. Transition(PMState.MFCVerification, FSM_MSG.TIMER, FnMFCVerificationTimeout, PMState.Idle);
  378. Transition(PMState.MFCVerification, MSG.Abort, FnAbortMFCVerification, PMState.Idle);
  379. //MFC verification
  380. Transition(PMState.Idle, MSG.AllMFCVerification, FnStartAllMFCVerification, PMState.AllMFCVerification);
  381. Transition(PMState.AllMFCVerification, FSM_MSG.TIMER, FnAllMFCVerificationTimeout, PMState.Idle);
  382. Transition(PMState.AllMFCVerification, MSG.Abort, FnAbortAllMFCVerification, PMState.Idle);
  383. // Transfer
  384. Transition(PMState.Idle, MSG.PrepareTransfer, FnStartPrepareTransfer, PMState.PrepareTransfer);
  385. Transition(PMState.PrepareTransfer, FSM_MSG.TIMER, FnPreTransferTimeout, PMState.Idle);
  386. Transition(PMState.PrepareTransfer, MSG.Abort, FnAbortTask, PMState.Idle);
  387. Transition(PMState.Idle, MSG.PostTransfer, FnStartPostTransfer, PMState.PostTransfer);
  388. Transition(PMState.PostTransfer, FSM_MSG.TIMER, FnPostTransferTimeout, PMState.Idle);
  389. Transition(PMState.PostTransfer, MSG.Abort, FnAbortTask, PMState.Idle);
  390. //EnterExitTransition<PMState, FSM_MSG>(PMState.TransferHandoff, null, FSM_MSG.NONE, fExitTransfer);
  391. //Transition(PMState.Idle, MSG.TransferHandoff, FnStartTransferHandoff, PMState.TransferHandoff);
  392. //Transition(PMState.TransferHandoff, FSM_MSG.TIMER, FnHandoffTime, PMState.Idle);
  393. //Transition(PMState.TransferHandoff, MSG.Abort, FnAbortTask, PMState.Idle);
  394. // lift pin
  395. Transition(PMState.Idle, MSG.MoveLiftPin, FnSetLiftpin, PMState.LiftpinMoving);
  396. Transition(PMState.LiftpinMoving, FSM_MSG.TIMER, FnLiftpinTimeout, PMState.Idle);
  397. // OpenSlitDoor
  398. Transition(PMState.Idle, MSG.OpenSlitDoor, FnOpenSlitDoor, PMState.OpeningSlitDoor);
  399. Transition(PMState.OpeningSlitDoor, FSM_MSG.TIMER, FnOpenSlitDoorTimeout, PMState.Idle);
  400. // CloseSlitDoor
  401. Transition(PMState.Idle, MSG.CloseSlitDoor, FnCloseSlitDoor, PMState.ClosingSlitDoor);
  402. Transition(PMState.ClosingSlitDoor, FSM_MSG.TIMER, FnCloseSlitDoorTimeout, PMState.Idle);
  403. // guide pin
  404. Transition(PMState.Idle, MSG.MoveGuidePin, FnSetGuidePin, PMState.GuidePinMoving);
  405. Transition(PMState.GuidePinMoving, FSM_MSG.TIMER, FnGuidePinTimeout, PMState.Idle);
  406. // PreClean sequence
  407. Transition(PMState.Idle, MSG.Clean, FnPreClean, PMState.PreClean);
  408. Transition(PMState.PreClean, FSM_MSG.TIMER, FnPreCleanTimeout, PMState.LoadProcessRecipe);
  409. // PreProcess sequence
  410. Transition(PMState.Idle, MSG.RunRecipe, FnProcessLoadRecipe, PMState.LoadProcessRecipe);
  411. Transition(PMState.LoadProcessRecipe, MSG.PreProcess, FnStartPreProcess, PMState.PreProcess);
  412. Transition(PMState.LoadProcessRecipe, MSG.Abort, null, PMState.Idle);
  413. Transition(PMState.LoadProcessRecipe, MSG.Error, null, PMState.Idle);
  414. Transition(PMState.PreProcess, FSM_MSG.TIMER, FnPreProcessTimeout, PMState.PreProcess);
  415. Transition(PMState.PreProcess, MSG.Abort, FnAbortPreProcess, PMState.Idle);
  416. Transition(PMState.PreProcess, MSG.RecipeAbort, FnAbortPreProcess, PMState.Idle);
  417. Transition(PMState.PreProcess, MSG.Error, FnAbortPreProcess, PMState.Error);
  418. // Process
  419. Transition(PMState.PreProcess, MSG.Process, FnStartProcess, PMState.Processing);
  420. Transition(PMState.Processing, FSM_MSG.TIMER, FnProcessTimeout, PMState.Processing);
  421. Transition(PMState.Processing, MSG.Error, FnAbortProcess, PMState.Error);
  422. Transition(PMState.Processing, MSG.RecipeAbort, FnAbortProcess, PMState.PostProcess);
  423. Transition(PMState.Processing, MSG.RecipePause, FnPauseProcess, PMState.Processing);
  424. Transition(PMState.Processing, MSG.RecipeResume, FnResumeRecipe, PMState.Processing);
  425. Transition(PMState.Processing, MSG.RecipeUpdate, FnUpdateRecipe, PMState.Processing);
  426. Transition(PMState.Processing, MSG.RecipeSkipStep, FnSkipStep, PMState.Processing);
  427. EnterExitTransition<PMState, FSM_MSG>(PMState.Processing, FnEnterProcess, FSM_MSG.NONE, FnExitProcess);
  428. //PostProcess sequence
  429. Transition(PMState.Processing, MSG.PostProcess, FnStartPostProcess, PMState.PostProcess);
  430. Transition(PMState.PostProcess, FSM_MSG.TIMER, FnPostProcessTimeout, PMState.Idle);
  431. Transition(PMState.PostProcess, MSG.Abort, FnAbortPostProcess, PMState.Idle);
  432. Transition(PMState.PostProcess, MSG.RecipeAbort, FnAbortPostProcess, PMState.Idle);
  433. EnterExitTransition<PMState, FSM_MSG>(PMState.PostProcess, null, FSM_MSG.NONE, fExitPostProcess);
  434. Running = true;
  435. }
  436. protected override bool Init()
  437. {
  438. DATA.Subscribe($"{Module}.FsmState", () => ((PMState)fsm.State).ToString());
  439. DATA.Subscribe($"{Module}.FsmPrevState", () => ((PMState)fsm.PrevState).ToString());
  440. DATA.Subscribe($"{Module}.FsmLastMessage", GetFsmLastMessage);
  441. DATA.Subscribe($"{Module}.PMState", () => fsm.State);
  442. DATA.Subscribe($"{Module}.IsAutoMode", () => IsAutoMode);
  443. DATA.Subscribe($"{Module}.IsOnline", () => _isOnline);
  444. DATA.Subscribe($"{Module}.IsAlarm", () => _isAlarm);
  445. DATA.Subscribe($"{Module}.ProcessStatus", () => _processStatus);
  446. DATA.Subscribe($"{Module}.PumpTime", () => PumpTime);
  447. DATA.Subscribe($"{Module}.TCTime", () => TCTime);
  448. DATA.Subscribe($"{Module}.StepNo", () => StepNo);
  449. DATA.Subscribe($"{Module}.RecipeStepName", () => RecipeStepName);
  450. DATA.Subscribe($"{Module}.RecipeName", () => RecipeName);
  451. DATA.Subscribe($"{Module}.LeakRate", () => LeakRate);
  452. DATA.Subscribe($"{Module}.LeakCheckElapseTime", () => LeakCheckElapseTime);
  453. DATA.Subscribe($"{Module}.SmallWafer", () => _smallWafer);
  454. DATA.Subscribe($"{Module}.BigWafer", () => _bigWafer);
  455. DATA.Subscribe($"{Module}.MidWafer", () => _midWafer);
  456. DATA.Subscribe($"{Module}.RecipeSteps", () => RecipeSteps);
  457. DATA.Subscribe($"{Module}.RecipeProcessTime", () => RecipeElapsedTime);
  458. DATA.Subscribe($"{Module}.RecipeTotalElapsedSeconds", () => RecipeTotalElapsedSeconds);
  459. DATA.Subscribe($"{Module}.RecipeStepTimeElapsed", () => (_processRoutine.CurStepElpasedTime / 1000).ToString("F0"));
  460. DATA.Subscribe($"{Module}.RecipeStepTimeSetPoint", () => (_processRoutine.CurStepTotalTime / 1000).ToString("F0"));
  461. OP.Subscribe($"{Module}.{RtOperation.GasFlow}", (cmd, args) => CheckToPostMessage((int)MSG.GasFlow, args));
  462. OP.Subscribe($"{Module}.{RtOperation.RfPower}", (cmd, args) => CheckToPostMessage((int)MSG.RfPower, args));
  463. OP.Subscribe($"{Module}.{RtOperation.MoveLiftPin}", (cmd, args) => CheckToPostMessage((int)MSG.MoveLiftPin, args[0], 0, true));
  464. OP.Subscribe($"{Module}.{RtOperation.MoveGuidePin}", (cmd, args) => CheckToPostMessage((int)MSG.MoveGuidePin, args[0], args[1]));
  465. OP.Subscribe($"{Module}.Home", (cmd, args) => CheckToPostMessage((int)MSG.Home));
  466. OP.Subscribe($"{Module}.{RtOperation.Reset}", (cmd, args) => CheckToPostMessage((int)MSG.Reset));
  467. OP.Subscribe($"{Module}.{RtOperation.Abort}", (cmd, args) => CheckToPostMessage((int)MSG.Abort));
  468. OP.Subscribe($"{Module}.PrepareTransfer", (cmd, args) => CheckToPostMessage((int)MSG.PrepareTransfer, args[0]));
  469. OP.Subscribe($"{Module}.TransferHandoff", (cmd, args) => CheckToPostMessage((int)MSG.TransferHandoff, args[0]));
  470. OP.Subscribe($"{Module}.{RtOperation.Pump}", (cmd, args) => CheckToPostMessage((int)MSG.Pump));
  471. OP.Subscribe($"{Module}.{RtOperation.StartPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchPump));
  472. OP.Subscribe($"{Module}.{RtOperation.Vent}", (cmd, args) => CheckToPostMessage((int)MSG.Vent));
  473. OP.Subscribe($"{Module}.{RtOperation.Purge}", (cmd, args) => CheckToPostMessage((int)MSG.CyclePurge));
  474. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck, args));
  475. OP.Subscribe($"{Module}.{RtOperation.DeleteLeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.DeleteLeakCheck, args));
  476. OP.Subscribe($"{Module}.{RtOperation.LockLid}", (cmd, args) => CheckToPostMessage((int)MSG.LockLid, true));
  477. OP.Subscribe($"{Module}.{RtOperation.UnlockLid}", (cmd, args) => CheckToPostMessage((int)MSG.LockLid, false));
  478. OP.Subscribe($"{Module}.{RtOperation.RunRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RunRecipe, (string)args[0], "", true));
  479. OP.Subscribe($"{Module}.{RtOperation.SkipCurrentStep}", (cmd, args) => CheckToPostMessage((int)MSG.RecipeSkipStep));
  480. OP.Subscribe($"{Module}.{RtOperation.AbortRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RecipeAbort));
  481. OP.Subscribe($"{Module}.{RtOperation.PmAuto}", (cmd, args) => CheckToPostMessage((int)MSG.AutoMode));
  482. OP.Subscribe($"{Module}.{RtOperation.PmManual}", (cmd, args) => CheckToPostMessage((int)MSG.ManualMode));
  483. OP.Subscribe($"{Module}.{RtOperation.PmOnline}", (cmd, args) => CheckToPostMessage((int)MSG.Online));
  484. OP.Subscribe($"{Module}.{RtOperation.PmOffline}", (cmd, args) => CheckToPostMessage((int)MSG.Offline));
  485. OP.Subscribe($"{Module}.{RtOperation.Heat}", (cmd, args) => CheckToPostMessage((int)MSG.Heat, args[0]));
  486. OP.Subscribe($"{Module}.{RtOperation.MFCVerification}", (cmd, args) => CheckToPostMessage((int)MSG.MFCVerification, args));
  487. OP.Subscribe($"{Module}.{RtOperation.AllMFCVerification}", (cmd, args) => CheckToPostMessage((int)MSG.AllMFCVerification, args));
  488. StatsDataManager.Instance.Subscribe($"{Module}.ProcessedWaferCount", "Processed Wafer Count", 0);
  489. StatsDataManager.Instance.Subscribe($"{Module}.RfOnTime", "Rf On Time");
  490. StatsDataManager.Instance.Subscribe($"{Module}.PumpOnTime", "Pump On Time");
  491. _statProcessedWafer = StatsDataManager.Instance.GetItem($"{Module}.ProcessedWaferCount");
  492. _statRfOnTime = StatsDataManager.Instance.GetItemRFAndPump($"{Module}.RfOnTime");
  493. _statPumpOnTime = StatsDataManager.Instance.GetItemRFAndPump($"{Module}.PumpOnTime");
  494. return true;
  495. }
  496. // Methods
  497. //
  498. private bool CheckToPostMessage(int msg, params object[] args)
  499. {
  500. if (!fsm.FindTransition(fsm.State, msg))
  501. {
  502. EV.PostWarningLog(Module.ToString(), $"{Module} is in { (PMState)fsm.State} state,can not do {(MSG)msg}");
  503. return false;
  504. }
  505. fsm.PostMsg(msg, args);
  506. return true;
  507. }
  508. private bool FnAbortTask(object[] param)
  509. {
  510. //_task.Abort();
  511. return true;
  512. }
  513. private bool FnSetAuto(object[] param)
  514. {
  515. this._AutoMode = AutoFlag.Auto;
  516. return true;
  517. }
  518. private bool FnSetManual(object[] param)
  519. {
  520. if (fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess)
  521. {
  522. EV.PostWarningLog(Module.ToString(), $"{Module} is in {(PMState)fsm.State},can not do SetAutoMode");
  523. return false;
  524. }
  525. this._AutoMode = AutoFlag.Manual;
  526. if (IsOnline)
  527. {
  528. EV.PostWarningLog(Module.ToString(), $"{Module} is online,change to offline due to the chamber change to manual mode");
  529. this._isOnline = false;
  530. }
  531. return true;
  532. }
  533. private bool FnSetOnline(object[] param)
  534. {
  535. if (!IsAutoMode)
  536. {
  537. EV.PostWarningLog(Module.ToString(), $"{Module} in manual mode,can not set online.");
  538. return false;
  539. }
  540. if (!_chamber.CheckSlitDoorClose())
  541. {
  542. EV.PostWarningLog(Module.ToString(), $"{Module} slit door is open,can not set online.");
  543. return false;
  544. }
  545. this._isOnline = true;
  546. return true;
  547. }
  548. private bool FnSetOffline(object[] param)
  549. {
  550. this._isOnline = false;
  551. return true;
  552. }
  553. #region Gas&RF
  554. private bool FnStartGasFlow(object[] objs)
  555. {
  556. Result ret = _gasFlowRoutine.Start(objs);
  557. if (ret == Result.FAIL || ret == Result.TIMEOUT)
  558. {
  559. return false; //do noting
  560. }
  561. return true;
  562. }
  563. private bool FnGasFlowTimeout(object[] objs)
  564. {
  565. Result ret = _gasFlowRoutine.Monitor();
  566. if (ret == Result.FAIL || ret == Result.TIMEOUT)
  567. {
  568. PostMsg(MSG.Abort);
  569. return true;
  570. }
  571. return false;
  572. }
  573. private bool FnAbortGasFlow(object[] objs)
  574. {
  575. _gasFlowRoutine.Abort();
  576. return true;
  577. }
  578. private bool FnStopGasFlow(object[] objs)
  579. {
  580. _gasFlowRoutine.StopFlow2();
  581. return true;
  582. }
  583. private bool FnStartRfPower(object[] objs)
  584. {
  585. _rfStartTime = DateTime.Now;
  586. Result ret = _rfPowerRoutine.Start(objs);
  587. if (ret == Result.DONE)
  588. {
  589. return false;
  590. }
  591. if (ret == Result.FAIL || ret == Result.TIMEOUT)
  592. {
  593. return false; //do noting
  594. }
  595. return true;
  596. }
  597. private bool FnRfPowerTimeout(object[] objs)
  598. {
  599. Result ret = _rfPowerRoutine.Monitor();
  600. if (ret == Result.DONE)
  601. return true;
  602. else if (ret == Result.FAIL || ret == Result.TIMEOUT)
  603. {
  604. //do nothing
  605. return true;
  606. }
  607. return false;
  608. ;
  609. }
  610. private bool FnAbortRfPower(object[] objs)
  611. {
  612. _rfPowerRoutine.Abort();
  613. if (_gasFlowRoutine._gasStatus)
  614. _gasFlowRoutine.Abort();
  615. return true;
  616. }
  617. private bool FnHeat(object[] objs)
  618. {
  619. _tcStartTime = DateTime.Now;
  620. return _temperatureControlRoutine.Start(objs) == Result.RUN;
  621. }
  622. private bool FnHeatTimeout(object[] param)
  623. {
  624. Result ret = _temperatureControlRoutine.Monitor();
  625. if (ret == Result.DONE)
  626. {
  627. return true;
  628. }
  629. if (ret == Result.FAIL || ret == Result.TIMEOUT)
  630. {
  631. //do nothing
  632. return true;
  633. }
  634. return false;
  635. }
  636. private bool FnAbortHeating(object[] param)
  637. {
  638. _temperatureControlRoutine.Abort();
  639. return true;
  640. }
  641. #endregion Gas&RF
  642. #region Subroutine
  643. private bool FnStartLeakCheck(object[] param)
  644. {
  645. _leakCheckStartTime = DateTime.Now;
  646. return _leakCheckRoutine.Start(param) == Result.RUN;
  647. }
  648. private bool FnLeakCheckTimeout(object[] param)
  649. {
  650. Result res = _leakCheckRoutine.Monitor();
  651. return res == Result.DONE || res == Result.FAIL;
  652. }
  653. private bool FnDeleteLeakCheck(object[] param)
  654. {
  655. _leakCheckRoutine.DeleteLeadCheck(param);
  656. return true;
  657. }
  658. private bool FnAbortLeakCheck(object[] param)
  659. {
  660. _leakCheckRoutine.Abort();
  661. return true;
  662. }
  663. private bool FnStartMFCVerification(object[] param)
  664. {
  665. _mfcVerification.Init((string)param[0], (float)param[1], (int)param[2]);
  666. return _mfcVerification.Start(param) == Result.RUN;
  667. }
  668. private bool FnMFCVerificationTimeout(object[] param)
  669. {
  670. Result res = _mfcVerification.Monitor();
  671. return res == Result.DONE || res == Result.FAIL;
  672. }
  673. private bool FnAbortMFCVerification(object[] param)
  674. {
  675. _mfcVerification.Abort();
  676. return true;
  677. }
  678. private bool FnStartAllMFCVerification(object[] param)
  679. {
  680. _allMfcVerification.Init((string[])param[0], (bool[])param[1]);
  681. return _allMfcVerification.Start(param) == Result.RUN;
  682. }
  683. private bool FnAllMFCVerificationTimeout(object[] param)
  684. {
  685. Result res = _allMfcVerification.Monitor();
  686. return res == Result.DONE || res == Result.FAIL;
  687. }
  688. private bool FnAbortAllMFCVerification(object[] param)
  689. {
  690. _allMfcVerification.Abort();
  691. return true;
  692. }
  693. private bool FnStartVent(object[] param)
  694. {
  695. Result ret = _ventRoutine.Start();
  696. if (ret == Result.DONE)
  697. {
  698. return false;
  699. }
  700. else if (ret == Result.FAIL)
  701. {
  702. return false; //do noting
  703. }
  704. return true;
  705. }
  706. private bool FnVentTimeout(object[] param)
  707. {
  708. Result ret = _ventRoutine.Monitor();
  709. if (ret == Result.DONE)
  710. {
  711. return true;
  712. }
  713. if (ret == Result.FAIL)
  714. {
  715. //do nothing
  716. return true;
  717. }
  718. return false;
  719. }
  720. private bool FnVentToPumping(object[] param)
  721. {
  722. _ventRoutine.Abort();
  723. return FnStartPumpDown(param);
  724. }
  725. private bool FnAbortVent(object[] param)
  726. {
  727. _ventRoutine.Abort();
  728. return true;
  729. }
  730. private bool FnLaunchPump(object[] param)
  731. {
  732. _pumpStartTime = DateTime.Now;
  733. return _startPumpRoutine.Start() == Result.RUN;
  734. }
  735. private bool FnLaunchPumpTimeout(object[] param)
  736. {
  737. Result ret = _startPumpRoutine.Monitor();
  738. if (ret == Result.DONE)
  739. {
  740. return true;
  741. }
  742. if (ret == Result.FAIL || ret == Result.TIMEOUT)
  743. {
  744. PostMsg(MSG.Abort);
  745. return false;
  746. }
  747. return false;
  748. }
  749. private bool FnAbortStartPumping(object[] param)
  750. {
  751. _startPumpRoutine.Abort();
  752. return true;
  753. }
  754. private bool FnStartPumpDown(object[] param)
  755. {
  756. _pumpStartTime = DateTime.Now;
  757. return _pumpRoutine.Start() == Result.RUN;
  758. }
  759. private bool FnPumpDownTimeout(object[] param)
  760. {
  761. Result ret = _pumpRoutine.Monitor();
  762. if (ret == Result.DONE)
  763. {
  764. return true;
  765. }
  766. if (ret == Result.FAIL || ret == Result.TIMEOUT)
  767. {
  768. //do nothing
  769. return true;
  770. }
  771. return false;
  772. }
  773. private bool FnPumpingToVent(object[] param)
  774. {
  775. _pumpRoutine.Abort();
  776. return FnStartVent(param);
  777. }
  778. private bool FnAbortPumping(object[] param)
  779. {
  780. _pumpRoutine.Abort();
  781. return true;
  782. }
  783. private bool FnStartPurge(object[] param)
  784. {
  785. return _cyclePurgeRoutine.Start(param) == Result.RUN;
  786. }
  787. private bool FnPurgeTimeout(object[] param)
  788. {
  789. Result ret = _cyclePurgeRoutine.Monitor();
  790. if (ret == Result.DONE)
  791. {
  792. return true;
  793. }
  794. else if (ret == Result.FAIL || ret == Result.TIMEOUT)
  795. {
  796. return true;
  797. }
  798. return false;
  799. }
  800. private bool FnAbortPurge(object[] param)
  801. {
  802. _cyclePurgeRoutine.Abort();
  803. return true;
  804. }
  805. #endregion Subroutine
  806. #region Transfer
  807. private bool FnStartPrepareTransfer(object[] param)
  808. {
  809. if (param.Length > 2)
  810. _prepareTrans.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), (float)param[1], (WaferSize)param[2]);
  811. else if (param.Length > 1)
  812. _prepareTrans.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), (float)param[1]);
  813. else
  814. _prepareTrans.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), 0);
  815. Result ret = _prepareTrans.Start();
  816. if (ret == Result.FAIL || ret == Result.DONE)
  817. return false;
  818. return ret == Result.RUN;
  819. }
  820. private bool FnPreTransferTimeout(object[] param)
  821. {
  822. Result ret = _prepareTrans.Monitor();
  823. if (ret == Result.FAIL)
  824. {
  825. PostMsg(MSG.Abort);
  826. return false;
  827. }
  828. return ret == Result.DONE;
  829. }
  830. private bool FnStartPostTransfer(object[] param)
  831. {
  832. Result ret = _postTrans.Start();
  833. if (ret == Result.FAIL)
  834. {
  835. PostMsg(MSG.Error);
  836. return false;
  837. }
  838. return ret == Result.RUN;
  839. }
  840. private bool FnPostTransferTimeout(object[] param)
  841. {
  842. Result ret = _postTrans.Monitor();
  843. if (ret == Result.FAIL)
  844. {
  845. PostMsg(MSG.Abort);
  846. return false;
  847. }
  848. return ret == Result.DONE;
  849. }
  850. private bool FnSetLiftpin(object[] param)
  851. {
  852. MovementPosition pos = (MovementPosition)param[0];
  853. _ActivatedActionID = (ushort)param[1];
  854. bool isPick = (bool) param[2];
  855. if (pos == MovementPosition.Down) //增加Place & Pick的Delay功能
  856. {
  857. int pinDownDelayTime = SC.GetValue<int>($"{Module}.PinDownDelayTimePick") * 1000;
  858. if (!isPick)
  859. {
  860. pinDownDelayTime = SC.GetValue<int>($"{Module}.PinDownDelayTimePlace") * 1000;
  861. }
  862. if (pinDownDelayTime > 0)
  863. {
  864. EV.PostInfoLog(Module.ToString(), $"Delay {pinDownDelayTime/1000} seconds before lift pin down");
  865. Thread.Sleep(pinDownDelayTime);
  866. }
  867. }
  868. _chamber.SetLiftPin(pos, out _);
  869. EV.PostInfoLog(Module.ToString(), $"执行 lift pin {pos}");
  870. _goalLiftPin = pos;
  871. return true;
  872. }
  873. private bool FnLiftpinTimeout(object[] param)
  874. {
  875. if (_chamber.LiftPinPosition == _goalLiftPin)
  876. {
  877. EV.PostInfoLog(Module.ToString(), $"lift pin 当前位置 {_chamber.LiftPinPosition}");
  878. Singleton<RouteManager>.Instance.EFEM.PostMsg(
  879. _goalLiftPin == MovementPosition.Up ? EfemEntity.MSG.PMLiftPinUp : EfemEntity.MSG.PMLiftPinDown, _ActivatedActionID);
  880. _goalLiftPin = MovementPosition.Unknown;
  881. _ActivatedActionID = 0;
  882. return true;
  883. }
  884. return false;
  885. }
  886. private bool FnOpenSlitDoor(object[] param)
  887. {
  888. _ActivatedActionID = (ushort)param[0];
  889. _chamber.SetSlitDoor(true, out _);
  890. EV.PostInfoLog(Module.ToString(), $"Start opening {Module} slit door");
  891. return true;
  892. }
  893. private bool FnOpenSlitDoorTimeout(object[] param)
  894. {
  895. if (_chamber.CheckSlitDoorOpen() )
  896. {
  897. EV.PostInfoLog(Module.ToString(), $"{Module} slit door is opened");
  898. Singleton<RouteManager>.Instance.EFEM.PostMsg( EfemEntity.MSG.PMSlitDoorOpened, _ActivatedActionID);
  899. _ActivatedActionID = 0;
  900. return true;
  901. }
  902. return false;
  903. }
  904. private bool FnCloseSlitDoor(object[] param)
  905. {
  906. _ActivatedActionID = (ushort)param[0];
  907. _chamber.SetSlitDoor(false, out _);
  908. EV.PostInfoLog(Module.ToString(), $"Start closing {Module} slit door");
  909. return true;
  910. }
  911. private bool FnCloseSlitDoorTimeout(object[] param)
  912. {
  913. if (_chamber.CheckSlitDoorClose())
  914. {
  915. EV.PostInfoLog(Module.ToString(), $"{Module} slit door is closed");
  916. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.PMSlitDoorClosed, _ActivatedActionID);
  917. _ActivatedActionID = 0;
  918. return true;
  919. }
  920. return false;
  921. }
  922. private bool FnSetGuidePin(object[] param)
  923. {
  924. WaferSize ws = (WaferSize)param[0];
  925. MovementPosition pos = (MovementPosition)param[1];
  926. _chamber.SetGuidePin(ws, pos);
  927. return true;
  928. }
  929. private bool FnGuidePinTimeout(object[] param)
  930. {
  931. return true;
  932. }
  933. private bool FnPreClean(object[] param)
  934. {
  935. _cleanRoutine.param = param;
  936. _chamber.SetSlitDoor(false, out _);
  937. return true;
  938. }
  939. private bool FnPreCleanTimeout(object[] param)
  940. {
  941. if (_chamber.IsSlitDoorClosed)
  942. {
  943. if (!FnProcessLoadRecipe(_cleanRoutine.param))
  944. {
  945. EV.PostAlarmLog(_chamber.Module.ToString(), "Clean recipe read failed");
  946. PostMsg(FSM_MSG.ALARM);
  947. return false;
  948. }
  949. return true;
  950. }
  951. return false;
  952. }
  953. #endregion Transfer
  954. #region Process
  955. private bool FnProcessLoadRecipe(object[] param)
  956. {
  957. _processStatus = "Succeed to load recipe";
  958. _recipeStartTime = DateTime.Now;
  959. Result ret = _preProcessRoutine.LoadRecipe(param);
  960. if (ret == Result.DONE)
  961. {
  962. PostMsg(MSG.PreProcess);
  963. }
  964. else if (ret == Result.FAIL)
  965. {
  966. _processStatus = "Failed to load recipe";
  967. return false;
  968. }
  969. return true;
  970. }
  971. private bool FnStartPreProcess(object[] param)
  972. {
  973. _pumpStartTime = DateTime.Now;
  974. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipe;
  975. Result ret = _preProcessRoutine.Start(param);
  976. if (ret == Result.DONE)
  977. {
  978. return false;
  979. }
  980. if (ret == Result.FAIL || ret == Result.VERIFYFAIL)
  981. {
  982. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipeFailed;
  983. PostMsg(MSG.Error);
  984. return false; //do noting
  985. }
  986. WaferManager.Instance.UpdateWaferProcessStatus(this.Module, 0, EnumWaferProcessStatus.InProcess);
  987. return true;
  988. }
  989. private bool FnPreProcessTimeout(object[] param)
  990. {
  991. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDown;
  992. Result ret = _preProcessRoutine.Monitor();
  993. if (ret == Result.DONE)
  994. {
  995. PostMsg(MSG.Process,
  996. _preProcessRoutine.CurrentRecipeBaseName,
  997. _preProcessRoutine.CurrentRecipeRunningName,
  998. 0,
  999. _preProcessRoutine.CurrentLotName,
  1000. _preProcessRoutine.CurrentRecipeContent,
  1001. _preProcessRoutine.CurrentRecipeHead,
  1002. _preProcessRoutine.CurrentRecipeStepList,
  1003. _preProcessRoutine.CurrentRecipeGuid);
  1004. return true;
  1005. }
  1006. if (ret == Result.FAIL)
  1007. {
  1008. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDownFailed;
  1009. PostMsg(MSG.Error);
  1010. return true;
  1011. }
  1012. return false; ;
  1013. }
  1014. private bool FnAbortPreProcess(object[] param)
  1015. {
  1016. //_processStatus = Resources.PMEntity_fAbortPreProcess_RunRecipePumpingDownAborted;
  1017. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1018. _preProcessRoutine.Abort();
  1019. return true;
  1020. }
  1021. private bool FnStartProcess(object[] param)
  1022. {
  1023. //_processStatus = Resources.PMEntity_fStartProcess_StartRunningRecipe;
  1024. Result ret = _processRoutine.Start(param);
  1025. if (ret == Result.DONE)
  1026. {
  1027. return true;
  1028. }
  1029. else if (ret == Result.FAIL || ret == Result.VERIFYFAIL)
  1030. {
  1031. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1032. PostMsg(MSG.Error);
  1033. return true; //do noting
  1034. }
  1035. return true;
  1036. }
  1037. private bool FnProcessTimeout(object[] param)
  1038. {
  1039. //_processStatus = Resources.PMEntity_fProcess_RunningRecipe;
  1040. Result ret = _processRoutine.Monitor();
  1041. {
  1042. if (ret == Result.DONE)
  1043. {
  1044. PostMsg(MSG.PostProcess,
  1045. _processRoutine.CurrentRecipeRunningName,
  1046. _processRoutine.CurrentRecipeContent,
  1047. _preProcessRoutine.CurrentRecipeGuid);
  1048. return true;
  1049. }
  1050. else if (ret == Result.FAIL)
  1051. {
  1052. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1053. PostMsg(MSG.Error);
  1054. return true;
  1055. }
  1056. return false;
  1057. }
  1058. }
  1059. private bool FnAbortProcess(object[] param)
  1060. {
  1061. //_processStatus = Resources.PMEntity_fAbortProcess_RunningRecipeAborted;
  1062. _processRoutine.AbortRecipe();
  1063. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1064. _processRoutine.Abort();
  1065. Result ret = _postProcessRoutine.Start(new object[] { _processRoutine.CurrentRecipeRunningName, _processRoutine.CurrentRecipeContent, _processRoutine.CurrentRecipeGuid });
  1066. if (ret == Result.DONE)
  1067. {
  1068. return false;
  1069. }
  1070. else if (ret == Result.FAIL)
  1071. {
  1072. PostMsg(MSG.Error);
  1073. //_processStatus = Resources.PMEntity_fAbortProcess_RunRecipeAborted;
  1074. return false; //do noting
  1075. }
  1076. return true;
  1077. }
  1078. private bool FnPauseProcess(object[] param)
  1079. {
  1080. return true;
  1081. }
  1082. private bool FnResumeRecipe(object[] param)
  1083. {
  1084. return true;
  1085. }
  1086. private bool FnUpdateRecipe(object[] param)
  1087. {
  1088. return true;
  1089. }
  1090. private bool FnSkipStep(object[] param)
  1091. {
  1092. _processRoutine.SkipCurrentRecipeStep();
  1093. return true;
  1094. }
  1095. private bool FnExitProcess(object[] param)
  1096. {
  1097. //_statProcessedWafer
  1098. StatsDataManager.Instance.Increase(_statProcessedWafer.Name);
  1099. _processRoutine.Exit();
  1100. return true;
  1101. }
  1102. private bool FnEnterProcess(object[] param)
  1103. {
  1104. return true;
  1105. }
  1106. private bool FnStartPostProcess(object[] param)
  1107. {
  1108. //_processStatus = Resources.PMEntity_fStartPostProcess_RunRecipePostProcess;
  1109. Result ret = _postProcessRoutine.Start(param);
  1110. if (ret == Result.DONE)
  1111. {
  1112. return false;
  1113. }
  1114. else if (ret == Result.FAIL)
  1115. {
  1116. PostMsg(MSG.Error);
  1117. return false;
  1118. }
  1119. return true;
  1120. }
  1121. private bool FnPostProcessTimeout(object[] param)
  1122. {
  1123. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurge;
  1124. Result ret = _postProcessRoutine.Monitor();
  1125. if (ret == Result.DONE)
  1126. {
  1127. WaferManager.Instance.UpdateWaferProcessStatus(this.Module, 0, EnumWaferProcessStatus.Completed);
  1128. //_processStatus = Resources.PMEntity_fPostProcess_RecipeCompleted;
  1129. return true;
  1130. }
  1131. else if (ret == Result.FAIL)
  1132. {
  1133. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurgeError;
  1134. PostMsg(MSG.Error);
  1135. return true;
  1136. }
  1137. return false;
  1138. }
  1139. private bool FnAbortPostProcess(object[] param)
  1140. {
  1141. //_processStatus = Resources.PMEntity_fAbortPostProcess_RecipeAborted;
  1142. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1143. _postProcessRoutine.Abort();
  1144. return true;
  1145. }
  1146. private bool fExitPostProcess(object[] objs)
  1147. {
  1148. _postProcessRoutine.Exit();
  1149. //EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1150. //{
  1151. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1152. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1153. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1154. //});
  1155. return true;
  1156. }
  1157. #endregion PROCESS
  1158. private string GetFsmLastMessage()
  1159. {
  1160. int msg = fsm.LastMsg;
  1161. if (msg >= (int)MSG.Home && msg <= (int)MSG.MaxMsg)
  1162. return ((MSG)msg).ToString();
  1163. if (msg == (int)FSM_MSG.TIMER)
  1164. return "Timer";
  1165. return msg.ToString();
  1166. }
  1167. protected override void Term()
  1168. {
  1169. }
  1170. private bool FnReset(object[] param)
  1171. {
  1172. _isAlarm = false;
  1173. if ((PMState)fsm.State == PMState.Error)
  1174. return true;
  1175. return false;
  1176. }
  1177. public bool Check(int msg, out string reason, object[] objs)
  1178. {
  1179. reason = "";
  1180. return true;
  1181. }
  1182. public bool IsProcessed()
  1183. {
  1184. return IsIdle;
  1185. }
  1186. public bool IsPrepareTransferReady(ModuleName robot, EnumTransferType type, int slot, WaferSize size)
  1187. {
  1188. if (type == EnumTransferType.Pick)
  1189. {
  1190. return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(_chamber.Module, 0).Size);
  1191. }
  1192. else if (type == EnumTransferType.Place)
  1193. {
  1194. return _chamber.CheckEnableTransfer(type, size);
  1195. }
  1196. return false;
  1197. }
  1198. public void Home()
  1199. {
  1200. CheckToPostMessage((int)MSG.Home);
  1201. }
  1202. private bool FnExitHome(object[] param)
  1203. {
  1204. return true;
  1205. }
  1206. private bool FnEnterHome(object[] param)
  1207. {
  1208. return true;
  1209. }
  1210. private bool FnStartHome(object[] objs)
  1211. {
  1212. Result ret = _home.Start();
  1213. if (ret == Result.FAIL || ret == Result.DONE)
  1214. return false;
  1215. return ret == Result.RUN;
  1216. }
  1217. private bool FnMonitorHome(object[] objs)
  1218. {
  1219. Result ret = _home.Monitor();
  1220. if (ret == Result.FAIL)
  1221. {
  1222. PostMsg(MSG.Error);
  1223. return false;
  1224. }
  1225. return ret == Result.DONE;
  1226. }
  1227. private bool fExitTransfer(object[] objs)
  1228. {
  1229. return true;
  1230. }
  1231. private bool fEnterError(object[] objs)
  1232. {
  1233. //if (IsProcessMode)
  1234. //{
  1235. // EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1236. // {
  1237. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1238. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1239. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1240. // });
  1241. //}
  1242. _chamber.GeneratorPowerOn(false);
  1243. _chamber.StopAllGases();
  1244. return true;
  1245. }
  1246. private bool FnError(object[] objs)
  1247. {
  1248. Running = false;
  1249. if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  1250. || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  1251. return false;
  1252. if (IsProcessing)
  1253. {
  1254. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1255. }
  1256. return true;
  1257. }
  1258. private bool fWarning(object[] objs)
  1259. {
  1260. //IsWarning = false;
  1261. return true;
  1262. }
  1263. private bool fAlarm(object[] objs)
  1264. {
  1265. _isAlarm = true;
  1266. if (fsm.State == (int)PMState.Init)
  1267. return false;
  1268. if (fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.PostProcess)
  1269. {
  1270. PostMsg(MSG.Error);
  1271. return false;
  1272. }
  1273. //IsAlarm = true;
  1274. return true;
  1275. }
  1276. private bool FnIdle(object[] objs)
  1277. {
  1278. Running = false;
  1279. return true;
  1280. }
  1281. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  1282. {
  1283. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString()))
  1284. return (int)MSG.PrepareTransfer;
  1285. return (int)FSM_MSG.NONE;
  1286. }
  1287. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp)
  1288. {
  1289. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp))
  1290. return (int)MSG.PrepareTransfer;
  1291. return (int)FSM_MSG.NONE;
  1292. }
  1293. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp, WaferSize size)
  1294. {
  1295. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp, size))
  1296. return (int)MSG.PrepareTransfer;
  1297. return (int)FSM_MSG.NONE;
  1298. }
  1299. public int InvokePostTransfer(ModuleName robot, EnumTransferType type, int slot)
  1300. {
  1301. if (CheckToPostMessage((int)MSG.PostTransfer, type.ToString()))
  1302. return (int)MSG.PostTransfer;
  1303. return (int)FSM_MSG.NONE;
  1304. }
  1305. public int InvokeClean(string recipeName, string waferID, bool withWafer)
  1306. {
  1307. if (CheckToPostMessage((int)MSG.Clean, recipeName, waferID, withWafer))
  1308. {
  1309. return (int)MSG.Clean;
  1310. }
  1311. return (int)FSM_MSG.NONE;
  1312. }
  1313. public int InvokeProcess(string recipeName, string waferID, bool withWafer)
  1314. {
  1315. if (CheckToPostMessage((int)MSG.RunRecipe, recipeName, waferID, withWafer))
  1316. return (int)MSG.RunRecipe;
  1317. return (int)FSM_MSG.NONE;
  1318. }
  1319. public int InvokePreHeat(float temperature)
  1320. {
  1321. if (CheckToPostMessage((int)MSG.Heat, (double)temperature))
  1322. return (int)MSG.Heat;
  1323. return (int)FSM_MSG.NONE;
  1324. }
  1325. public void InvokeReset()
  1326. {
  1327. PostMsg((int)MSG.Reset);
  1328. }
  1329. public void SetAuto()
  1330. {
  1331. this._AutoMode = AutoFlag.Auto;
  1332. }
  1333. }
  1334. }