PMModule.cs 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324
  1. using System;
  2. using System.Diagnostics;
  3. using System.Linq;
  4. using Aitex.Core.Common;
  5. using Aitex.Core.RT.DataCenter;
  6. using Aitex.Core.RT.Device;
  7. using Aitex.Core.RT.Event;
  8. using Aitex.Core.RT.Fsm;
  9. using Aitex.Core.RT.Log;
  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.Core.Utilities;
  15. using Aitex.Sorter.Common;
  16. using JetVirgoPM.Devices;
  17. using JetVirgoPM.Devices.EPDs;
  18. using JetVirgoPM.PMs.RecipeExecutors;
  19. using JetVirgoPM.PMs.Routines;
  20. using MECF.Framework.Common.CommonData;
  21. using MECF.Framework.Common.DataCenter;
  22. using MECF.Framework.Common.Equipment;
  23. using MECF.Framework.Common.Schedulers;
  24. using MECF.Framework.Common.SubstrateTrackings;
  25. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
  26. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps.EdwardsPump;
  27. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps.SkyPump;
  28. using MECF.Framework.RT.ModuleLibrary.PMModules;
  29. using MECF.Framework.RT.ModuleLibrary.SystemModules;
  30. namespace JetVirgoPM.PMs
  31. {
  32. public class PMModule : PMModuleBase, IRecipeExecutor
  33. {
  34. public enum MSG
  35. {
  36. Home,
  37. Transfer,
  38. PrepareTransfer,
  39. PostTransfer,
  40. Reset,
  41. Abort,
  42. Error,
  43. LaunchPump,
  44. Pump,
  45. Vent,
  46. Purge,
  47. CyclePurge,
  48. Heat,
  49. TransferHandoff,
  50. StartTransfer,
  51. LeakCheck,
  52. DeleteLeakCheck,
  53. MoveLiftPin1,
  54. MoveLiftPin2,
  55. MoveGuidePin1,
  56. MoveGuidePin2,
  57. MFCVerification,
  58. Clean,
  59. CleanReady,
  60. ATMProcess,
  61. Process,
  62. RunRecipe,
  63. PostProcess,
  64. RecipeSkipStep,
  65. RecipeUpdate,
  66. RecipeResume,
  67. RecipePause,
  68. RecipeAbort,
  69. PreProcess,
  70. AutoMode,
  71. ManualMode,
  72. LockLid,
  73. SetOnline,
  74. SetOffline,
  75. SelectRecipe,
  76. GasFlow,
  77. StopGasFlow,
  78. RfPower,
  79. MaxMsg
  80. }
  81. public enum STATE
  82. {
  83. Init,
  84. Idle,
  85. Homing,
  86. GasFlowing,
  87. RfPowering,
  88. Heating,
  89. LaunchingPump,
  90. Pumping,
  91. Venting,
  92. Purging,
  93. MoveLift,
  94. Purge,
  95. Transfer,
  96. Error,
  97. PrepareTransfer,
  98. PostTransfer,
  99. TransferHandoff,
  100. //Process,
  101. LeakCheck,
  102. Liftpin1Moving,
  103. Liftpin2Moving,
  104. GuidePin1Moving,
  105. GuidePin2Moving,
  106. PreClean,
  107. LoadProcessRecipe,
  108. ATMProcessing,
  109. PreProcess,
  110. Processing,
  111. PostProcess,
  112. OpeningLid,
  113. ClosingLid,
  114. MFCVerification,
  115. NotInstall
  116. }
  117. #region Fields
  118. private int _bigWafer = 0;
  119. private int _midWafer = 0;
  120. private int _smallWafer = 0;
  121. private bool _enableBiasRF1;
  122. private bool _enableBiasRF2;
  123. private bool _chamber1Disabled;
  124. private bool _chamber2Disabled;
  125. private StatsDataItemRFAndPump _statRf1OnTime;
  126. private StatsDataItemRFAndPump _statRf2OnTime;
  127. private StatsDataItemRFAndPump _statBiasRf1OnTime;
  128. private StatsDataItemRFAndPump _statBiasRf2OnTime;
  129. private StatsDataItemRFAndPump _statPumpOnTime;
  130. private readonly JetDualPM _chamber;
  131. private string _processStatus;
  132. private DateTime _recipeStartTime;
  133. //routine
  134. private VentRoutine _ventRoutine;
  135. private PumpDownRoutine _pumpRoutine;
  136. private StartPumpRoutine _startPumpRoutine;
  137. private TemperatureControlRoutine _temperatureControlRoutine;
  138. private GasFlowRoutine _gasFlowRoutine;
  139. private RfPowerRoutine _rfPowerRoutine;
  140. private CyclePurgeRoutine _cyclePurgeRoutine;
  141. private CleanRoutine _cleanRoutine;
  142. private PMATMProcessRoutine _ATMProcessRoutine;
  143. private ProcessRoutine _processRoutine;
  144. private PreProcessRoutine _preProcessRoutine;
  145. private PostProcessRoutine _postProcessRoutine;
  146. private LeakCheckRoutine _leakCheckRoutine;
  147. private PMPrepareTransferRoutine _prepareTrans;
  148. private PMPostTransferRoutine _postTrans;
  149. private PMTransferHandoffRoutine _transferHandoff;
  150. private PMHomeRoutine _home;
  151. private PMMfcVerificationRoutine _mfcVerification;
  152. private AutoFlag _AutoMode;
  153. private bool _isAlarm;
  154. private DateTime _pumpStartTime;
  155. private TimeSpan _pumpElapsedTime;
  156. private DateTime _rfStartTime;
  157. private DateTime _tcStartTime;
  158. private TimeSpan _rfElapsedTime;
  159. private TimeSpan _tcElapsedTime;
  160. private MovementPosition _goalLiftPin;
  161. private ushort _ActivatedActionID;
  162. private RecipeRunningInfo _recipeRunningInfo = new RecipeRunningInfo();
  163. #endregion
  164. #region Properties
  165. public Action<bool, bool> TransferPrepared;
  166. public bool IsIdle
  167. {
  168. get { return FsmState == (int)STATE.Idle; }
  169. }
  170. public bool IsAutoMode => _AutoMode == AutoFlag.Auto;
  171. public RecipeRunningInfo RecipeRunningInfo
  172. {
  173. get
  174. {
  175. return _recipeRunningInfo;
  176. }
  177. }
  178. public int Invoke(string function, params object[] args)
  179. {
  180. switch (function)
  181. {
  182. case "Home":
  183. CheckToPostMessage((int)MSG.Home);
  184. return (int)MSG.Home;
  185. }
  186. return (int)FSM_MSG.NONE;
  187. }
  188. public override bool IsInit
  189. {
  190. get { return FsmState == (int)STATE.Init; }
  191. }
  192. public bool IsBusy
  193. {
  194. get { return !IsInit && !IsError && !IsIdle; }
  195. }
  196. public bool IsProcessing
  197. {
  198. get { return FsmState == (int)STATE.PreProcess || FsmState == (int)STATE.Processing || FsmState == (int)STATE.PostProcess; }
  199. }
  200. private DateTime _leakCheckStartTime;
  201. private TimeSpan _leakCheckElapsedTime;
  202. private string LeakCheckElapseTime
  203. {
  204. get
  205. {
  206. if ((FsmState == (int)STATE.LeakCheck))
  207. _leakCheckElapsedTime = DateTime.Now - _leakCheckStartTime;
  208. return string.Format("{0}:{1}:{2}", ((int)_leakCheckElapsedTime.TotalHours).ToString("00"),
  209. _leakCheckElapsedTime.Minutes.ToString("00"), _leakCheckElapsedTime.Seconds.ToString("00"));
  210. }
  211. }
  212. private string PumpTime
  213. {
  214. get
  215. {
  216. if ((FsmState == (int)STATE.Pumping) || (FsmState == (int)STATE.PreProcess))
  217. _pumpElapsedTime = DateTime.Now - _pumpStartTime;
  218. return string.Format("{0}:{1}:{2}", ((int)_pumpElapsedTime.TotalHours).ToString("00"),
  219. _pumpElapsedTime.Minutes.ToString("00"), _pumpElapsedTime.Seconds.ToString("00"));
  220. }
  221. }
  222. private int StepNo
  223. {
  224. get
  225. {
  226. if ((FsmState == (int)STATE.Processing) || (FsmState == (int)STATE.PostProcess) ||
  227. ((FsmPreviousState == (int)STATE.Processing || FsmPreviousState == (int)STATE.PostProcess) && FsmState == (int)STATE.Error))
  228. {
  229. return _processRoutine.CurStepNum + 1;
  230. }
  231. return 0;
  232. }
  233. }
  234. private int RecipeSteps
  235. {
  236. get
  237. {
  238. if ((FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.Processing) || (FsmState == (int)STATE.PostProcess))
  239. {
  240. return _preProcessRoutine.CurrentRecipeStepList.Count;
  241. }
  242. return 0;
  243. }
  244. }
  245. private string RecipeStepName
  246. {
  247. get
  248. {
  249. if ((FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.Processing) || (FsmState == (int)STATE.PostProcess))
  250. {
  251. return _processRoutine.CurStepComment;
  252. }
  253. return null;
  254. }
  255. }
  256. private double LeakRate
  257. {
  258. get { return _leakCheckRoutine.LeakRate; }
  259. }
  260. private string RecipeName
  261. {
  262. get
  263. {
  264. if ((FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.Processing) || (FsmState == (int)STATE.PostProcess))
  265. {
  266. return _preProcessRoutine.CurrentRecipeRunningName.Split('\\').Last();
  267. }
  268. return null;
  269. }
  270. }
  271. private string RFTime
  272. {
  273. get
  274. {
  275. if (FsmState == (int)STATE.RfPowering)
  276. _rfElapsedTime = DateTime.Now - _rfStartTime;
  277. return $"{((int)_rfElapsedTime.TotalHours).ToString("00")}:{_rfElapsedTime.Minutes.ToString("00")}:{_rfElapsedTime.Seconds.ToString("00")}";
  278. }
  279. }
  280. private string TCTime
  281. {
  282. get
  283. {
  284. if (FsmState == (int)STATE.Heating)
  285. _tcElapsedTime = DateTime.Now - _tcStartTime;
  286. return $"{((int)_tcElapsedTime.TotalHours).ToString("00")}:{_tcElapsedTime.Minutes.ToString("00")}:{_tcElapsedTime.Seconds.ToString("00")}";
  287. }
  288. }
  289. private TimeSpan _recipeElapsedTime;
  290. public string RecipeElapsedTime
  291. {
  292. get
  293. {
  294. if (FsmState == (int)STATE.LoadProcessRecipe || FsmState == (int)STATE.PreProcess
  295. || FsmState == (int)STATE.Processing || FsmState == (int)STATE.PostProcess)
  296. _recipeElapsedTime = DateTime.Now - _recipeStartTime;
  297. return string.Format("{0}:{1}:{2}", ((int)_recipeElapsedTime.TotalHours).ToString("00"),
  298. _recipeElapsedTime.Minutes.ToString("00"), _recipeElapsedTime.Seconds.ToString("00"));
  299. }
  300. }
  301. #endregion
  302. public override bool CheckAcked(int entityTaskToken)
  303. {
  304. return CheckExecuted(entityTaskToken);
  305. }
  306. public override bool IsReady
  307. {
  308. get { return FsmState == (int)STATE.Idle && CheckAllMessageProcessed(); }
  309. }
  310. public override void AssertPMReady(string description)
  311. {
  312. if (!IsReady)
  313. {
  314. LOG.Error($"{Module} {Name} {description} Assert当前状态 FsmState={FsmState} CheckAllMessageProcessed={CheckAllMessageProcessed()}");
  315. }
  316. }
  317. public override bool IsError
  318. {
  319. get { return FsmState == (int)STATE.Error; }
  320. }
  321. public bool IsPaused { get; set; }
  322. public override double ChamberPressure { get; }
  323. public bool CheckEnableRunProcess(out string reason)
  324. {
  325. throw new NotImplementedException();
  326. }
  327. public void ResetToleranceChecker()
  328. {
  329. throw new NotImplementedException();
  330. }
  331. public void OnProcessStart(string v1, string recipeName, bool v2)
  332. {
  333. throw new NotImplementedException();
  334. }
  335. public void PauseRecipe(out string reason)
  336. {
  337. throw new NotImplementedException();
  338. }
  339. public bool CheckAllDevicesStable(float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8, float v9)
  340. {
  341. throw new NotImplementedException();
  342. }
  343. public void AbortRunProcess(out string reason)
  344. {
  345. throw new NotImplementedException();
  346. }
  347. public event Action<string> OnEnterError;
  348. private ModuleName _module;
  349. private bool _isInit;
  350. private StatsData _statWaferCount1;
  351. private StatsData _statProcessTime1;
  352. private StatsData _statWaferCount2;
  353. private StatsData _statProcessTime2;
  354. private Stopwatch _processTimer = new Stopwatch();
  355. public PMModule(ModuleName module, int slotCount) : base(slotCount)
  356. {
  357. _module = module;
  358. Module = module.ToString();
  359. Name = module.ToString();
  360. _chamber = DEVICE.GetDevice<JetDualPM>($"{module}.{module}");
  361. _chamber1Disabled = _chamber.Chamber1Disable;
  362. _chamber2Disabled = _chamber.Chamber2Disable;
  363. _enableBiasRF1 = _chamber.BiasRf1Enable;
  364. _enableBiasRF2 = _chamber.BiasRf2Enable;
  365. EnumLoop<STATE>.ForEach((item) =>
  366. {
  367. MapState((int)item, item.ToString());
  368. });
  369. EnumLoop<MSG>.ForEach((item) =>
  370. {
  371. MapMessage((int)item, item.ToString());
  372. });
  373. EnableFsm(50, IsInstalled ? STATE.Init : STATE.NotInstall);
  374. LeakCheckResultManager.Instance.Initialize(Module.ToString());
  375. }
  376. public override bool Initialize()
  377. {
  378. if (!IsInstalled)
  379. return true;
  380. IsOnline = false;
  381. InitDevice();
  382. InitRoutine();
  383. InitInterlock();
  384. InitFsm();
  385. InitOp();
  386. InitData();
  387. InitStats();
  388. return base.Initialize();
  389. }
  390. protected virtual void InitRoutine()
  391. {
  392. _ventRoutine = new VentRoutine(_chamber);
  393. _pumpRoutine = new PumpDownRoutine(_chamber);
  394. _startPumpRoutine = new StartPumpRoutine(_chamber);
  395. _temperatureControlRoutine = new TemperatureControlRoutine(_chamber);
  396. _prepareTrans = new PMPrepareTransferRoutine(_chamber, _ventRoutine);
  397. _transferHandoff = new PMTransferHandoffRoutine(_chamber);
  398. _postTrans = new PMPostTransferRoutine(_chamber);
  399. _gasFlowRoutine = new GasFlowRoutine(_chamber);
  400. _rfPowerRoutine = new RfPowerRoutine(_chamber, true);
  401. _cyclePurgeRoutine = new CyclePurgeRoutine(_chamber);
  402. _leakCheckRoutine = new LeakCheckRoutine(_chamber, _pumpRoutine);
  403. _cleanRoutine = new CleanRoutine(_chamber);
  404. _ATMProcessRoutine = new PMATMProcessRoutine(_chamber);
  405. _preProcessRoutine = new PreProcessRoutine(_chamber, _pumpRoutine);
  406. _processRoutine = new ProcessRoutine(_chamber, this);
  407. _postProcessRoutine = new PostProcessRoutine(_chamber, _ventRoutine);
  408. _home = new PMHomeRoutine(_chamber);
  409. _mfcVerification = new PMMfcVerificationRoutine(_chamber, _pumpRoutine);
  410. }
  411. protected virtual void InitData()
  412. {
  413. DATA.Subscribe($"{Module}.IsError", () => IsError);
  414. DATA.Subscribe($"{Module}.State", () => FsmState);
  415. DATA.Subscribe($"{Module}.Status", () => StringFsmStatus);
  416. DATA.Subscribe($"{Module}.IsOnline", () => IsOnline);
  417. DATA.Subscribe($"{Module}.WaferSize", () => WaferManager.Instance.GetWaferSize(_module, 0).ToString());
  418. DATA.Subscribe($"{Module}.WaferSize1", () => WaferManager.Instance.GetWaferSize(_module, 1).ToString());
  419. DATA.Subscribe($"{Module}.IsInMaintainMode", () => !IsOnline);
  420. //DATA.Subscribe($"{Name}.SelectedRecipeName", () => _recipeRunningInfo.RecipeName);
  421. //DATA.Subscribe($"{Name}.RecipeStepNumber", () => _recipeRunningInfo.StepNumber);
  422. //DATA.Subscribe($"{Name}.RecipeStepName", () => _recipeRunningInfo.StepName);
  423. //DATA.Subscribe($"{Name}.RecipeStepElapseTime", () => _recipeRunningInfo.StepElapseTime);
  424. //DATA.Subscribe($"{Name}.RecipeStepTime", () => _recipeRunningInfo.StepTime);
  425. //DATA.Subscribe($"{Name}.RecipeTotalElapseTime", () => _recipeRunningInfo.TotalElapseTime);
  426. //DATA.Subscribe($"{Name}.RecipeTotalTime", () => _recipeRunningInfo.TotalTime);
  427. DATA.Subscribe($"{Module}.FsmState", () => ((STATE)FsmState).ToString());
  428. DATA.Subscribe($"{Module}.FsmPrevState", () => ((STATE)FsmPreviousState).ToString());
  429. DATA.Subscribe($"{Module}.FsmLastMessage", ((MSG)FsmLastMessage).ToString());
  430. DATA.Subscribe($"{Module}.IsAutoMode", () => IsAutoMode);
  431. DATA.Subscribe($"{Module}.IsAlarm", () => _isAlarm);
  432. DATA.Subscribe($"{Module}.ProcessStatus", () => _processStatus);
  433. DATA.Subscribe($"{Module}.PumpTime", () => PumpTime);
  434. DATA.Subscribe($"{Module}.TCTime", () => TCTime);
  435. DATA.Subscribe($"{Module}.StepNo", () => StepNo);
  436. DATA.Subscribe($"{Module}.RecipeStepName", () => RecipeStepName);
  437. DATA.Subscribe($"{Module}.RecipeName", () => RecipeName);
  438. DATA.Subscribe($"{Module}.LeakRate", () => LeakRate);
  439. DATA.Subscribe($"{Module}.LeakCheckElapseTime", () => LeakCheckElapseTime);
  440. DATA.Subscribe($"{Module}.SmallWafer", () => _smallWafer);
  441. DATA.Subscribe($"{Module}.BigWafer", () => _bigWafer);
  442. DATA.Subscribe($"{Module}.MidWafer", () => _midWafer);
  443. DATA.Subscribe($"{Module}.RecipeSteps", () => RecipeSteps);
  444. DATA.Subscribe($"{Module}.RecipeProcessTime", () => RecipeElapsedTime);
  445. DATA.Subscribe($"{Module}.RecipeStepTimeElapsed", () => (_processRoutine.CurStepElpasedTime / 1000).ToString("F0"));
  446. DATA.Subscribe($"{Module}.RecipeStepTimeSetPoint", () => (_processRoutine.CurStepTotalTime / 1000).ToString("F0"));
  447. }
  448. private void InitStats()
  449. {
  450. _statWaferCount1 = new StatsData($"{Module}.ProcessedWaferCount1", "PM1 Total processed wafer", 0);
  451. _statWaferCount2 = new StatsData($"{Module}.ProcessedWaferCount2", "PM2 Total processed wafer", 0);
  452. _statProcessTime1 = new StatsData($"{Module}.ProcessTime1", "PM1 Total process time", 0);
  453. _statProcessTime2 = new StatsData($"{Module}.ProcessTime2", "PM2 Total process time", 0);
  454. StatsDataManager.Instance.Subscribe($"{Module}.ProcessedWaferCount1", "PM1 Processed Wafer Count", 0);
  455. StatsDataManager.Instance.Subscribe($"{Module}.ProcessedWaferCount2", "PM2 Processed Wafer Count", 0);
  456. StatsDataManager.Instance.Subscribe($"{Module}.Rf1.RfOnTime", "Rf 1 On Time");
  457. StatsDataManager.Instance.Subscribe($"{Module}.Rf2.RfOnTime", "Rf 2 On Time");
  458. if (_enableBiasRF1)
  459. StatsDataManager.Instance.Subscribe($"{Module}.BiasRf1.RfOnTime", "Bias Rf 1 On Time");
  460. if (_enableBiasRF2)
  461. StatsDataManager.Instance.Subscribe($"{Module}.BiasRf2.RfOnTime", "Bias Rf 2 On Time");
  462. StatsDataManager.Instance.Subscribe($"{Module}.PumpOnTime", "Pump On Time");
  463. _statRf1OnTime = StatsDataManager.Instance.GetItemRFAndPump($"{Module}.Rf1.RfOnTime");
  464. _statRf2OnTime = StatsDataManager.Instance.GetItemRFAndPump($"{Module}.Rf2.RfOnTime");
  465. if (_enableBiasRF1)
  466. _statBiasRf1OnTime = StatsDataManager.Instance.GetItemRFAndPump($"{Module}.BiasRf1.RfOnTime");
  467. if (_enableBiasRF2)
  468. _statBiasRf2OnTime = StatsDataManager.Instance.GetItemRFAndPump($"{Module}.BiasRf2.RfOnTime");
  469. _statPumpOnTime = StatsDataManager.Instance.GetItemRFAndPump($"{Module}.PumpOnTime");
  470. DATA.Subscribe($"{Module}.ProcessTime1.Value", () => _statProcessTime1.GetValue());
  471. DATA.Subscribe($"{Module}.ProcessedWaferCount1.Value", () => _statWaferCount1.GetValue());
  472. DATA.Subscribe($"{Module}.ProcessTime2.Value", () => _statProcessTime2.GetValue());
  473. DATA.Subscribe($"{Module}.ProcessedWaferCount2.Value", () => _statWaferCount2.GetValue());
  474. DATA.Subscribe($"{Module}.Rf1.RfOnTime.Value", () => _statRf1OnTime.fromLastPM);
  475. DATA.Subscribe($"{Module}.Rf2.RfOnTime.Value", () => _statRf2OnTime.fromLastPM);
  476. DATA.Subscribe($"{Module}.PumpOnTime.Value", () => _statPumpOnTime.fromLastPM);
  477. if (_enableBiasRF1)
  478. DATA.Subscribe($"{Module}.BiasRf1.RfOnTime.Value", () => _statBiasRf1OnTime.fromLastPM);
  479. if (_enableBiasRF2)
  480. DATA.Subscribe($"{Module}.BiasRf2.RfOnTime.Value", () => _statBiasRf2OnTime.fromLastPM);
  481. }
  482. private void InitOp()
  483. {
  484. OP.Subscribe($"{Module}.Home", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Home));
  485. OP.Subscribe($"{Module}.Reset", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Reset));
  486. OP.Subscribe($"{Module}.Abort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Abort));
  487. OP.Subscribe($"{Module}.Pump", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Pump));
  488. OP.Subscribe($"{Module}.Vent", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Vent));
  489. OP.Subscribe($"{Module}.Purge", (string cmd, object[] args) => CheckToPostMessage((int)MSG.CyclePurge));
  490. OP.Subscribe($"{Module}.PutOnline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOnline));
  491. OP.Subscribe($"{Module}.PutOffline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOffline));
  492. OP.Subscribe($"{Module}.{RtOperation.PmOnline}", (cmd, args) => CheckToPostMessage((int)MSG.SetOnline));
  493. OP.Subscribe($"{Module}.{RtOperation.PmOffline}", (cmd, args) => CheckToPostMessage((int)MSG.SetOffline));
  494. OP.Subscribe($"{Name}.SelectRecipe", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SelectRecipe, args[0]));
  495. OP.Subscribe($"{Module}.{RtOperation.GasFlow}", (cmd, args) => CheckToPostMessage((int)MSG.GasFlow, args));
  496. OP.Subscribe($"{Module}.{RtOperation.RfPower}", (cmd, args) => CheckToPostMessage((int)MSG.RfPower, args));
  497. OP.Subscribe($"{Module}.MoveLiftPin1", (cmd, args) => CheckToPostMessage((int)MSG.MoveLiftPin1, args[0]));
  498. OP.Subscribe($"{Module}.MoveLiftPin2", (cmd, args) => CheckToPostMessage((int)MSG.MoveLiftPin2, args[0]));
  499. OP.Subscribe($"{Module}.MoveGuidePin1", (cmd, args) => CheckToPostMessage((int)MSG.MoveGuidePin1, args[0], args[1]));
  500. OP.Subscribe($"{Module}.MoveGuidePin2", (cmd, args) => CheckToPostMessage((int)MSG.MoveGuidePin2, args[0], args[1]));
  501. OP.Subscribe($"{Module}.PrepareTransfer", (cmd, args) => CheckToPostMessage((int)MSG.PrepareTransfer, args[0]));
  502. OP.Subscribe($"{Module}.TransferHandoff", (cmd, args) => CheckToPostMessage((int)MSG.TransferHandoff, args[0]));
  503. OP.Subscribe($"{Module}.{RtOperation.StartPump}", (cmd, args) => CheckToPostMessage((int)MSG.LaunchPump));
  504. OP.Subscribe($"{Module}.{RtOperation.LeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.LeakCheck, args));
  505. OP.Subscribe($"{Module}.{RtOperation.DeleteLeakCheck}", (cmd, args) => CheckToPostMessage((int)MSG.DeleteLeakCheck, args));
  506. OP.Subscribe($"{Module}.{RtOperation.LockLid}", (cmd, args) => CheckToPostMessage((int)MSG.LockLid, true));
  507. OP.Subscribe($"{Module}.{RtOperation.UnlockLid}", (cmd, args) => CheckToPostMessage((int)MSG.LockLid, false));
  508. OP.Subscribe($"{Module}.{RtOperation.RunRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RunRecipe, (string)args[0], "", true));
  509. OP.Subscribe($"{Module}.{RtOperation.SkipCurrentStep}", (cmd, args) => CheckToPostMessage((int)MSG.RecipeSkipStep));
  510. OP.Subscribe($"{Module}.{RtOperation.AbortRecipe}", (cmd, args) => CheckToPostMessage((int)MSG.RecipeAbort));
  511. OP.Subscribe($"{Module}.{RtOperation.PmAuto}", (cmd, args) => CheckToPostMessage((int)MSG.AutoMode));
  512. OP.Subscribe($"{Module}.{RtOperation.PmManual}", (cmd, args) => CheckToPostMessage((int)MSG.ManualMode));
  513. OP.Subscribe($"{Module}.{RtOperation.Heat}", (cmd, args) => CheckToPostMessage((int)MSG.Heat, args));
  514. OP.Subscribe($"{Module}.{RtOperation.MFCVerification}", (cmd, args) => CheckToPostMessage((int)MSG.MFCVerification, args));
  515. }
  516. private void InitFsm()
  517. {
  518. //Idle
  519. EnterExitTransition((int)STATE.Idle, FnIdle, (int)FSM_MSG.NONE, null);
  520. EnterExitTransition<STATE, FSM_MSG>(STATE.Error, fEnterError, FSM_MSG.NONE, null);
  521. //Error
  522. Transition(STATE.Init, MSG.Error, FnError, STATE.Error);
  523. Transition(STATE.Error, MSG.Reset, FnReset, STATE.Idle);
  524. AnyStateTransition(MSG.Error, FnError, STATE.Error);
  525. AnyStateTransition(FSM_MSG.WARNING, fWarning, FSM_STATE.SAME);
  526. AnyStateTransition((int)FSM_MSG.ALARM, fAlarm, (int)STATE.Error);
  527. AnyStateTransition(MSG.AutoMode, FnSetAuto, FSM_STATE.SAME);
  528. AnyStateTransition(MSG.ManualMode, FnSetManual, FSM_STATE.SAME);
  529. AnyStateTransition(MSG.SetOnline, FnSetOnline, FSM_STATE.SAME);
  530. AnyStateTransition(MSG.SetOffline, FnSetOffline, FSM_STATE.SAME);
  531. //Home
  532. EnterExitTransition((int)STATE.Homing, FnEnterHome, (int)FSM_MSG.NONE, FnExitHome);
  533. Transition(STATE.Init, MSG.Home, FnStartHome, STATE.Homing);
  534. Transition(STATE.Error, MSG.Home, FnStartHome, STATE.Homing);
  535. Transition(STATE.Idle, MSG.Home, FnStartHome, STATE.Homing);
  536. Transition(STATE.Homing, FSM_MSG.TIMER, FnMonitorHome, STATE.Idle);
  537. Transition(STATE.Homing, MSG.Error, null, STATE.Init);
  538. Transition(STATE.Homing, MSG.Abort, FnAbortTask, STATE.Init);
  539. // Gas Flow sequence
  540. Transition(STATE.Idle, MSG.GasFlow, FnStartGasFlow, STATE.GasFlowing);
  541. Transition(STATE.GasFlowing, MSG.GasFlow, FnStartGasFlow, STATE.GasFlowing);
  542. Transition(STATE.GasFlowing, FSM_MSG.TIMER, FnGasFlowTimeout, STATE.Idle);
  543. Transition(STATE.GasFlowing, MSG.StopGasFlow, FnStopGasFlow, STATE.Idle);
  544. Transition(STATE.GasFlowing, MSG.Abort, FnAbortGasFlow, STATE.Idle);
  545. //RF Power sequence
  546. Transition(STATE.Idle, MSG.RfPower, FnStartRfPower, STATE.RfPowering);
  547. Transition(STATE.GasFlowing, MSG.RfPower, FnStartRfPower, STATE.RfPowering);
  548. Transition(STATE.RfPowering, FSM_MSG.TIMER, FnRfPowerTimeout, STATE.Idle);
  549. Transition(STATE.RfPowering, MSG.Abort, FnAbortRfPower, STATE.Idle);
  550. // Heat substrate
  551. Transition(STATE.Idle, MSG.Heat, FnHeat, STATE.Heating);
  552. Transition(STATE.Heating, FSM_MSG.TIMER, FnHeatTimeout, STATE.Idle);
  553. Transition(STATE.Heating, MSG.Abort, FnAbortHeating, STATE.Idle);
  554. //Launch Pump sequence
  555. Transition(STATE.Idle, MSG.LaunchPump, FnLaunchPump, STATE.LaunchingPump);
  556. Transition(STATE.LaunchingPump, FSM_MSG.TIMER, FnLaunchPumpTimeout, STATE.Idle);
  557. Transition(STATE.LaunchingPump, MSG.Abort, FnAbortStartPumping, STATE.Idle);
  558. //Pump sequence
  559. Transition(STATE.Idle, MSG.Pump, FnStartPumpDown, STATE.Pumping);
  560. Transition(STATE.Venting, MSG.Pump, FnVentToPumping, STATE.Pumping);
  561. Transition(STATE.Pumping, FSM_MSG.TIMER, FnPumpDownTimeout, STATE.Idle);
  562. Transition(STATE.Pumping, MSG.Abort, FnAbortPumping, STATE.Idle);
  563. //vent sequence
  564. Transition(STATE.Idle, MSG.Vent, FnStartVent, STATE.Venting);
  565. Transition(STATE.Pumping, MSG.Vent, FnPumpingToVent, STATE.Venting);
  566. Transition(STATE.Venting, FSM_MSG.TIMER, FnVentTimeout, STATE.Idle);
  567. Transition(STATE.Venting, MSG.Abort, FnAbortVent, STATE.Idle);
  568. // Purge sequence
  569. Transition(STATE.Idle, MSG.CyclePurge, FnStartPurge, STATE.Purging);
  570. Transition(STATE.Purging, FSM_MSG.TIMER, FnPurgeTimeout, STATE.Idle);
  571. Transition(STATE.Purging, MSG.Abort, FnAbortPurge, STATE.Idle);
  572. //Leak check sequence
  573. Transition(STATE.Idle, MSG.LeakCheck, FnStartLeakCheck, STATE.LeakCheck);
  574. Transition(STATE.Idle, MSG.DeleteLeakCheck, FnDeleteLeakCheck, STATE.Idle);
  575. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FnLeakCheckTimeout, STATE.Idle);
  576. Transition(STATE.LeakCheck, MSG.Abort, FnAbortLeakCheck, STATE.Idle);
  577. //MFC verification
  578. Transition(STATE.Idle, MSG.MFCVerification, FnStartMFCVerification, STATE.MFCVerification);
  579. Transition(STATE.MFCVerification, FSM_MSG.TIMER, FnMFCVerificationTimeout, STATE.Idle);
  580. Transition(STATE.MFCVerification, MSG.Abort, FnAbortMFCVerification, STATE.Idle);
  581. // Transfer
  582. Transition(STATE.Idle, MSG.PrepareTransfer, FnStartPrepareTransfer, STATE.PrepareTransfer);
  583. Transition(STATE.PrepareTransfer, FSM_MSG.TIMER, FnPreTransferTimeout, STATE.Idle);
  584. Transition(STATE.PrepareTransfer, MSG.Abort, FnAbortTask, STATE.Idle);
  585. Transition(STATE.Idle, MSG.PostTransfer, FnStartPostTransfer, STATE.PostTransfer);
  586. Transition(STATE.PostTransfer, FSM_MSG.TIMER, FnPostTransferTimeout, STATE.Idle);
  587. Transition(STATE.PostTransfer, MSG.Abort, FnAbortTask, STATE.Idle);
  588. Transition(STATE.Idle, MSG.TransferHandoff, FnStartTransferHandoff, STATE.TransferHandoff);
  589. Transition(STATE.TransferHandoff, FSM_MSG.TIMER, FnTransferHandoffTimeout, STATE.Idle);
  590. Transition(STATE.TransferHandoff, MSG.Abort, FnAbortTask, STATE.Idle);
  591. // lift pin
  592. Transition(STATE.Idle, MSG.MoveLiftPin1, FnSetLiftPin1, STATE.Liftpin1Moving);
  593. Transition(STATE.Idle, MSG.MoveLiftPin2, FnSetLiftPin2, STATE.Liftpin2Moving);
  594. Transition(STATE.Liftpin1Moving, FSM_MSG.TIMER, FnLiftpin1Timeout, STATE.Idle);
  595. Transition(STATE.Liftpin1Moving, FSM_MSG.TIMER, FnLiftpin2Timeout, STATE.Idle);
  596. // guide pin
  597. Transition(STATE.Idle, MSG.MoveGuidePin1, FnSetGuidePin, STATE.GuidePin1Moving);
  598. Transition(STATE.Idle, MSG.MoveGuidePin2, FnSetGuidePin, STATE.GuidePin2Moving);
  599. Transition(STATE.GuidePin1Moving, FSM_MSG.TIMER, FnGuidePin1Timeout, STATE.Idle);
  600. Transition(STATE.GuidePin2Moving, FSM_MSG.TIMER, FnGuidePin2Timeout, STATE.Idle);
  601. //ATM Process
  602. Transition(STATE.Idle, MSG.ATMProcess, FnStartATMProcess, STATE.ATMProcessing);
  603. Transition(STATE.ATMProcessing, FSM_MSG.TIMER, FnATMProcessTimeout, STATE.Idle);
  604. Transition(STATE.ATMProcessing, MSG.Abort, FnAbortATMProcess, STATE.Idle);
  605. Transition(STATE.ATMProcessing, MSG.RecipeAbort, FnAbortATMProcess, STATE.Idle);
  606. // PreClean sequence
  607. Transition(STATE.Idle, MSG.Clean, FnPreClean, STATE.PreClean);
  608. Transition(STATE.PreClean, FSM_MSG.TIMER, FnPreCleanTimeout, STATE.LoadProcessRecipe);
  609. // PreProcess sequence
  610. Transition(STATE.Idle, MSG.RunRecipe, FnProcessLoadRecipe, STATE.LoadProcessRecipe);
  611. Transition(STATE.LoadProcessRecipe, MSG.PreProcess, FnStartPreProcess, STATE.PreProcess);
  612. Transition(STATE.LoadProcessRecipe, MSG.Abort, null, STATE.Idle);
  613. Transition(STATE.LoadProcessRecipe, MSG.Error, null, STATE.Idle);
  614. Transition(STATE.PreProcess, FSM_MSG.TIMER, FnPreProcessTimeout, STATE.PreProcess);
  615. Transition(STATE.PreProcess, MSG.Abort, FnAbortPreProcess, STATE.Idle);
  616. Transition(STATE.PreProcess, MSG.RecipeAbort, FnAbortPreProcess, STATE.Idle);
  617. Transition(STATE.PreProcess, MSG.Error, FnAbortPreProcess, STATE.Error);
  618. // Process
  619. Transition(STATE.PreProcess, MSG.Process, FnStartProcess, STATE.Processing);
  620. Transition(STATE.Processing, FSM_MSG.TIMER, FnProcessTimeout, STATE.Processing);
  621. Transition(STATE.Processing, MSG.Error, FnAbortProcess, STATE.Error);
  622. Transition(STATE.Processing, MSG.RecipeAbort, FnAbortProcess, STATE.PostProcess);
  623. Transition(STATE.Processing, MSG.RecipePause, FnPauseProcess, STATE.Processing);
  624. Transition(STATE.Processing, MSG.RecipeResume, FnResumeRecipe, STATE.Processing);
  625. Transition(STATE.Processing, MSG.RecipeUpdate, FnUpdateRecipe, STATE.Processing);
  626. Transition(STATE.Processing, MSG.RecipeSkipStep, FnSkipStep, STATE.Processing);
  627. EnterExitTransition<STATE, FSM_MSG>(STATE.Processing, FnEnterProcess, FSM_MSG.NONE, FnExitProcess);
  628. //PostProcess sequence
  629. Transition(STATE.Processing, MSG.PostProcess, FnStartPostProcess, STATE.PostProcess);
  630. Transition(STATE.PostProcess, FSM_MSG.TIMER, FnPostProcessTimeout, STATE.Idle);
  631. Transition(STATE.PostProcess, MSG.Abort, FnAbortPostProcess, STATE.Idle);
  632. Transition(STATE.PostProcess, MSG.RecipeAbort, FnAbortPostProcess, STATE.Idle);
  633. EnterExitTransition<STATE, FSM_MSG>(STATE.PostProcess, null, FSM_MSG.NONE, fExitPostProcess);
  634. }
  635. protected virtual void InitDevice()
  636. {
  637. }
  638. protected virtual void InitInterlock()
  639. {
  640. }
  641. private bool FsmSelectRecipe(object[] param)
  642. {
  643. _recipeRunningInfo.RecipeName = (string)param[0];
  644. return true;
  645. }
  646. #region Service functions
  647. public override bool Home(out string reason)
  648. {
  649. CheckToPostMessage((int)MSG.Home);
  650. reason = string.Empty;
  651. return true;
  652. }
  653. public override void Reset()
  654. {
  655. if (IsError)
  656. CheckToPostMessage((int)MSG.Reset);
  657. }
  658. public override bool PrepareTransfer(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason)
  659. {
  660. reason = "";
  661. return true;
  662. }
  663. public override bool PrepareTransfer(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, double temp1, double temp2, bool EanbleCheck, out string reason, EnumDualPM autoPos = EnumDualPM.None)
  664. {
  665. CheckToPostMessage((int)MSG.PrepareTransfer, transferType.ToString(), targetSlot, temp1, temp2, EanbleCheck, (int)blade, autoPos.ToString());
  666. reason = string.Empty;
  667. return true;
  668. }
  669. public override bool TransferHandoff(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason)
  670. {
  671. CheckToPostMessage((int)MSG.TransferHandoff, transferType.ToString(), targetSlot);
  672. reason = string.Empty;
  673. return true;
  674. }
  675. public override bool PostTransfer(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason)
  676. {
  677. CheckToPostMessage((int)MSG.PostTransfer, transferType.ToString(), targetSlot);
  678. reason = string.Empty;
  679. return true;
  680. }
  681. public override bool CheckTempReady(double Temp1, double Temp2)
  682. {
  683. double _checkTemp1;
  684. double _checkTemp2;
  685. double _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
  686. if (_chamber.Chiller1Enable)
  687. {
  688. _checkTemp1 = (double)_chamber.CoolantOutletTempFB1;
  689. }
  690. else
  691. {
  692. _checkTemp1 = (double)_chamber.LETempFB1;
  693. }
  694. if (_chamber.Chiller2Enable)
  695. {
  696. _checkTemp2 = (double)_chamber.CoolantOutletTempFB2;
  697. }
  698. else
  699. {
  700. _checkTemp2 = (double)_chamber.LETempFB2;
  701. }
  702. return ((_chamber1Disabled || Temp1 <= 0) || ((Temp1 - _tolerance) <= _checkTemp1 && _checkTemp1 <= (Temp1 + _tolerance))) &&
  703. ((_chamber2Disabled || Temp2 <= 0) || ((Temp2 - _tolerance) <= _checkTemp2 && _checkTemp2 <= (Temp2 + _tolerance)));
  704. }
  705. public override bool CheckTemp1Alarm(double recipeTemp1)
  706. {
  707. double _checkTemp1;
  708. double _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceTransferWafer");
  709. if (_chamber.Chiller1Enable)
  710. {
  711. _checkTemp1 = (double)_chamber.CoolantOutletTempFB1;
  712. }
  713. else
  714. {
  715. _checkTemp1 = (double)_chamber.LETempFB1;
  716. }
  717. return recipeTemp1 > (_checkTemp1 + _tolerance);
  718. }
  719. public override bool CheckTemp2Alarm(double recipeTemp2)
  720. {
  721. double _checkTemp2;
  722. double _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceTransferWafer");
  723. if (_chamber.Chiller2Enable)
  724. {
  725. _checkTemp2 = (double)_chamber.CoolantOutletTempFB2;
  726. }
  727. else
  728. {
  729. _checkTemp2 = (double)_chamber.LETempFB2;
  730. }
  731. return recipeTemp2 > (_checkTemp2 + _tolerance);
  732. }
  733. public override bool CheckTransferTempReady(double Temp1, double Temp2)
  734. {
  735. double _checkTemp1;
  736. double _checkTemp2;
  737. double _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceTransferWafer");
  738. if (_chamber.Chiller1Enable)
  739. {
  740. _checkTemp1 = (double)_chamber.CoolantOutletTempFB1;
  741. }
  742. else
  743. {
  744. _checkTemp1 = (double)_chamber.LETempFB1;
  745. }
  746. if (_chamber.Chiller2Enable)
  747. {
  748. _checkTemp2 = (double)_chamber.CoolantOutletTempFB2;
  749. }
  750. else
  751. {
  752. _checkTemp2 = (double)_chamber.LETempFB2;
  753. }
  754. return ((_chamber1Disabled || Temp1 <= 0 ) || ((Temp1 - _tolerance) <= _checkTemp1 && _checkTemp1 <= (Temp1 + _tolerance))) &&
  755. ((_chamber2Disabled || Temp2 <= 0 ) || ((Temp2 - _tolerance) <= _checkTemp2 && _checkTemp2 <= (Temp2 + _tolerance)));
  756. }
  757. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  758. {
  759. reason = string.Empty;
  760. if (targetSlot == 0)
  761. {
  762. if (transferType == EnumTransferType.Pick)
  763. {
  764. if (!_chamber.CheckSlitDoor1Open())
  765. {
  766. reason = "Slit door is closed";
  767. return false;
  768. }
  769. if (!_chamber.CheckLift1Up())
  770. {
  771. reason = "Lift pin is down";
  772. return false;
  773. }
  774. return _chamber.CheckSlitDoor1Open() && _chamber.CheckLift1Up();
  775. }
  776. else if (transferType == EnumTransferType.Place)
  777. {
  778. if (!_chamber.CheckSlitDoor1Open())
  779. {
  780. reason = "Slit door is closed";
  781. return false;
  782. }
  783. if (!_chamber.CheckLift1Down())
  784. {
  785. reason = "Lift pin is Up";
  786. return false;
  787. }
  788. return _chamber.CheckSlitDoor1Open() && _chamber.CheckLift1Down();
  789. }
  790. }
  791. if (targetSlot == 1)
  792. {
  793. if (transferType == EnumTransferType.Pick)
  794. {
  795. if (!_chamber.CheckSlitDoor2Open())
  796. {
  797. reason = "Slit door is Closed";
  798. return false;
  799. }
  800. if (!_chamber.CheckLift2Up())
  801. {
  802. reason = "Lift pin is Down";
  803. return false;
  804. }
  805. return _chamber.CheckSlitDoor2Open() && _chamber.CheckLift2Up();
  806. }
  807. else if (transferType == EnumTransferType.Place)
  808. {
  809. if (!_chamber.CheckSlitDoor2Open())
  810. {
  811. reason = "Slit door is Closed";
  812. return false;
  813. }
  814. if (!_chamber.CheckLift2Down())
  815. {
  816. reason = "Lift pin is Up";
  817. return false;
  818. }
  819. return _chamber.CheckSlitDoor2Open() && _chamber.CheckLift2Down();
  820. }
  821. }
  822. reason = "Check Ready For Transfer Failed";
  823. return false;
  824. }
  825. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  826. {
  827. //if (FsmState == (int)STATE.InTransfer)
  828. // CheckToPostMessage(MSG.Transfer)
  829. }
  830. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  831. {
  832. //if (FsmState == (int)STATE.InTransfer)
  833. // CheckToPostMessage(MSG.Transfer)
  834. }
  835. public override bool Process(string recipeName, bool isCleanRecipe, bool withWafer, out string reason)
  836. {
  837. if (isCleanRecipe)
  838. {
  839. CheckToPostMessage((int)MSG.Clean, recipeName, "", withWafer);
  840. reason = string.Empty;
  841. return true;
  842. }
  843. if (SC.IsATMMode)
  844. {
  845. CheckToPostMessage((int)MSG.ATMProcess, recipeName);
  846. reason = string.Empty;
  847. return true;
  848. }
  849. _recipeRunningInfo.RecipeName = recipeName;
  850. CheckToPostMessage((int)MSG.RunRecipe, recipeName);
  851. reason = string.Empty;
  852. return true;
  853. }
  854. public override bool PreparePump(out string reason)
  855. {
  856. throw new NotImplementedException();
  857. }
  858. public override bool CheckPreparePump()
  859. {
  860. throw new NotImplementedException();
  861. }
  862. public override bool SlowPump(int tvPosition, out string reason)
  863. {
  864. throw new NotImplementedException();
  865. }
  866. public override bool FastPump(int tvPosition, out string reason)
  867. {
  868. throw new NotImplementedException();
  869. }
  870. public override bool TurnOnPump(out string reason)
  871. {
  872. throw new NotImplementedException();
  873. }
  874. public override bool CheckPumpIsOn()
  875. {
  876. throw new NotImplementedException();
  877. }
  878. public override bool ShutDownPump(out string reason)
  879. {
  880. throw new NotImplementedException();
  881. }
  882. public override bool AbortPump()
  883. {
  884. throw new NotImplementedException();
  885. }
  886. public override bool PrepareVent(out string reason)
  887. {
  888. throw new NotImplementedException();
  889. }
  890. public override bool CheckPrepareVent()
  891. {
  892. throw new NotImplementedException();
  893. }
  894. public override bool Vent(out string reason)
  895. {
  896. throw new NotImplementedException();
  897. }
  898. public override bool StopVent(out string reason)
  899. {
  900. throw new NotImplementedException();
  901. }
  902. public override bool CloseSlitValve(out string reason)
  903. {
  904. return _chamber.SetSlitDoor1(false, out reason) && _chamber.SetSlitDoor2(false, out reason);
  905. }
  906. public override bool CheckSlitValveClose()
  907. {
  908. return _chamber.IsSlitDoor1Closed && _chamber.IsSlitDoor2Closed;
  909. }
  910. public override bool CheckLiftUp(int _slot)
  911. {
  912. if(_slot == 0)
  913. {
  914. return _chamber.CheckLift1Up();
  915. }
  916. else if(_slot == 1)
  917. {
  918. return _chamber.CheckLift2Up();
  919. }
  920. return false;
  921. }
  922. public override bool CheckLiftDown(int _slot)
  923. {
  924. if (_slot == 0)
  925. {
  926. return _chamber.CheckLift1Down();
  927. }
  928. else if (_slot == 1)
  929. {
  930. return _chamber.CheckLift2Down();
  931. }
  932. return false;
  933. }
  934. public override bool CheckLidClosed()
  935. {
  936. throw new NotImplementedException();
  937. }
  938. // Methods
  939. //
  940. private bool FnAbortTask(object[] param)
  941. {
  942. //_task.Abort();
  943. return true;
  944. }
  945. private bool FnSetAuto(object[] param)
  946. {
  947. this._AutoMode = AutoFlag.Auto;
  948. return true;
  949. }
  950. private bool FnSetManual(object[] param)
  951. {
  952. if (FsmState == (int)STATE.PreProcess || FsmState == (int)STATE.Processing || FsmState == (int)STATE.PostProcess)
  953. {
  954. EV.PostWarningLog(Module.ToString(), $"{Module} is in {(STATE)FsmState},can not do SetAutoMode");
  955. return false;
  956. }
  957. this._AutoMode = AutoFlag.Manual;
  958. return true;
  959. }
  960. private bool FnSetOnline(object[] param)
  961. {
  962. if (FsmState != (int)STATE.Idle)
  963. {
  964. EV.PostWarningLog(Module.ToString(), $"{Module} is in {(STATE)FsmState},can not do SetOnline");
  965. return false;
  966. }
  967. _chamber.CloseAllGenerator();
  968. _chamber.CloseAllGasValve();
  969. IsOnline = true;
  970. return true;
  971. }
  972. private bool FnSetOffline(object[] param)
  973. {
  974. IsOnline = false;
  975. return true;
  976. }
  977. #region Gas&RF
  978. private bool FnStartGasFlow(object[] objs)
  979. {
  980. RState ret = _gasFlowRoutine.Start(objs);
  981. if (ret == RState.Failed || ret == RState.Timeout)
  982. {
  983. PostMsg(MSG.Error);
  984. return false; //do noting
  985. }
  986. return true;
  987. }
  988. private bool FnGasFlowTimeout(object[] objs)
  989. {
  990. RState ret = _gasFlowRoutine.Monitor();
  991. if (ret == RState.Failed || ret == RState.Timeout)
  992. {
  993. PostMsg(MSG.Error);
  994. return true;
  995. }
  996. return false;
  997. }
  998. private bool FnAbortGasFlow(object[] objs)
  999. {
  1000. _gasFlowRoutine.Abort();
  1001. return true;
  1002. }
  1003. private bool FnStopGasFlow(object[] objs)
  1004. {
  1005. _gasFlowRoutine.StopFlow2();
  1006. return true;
  1007. }
  1008. private bool FnStartRfPower(object[] objs)
  1009. {
  1010. _rfStartTime = DateTime.Now;
  1011. RState ret = _rfPowerRoutine.Start(objs);
  1012. if (ret == RState.End)
  1013. {
  1014. return false;
  1015. }
  1016. if (ret == RState.Failed || ret == RState.Timeout)
  1017. {
  1018. PostMsg(MSG.Error);
  1019. return false; //do noting
  1020. }
  1021. return true;
  1022. }
  1023. private bool FnRfPowerTimeout(object[] objs)
  1024. {
  1025. RState ret = _rfPowerRoutine.Monitor();
  1026. if (ret == RState.End)
  1027. return true;
  1028. else if (ret == RState.Failed || ret == RState.Timeout)
  1029. {
  1030. PostMsg(MSG.Error);
  1031. //do nothing
  1032. return true;
  1033. }
  1034. return false;
  1035. }
  1036. private bool FnAbortRfPower(object[] objs)
  1037. {
  1038. _rfPowerRoutine.Abort();
  1039. if (_gasFlowRoutine._gasStatus)
  1040. _gasFlowRoutine.Abort();
  1041. return true;
  1042. }
  1043. private bool FnHeat(object[] objs)
  1044. {
  1045. _tcStartTime = DateTime.Now;
  1046. RState ret = _temperatureControlRoutine.Start(objs);
  1047. if (ret == RState.End)
  1048. {
  1049. return false;
  1050. }
  1051. if (ret == RState.Failed || ret == RState.Timeout)
  1052. {
  1053. PostMsg(MSG.Error);
  1054. return false; //do noting
  1055. }
  1056. return true;
  1057. //return _temperatureControlRoutine.Start(objs) == RState.RUN;
  1058. }
  1059. private bool FnHeatTimeout(object[] param)
  1060. {
  1061. RState ret = _temperatureControlRoutine.Monitor();
  1062. if (ret == RState.End)
  1063. {
  1064. return true;
  1065. }
  1066. if (ret == RState.Failed || ret == RState.Timeout)
  1067. {
  1068. PostMsg(MSG.Error);
  1069. //do nothing
  1070. return true;
  1071. }
  1072. return false;
  1073. }
  1074. private bool FnAbortHeating(object[] param)
  1075. {
  1076. _temperatureControlRoutine.Abort();
  1077. return true;
  1078. }
  1079. #endregion Gas&RF
  1080. #region Subroutine
  1081. private bool FnStartLeakCheck(object[] param)
  1082. {
  1083. _leakCheckStartTime = DateTime.Now;
  1084. RState ret = _leakCheckRoutine.Start(param);
  1085. if (ret == RState.End)
  1086. {
  1087. return false;
  1088. }
  1089. if (ret == RState.Failed || ret == RState.Timeout)
  1090. {
  1091. PostMsg(MSG.Error);
  1092. return false; //do noting
  1093. }
  1094. return true;
  1095. //return _leakCheckRoutine.Start(param) == Result.RUN;
  1096. }
  1097. private bool FnLeakCheckTimeout(object[] param)
  1098. {
  1099. RState ret = _leakCheckRoutine.Monitor();
  1100. if (ret == RState.End)
  1101. {
  1102. return true;
  1103. }
  1104. if (ret == RState.Failed || ret == RState.Timeout)
  1105. {
  1106. PostMsg(MSG.Error);
  1107. //do nothing
  1108. return true;
  1109. }
  1110. return false;
  1111. //return res == Result.DONE || res == Result.FAIL;
  1112. }
  1113. private bool FnDeleteLeakCheck(object[] param)
  1114. {
  1115. _leakCheckRoutine.DeleteLeadCheck(param);
  1116. return true;
  1117. }
  1118. private bool FnAbortLeakCheck(object[] param)
  1119. {
  1120. _leakCheckRoutine.Abort();
  1121. return true;
  1122. }
  1123. private bool FnStartMFCVerification(object[] param)
  1124. {
  1125. _mfcVerification.Init((string)param[0], (float)param[1], (int)param[2]);
  1126. RState ret = _mfcVerification.Start(param);
  1127. if (ret == RState.End)
  1128. {
  1129. return false;
  1130. }
  1131. if (ret == RState.Failed || ret == RState.Timeout)
  1132. {
  1133. PostMsg(MSG.Error);
  1134. return false; //do noting
  1135. }
  1136. return true;
  1137. //return _mfcVerification.Start(param) == Result.RUN;
  1138. }
  1139. private bool FnMFCVerificationTimeout(object[] param)
  1140. {
  1141. RState ret = _mfcVerification.Monitor();
  1142. if (ret == RState.End)
  1143. {
  1144. return true;
  1145. }
  1146. if (ret == RState.Failed || ret == RState.Timeout)
  1147. {
  1148. PostMsg(MSG.Error);
  1149. //do nothing
  1150. return true;
  1151. }
  1152. return false;
  1153. //return res == Result.DONE || res == Result.FAIL;
  1154. }
  1155. private bool FnAbortMFCVerification(object[] param)
  1156. {
  1157. _mfcVerification.Abort();
  1158. return true;
  1159. }
  1160. private bool FnStartVent(object[] param)
  1161. {
  1162. RState ret = _ventRoutine.Start();
  1163. if (ret == RState.End)
  1164. {
  1165. return false;
  1166. }
  1167. else if (ret == RState.Failed)
  1168. {
  1169. PostMsg(MSG.Error);
  1170. return false; //do noting
  1171. }
  1172. return true;
  1173. }
  1174. private bool FnVentTimeout(object[] param)
  1175. {
  1176. RState ret = _ventRoutine.Monitor();
  1177. if (ret == RState.End)
  1178. {
  1179. return true;
  1180. }
  1181. if (ret == RState.Failed)
  1182. {
  1183. PostMsg(MSG.Error);
  1184. //do nothing
  1185. return true;
  1186. }
  1187. return false;
  1188. }
  1189. private bool FnVentToPumping(object[] param)
  1190. {
  1191. _ventRoutine.Abort();
  1192. return FnStartPumpDown(param);
  1193. }
  1194. private bool FnAbortVent(object[] param)
  1195. {
  1196. _ventRoutine.Abort();
  1197. return true;
  1198. }
  1199. private bool FnLaunchPump(object[] param)
  1200. {
  1201. _pumpStartTime = DateTime.Now;
  1202. RState ret = _startPumpRoutine.Start(param);
  1203. if (ret == RState.End)
  1204. {
  1205. return false;
  1206. }
  1207. if (ret == RState.Failed || ret == RState.Timeout)
  1208. {
  1209. PostMsg(MSG.Error);
  1210. return false; //do noting
  1211. }
  1212. return true;
  1213. //return _startPumpRoutine.Start() == Result.RUN;
  1214. }
  1215. private bool FnLaunchPumpTimeout(object[] param)
  1216. {
  1217. RState ret = _startPumpRoutine.Monitor();
  1218. if (ret == RState.End)
  1219. {
  1220. return true;
  1221. }
  1222. if (ret == RState.Failed || ret == RState.Timeout)
  1223. {
  1224. PostMsg(MSG.Error);
  1225. //do nothing
  1226. return true;
  1227. }
  1228. return false;
  1229. }
  1230. private bool FnAbortStartPumping(object[] param)
  1231. {
  1232. _startPumpRoutine.Abort();
  1233. return true;
  1234. }
  1235. private bool FnStartPumpDown(object[] param)
  1236. {
  1237. _pumpStartTime = DateTime.Now;
  1238. RState ret = _pumpRoutine.Start(param);
  1239. if (ret == RState.End)
  1240. {
  1241. return false;
  1242. }
  1243. if (ret == RState.Failed || ret == RState.Timeout)
  1244. {
  1245. PostMsg(MSG.Error);
  1246. return false; //do noting
  1247. }
  1248. return true;
  1249. //return _pumpRoutine.Start() == Result.RUN;
  1250. }
  1251. private bool FnPumpDownTimeout(object[] param)
  1252. {
  1253. RState ret = _pumpRoutine.Monitor();
  1254. if (ret == RState.End)
  1255. {
  1256. return true;
  1257. }
  1258. if (ret == RState.Failed || ret == RState.Timeout)
  1259. {
  1260. PostMsg(MSG.Error);
  1261. //do nothing
  1262. return true;
  1263. }
  1264. return false;
  1265. }
  1266. private bool FnPumpingToVent(object[] param)
  1267. {
  1268. _pumpRoutine.Abort();
  1269. return FnStartVent(param);
  1270. }
  1271. private bool FnAbortPumping(object[] param)
  1272. {
  1273. _pumpRoutine.Abort();
  1274. return true;
  1275. }
  1276. private bool FnStartPurge(object[] param)
  1277. {
  1278. RState ret = _cyclePurgeRoutine.Start(param);
  1279. if (ret == RState.End)
  1280. {
  1281. return false;
  1282. }
  1283. if (ret == RState.Failed || ret == RState.Timeout)
  1284. {
  1285. PostMsg(MSG.Error);
  1286. return false; //do noting
  1287. }
  1288. return true;
  1289. //return _cyclePurgeRoutine.Start(param) == Result.RUN;
  1290. }
  1291. private bool FnPurgeTimeout(object[] param)
  1292. {
  1293. RState ret = _cyclePurgeRoutine.Monitor();
  1294. if (ret == RState.End)
  1295. {
  1296. return true;
  1297. }
  1298. else if (ret == RState.Failed || ret == RState.Timeout)
  1299. {
  1300. PostMsg(MSG.Error);
  1301. return true;
  1302. }
  1303. return false;
  1304. }
  1305. private bool FnAbortPurge(object[] param)
  1306. {
  1307. _cyclePurgeRoutine.Abort();
  1308. return true;
  1309. }
  1310. #endregion Subroutine
  1311. #region Transfer
  1312. private bool FnStartPrepareTransfer(object[] param)
  1313. {
  1314. //if (param.Length > 2)
  1315. // _prepareTrans.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), (EnumDualPM)Enum.Parse(typeof(EnumDualPM), (string)param[1]), (float)param[2], (WaferSize)param[3]);
  1316. //else if (param.Length > 1)
  1317. // _prepareTrans.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), (EnumDualPM)Enum.Parse(typeof(EnumDualPM), (string)param[1]), (float)param[2]);
  1318. //else
  1319. int blade = -1;
  1320. int bladeIndex = 5;
  1321. if(param.Length > bladeIndex)
  1322. {
  1323. int.TryParse(param[bladeIndex].ToString(), out blade);
  1324. }
  1325. EnumDualPM pos = EnumDualPM.None;
  1326. int posIndex = 6;
  1327. if(param.Length > posIndex)
  1328. {
  1329. pos = (EnumDualPM)Enum.Parse(typeof(EnumDualPM), (string)param[posIndex]);
  1330. }
  1331. _prepareTrans.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), (int[])param[1], (double)param[2], (double)param[3], (bool)param[4], blade, pos);
  1332. RState ret = _prepareTrans.Start();
  1333. if (ret == RState.End)
  1334. {
  1335. return false;
  1336. }
  1337. if (ret == RState.Failed || ret == RState.Timeout)
  1338. {
  1339. PostMsg(MSG.Error);
  1340. return false; //do noting
  1341. }
  1342. return true;
  1343. //Result ret = _prepareTrans.Start();
  1344. //if (ret == Result.FAIL || ret == Result.DONE)
  1345. // return false;
  1346. //return ret == Result.RUN;
  1347. }
  1348. private bool FnPreTransferTimeout(object[] param)
  1349. {
  1350. RState ret = _prepareTrans.Monitor();
  1351. if (ret == RState.End)
  1352. {
  1353. return true;
  1354. }
  1355. if (ret == RState.Failed || ret == RState.Timeout)
  1356. {
  1357. PostMsg(MSG.Error);
  1358. //do nothing
  1359. return true;
  1360. }
  1361. return false;
  1362. }
  1363. private bool FnStartPostTransfer(object[] param)
  1364. {
  1365. _postTrans.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), (int[])param[1]);
  1366. RState ret = _postTrans.Start();
  1367. if (ret == RState.Failed)
  1368. {
  1369. PostMsg(MSG.Error);
  1370. return false;
  1371. }
  1372. return ret == RState.Running;
  1373. }
  1374. private bool FnPostTransferTimeout(object[] param)
  1375. {
  1376. RState ret = _postTrans.Monitor();
  1377. if (ret == RState.End)
  1378. {
  1379. return true;
  1380. }
  1381. if (ret == RState.Failed || ret == RState.Timeout)
  1382. {
  1383. PostMsg(MSG.Error);
  1384. //do nothing
  1385. return true;
  1386. }
  1387. return false;
  1388. }
  1389. private bool FnStartTransferHandoff(object[] param)
  1390. {
  1391. _transferHandoff.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]), (int[])param[1]);
  1392. RState ret = _transferHandoff.Start();
  1393. if (ret == RState.Failed)
  1394. {
  1395. PostMsg(MSG.Error);
  1396. return false;
  1397. }
  1398. return ret == RState.Running;
  1399. }
  1400. private bool FnTransferHandoffTimeout(object[] param)
  1401. {
  1402. RState ret = _transferHandoff.Monitor();
  1403. if (ret == RState.Failed)
  1404. {
  1405. PostMsg(MSG.Error);
  1406. return false;
  1407. }
  1408. return ret == RState.End;
  1409. }
  1410. private bool FnSetLiftPin1(object[] param)
  1411. {
  1412. MovementPosition pos = (MovementPosition)param[0];
  1413. _ActivatedActionID = (ushort)param[1];
  1414. if (pos == MovementPosition.Down) //增加Place & Pick的Delay功能
  1415. {
  1416. int LiftDelayTime = SC.GetValue<int>($"{Module}.PlaceAndPickDelayTime") * 1000;
  1417. System.Threading.Thread.Sleep(LiftDelayTime);
  1418. }
  1419. _chamber.SetLiftPin1(pos, out _);
  1420. EV.PostInfoLog(Module.ToString(), $"执行 lift pin {pos}");
  1421. _goalLiftPin = pos;
  1422. return true;
  1423. }
  1424. private bool FnSetLiftPin2(object[] param)
  1425. {
  1426. MovementPosition pos = (MovementPosition)param[0];
  1427. _ActivatedActionID = (ushort)param[1];
  1428. if (pos == MovementPosition.Down) //增加Place & Pick的Delay功能
  1429. {
  1430. int LiftDelayTime = SC.GetValue<int>($"{Module}.PlaceAndPickDelayTime") * 1000;
  1431. System.Threading.Thread.Sleep(LiftDelayTime);
  1432. }
  1433. _chamber.SetLiftPin2(pos, out _);
  1434. EV.PostInfoLog(Module.ToString(), $"执行 lift pin {pos}");
  1435. _goalLiftPin = pos;
  1436. return true;
  1437. }
  1438. private bool FnLiftpin1Timeout(object[] param)
  1439. {
  1440. if (_chamber.LiftPinPosition == _goalLiftPin)
  1441. {
  1442. EV.PostInfoLog(Module.ToString(), $"lift pin 当前位置 {_chamber.LiftPinPosition}");
  1443. //EquipmentManager.Modules[ModuleName.EFEM].PostMsg(
  1444. // _goalLiftPin == MovementPosition.Up ? EfemEntity.MSG.PMLiftPinUp : EfemEntity.MSG.PMLiftPinDown, _ActivatedActionID);
  1445. _goalLiftPin = MovementPosition.Unknown;
  1446. _ActivatedActionID = 0;
  1447. return true;
  1448. }
  1449. return false;
  1450. }
  1451. private bool FnLiftpin2Timeout(object[] param)
  1452. {
  1453. if (_chamber.LiftPinPosition == _goalLiftPin)
  1454. {
  1455. EV.PostInfoLog(Module.ToString(), $"lift pin 当前位置 {_chamber.LiftPinPosition}");
  1456. //EquipmentManager.Modules[ModuleName.EFEM].PostMsg(
  1457. // _goalLiftPin == MovementPosition.Up ? EfemEntity.MSG.PMLiftPinUp : EfemEntity.MSG.PMLiftPinDown, _ActivatedActionID);
  1458. _goalLiftPin = MovementPosition.Unknown;
  1459. _ActivatedActionID = 0;
  1460. return true;
  1461. }
  1462. return false;
  1463. }
  1464. private bool FnSetGuidePin(object[] param)
  1465. {
  1466. WaferSize ws = (WaferSize)param[0];
  1467. MovementPosition pos = (MovementPosition)param[1];
  1468. _chamber.SetGuidePin(ws, pos);
  1469. return true;
  1470. }
  1471. private bool FnGuidePin1Timeout(object[] param)
  1472. {
  1473. return true;
  1474. }
  1475. private bool FnGuidePin2Timeout(object[] param)
  1476. {
  1477. return true;
  1478. }
  1479. private bool FnPreClean(object[] param)
  1480. {
  1481. _cleanRoutine.param = param;
  1482. _chamber.SetSlitDoor1(false, out _);
  1483. _chamber.SetSlitDoor2(false, out _);
  1484. return true;
  1485. }
  1486. private bool FnPreCleanTimeout(object[] param)
  1487. {
  1488. if (_chamber.IsSlitDoor1Closed && _chamber.IsSlitDoor2Closed)
  1489. {
  1490. if (!FnProcessLoadRecipe(_cleanRoutine.param))
  1491. {
  1492. EV.PostAlarmLog(_chamber.Module.ToString(), "Clean recipe read failed");
  1493. PostMsg(FSM_MSG.ALARM);
  1494. return false;
  1495. }
  1496. return true;
  1497. }
  1498. return false;
  1499. }
  1500. #endregion Transfer
  1501. #region Process
  1502. private bool FnStartATMProcess(object[] param)
  1503. {
  1504. RState ret = _ATMProcessRoutine.Start(param);
  1505. if (ret == RState.End)
  1506. {
  1507. return false;
  1508. }
  1509. if (ret == RState.Failed)
  1510. {
  1511. PostMsg(MSG.Error);
  1512. return false; //do noting
  1513. }
  1514. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1515. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.InProcess);
  1516. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1517. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.InProcess);
  1518. return true;
  1519. }
  1520. private bool FnATMProcessTimeout(object[] param)
  1521. {
  1522. RState ret = _ATMProcessRoutine.Monitor();
  1523. if (ret == RState.End)
  1524. {
  1525. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1526. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Completed);
  1527. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1528. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Completed);
  1529. return true;
  1530. }
  1531. if (ret == RState.Failed)
  1532. {
  1533. PostMsg(MSG.Error);
  1534. return true;
  1535. }
  1536. return false;
  1537. }
  1538. private bool FnAbortATMProcess(object[] param)
  1539. {
  1540. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1541. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Failed);
  1542. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1543. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Failed);
  1544. _ATMProcessRoutine.Abort();
  1545. return true;
  1546. }
  1547. private bool FnProcessLoadRecipe(object[] param)
  1548. {
  1549. _processStatus = "Succeed to load recipe";
  1550. _recipeStartTime = DateTime.Now;
  1551. RState ret = _preProcessRoutine.LoadRecipe(param);
  1552. if (ret == RState.End)
  1553. {
  1554. PostMsg(MSG.PreProcess);
  1555. }
  1556. else if (ret == RState.Failed)
  1557. {
  1558. _processStatus = "Failed to load recipe";
  1559. return false;
  1560. }
  1561. return true;
  1562. }
  1563. private bool FnStartPreProcess(object[] param)
  1564. {
  1565. _pumpStartTime = DateTime.Now;
  1566. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipe;
  1567. RState ret = _preProcessRoutine.Start(param);
  1568. if (ret == RState.End)
  1569. {
  1570. return false;
  1571. }
  1572. if (ret == RState.Failed)
  1573. {
  1574. //_processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipeFailed;
  1575. PostMsg(MSG.Error);
  1576. return false; //do noting
  1577. }
  1578. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1579. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.InProcess);
  1580. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1581. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.InProcess);
  1582. return true;
  1583. }
  1584. private bool FnPreProcessTimeout(object[] param)
  1585. {
  1586. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDown;
  1587. RState ret = _preProcessRoutine.Monitor();
  1588. if (ret == RState.End)
  1589. {
  1590. PostMsg(MSG.Process,
  1591. _preProcessRoutine.CurrentRecipeBaseName,
  1592. _preProcessRoutine.CurrentRecipeRunningName,
  1593. 0,
  1594. _preProcessRoutine.CurrentLotName,
  1595. _preProcessRoutine.CurrentRecipeContent,
  1596. _preProcessRoutine.CurrentRecipeHead,
  1597. _preProcessRoutine.CurrentRecipeStepList);
  1598. return true;
  1599. }
  1600. if (ret == RState.Failed)
  1601. {
  1602. //_processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDownFailed;
  1603. PostMsg(MSG.Error);
  1604. return true;
  1605. }
  1606. return false; ;
  1607. }
  1608. private bool FnAbortPreProcess(object[] param)
  1609. {
  1610. //_processStatus = Resources.PMEntity_fAbortPreProcess_RunRecipePumpingDownAborted;
  1611. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1612. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Failed);
  1613. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1614. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Failed);
  1615. _preProcessRoutine.Abort();
  1616. return true;
  1617. }
  1618. private bool FnStartProcess(object[] param)
  1619. {
  1620. //_processStatus = Resources.PMEntity_fStartProcess_StartRunningRecipe;
  1621. RState ret = _processRoutine.Start(param);
  1622. if (ret == RState.End)
  1623. {
  1624. return true;
  1625. }
  1626. else if (ret == RState.Failed)
  1627. {
  1628. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1629. PostMsg(MSG.Error);
  1630. return true; //do noting
  1631. }
  1632. return true;
  1633. }
  1634. private bool FnProcessTimeout(object[] param)
  1635. {
  1636. //_processStatus = Resources.PMEntity_fProcess_RunningRecipe;
  1637. RState ret = _processRoutine.Monitor();
  1638. {
  1639. if (ret == RState.End)
  1640. {
  1641. PostMsg(MSG.PostProcess, _processRoutine.CurrentRecipeRunningName, _processRoutine.CurrentRecipeContent);
  1642. return true;
  1643. }
  1644. else if (ret == RState.Failed)
  1645. {
  1646. //_processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
  1647. PostMsg(MSG.Error);
  1648. return true;
  1649. }
  1650. return false;
  1651. }
  1652. }
  1653. private bool FnAbortProcess(object[] param)
  1654. {
  1655. //_processStatus = Resources.PMEntity_fAbortProcess_RunningRecipeAborted;
  1656. _processRoutine.AbortRecipe();
  1657. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1658. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Failed);
  1659. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1660. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Failed);
  1661. _processRoutine.Abort();
  1662. RState ret = _postProcessRoutine.Start(new object[] { _processRoutine.CurrentRecipeRunningName, _processRoutine.CurrentRecipeContent });
  1663. if (ret == RState.End)
  1664. {
  1665. return false;
  1666. }
  1667. else if (ret == RState.Failed)
  1668. {
  1669. PostMsg(MSG.Error);
  1670. //_processStatus = Resources.PMEntity_fAbortProcess_RunRecipeAborted;
  1671. return false; //do noting
  1672. }
  1673. return true;
  1674. }
  1675. private bool FnPauseProcess(object[] param)
  1676. {
  1677. return true;
  1678. }
  1679. private bool FnResumeRecipe(object[] param)
  1680. {
  1681. return true;
  1682. }
  1683. private bool FnUpdateRecipe(object[] param)
  1684. {
  1685. return true;
  1686. }
  1687. private bool FnSkipStep(object[] param)
  1688. {
  1689. _processRoutine.SkipCurrentRecipeStep();
  1690. return true;
  1691. }
  1692. private bool FnExitProcess(object[] param)
  1693. {
  1694. _processRoutine.Exit();
  1695. return true;
  1696. }
  1697. private bool FnEnterProcess(object[] param)
  1698. {
  1699. return true;
  1700. }
  1701. private bool FnStartPostProcess(object[] param)
  1702. {
  1703. //_processStatus = Resources.PMEntity_fStartPostProcess_RunRecipePostProcess;
  1704. RState ret = _postProcessRoutine.Start(param);
  1705. if (ret == RState.End)
  1706. {
  1707. return false;
  1708. }
  1709. else if (ret == RState.Failed)
  1710. {
  1711. PostMsg(MSG.Error);
  1712. return false;
  1713. }
  1714. return true;
  1715. }
  1716. private bool FnPostProcessTimeout(object[] param)
  1717. {
  1718. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurge;
  1719. RState ret = _postProcessRoutine.Monitor();
  1720. if (ret == RState.End)
  1721. {
  1722. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty &&
  1723. WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).ProcessState != EnumWaferProcessStatus.Failed)
  1724. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Completed);
  1725. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty &&
  1726. WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).ProcessState != EnumWaferProcessStatus.Failed)
  1727. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Completed);
  1728. //_processStatus = Resources.PMEntity_fPostProcess_RecipeCompleted;
  1729. return true;
  1730. }
  1731. else if (ret == RState.Failed)
  1732. {
  1733. //_processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurgeError;
  1734. PostMsg(MSG.Error);
  1735. return true;
  1736. }
  1737. return false;
  1738. }
  1739. private bool FnAbortPostProcess(object[] param)
  1740. {
  1741. //_processStatus = Resources.PMEntity_fAbortPostProcess_RecipeAborted;
  1742. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1743. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Failed);
  1744. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1745. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Failed);
  1746. _postProcessRoutine.Abort();
  1747. return true;
  1748. }
  1749. private bool fExitPostProcess(object[] objs)
  1750. {
  1751. _postProcessRoutine.Exit();
  1752. //EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1753. //{
  1754. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1755. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1756. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1757. //});
  1758. return true;
  1759. }
  1760. #endregion PROCESS
  1761. private bool FnReset(object[] param)
  1762. {
  1763. _isAlarm = false;
  1764. if ((STATE)FsmState == STATE.Error)
  1765. return true;
  1766. return false;
  1767. }
  1768. public bool Check(int msg, out string reason, object[] objs)
  1769. {
  1770. reason = "";
  1771. return true;
  1772. }
  1773. public bool IsProcessed()
  1774. {
  1775. return IsIdle;
  1776. }
  1777. public override bool IsPrepareTransferReady(EnumTransferType type, EnumDualPM pos, WaferSize waferSize)
  1778. {
  1779. return _chamber.CheckEnableTransfer(type, pos, waferSize);
  1780. }
  1781. public void Home()
  1782. {
  1783. CheckToPostMessage((int)MSG.Home);
  1784. }
  1785. private bool FnExitHome(object[] param)
  1786. {
  1787. return true;
  1788. }
  1789. private bool FnEnterHome(object[] param)
  1790. {
  1791. return true;
  1792. }
  1793. private bool FnStartHome(object[] objs)
  1794. {
  1795. RState ret = _home.Start();
  1796. if (ret == RState.Failed || ret == RState.End)
  1797. return false;
  1798. return ret == RState.Running;
  1799. }
  1800. private bool FnMonitorHome(object[] objs)
  1801. {
  1802. RState ret = _home.Monitor();
  1803. if (ret == RState.Failed || ret == RState.Timeout)
  1804. {
  1805. PostMsg(MSG.Error);
  1806. return false;
  1807. }
  1808. return ret == RState.End;
  1809. }
  1810. private bool fExitTransfer(object[] objs)
  1811. {
  1812. return true;
  1813. }
  1814. private bool fEnterError(object[] objs)
  1815. {
  1816. //if (IsProcessMode)
  1817. //{
  1818. // EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
  1819. // {
  1820. // {DVIDName.LotId, preProcessRoutine.CurrentLotName},
  1821. // {DVIDName.JobId, preProcessRoutine.CurrentJobName},
  1822. // {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
  1823. // });
  1824. //}
  1825. _chamber.Generator1PowerOn(false);
  1826. _chamber.GeneratorBias1PowerOn(false);
  1827. _chamber.Generator2PowerOn(false);
  1828. _chamber.GeneratorBias2PowerOn(false);
  1829. _chamber.StopAllGases();
  1830. return true;
  1831. }
  1832. private bool FnError(object[] objs)
  1833. {
  1834. if (((STATE)FsmState == STATE.Processing) || ((STATE)FsmState == STATE.PreProcess)
  1835. || ((STATE)FsmState == STATE.Homing) || ((STATE)FsmState == STATE.LoadProcessRecipe))
  1836. return false;
  1837. if (IsProcessing)
  1838. {
  1839. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1840. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Failed);
  1841. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1842. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Failed);
  1843. }
  1844. return true;
  1845. }
  1846. private bool fWarning(object[] objs)
  1847. {
  1848. //IsWarning = false;
  1849. return true;
  1850. }
  1851. private bool fAlarm(object[] objs)
  1852. {
  1853. _isAlarm = true;
  1854. if (FsmState == (int)STATE.Init)
  1855. return false;
  1856. if (FsmState == (int)STATE.GasFlowing)
  1857. {
  1858. FnAbortGasFlow(null);
  1859. }
  1860. if (FsmState == (int)STATE.RfPowering)
  1861. {
  1862. FnAbortRfPower(null);
  1863. }
  1864. if (IsProcessing || FsmState == (int)STATE.ATMProcessing)
  1865. {
  1866. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 0).IsEmpty)
  1867. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.Failed);
  1868. if (!WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), 1).IsEmpty)
  1869. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 1, EnumWaferProcessStatus.Failed);
  1870. }
  1871. return true;
  1872. }
  1873. private bool FnIdle(object[] objs)
  1874. {
  1875. return true;
  1876. }
  1877. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  1878. {
  1879. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString()))
  1880. return (int)MSG.PrepareTransfer;
  1881. return (int)FSM_MSG.NONE;
  1882. }
  1883. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp)
  1884. {
  1885. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp))
  1886. return (int)MSG.PrepareTransfer;
  1887. return (int)FSM_MSG.NONE;
  1888. }
  1889. public int InvokePrepareTransfer(ModuleName robot, EnumTransferType type, int slot, float temp, WaferSize size)
  1890. {
  1891. if (CheckToPostMessage((int)MSG.PrepareTransfer, type.ToString(), temp, size))
  1892. return (int)MSG.PrepareTransfer;
  1893. return (int)FSM_MSG.NONE;
  1894. }
  1895. public int InvokePostTransfer(ModuleName robot, EnumTransferType type, int slot)
  1896. {
  1897. if (CheckToPostMessage((int)MSG.PostTransfer, type.ToString()))
  1898. return (int)MSG.PostTransfer;
  1899. return (int)FSM_MSG.NONE;
  1900. }
  1901. public int InvokeClean(string recipeName, string waferID, bool withWafer)
  1902. {
  1903. if (CheckToPostMessage((int)MSG.Clean, recipeName, waferID, withWafer))
  1904. {
  1905. return (int)MSG.Clean;
  1906. }
  1907. return (int)FSM_MSG.NONE;
  1908. }
  1909. public int InvokeProcess(string recipeName, string waferID, bool withWafer)
  1910. {
  1911. if (CheckToPostMessage((int)MSG.RunRecipe, recipeName, waferID, withWafer))
  1912. return (int)MSG.RunRecipe;
  1913. return (int)FSM_MSG.NONE;
  1914. }
  1915. public override bool InvokePreHeat(double temperature1, double temperature2)
  1916. {
  1917. if (CheckToPostMessage((int)MSG.Heat, (double)temperature1, (double)temperature2))
  1918. return true;
  1919. return false;
  1920. }
  1921. public void InvokeReset()
  1922. {
  1923. PostMsg((int)MSG.Reset);
  1924. }
  1925. public void SetAuto()
  1926. {
  1927. this._AutoMode = AutoFlag.Auto;
  1928. }
  1929. #region EndPoint
  1930. public bool CheckEndPoint()
  1931. {
  1932. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1933. if (epd == null)
  1934. return false;
  1935. return epd.IsEnd;
  1936. }
  1937. public void StartEndPoint(string config, int index)
  1938. {
  1939. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1940. if (epd == null)
  1941. return;
  1942. epd.StepStart(config, index);
  1943. }
  1944. public void StopEndPoint()
  1945. {
  1946. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1947. if (epd == null)
  1948. return;
  1949. epd.StepStop();
  1950. }
  1951. public void EndPointRecipeStop()
  1952. {
  1953. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1954. if (epd == null)
  1955. return;
  1956. epd.RecipeStop();
  1957. }
  1958. public void EndPointRecipeStart(string recipeName)
  1959. {
  1960. EPDDevice epd = DEVICE.GetDevice<EPDDevice>($"{Module}.EPD");
  1961. if (epd == null)
  1962. return;
  1963. epd.RecipeStart(recipeName);
  1964. }
  1965. #endregion
  1966. #endregion
  1967. }
  1968. }