PMEntity.cs 57 KB

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