PMEntity.cs 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610
  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. bool isDelay = false;
  870. if(param.Length > 3)
  871. {
  872. isDelay = (bool)param[3];
  873. }
  874. if (pos == MovementPosition.Down || isDelay) //增加Place & Pick的Delay功能
  875. {
  876. int pinDownDelayTime = SC.GetValue<int>($"{Module}.PinDownDelayTimePick") * 1000;
  877. if (!isPick)
  878. {
  879. pinDownDelayTime = SC.GetValue<int>($"{Module}.PinDownDelayTimePlace") * 1000;
  880. }
  881. if (pinDownDelayTime > 0)
  882. {
  883. EV.PostInfoLog(Module.ToString(), $"Delay {pinDownDelayTime/1000} seconds before lift pin down");
  884. Thread.Sleep(pinDownDelayTime);
  885. }
  886. }
  887. _chamber.SetLiftPin(pos, out _);
  888. EV.PostInfoLog(Module.ToString(), $"执行 lift pin {pos}");
  889. _goalLiftPin = pos;
  890. return true;
  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 FnOpenSlitDoor(object[] param)
  906. {
  907. _ActivatedActionID = (ushort)param[0];
  908. _chamber.SetSlitDoor(true, out _);
  909. EV.PostInfoLog(Module.ToString(), $"Start opening {Module} slit door");
  910. return true;
  911. }
  912. private bool FnOpenSlitDoorTimeout(object[] param)
  913. {
  914. if (_chamber.CheckSlitDoorOpen() )
  915. {
  916. EV.PostInfoLog(Module.ToString(), $"{Module} slit door is opened");
  917. Singleton<RouteManager>.Instance.EFEM.PostMsg( EfemEntity.MSG.PMSlitDoorOpened, _ActivatedActionID);
  918. _ActivatedActionID = 0;
  919. return true;
  920. }
  921. return false;
  922. }
  923. private bool FnCloseSlitDoor(object[] param)
  924. {
  925. _ActivatedActionID = (ushort)param[0];
  926. _chamber.SetSlitDoor(false, out _);
  927. EV.PostInfoLog(Module.ToString(), $"Start closing {Module} slit door");
  928. return true;
  929. }
  930. private bool FnCloseSlitDoorTimeout(object[] param)
  931. {
  932. if (_chamber.CheckSlitDoorClose())
  933. {
  934. EV.PostInfoLog(Module.ToString(), $"{Module} slit door is closed");
  935. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.PMSlitDoorClosed, _ActivatedActionID);
  936. _ActivatedActionID = 0;
  937. return true;
  938. }
  939. return false;
  940. }
  941. private bool FnSetGuidePin(object[] param)
  942. {
  943. WaferSize ws = (WaferSize)param[0];
  944. MovementPosition pos = (MovementPosition)param[1];
  945. _chamber.SetGuidePin(ws, pos);
  946. return true;
  947. }
  948. private bool FnGuidePinTimeout(object[] param)
  949. {
  950. return true;
  951. }
  952. private bool FnPreClean(object[] param)
  953. {
  954. _cleanRoutine.param = param;
  955. _chamber.SetSlitDoor(false, out _);
  956. return true;
  957. }
  958. private bool FnPreCleanTimeout(object[] param)
  959. {
  960. if (_chamber.IsSlitDoorClosed)
  961. {
  962. if (!FnProcessLoadRecipe(_cleanRoutine.param))
  963. {
  964. EV.PostAlarmLog(_chamber.Module.ToString(), "Clean recipe read failed");
  965. PostMsg(FSM_MSG.ALARM);
  966. return false;
  967. }
  968. return true;
  969. }
  970. return false;
  971. }
  972. #endregion Transfer
  973. #region Process
  974. private bool FnProcessLoadRecipe(object[] param)
  975. {
  976. _processStatus = "Succeed to load recipe";
  977. _recipeStartTime = DateTime.Now;
  978. Result ret = _preProcessRoutine.LoadRecipe(param);
  979. if (ret == Result.DONE)
  980. {
  981. PostMsg(MSG.PreProcess);
  982. }
  983. else if (ret == Result.FAIL)
  984. {
  985. _processStatus = "Failed to load recipe";
  986. return false;
  987. }
  988. return true;
  989. }
  990. private bool FnStartPreProcess(object[] param)
  991. {
  992. _pumpStartTime = DateTime.Now;
  993. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipe;
  994. Result ret = _preProcessRoutine.Start(param);
  995. if (ret == Result.DONE)
  996. {
  997. return false;
  998. }
  999. if (ret == Result.FAIL || ret == Result.VERIFYFAIL)
  1000. {
  1001. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipeFailed;
  1002. PostMsg(MSG.Error);
  1003. return false; //do noting
  1004. }
  1005. WaferManager.Instance.UpdateWaferProcessStatus(this.Module, 0, EnumWaferProcessStatus.InProcess);
  1006. return true;
  1007. }
  1008. private bool FnPreProcessTimeout(object[] param)
  1009. {
  1010. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDown;
  1011. Result ret = _preProcessRoutine.Monitor();
  1012. if (ret == Result.DONE)
  1013. {
  1014. PostMsg(MSG.Process,
  1015. _preProcessRoutine.CurrentRecipeBaseName,
  1016. _preProcessRoutine.CurrentRecipeRunningName,
  1017. 0,
  1018. _preProcessRoutine.CurrentLotName,
  1019. _preProcessRoutine.CurrentRecipeContent,
  1020. _preProcessRoutine.CurrentRecipeHead,
  1021. _preProcessRoutine.CurrentRecipeStepList,
  1022. _preProcessRoutine.CurrentRecipeGuid);
  1023. return true;
  1024. }
  1025. if (ret == Result.FAIL)
  1026. {
  1027. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDownFailed;
  1028. PostMsg(MSG.Error);
  1029. return true;
  1030. }
  1031. return false; ;
  1032. }
  1033. private bool FnAbortPreProcess(object[] param)
  1034. {
  1035. //_processStatus = Resources.PMEntity_fAbortPreProcess_RunRecipePumpingDownAborted;
  1036. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1037. _preProcessRoutine.Abort();
  1038. return true;
  1039. }
  1040. private bool FnStartProcess(object[] param)
  1041. {
  1042. //_processStatus = Resources.PMEntity_fStartProcess_StartRunningRecipe;
  1043. Result ret = _processRoutine.Start(param);
  1044. if (ret == Result.DONE)
  1045. {
  1046. return true;
  1047. }
  1048. else if (ret == Result.FAIL || ret == Result.VERIFYFAIL)
  1049. {
  1050. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1051. PostMsg(MSG.Error);
  1052. return true; //do noting
  1053. }
  1054. return true;
  1055. }
  1056. private bool FnProcessTimeout(object[] param)
  1057. {
  1058. //_processStatus = Resources.PMEntity_fProcess_RunningRecipe;
  1059. Result ret = _processRoutine.Monitor();
  1060. {
  1061. if (ret == Result.DONE)
  1062. {
  1063. PostMsg(MSG.PostProcess,
  1064. _processRoutine.CurrentRecipeRunningName,
  1065. _processRoutine.CurrentRecipeContent,
  1066. _preProcessRoutine.CurrentRecipeGuid);
  1067. return true;
  1068. }
  1069. else if (ret == Result.FAIL)
  1070. {
  1071. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1072. PostMsg(MSG.Error);
  1073. return true;
  1074. }
  1075. return false;
  1076. }
  1077. }
  1078. private bool FnAbortProcess(object[] param)
  1079. {
  1080. //_processStatus = Resources.PMEntity_fAbortProcess_RunningRecipeAborted;
  1081. _processRoutine.AbortRecipe();
  1082. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1083. _processRoutine.Abort();
  1084. Result ret = _postProcessRoutine.Start(new object[] { _processRoutine.CurrentRecipeRunningName, _processRoutine.CurrentRecipeContent, _processRoutine.CurrentRecipeGuid });
  1085. if (ret == Result.DONE)
  1086. {
  1087. return false;
  1088. }
  1089. else if (ret == Result.FAIL)
  1090. {
  1091. PostMsg(MSG.Error);
  1092. //_processStatus = Resources.PMEntity_fAbortProcess_RunRecipeAborted;
  1093. return false; //do noting
  1094. }
  1095. return true;
  1096. }
  1097. private bool FnPauseProcess(object[] param)
  1098. {
  1099. return true;
  1100. }
  1101. private bool FnResumeRecipe(object[] param)
  1102. {
  1103. return true;
  1104. }
  1105. private bool FnUpdateRecipe(object[] param)
  1106. {
  1107. return true;
  1108. }
  1109. private bool FnSkipStep(object[] param)
  1110. {
  1111. _processRoutine.SkipCurrentRecipeStep();
  1112. return true;
  1113. }
  1114. private bool FnExitProcess(object[] param)
  1115. {
  1116. //_statProcessedWafer
  1117. StatsDataManager.Instance.Increase(_statProcessedWafer.Name);
  1118. _processRoutine.Exit();
  1119. return true;
  1120. }
  1121. private bool FnEnterProcess(object[] param)
  1122. {
  1123. return true;
  1124. }
  1125. private bool FnStartPostProcess(object[] param)
  1126. {
  1127. //_processStatus = Resources.PMEntity_fStartPostProcess_RunRecipePostProcess;
  1128. Result ret = _postProcessRoutine.Start(param);
  1129. if (ret == Result.DONE)
  1130. {
  1131. return false;
  1132. }
  1133. else if (ret == Result.FAIL)
  1134. {
  1135. PostMsg(MSG.Error);
  1136. return false;
  1137. }
  1138. return true;
  1139. }
  1140. private bool FnPostProcessTimeout(object[] param)
  1141. {
  1142. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurge;
  1143. Result ret = _postProcessRoutine.Monitor();
  1144. if (ret == Result.DONE)
  1145. {
  1146. WaferManager.Instance.UpdateWaferProcessStatus(this.Module, 0, EnumWaferProcessStatus.Completed);
  1147. //_processStatus = Resources.PMEntity_fPostProcess_RecipeCompleted;
  1148. return true;
  1149. }
  1150. else if (ret == Result.FAIL)
  1151. {
  1152. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurgeError;
  1153. PostMsg(MSG.Error);
  1154. return true;
  1155. }
  1156. return false;
  1157. }
  1158. private bool FnAbortPostProcess(object[] param)
  1159. {
  1160. //_processStatus = Resources.PMEntity_fAbortPostProcess_RecipeAborted;
  1161. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1162. _postProcessRoutine.Abort();
  1163. return true;
  1164. }
  1165. private bool fExitPostProcess(object[] objs)
  1166. {
  1167. _postProcessRoutine.Exit();
  1168. //EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1169. //{
  1170. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1171. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1172. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1173. //});
  1174. return true;
  1175. }
  1176. #endregion PROCESS
  1177. private string GetFsmLastMessage()
  1178. {
  1179. int msg = fsm.LastMsg;
  1180. if (msg >= (int)MSG.Home && msg <= (int)MSG.MaxMsg)
  1181. return ((MSG)msg).ToString();
  1182. if (msg == (int)FSM_MSG.TIMER)
  1183. return "Timer";
  1184. return msg.ToString();
  1185. }
  1186. protected override void Term()
  1187. {
  1188. }
  1189. private bool FnReset(object[] param)
  1190. {
  1191. _isAlarm = false;
  1192. if ((PMState)fsm.State == PMState.Error)
  1193. return true;
  1194. return false;
  1195. }
  1196. public bool Check(int msg, out string reason, object[] objs)
  1197. {
  1198. reason = "";
  1199. return true;
  1200. }
  1201. public bool IsProcessed()
  1202. {
  1203. return IsIdle;
  1204. }
  1205. public bool IsPrepareTransferReady(ModuleName robot, EnumTransferType type, int slot, WaferSize size)
  1206. {
  1207. if (type == EnumTransferType.Pick)
  1208. {
  1209. return _chamber.CheckEnableTransfer(type, WaferManager.Instance.GetWafer(_chamber.Module, 0).Size);
  1210. }
  1211. else if (type == EnumTransferType.Place)
  1212. {
  1213. return _chamber.CheckEnableTransfer(type, size);
  1214. }
  1215. return false;
  1216. }
  1217. public void Home()
  1218. {
  1219. CheckToPostMessage((int)MSG.Home);
  1220. }
  1221. private bool FnExitHome(object[] param)
  1222. {
  1223. return true;
  1224. }
  1225. private bool FnEnterHome(object[] param)
  1226. {
  1227. return true;
  1228. }
  1229. private bool FnStartHome(object[] objs)
  1230. {
  1231. Result ret = _home.Start();
  1232. if (ret == Result.FAIL || ret == Result.DONE)
  1233. return false;
  1234. return ret == Result.RUN;
  1235. }
  1236. private bool FnMonitorHome(object[] objs)
  1237. {
  1238. Result ret = _home.Monitor();
  1239. if (ret == Result.FAIL)
  1240. {
  1241. PostMsg(MSG.Error);
  1242. return false;
  1243. }
  1244. return ret == Result.DONE;
  1245. }
  1246. private bool fExitTransfer(object[] objs)
  1247. {
  1248. return true;
  1249. }
  1250. private bool fEnterError(object[] objs)
  1251. {
  1252. //if (IsProcessMode)
  1253. //{
  1254. // EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1255. // {
  1256. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1257. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1258. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1259. // });
  1260. //}
  1261. _chamber.GeneratorPowerOn(false);
  1262. _chamber.StopAllGases();
  1263. return true;
  1264. }
  1265. private bool FnError(object[] objs)
  1266. {
  1267. Running = false;
  1268. if (((PMState)fsm.State == PMState.Processing) || ((PMState)fsm.State == PMState.PreProcess)
  1269. || ((PMState)fsm.State == PMState.Homing) || ((PMState)fsm.State == PMState.LoadProcessRecipe))
  1270. return false;
  1271. if (IsProcessing)
  1272. {
  1273. WaferManager.Instance.UpdateWaferProcessStatus(Module, 0, EnumWaferProcessStatus.Failed);
  1274. }
  1275. return true;
  1276. }
  1277. private bool fWarning(object[] objs)
  1278. {
  1279. //IsWarning = false;
  1280. return true;
  1281. }
  1282. private bool fAlarm(object[] objs)
  1283. {
  1284. _isAlarm = true;
  1285. if (fsm.State == (int)PMState.Init)
  1286. return false;
  1287. if (fsm.State == (int)PMState.Processing || fsm.State == (int)PMState.PreProcess || fsm.State == (int)PMState.PostProcess)
  1288. {
  1289. PostMsg(MSG.Error);
  1290. return false;
  1291. }
  1292. //IsAlarm = true;
  1293. return true;
  1294. }
  1295. private bool FnIdle(object[] objs)
  1296. {
  1297. Running = false;
  1298. return true;
  1299. }
  1300. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  1301. {
  1302. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString()))
  1303. return (int)MSG.PrepareTransfer;
  1304. return (int)FSM_MSG.NONE;
  1305. }
  1306. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp)
  1307. {
  1308. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp))
  1309. return (int)MSG.PrepareTransfer;
  1310. return (int)FSM_MSG.NONE;
  1311. }
  1312. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp, WaferSize size)
  1313. {
  1314. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp, size))
  1315. return (int)MSG.PrepareTransfer;
  1316. return (int)FSM_MSG.NONE;
  1317. }
  1318. public int InvokePostTransfer(ModuleName robot, EnumTransferType type, int slot)
  1319. {
  1320. if (CheckToPostMessage((int)MSG.PostTransfer, type.ToString()))
  1321. return (int)MSG.PostTransfer;
  1322. return (int)FSM_MSG.NONE;
  1323. }
  1324. public int InvokeClean(string recipeName, string waferID, bool withWafer)
  1325. {
  1326. if (CheckToPostMessage((int)MSG.Clean, recipeName, waferID, withWafer))
  1327. {
  1328. return (int)MSG.Clean;
  1329. }
  1330. return (int)FSM_MSG.NONE;
  1331. }
  1332. public int InvokeProcess(string recipeName, string waferID, bool withWafer)
  1333. {
  1334. if (CheckToPostMessage((int)MSG.RunRecipe, recipeName, waferID, withWafer))
  1335. return (int)MSG.RunRecipe;
  1336. return (int)FSM_MSG.NONE;
  1337. }
  1338. public int InvokePreHeat(float temperature)
  1339. {
  1340. if (CheckToPostMessage((int)MSG.Heat, (double)temperature))
  1341. return (int)MSG.Heat;
  1342. return (int)FSM_MSG.NONE;
  1343. }
  1344. public void InvokeReset()
  1345. {
  1346. PostMsg((int)MSG.Reset);
  1347. }
  1348. public void SetAuto()
  1349. {
  1350. this._AutoMode = AutoFlag.Auto;
  1351. }
  1352. }
  1353. }