PMEntity.cs 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Diagnostics;
  5. using Aitex.Core.Common;
  6. using Aitex.Core.RT.DataCenter;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Event;
  9. using Aitex.Core.RT.Fsm;
  10. using Aitex.Core.RT.OperationCenter;
  11. using Aitex.Core.RT.Routine;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.Util;
  14. using Aitex.RT.Device.Custom;
  15. using Aitex.Sorter.Common;
  16. using MECF.Framework.Common.DataCenter;
  17. using MECF.Framework.Common.Equipment;
  18. using MECF.Framework.Common.Schedulers;
  19. using MECF.Framework.Common.SubstrateTrackings;
  20. using VirgoCommon;
  21. using VirgoRT.Devices;
  22. using VirgoRT.Modules;
  23. using VirgoRT.Modules.PMs;
  24. namespace VirgoRT.Module
  25. {
  26. public class RecipeRunningInfo
  27. {
  28. public Guid InnerId { get; set; }
  29. public RecipeHead Head { get; set; }
  30. public List<RecipeStep> RecipeStepList { get; set; }
  31. public string RecipeName { get; set; }
  32. public DateTime BeginTime { get; set; }
  33. public DateTime EndTime { get; set; }
  34. public int StepNumber { get; set; }
  35. public string StepName { get; set; }
  36. public double StepTime { get; set; }
  37. public double StepElapseTime { get; set; }
  38. public double TotalTime { get; set; }
  39. public double TotalElapseTime { get; set; }
  40. }
  41. public class PMEntity : Entity, IModuleEntity
  42. {
  43. public enum MSG
  44. {
  45. Home,
  46. Transfer,
  47. PrepareTransfer,
  48. PostTransfer,
  49. Reset,
  50. Abort,
  51. Error,
  52. LaunchPump,
  53. Pump,
  54. Vent,
  55. CyclePurge,
  56. Heat,
  57. TransferHandoff,
  58. StartTransfer,
  59. LeakCheck,
  60. DeleteLeakCheck,
  61. MoveLiftPin,
  62. WaitLiftpin,
  63. MoveGuidePin,
  64. MFCVerification,
  65. AllMFCVerification,
  66. Clean,
  67. CleanReady,
  68. Process,
  69. RunRecipe,
  70. PostProcess,
  71. RecipeSkipStep,
  72. RecipeUpdate,
  73. RecipeResume,
  74. RecipePause,
  75. RecipeAbort,
  76. PreProcess,
  77. AutoMode,
  78. ManualMode,
  79. LockLid,
  80. Online,
  81. Offline,
  82. GasFlow,
  83. StopGasFlow,
  84. RfPower,
  85. MaxMsg
  86. }
  87. // ----------------------------Fields--------------------------
  88. //
  89. private int _bigWafer = 0;
  90. private int _midWafer = 0;
  91. private int _smallWafer = 0;
  92. private bool _enableBias;
  93. private int _liftpinDelayTime = 0;
  94. private StatsDataItem _statProcessedWafer;
  95. private StatsDataItemRFAndPump _statRfOnTime;
  96. private StatsDataItemRFAndPump _statBiasRfOnTime;
  97. private StatsDataItemRFAndPump _statPumpOnTime;
  98. private readonly JetPM _chamber;
  99. private string _processStatus;
  100. private DateTime _recipeStartTime;
  101. //routine
  102. private readonly VentRoutine _ventRoutine;
  103. private readonly PumpDownRoutine _pumpRoutine;
  104. private readonly StartPumpRoutine _startPumpRoutine;
  105. private readonly TemperatureControlRoutine _temperatureControlRoutine;
  106. private readonly GasFlowRoutine _gasFlowRoutine;
  107. private readonly RfPowerRoutine _rfPowerRoutine;
  108. private readonly CyclePurgeRoutine _cyclePurgeRoutine;
  109. private readonly CleanRoutine _cleanRoutine;
  110. private readonly ProcessRoutine _processRoutine;
  111. private readonly PreProcessRoutine _preProcessRoutine;
  112. private readonly PostProcessRoutine _postProcessRoutine;
  113. private readonly LeakCheckRoutine _leakCheckRoutine;
  114. private readonly PMPrepareTransferRoutine _prepareTrans;
  115. private readonly PMPostTransferRoutine _postTrans;
  116. private readonly PMHomeRoutine _home;
  117. private readonly PMMfcVerificationRoutine _mfcVerification;
  118. private readonly PMAllMfcVerificationRoutine _allMfcVerification;
  119. private AutoFlag _AutoMode;
  120. private bool _isOnline;
  121. private bool _isAlarm;
  122. private DateTime _pumpStartTime;
  123. private TimeSpan _pumpElapsedTime;
  124. private DateTime _rfStartTime;
  125. private DateTime _tcStartTime;
  126. private TimeSpan _rfElapsedTime;
  127. private TimeSpan _tcElapsedTime;
  128. private MovementPosition _goalLiftPin;
  129. private ushort _ActivatedActionID;
  130. private Stopwatch _LifpinSleepTimer;
  131. // --------------------------Properties------------------------
  132. //
  133. public ModuleName Module { get; }
  134. public Action<bool, bool> TransferPrepared;
  135. public bool IsIdle
  136. {
  137. get { return fsm.State == (int)PMState.Idle; }
  138. }
  139. public bool IsError
  140. {
  141. get { return fsm.State == (int)PMState.Error; }
  142. }
  143. public bool IsAutoMode => _AutoMode == AutoFlag.Auto;
  144. public RecipeRunningInfo RecipeRunningInfo
  145. {
  146. get
  147. {
  148. return _recipeRunningInfo;
  149. }
  150. }
  151. public int Invoke(string function, params object[] args)
  152. {
  153. switch (function)
  154. {
  155. case "Home":
  156. CheckToPostMessage((int)MSG.Home);
  157. return (int)MSG.Home;
  158. }
  159. return (int)FSM_MSG.NONE;
  160. }
  161. public bool CheckAcked(int msg)
  162. {
  163. return fsm.CheckExecuted(msg);
  164. }
  165. public bool IsInit
  166. {
  167. get { return fsm.State == (int)PMState.Init; }
  168. }
  169. public bool IsBusy
  170. {
  171. get { return !IsInit && !IsError && !IsIdle; }
  172. }
  173. public bool IsProcessing
  174. {
  175. get { return fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess ; }
  176. }
  177. private DateTime _leakCheckStartTime;
  178. private TimeSpan _leakCheckElapsedTime;
  179. private string LeakCheckElapseTime
  180. {
  181. get
  182. {
  183. if ((fsm.State == (int)PMState.LeakCheck))
  184. _leakCheckElapsedTime = DateTime.Now - _leakCheckStartTime;
  185. return string.Format("{0}:{1}:{2}", ((int)_leakCheckElapsedTime.TotalHours).ToString("00"),
  186. _leakCheckElapsedTime.Minutes.ToString("00"), _leakCheckElapsedTime.Seconds.ToString("00"));
  187. }
  188. }
  189. private string PumpTime
  190. {
  191. get
  192. {
  193. if ((fsm.State == (int)PMState.Pumping) || (fsm.State == (int)PMState.PreProcess))
  194. _pumpElapsedTime = DateTime.Now - _pumpStartTime;
  195. return string.Format("{0}:{1}:{2}", ((int)_pumpElapsedTime.TotalHours).ToString("00"),
  196. _pumpElapsedTime.Minutes.ToString("00"), _pumpElapsedTime.Seconds.ToString("00"));
  197. }
  198. }
  199. private int StepNo
  200. {
  201. get
  202. {
  203. if ( (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  204. {
  205. return _processRoutine.CurStepNum + 1;
  206. }
  207. return 0;
  208. }
  209. }
  210. private int RecipeSteps
  211. {
  212. get
  213. {
  214. if ((fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  215. {
  216. return _preProcessRoutine.CurrentRecipeStepList.Count;
  217. }
  218. return 0;
  219. }
  220. }
  221. private string RecipeStepName
  222. {
  223. get
  224. {
  225. if ((fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  226. {
  227. return _processRoutine.CurStepComment;
  228. }
  229. return null;
  230. }
  231. }
  232. private double LeakRate
  233. {
  234. get { return _leakCheckRoutine.LeakRate; }
  235. }
  236. private string RecipeName
  237. {
  238. get
  239. {
  240. if ((fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PostProcess))
  241. {
  242. return _preProcessRoutine.CurrentRecipeRunningName.Split('\\')[1];
  243. }
  244. return null;
  245. }
  246. }
  247. private string RFTime
  248. {
  249. get
  250. {
  251. if (fsm.State == (int)PMState.RfPowering)
  252. _rfElapsedTime = DateTime.Now - _rfStartTime;
  253. return $"{((int)_rfElapsedTime.TotalHours).ToString("00")}:{_rfElapsedTime.Minutes.ToString("00")}:{_rfElapsedTime.Seconds.ToString("00")}";
  254. }
  255. }
  256. private string TCTime
  257. {
  258. get
  259. {
  260. if (fsm.State == (int)PMState.Heating)
  261. _tcElapsedTime = DateTime.Now - _tcStartTime;
  262. return $"{((int)_tcElapsedTime.TotalHours).ToString("00")}:{_tcElapsedTime.Minutes.ToString("00")}:{_tcElapsedTime.Seconds.ToString("00")}";
  263. }
  264. }
  265. private TimeSpan _recipeElapsedTime;
  266. public string RecipeElapsedTime
  267. {
  268. get
  269. {
  270. if (fsm.State == (int)PMState.LoadProcessRecipe || fsm.State == (int)PMState.PreProcess
  271. || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess)
  272. _recipeElapsedTime = DateTime.Now - _recipeStartTime;
  273. return string.Format("{0}:{1}:{2}", ((int)_recipeElapsedTime.TotalHours).ToString("00"),
  274. _recipeElapsedTime.Minutes.ToString("00"), _recipeElapsedTime.Seconds.ToString("00"));
  275. }
  276. }
  277. public double RecipeTotalElapsedSeconds
  278. {
  279. get
  280. {
  281. if (fsm.State == (int)PMState.LoadProcessRecipe || fsm.State == (int)PMState.PreProcess
  282. || fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PostProcess)
  283. _recipeElapsedTime = DateTime.Now - _recipeStartTime;
  284. return _recipeElapsedTime.TotalSeconds;
  285. }
  286. }
  287. public bool IsOnline
  288. {
  289. get { return _isOnline; }
  290. }
  291. private RecipeRunningInfo _recipeRunningInfo = new RecipeRunningInfo();
  292. // --------------------------Constructor-----------------------
  293. //
  294. public PMEntity(ModuleName module)
  295. {
  296. this.Module = module;
  297. //_chamber = new JetPM(ModuleHelper.Converter(Name));
  298. _smallWafer = SC.GetValue<int>($"System.SmallWafer");
  299. _midWafer = SC.GetValue<int>($"System.MidWafer");
  300. _bigWafer = SC.GetValue<int>($"System.BigWafer");
  301. _enableBias = SC.GetValue<bool>($"{Module}.BiasRf.EnableBiasRF");
  302. _chamber = DEVICE.GetDevice<JetPM>(Module.ToString());
  303. _isAlarm = false;
  304. _LifpinSleepTimer = new Stopwatch();
  305. LeakCheckResultManager.Instance.Initialize(Module.ToString());
  306. fsm = new StateMachine<PMEntity>(Module.ToString(), (int)PMState.Init, 50);
  307. _ventRoutine = new VentRoutine(_chamber);
  308. _pumpRoutine = new PumpDownRoutine(_chamber);
  309. _startPumpRoutine = new StartPumpRoutine(_chamber);
  310. _temperatureControlRoutine = new TemperatureControlRoutine(_chamber);
  311. _prepareTrans = new PMPrepareTransferRoutine(_chamber, _ventRoutine);
  312. _postTrans = new PMPostTransferRoutine(_chamber);
  313. _gasFlowRoutine = new GasFlowRoutine(_chamber);
  314. _rfPowerRoutine = new RfPowerRoutine(_chamber, true);
  315. _cyclePurgeRoutine = new CyclePurgeRoutine(_chamber);
  316. _leakCheckRoutine = new LeakCheckRoutine(_chamber, _pumpRoutine);
  317. _cleanRoutine = new CleanRoutine(_chamber);
  318. _preProcessRoutine = new PreProcessRoutine(_chamber, _pumpRoutine);
  319. _processRoutine = new ProcessRoutine(_chamber, this);
  320. _postProcessRoutine = new PostProcessRoutine(_chamber, _ventRoutine);
  321. _home = new PMHomeRoutine(_chamber);
  322. _mfcVerification = new PMMfcVerificationRoutine(_chamber, _pumpRoutine);
  323. _allMfcVerification = new PMAllMfcVerificationRoutine(_chamber, _pumpRoutine);
  324. //Idle
  325. EnterExitTransition((int)PMState.Idle, FnIdle, (int)FSM_MSG.NONE, null);
  326. EnterExitTransition<PMState, FSM_MSG>(PMState.Error, fEnterError, FSM_MSG.NONE, null);
  327. //Error
  328. Transition(PMState.Init, MSG.Error, FnError, PMState.Error);
  329. Transition(PMState.Error, MSG.Reset, FnReset, PMState.Idle);
  330. //AnyStateTransition(MSG.Error, FnError, PMState.Error);
  331. AnyStateTransition(FSM_MSG.WARNING, fWarning, FSM_STATE.SAME);
  332. AnyStateTransition((int)FSM_MSG.ALARM, fAlarm, (int)PMState.Error);
  333. AnyStateTransition(MSG.AutoMode, FnSetAuto, FSM_STATE.SAME);
  334. AnyStateTransition(MSG.ManualMode, FnSetManual, FSM_STATE.SAME);
  335. AnyStateTransition(MSG.Online, FnSetOnline, FSM_STATE.SAME);
  336. AnyStateTransition(MSG.Offline, FnSetOffline, FSM_STATE.SAME);
  337. //Home
  338. EnterExitTransition((int)PMState.Homing, FnEnterHome, (int)FSM_MSG.NONE, FnExitHome);
  339. Transition(PMState.Init, MSG.Home, FnStartHome, PMState.Homing);
  340. Transition(PMState.Error, MSG.Home, FnStartHome, PMState.Homing);
  341. Transition(PMState.Idle, MSG.Home, FnStartHome, PMState.Homing);
  342. Transition(PMState.Homing, FSM_MSG.TIMER, FnMonitorHome, PMState.Idle);
  343. Transition(PMState.Homing, MSG.Error, null, PMState.Init);
  344. Transition(PMState.Homing, MSG.Abort, FnAbortTask, PMState.Init);
  345. // Gas Flow sequence
  346. Transition(PMState.Idle, MSG.GasFlow, FnStartGasFlow, PMState.GasFlowing);
  347. Transition(PMState.GasFlowing, MSG.GasFlow, FnStartGasFlow, PMState.GasFlowing);
  348. Transition(PMState.GasFlowing, FSM_MSG.TIMER, FnGasFlowTimeout, PMState.Idle);
  349. Transition(PMState.GasFlowing, MSG.StopGasFlow, FnStopGasFlow, PMState.Idle);
  350. Transition(PMState.GasFlowing, MSG.Abort, FnAbortGasFlow, PMState.Idle);
  351. //RF Power sequence
  352. Transition(PMState.Idle, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  353. Transition(PMState.GasFlowing, MSG.RfPower, FnStartRfPower, PMState.RfPowering);
  354. Transition(PMState.RfPowering, FSM_MSG.TIMER, FnRfPowerTimeout, PMState.Idle);
  355. Transition(PMState.RfPowering, MSG.Abort, FnAbortRfPower, PMState.Idle);
  356. // Heat substrate
  357. Transition(PMState.Idle, MSG.Heat, FnHeat, PMState.Heating);
  358. Transition(PMState.Heating, FSM_MSG.TIMER, FnHeatTimeout, PMState.Idle);
  359. Transition(PMState.Heating, MSG.Abort, FnAbortHeating, PMState.Idle);
  360. //Launch Pump sequence
  361. Transition(PMState.Idle, MSG.LaunchPump, FnLaunchPump, PMState.LaunchingPump);
  362. Transition(PMState.LaunchingPump, FSM_MSG.TIMER, FnLaunchPumpTimeout, PMState.Idle);
  363. Transition(PMState.LaunchingPump, MSG.Abort, FnAbortStartPumping, PMState.Idle);
  364. //Pump sequence
  365. Transition(PMState.Idle, MSG.Pump, FnStartPumpDown, PMState.Pumping);
  366. Transition(PMState.Venting, MSG.Pump, FnVentToPumping, PMState.Pumping);
  367. Transition(PMState.Pumping, FSM_MSG.TIMER, FnPumpDownTimeout, PMState.Idle);
  368. Transition(PMState.Pumping, MSG.Abort, FnAbortPumping, PMState.Idle);
  369. //vent sequence
  370. Transition(PMState.Idle, MSG.Vent, FnStartVent, PMState.Venting);
  371. Transition(PMState.Pumping, MSG.Vent, FnPumpingToVent, PMState.Venting);
  372. Transition(PMState.Venting, FSM_MSG.TIMER, FnVentTimeout, PMState.Idle);
  373. Transition(PMState.Venting, MSG.Abort, FnAbortVent, PMState.Idle);
  374. // Purge sequence
  375. Transition(PMState.Idle, MSG.CyclePurge, FnStartPurge, PMState.Purging);
  376. Transition(PMState.Purging, FSM_MSG.TIMER, FnPurgeTimeout, PMState.Idle);
  377. Transition(PMState.Purging, MSG.Abort, FnAbortPurge, PMState.Idle);
  378. //Leak check sequence
  379. Transition(PMState.Idle, MSG.LeakCheck, FnStartLeakCheck, PMState.LeakCheck);
  380. Transition(PMState.Idle, MSG.DeleteLeakCheck, FnDeleteLeakCheck, PMState.Idle);
  381. Transition(PMState.LeakCheck, FSM_MSG.TIMER, FnLeakCheckTimeout, PMState.Idle);
  382. Transition(PMState.LeakCheck, MSG.Abort, FnAbortLeakCheck, PMState.Idle);
  383. //MFC verification
  384. Transition(PMState.Idle, MSG.MFCVerification, FnStartMFCVerification, PMState.MFCVerification);
  385. Transition(PMState.MFCVerification, FSM_MSG.TIMER, FnMFCVerificationTimeout, PMState.Idle);
  386. Transition(PMState.MFCVerification, MSG.Abort, FnAbortMFCVerification, PMState.Idle);
  387. //MFC verification
  388. Transition(PMState.Idle, MSG.AllMFCVerification, FnStartAllMFCVerification, PMState.AllMFCVerification);
  389. Transition(PMState.AllMFCVerification, FSM_MSG.TIMER, FnAllMFCVerificationTimeout, PMState.Idle);
  390. Transition(PMState.AllMFCVerification, MSG.Abort, FnAbortAllMFCVerification, PMState.Idle);
  391. // Transfer
  392. Transition(PMState.Idle, MSG.PrepareTransfer, FnStartPrepareTransfer, PMState.PrepareTransfer);
  393. Transition(PMState.PrepareTransfer, FSM_MSG.TIMER, FnPreTransferTimeout, PMState.Idle);
  394. Transition(PMState.PrepareTransfer, MSG.Abort, FnAbortTask, PMState.Idle);
  395. Transition(PMState.Idle, MSG.PostTransfer, FnStartPostTransfer, PMState.PostTransfer);
  396. Transition(PMState.PostTransfer, FSM_MSG.TIMER, FnPostTransferTimeout, PMState.Idle);
  397. Transition(PMState.PostTransfer, MSG.Abort, FnAbortTask, PMState.Idle);
  398. //EnterExitTransition<PMState, FSM_MSG>(PMState.TransferHandoff, null, FSM_MSG.NONE, fExitTransfer);
  399. //Transition(PMState.Idle, MSG.TransferHandoff, FnStartTransferHandoff, PMState.TransferHandoff);
  400. //Transition(PMState.TransferHandoff, FSM_MSG.TIMER, FnHandoffTime, PMState.Idle);
  401. //Transition(PMState.TransferHandoff, MSG.Abort, FnAbortTask, PMState.Idle);
  402. // lift pin
  403. Transition(PMState.Idle, MSG.MoveLiftPin, FnSetLiftpin, PMState.LiftpinMoving);
  404. Transition(PMState.Idle, MSG.WaitLiftpin, null, PMState.LiftpinWaiting);
  405. Transition(PMState.LiftpinWaiting, FSM_MSG.TIMER, FnWaitLiftpinTimeout, PMState.LiftpinMoving);
  406. Transition(PMState.LiftpinMoving, FSM_MSG.TIMER, FnLiftpinTimeout, PMState.Idle);
  407. // guide pin
  408. Transition(PMState.Idle, MSG.MoveGuidePin, FnSetGuidePin, PMState.GuidePinMoving);
  409. Transition(PMState.GuidePinMoving, FSM_MSG.TIMER, FnGuidePinTimeout, PMState.Idle);
  410. // PreClean sequence
  411. Transition(PMState.Idle, MSG.Clean, FnPreClean, PMState.PreClean);
  412. Transition(PMState.PreClean, FSM_MSG.TIMER, FnPreCleanTimeout, PMState.LoadProcessRecipe);
  413. // PreProcess sequence
  414. Transition(PMState.Idle, MSG.RunRecipe, FnProcessLoadRecipe, PMState.LoadProcessRecipe);
  415. Transition(PMState.LoadProcessRecipe, MSG.PreProcess, FnStartPreProcess, PMState.PreProcess);
  416. Transition(PMState.LoadProcessRecipe, MSG.Abort, null, PMState.Idle);
  417. Transition(PMState.LoadProcessRecipe, MSG.Error, null, PMState.Idle);
  418. Transition(PMState.PreProcess, FSM_MSG.TIMER, FnPreProcessTimeout, PMState.PreProcess);
  419. Transition(PMState.PreProcess, MSG.Abort, FnAbortPreProcess, PMState.Idle);
  420. Transition(PMState.PreProcess, MSG.RecipeAbort, FnAbortPreProcess, PMState.Idle);
  421. Transition(PMState.PreProcess, MSG.Error, FnAbortPreProcess, PMState.Error);
  422. // Process
  423. Transition(PMState.PreProcess, MSG.Process, FnStartProcess, PMState.Processing);
  424. Transition(PMState.Processing, FSM_MSG.TIMER, FnProcessTimeout, PMState.Processing);
  425. Transition(PMState.Processing, MSG.Error, FnAbortProcess, PMState.Error);
  426. Transition(PMState.Processing, MSG.RecipeAbort, FnAbortProcess, PMState.PostProcess);
  427. Transition(PMState.Processing, MSG.RecipePause, FnPauseProcess, PMState.Processing);
  428. Transition(PMState.Processing, MSG.RecipeResume, FnResumeRecipe, PMState.Processing);
  429. Transition(PMState.Processing, MSG.RecipeUpdate, FnUpdateRecipe, PMState.Processing);
  430. Transition(PMState.Processing, MSG.RecipeSkipStep, FnSkipStep, PMState.Processing);
  431. EnterExitTransition<PMState, FSM_MSG>(PMState.Processing, FnEnterProcess, FSM_MSG.NONE, FnExitProcess);
  432. //PostProcess sequence
  433. Transition(PMState.Processing, MSG.PostProcess, FnStartPostProcess, PMState.PostProcess);
  434. Transition(PMState.PostProcess, FSM_MSG.TIMER, FnPostProcessTimeout, PMState.Idle);
  435. Transition(PMState.PostProcess, MSG.Abort, FnAbortPostProcess, PMState.Idle);
  436. Transition(PMState.PostProcess, MSG.RecipeAbort, FnAbortPostProcess, PMState.Idle);
  437. Transition(PMState.PostProcess, MSG.Error, FnAbortPostProcess, PMState.Error);
  438. EnterExitTransition<PMState, FSM_MSG>(PMState.PostProcess, null, FSM_MSG.NONE, fExitPostProcess);
  439. Running = true;
  440. }
  441. protected override bool Init()
  442. {
  443. DATA.Subscribe($"{Module}.FsmState", () => ((PMState)fsm.State).ToString());
  444. DATA.Subscribe($"{Module}.FsmPrevState", () => ((PMState)fsm.PrevState).ToString());
  445. DATA.Subscribe($"{Module}.FsmLastMessage", GetFsmLastMessage);
  446. DATA.Subscribe($"{Module}.PMState", () => fsm.State);
  447. DATA.Subscribe($"{Module}.IsAutoMode", () => IsAutoMode);
  448. DATA.Subscribe($"{Module}.IsOnline", () => _isOnline);
  449. DATA.Subscribe($"{Module}.IsAlarm", () => _isAlarm);
  450. DATA.Subscribe($"{Module}.ProcessStatus", () => _processStatus);
  451. DATA.Subscribe($"{Module}.PumpTime", () => PumpTime);
  452. DATA.Subscribe($"{Module}.TCTime", () => TCTime);
  453. DATA.Subscribe($"{Module}.StepNo", () => StepNo);
  454. DATA.Subscribe($"{Module}.RecipeStepName", () => RecipeStepName);
  455. DATA.Subscribe($"{Module}.RecipeName", () => RecipeName);
  456. DATA.Subscribe($"{Module}.LeakRate", () => LeakRate);
  457. DATA.Subscribe($"{Module}.LeakCheckElapseTime", () => LeakCheckElapseTime);
  458. DATA.Subscribe($"{Module}.SmallWafer", () => _smallWafer);
  459. DATA.Subscribe($"{Module}.BigWafer", () => _bigWafer);
  460. DATA.Subscribe($"{Module}.MidWafer", () => _midWafer);
  461. DATA.Subscribe($"{Module}.RecipeSteps", () => RecipeSteps);
  462. DATA.Subscribe($"{Module}.RecipeProcessTime", () => RecipeElapsedTime);
  463. DATA.Subscribe($"{Module}.RecipeTotalElapsedSeconds", () => RecipeTotalElapsedSeconds);
  464. DATA.Subscribe($"{Module}.RecipeStepTimeElapsed", () => (_processRoutine.CurStepElpasedTime / 1000).ToString("F0"));
  465. DATA.Subscribe($"{Module}.RecipeStepTimeSetPoint", () => (_processRoutine.CurStepTotalTime / 1000).ToString("F0"));
  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);
  504. DATA.Subscribe($"{Module}.RfOnTime", () => _statRfOnTime.fromLastPM);
  505. if (_enableBias)
  506. DATA.Subscribe($"{Module}.BiasRfOnTime", () => _statBiasRfOnTime.fromLastPM);
  507. DATA.Subscribe($"{Module}.PumpOnTime", () => _statPumpOnTime.fromLastPM);
  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. _goalLiftPin = pos;
  870. _liftpinDelayTime = SC.GetValue<int>(isPick ? $"{Module}.PinDownDelayTimePick" : $"{Module}.PinDownDelayTimePlace") * 1000;
  871. if (_liftpinDelayTime > 0)
  872. {
  873. _LifpinSleepTimer.Restart();
  874. CheckToPostMessage((int)MSG.WaitLiftpin);
  875. return false;
  876. }
  877. _chamber.SetLiftPin(pos, out _);
  878. EV.PostInfoLog(Module.ToString(), $"执行 lift pin {pos}");
  879. return true;
  880. }
  881. private bool FnWaitLiftpinTimeout(object[] param)
  882. {
  883. if (_LifpinSleepTimer.ElapsedMilliseconds > _liftpinDelayTime)
  884. {
  885. _chamber.SetLiftPin(_goalLiftPin, out _);
  886. EV.PostInfoLog(Module.ToString(), $"执行 lift pin {_goalLiftPin}");
  887. _LifpinSleepTimer.Reset();
  888. return true;
  889. }
  890. return false;
  891. }
  892. private bool FnLiftpinTimeout(object[] param)
  893. {
  894. if (_chamber.LiftPinPosition == _goalLiftPin)
  895. {
  896. EV.PostInfoLog(Module.ToString(), $"lift pin 当前位置 {_chamber.LiftPinPosition}");
  897. Singleton<RouteManager>.Instance.EFEM.PostMsg(
  898. _goalLiftPin == MovementPosition.Up ? EfemEntity.MSG.PMLiftPinUp : EfemEntity.MSG.PMLiftPinDown, _ActivatedActionID);
  899. _goalLiftPin = MovementPosition.Unknown;
  900. _ActivatedActionID = 0;
  901. return true;
  902. }
  903. return false;
  904. }
  905. private bool FnSetGuidePin(object[] param)
  906. {
  907. WaferSize ws = (WaferSize)param[0];
  908. MovementPosition pos = (MovementPosition)param[1];
  909. _chamber.SetGuidePin(ws, pos);
  910. return true;
  911. }
  912. private bool FnGuidePinTimeout(object[] param)
  913. {
  914. return true;
  915. }
  916. private bool FnPreClean(object[] param)
  917. {
  918. _cleanRoutine.param = param;
  919. _chamber.SetSlitDoor(false, out _);
  920. return true;
  921. }
  922. private bool FnPreCleanTimeout(object[] param)
  923. {
  924. if (_chamber.IsSlitDoorClosed)
  925. {
  926. if (!FnProcessLoadRecipe(_cleanRoutine.param))
  927. {
  928. EV.PostAlarmLog(_chamber.Module.ToString(), "Clean recipe read failed");
  929. PostMsg(FSM_MSG.ALARM);
  930. return false;
  931. }
  932. return true;
  933. }
  934. return false;
  935. }
  936. #endregion Transfer
  937. #region Process
  938. private bool FnProcessLoadRecipe(object[] param)
  939. {
  940. _processStatus = "Succeed to load recipe";
  941. _recipeStartTime = DateTime.Now;
  942. Result ret = _preProcessRoutine.LoadRecipe(param);
  943. if (ret == Result.DONE)
  944. {
  945. PostMsg(MSG.PreProcess);
  946. }
  947. else if (ret == Result.FAIL)
  948. {
  949. _processStatus = "Failed to load recipe";
  950. return false;
  951. }
  952. return true;
  953. }
  954. private bool FnStartPreProcess(object[] param)
  955. {
  956. _pumpStartTime = DateTime.Now;
  957. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipe;
  958. Result ret = _preProcessRoutine.Start(param);
  959. if (ret == Result.DONE)
  960. {
  961. return false;
  962. }
  963. if (ret == Result.FAIL || ret == Result.VERIFYFAIL)
  964. {
  965. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipeFailed;
  966. PostMsg(MSG.Error);
  967. return false; //do noting
  968. }
  969. WaferManager.Instance.UpdateWaferProcessStatus(this.Module, 0, EnumWaferProcessStatus.InProcess);
  970. return true;
  971. }
  972. private bool FnPreProcessTimeout(object[] param)
  973. {
  974. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDown;
  975. Result ret = _preProcessRoutine.Monitor();
  976. if (ret == Result.DONE)
  977. {
  978. PostMsg(MSG.Process,
  979. _preProcessRoutine.CurrentRecipeBaseName,
  980. _preProcessRoutine.CurrentRecipeRunningName,
  981. 0,
  982. _preProcessRoutine.CurrentLotName,
  983. _preProcessRoutine.CurrentRecipeContent,
  984. _preProcessRoutine.CurrentRecipeHead,
  985. _preProcessRoutine.CurrentRecipeStepList);
  986. return true;
  987. }
  988. if (ret == Result.FAIL)
  989. {
  990. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDownFailed;
  991. PostMsg(MSG.Error);
  992. return true;
  993. }
  994. return false; ;
  995. }
  996. private bool FnAbortPreProcess(object[] param)
  997. {
  998. //_processStatus = Resources.PMEntity_fAbortPreProcess_RunRecipePumpingDownAborted;
  999. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1000. _preProcessRoutine.Abort();
  1001. return true;
  1002. }
  1003. private bool FnStartProcess(object[] param)
  1004. {
  1005. //_processStatus = Resources.PMEntity_fStartProcess_StartRunningRecipe;
  1006. Result ret = _processRoutine.Start(param);
  1007. if (ret == Result.DONE)
  1008. {
  1009. return true;
  1010. }
  1011. else if (ret == Result.FAIL || ret == Result.VERIFYFAIL)
  1012. {
  1013. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1014. PostMsg(MSG.Error);
  1015. return true; //do noting
  1016. }
  1017. return true;
  1018. }
  1019. private bool FnProcessTimeout(object[] param)
  1020. {
  1021. //_processStatus = Resources.PMEntity_fProcess_RunningRecipe;
  1022. Result ret = _processRoutine.Monitor();
  1023. {
  1024. if (ret == Result.DONE)
  1025. {
  1026. PostMsg(MSG.PostProcess, _processRoutine.CurrentRecipeRunningName, _processRoutine.CurrentRecipeContent);
  1027. return true;
  1028. }
  1029. else if (ret == Result.FAIL)
  1030. {
  1031. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1032. PostMsg(MSG.Error);
  1033. return true;
  1034. }
  1035. return false;
  1036. }
  1037. }
  1038. private bool FnAbortProcess(object[] param)
  1039. {
  1040. //_processStatus = Resources.PMEntity_fAbortProcess_RunningRecipeAborted;
  1041. _processRoutine.AbortRecipe();
  1042. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1043. _processRoutine.Abort();
  1044. Result ret = _postProcessRoutine.Start(new object[] { _processRoutine.CurrentRecipeRunningName, _processRoutine.CurrentRecipeContent });
  1045. if (ret == Result.DONE)
  1046. {
  1047. return false;
  1048. }
  1049. else if (ret == Result.FAIL)
  1050. {
  1051. PostMsg(MSG.Error);
  1052. //_processStatus = Resources.PMEntity_fAbortProcess_RunRecipeAborted;
  1053. return false; //do noting
  1054. }
  1055. return true;
  1056. }
  1057. private bool FnPauseProcess(object[] param)
  1058. {
  1059. return true;
  1060. }
  1061. private bool FnResumeRecipe(object[] param)
  1062. {
  1063. return true;
  1064. }
  1065. private bool FnUpdateRecipe(object[] param)
  1066. {
  1067. return true;
  1068. }
  1069. private bool FnSkipStep(object[] param)
  1070. {
  1071. _processRoutine.SkipCurrentRecipeStep();
  1072. return true;
  1073. }
  1074. private bool FnExitProcess(object[] param)
  1075. {
  1076. //_statProcessedWafer
  1077. StatsDataManager.Instance.Increase(_statProcessedWafer.Name);
  1078. _processRoutine.Exit();
  1079. return true;
  1080. }
  1081. private bool FnEnterProcess(object[] param)
  1082. {
  1083. return true;
  1084. }
  1085. private bool FnStartPostProcess(object[] param)
  1086. {
  1087. //_processStatus = Resources.PMEntity_fStartPostProcess_RunRecipePostProcess;
  1088. Result ret = _postProcessRoutine.Start(param);
  1089. if (ret == Result.DONE)
  1090. {
  1091. return false;
  1092. }
  1093. else if (ret == Result.FAIL)
  1094. {
  1095. PostMsg(MSG.Error);
  1096. return false;
  1097. }
  1098. return true;
  1099. }
  1100. private bool FnPostProcessTimeout(object[] param)
  1101. {
  1102. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurge;
  1103. Result ret = _postProcessRoutine.Monitor();
  1104. if (ret == Result.DONE)
  1105. {
  1106. WaferManager.Instance.UpdateWaferProcessStatus(this.Module, 0, EnumWaferProcessStatus.Completed);
  1107. //_processStatus = Resources.PMEntity_fPostProcess_RecipeCompleted;
  1108. return true;
  1109. }
  1110. else if (ret == Result.FAIL)
  1111. {
  1112. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurgeError;
  1113. PostMsg(MSG.Error);
  1114. return true;
  1115. }
  1116. return false;
  1117. }
  1118. private bool FnAbortPostProcess(object[] param)
  1119. {
  1120. //_processStatus = Resources.PMEntity_fAbortPostProcess_RecipeAborted;
  1121. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1122. _postProcessRoutine.Abort();
  1123. return true;
  1124. }
  1125. private bool fExitPostProcess(object[] objs)
  1126. {
  1127. _postProcessRoutine.Exit();
  1128. //EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1129. //{
  1130. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1131. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1132. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1133. //});
  1134. return true;
  1135. }
  1136. #endregion PROCESS
  1137. private string GetFsmLastMessage()
  1138. {
  1139. int msg = fsm.LastMsg;
  1140. if (msg >= (int)MSG.Home && msg <= (int)MSG.MaxMsg)
  1141. return ((MSG)msg).ToString();
  1142. if (msg == (int)FSM_MSG.TIMER)
  1143. return "Timer";
  1144. return msg.ToString();
  1145. }
  1146. protected override void Term()
  1147. {
  1148. }
  1149. private bool FnReset(object[] param)
  1150. {
  1151. _isAlarm = false;
  1152. if ((PMState)fsm.State == PMState.Error)
  1153. return true;
  1154. return false;
  1155. }
  1156. public bool Check(int msg, out string reason, object[] objs)
  1157. {
  1158. reason = "";
  1159. return true;
  1160. }
  1161. public bool IsProcessed()
  1162. {
  1163. return IsIdle;
  1164. }
  1165. public bool IsPrepareTransferReady(ModuleName robot, EnumTransferType type, int slot, Hand blade)
  1166. {
  1167. if (type == EnumTransferType.Pick)
  1168. {
  1169. return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(_chamber.Module, 0).Size);
  1170. }
  1171. else if (type == EnumTransferType.Place)
  1172. {
  1173. return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(robot, (int)blade).Size);
  1174. }
  1175. return false;
  1176. }
  1177. public void Home()
  1178. {
  1179. CheckToPostMessage((int)MSG.Home);
  1180. }
  1181. private bool FnExitHome(object[] param)
  1182. {
  1183. return true;
  1184. }
  1185. private bool FnEnterHome(object[] param)
  1186. {
  1187. return true;
  1188. }
  1189. private bool FnStartHome(object[] objs)
  1190. {
  1191. Result ret = _home.Start();
  1192. if (ret == Result.FAIL || ret == Result.DONE)
  1193. return false;
  1194. return ret == Result.RUN;
  1195. }
  1196. private bool FnMonitorHome(object[] objs)
  1197. {
  1198. Result ret = _home.Monitor();
  1199. if (ret == Result.FAIL)
  1200. {
  1201. PostMsg(MSG.Error);
  1202. return false;
  1203. }
  1204. return ret == Result.DONE;
  1205. }
  1206. private bool fExitTransfer(object[] objs)
  1207. {
  1208. return true;
  1209. }
  1210. private bool fEnterError(object[] objs)
  1211. {
  1212. //if (IsProcessMode)
  1213. //{
  1214. // EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1215. // {
  1216. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1217. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1218. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1219. // });
  1220. //}
  1221. _chamber.GeneratorPowerOn(false);
  1222. _chamber.GeneratorBiasPowerOn(false);
  1223. _chamber.StopAllGases();
  1224. return true;
  1225. }
  1226. private bool FnError(object[] objs)
  1227. {
  1228. Running = false;
  1229. if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  1230. || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  1231. return false;
  1232. if (IsProcessing)
  1233. {
  1234. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1235. }
  1236. return true;
  1237. }
  1238. private bool fWarning(object[] objs)
  1239. {
  1240. //IsWarning = false;
  1241. return true;
  1242. }
  1243. private bool fAlarm(object[] objs)
  1244. {
  1245. _isAlarm = true;
  1246. if (fsm.State == (int)PMState.Init)
  1247. return false;
  1248. if (fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.PostProcess)
  1249. {
  1250. PostMsg(MSG.Error);
  1251. return false;
  1252. }
  1253. //IsAlarm = true;
  1254. return true;
  1255. }
  1256. private bool FnIdle(object[] objs)
  1257. {
  1258. Running = false;
  1259. return true;
  1260. }
  1261. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  1262. {
  1263. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString()))
  1264. return (int)MSG.PrepareTransfer;
  1265. return (int)FSM_MSG.NONE;
  1266. }
  1267. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp)
  1268. {
  1269. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp))
  1270. return (int)MSG.PrepareTransfer;
  1271. return (int)FSM_MSG.NONE;
  1272. }
  1273. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp, WaferSize size)
  1274. {
  1275. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp, size))
  1276. return (int)MSG.PrepareTransfer;
  1277. return (int)FSM_MSG.NONE;
  1278. }
  1279. public int InvokePostTransfer(ModuleName robot, EnumTransferType type, int slot)
  1280. {
  1281. if (CheckToPostMessage((int)MSG.PostTransfer, type.ToString()))
  1282. return (int)MSG.PostTransfer;
  1283. return (int)FSM_MSG.NONE;
  1284. }
  1285. public int InvokeClean(string recipeName, string waferID, bool withWafer)
  1286. {
  1287. if (CheckToPostMessage((int)MSG.Clean, recipeName, waferID, withWafer))
  1288. {
  1289. return (int)MSG.Clean;
  1290. }
  1291. return (int)FSM_MSG.NONE;
  1292. }
  1293. public int InvokeProcess(string recipeName, string waferID, bool withWafer)
  1294. {
  1295. if (CheckToPostMessage((int)MSG.RunRecipe, recipeName, waferID, withWafer))
  1296. return (int)MSG.RunRecipe;
  1297. return (int)FSM_MSG.NONE;
  1298. }
  1299. public int InvokePreHeat(float temperature)
  1300. {
  1301. if (CheckToPostMessage((int)MSG.Heat, (double)temperature))
  1302. return (int)MSG.Heat;
  1303. return (int)FSM_MSG.NONE;
  1304. }
  1305. public void InvokeReset()
  1306. {
  1307. PostMsg((int)MSG.Reset);
  1308. }
  1309. public void SetAuto()
  1310. {
  1311. this._AutoMode = AutoFlag.Auto;
  1312. }
  1313. #region EndPoint
  1314. public bool CheckEndPoint()
  1315. {
  1316. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1317. if (epd == null)
  1318. return false;
  1319. return epd.IsEnd;
  1320. }
  1321. public void StartEndPoint(string config, int index)
  1322. {
  1323. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1324. if (epd == null)
  1325. return;
  1326. epd.StepStart(config, index);
  1327. }
  1328. public void StopEndPoint()
  1329. {
  1330. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1331. if (epd == null)
  1332. return;
  1333. epd.StepStop();
  1334. }
  1335. public void EndPointRecipeStop()
  1336. {
  1337. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1338. if (epd == null)
  1339. return;
  1340. epd.RecipeStop();
  1341. }
  1342. public void EndPointRecipeStart(string recipeName)
  1343. {
  1344. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1345. if (epd == null)
  1346. return;
  1347. epd.RecipeStart(recipeName);
  1348. }
  1349. #endregion
  1350. }
  1351. }