PMModule.cs 88 KB

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