Process.cs 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.OperationCenter;
  5. using Aitex.Core.RT.Routine;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using MECF.Framework.Common.DBCore;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.Alarms;
  11. using MECF.Framework.Common.Event;
  12. using MECF.Framework.Common.SubstrateTrackings;
  13. using System;
  14. using System.Collections.Generic;
  15. using FurnaceRT.Equipments.PMs.Routines;
  16. using System.Diagnostics;
  17. using MECF.Framework.Common.DataCenter;
  18. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  19. using FurnaceRT.Equipments.Systems;
  20. using MECF.Framework.Common.CommonData.EnumData;
  21. using MECF.Framework.Common.FAServices;
  22. using System.Threading.Tasks;
  23. using DocumentFormat.OpenXml.Drawing.Charts;
  24. using MECF.Framework.Common.Device;
  25. using Aitex.Core.Common.DeviceData;
  26. using Aitex.Sorter.Common;
  27. using MECF.Framework.FA.Core.FAControl;
  28. namespace FurnaceRT.Equipments.PMs.RecipeExecutions
  29. {
  30. public enum RecipeContinueMode
  31. {
  32. None,
  33. WaferReturnAndJobStop,
  34. RecipeCompleted,
  35. StepContinue,
  36. StepRestart,
  37. RecipeRestart,
  38. NextStep,
  39. }
  40. public class Process : PMBaseRoutine
  41. {
  42. enum RecipeRunningState
  43. {
  44. Error,
  45. RecipeCompleted,
  46. ExecStep,
  47. TimeWait,
  48. ConditionWait,
  49. StepCompleted,
  50. Paused,
  51. }
  52. enum RecipeAlaramAction
  53. {
  54. None,
  55. JumpAbortRecipe,
  56. JumpStep,
  57. JumpStepCancelCallLoop,
  58. Abort,
  59. Hold,
  60. IgnoreAlaram,
  61. }
  62. private object _recipeLocker = new object();
  63. private RecipeRunningState _state = RecipeRunningState.ExecStep;
  64. private RecipeRunningState _pausedState = RecipeRunningState.ExecStep;
  65. private double _curStepElpasedTimeBeforePaused;
  66. private double _holdTimeElpasedTime;
  67. private bool _hasItBeenTriggeredRecipeComplete;
  68. private double _waferTimeElpasedTimeBeforPaused;
  69. //Add by SSH,20250930,判断recipe是否执行结束,给job使用
  70. public bool IsRecipeCompleted { get { return _state == RecipeRunningState.RecipeCompleted || _state == RecipeRunningState.Error; } }
  71. private double _totalElpasedTime;
  72. public RecipeContinueMode ContinueAction { get; set; }
  73. public DateTime _recipeStartTime
  74. {
  75. get;
  76. private set;
  77. }
  78. public string CurrentRecipeContent { get; private set; }
  79. public int _currentStepNumber;
  80. private int _currentSubRecipeStepNumber;
  81. private bool _loopEnd;
  82. public int CurStepTotalLoopCount
  83. {
  84. get;
  85. private set;
  86. }
  87. public int CurSubRecipeStepTotalLoopCount
  88. {
  89. get;
  90. private set;
  91. }
  92. public double CurStepTotalTime
  93. {
  94. get
  95. {
  96. if (PMModule.RecipeRunningInfo.RecipeStepList == null || PMModule.RecipeRunningInfo.RecipeStepList.Count == 0 || _state == RecipeRunningState.RecipeCompleted || _state == RecipeRunningState.Error)
  97. return 0;
  98. return PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime * 1000;
  99. }
  100. }
  101. public string FDCRecipeStep { get; set; }
  102. public int CurrentLoopCount
  103. {
  104. get;
  105. private set;
  106. }
  107. public int CurrentAbortRecipeLoopCount
  108. {
  109. get;
  110. private set;
  111. }
  112. public int CurrentSubRecipeLoopCount
  113. {
  114. get;
  115. private set;
  116. }
  117. public bool IsExecuteAbort
  118. {
  119. get;
  120. private set;
  121. }
  122. public bool IsSubReciep
  123. {
  124. get;
  125. private set;
  126. }
  127. public int AlarmConditionJumpStep { get; set; } = -1;
  128. private DeviceTimer _stepTimer = new DeviceTimer();
  129. private DeviceTimer _holdTimer = new DeviceTimer();
  130. private RecipeFACallback _faCallback;
  131. private RecipeDBCallback _dbCallback;
  132. private Fdc _fdc;
  133. private ModuleName _doModule = ModuleName.PM1;
  134. private bool IsJumpStepCancelCallLoop;
  135. private int _jumpStepNumber;
  136. private int _showStepNo;
  137. private int _subRecipeStartStepNumber;
  138. private RecipeAlaramAction _alarmAction = RecipeAlaramAction.None;
  139. public List<string> _alarmNames
  140. {
  141. private set;
  142. get;
  143. }
  144. private R_TRIG _trigHeaterBottomToleranceAlarm = new R_TRIG();
  145. private R_TRIG _trigHeaterBottomToleranceWarning = new R_TRIG();
  146. private R_TRIG _trigHeaterCenterBottomToleranceAlarm = new R_TRIG();
  147. private R_TRIG _trigHeaterCenterBottomToleranceWarning = new R_TRIG();
  148. private R_TRIG _trigHeaterCenterToleranceAlarm = new R_TRIG();
  149. private R_TRIG _trigHeaterCenterToleranceWarning = new R_TRIG();
  150. private R_TRIG _trigHeaterCenterTopToleranceAlarm = new R_TRIG();
  151. private R_TRIG _trigHeaterCenterTopToleranceWarning = new R_TRIG();
  152. private R_TRIG _trigHeaterTopToleranceAlarm = new R_TRIG();
  153. private R_TRIG _trigHeaterTopToleranceWarning = new R_TRIG();
  154. private R_TRIG _trigPressureToleranceAlarm = new R_TRIG();
  155. private R_TRIG _trigPressureToleranceWarning = new R_TRIG();
  156. private R_TRIG _trigInputSignalTimeOutAlarm = new R_TRIG();
  157. private R_TRIG _trigTemperatureConvergenceTimeOutAlarm = new R_TRIG();
  158. private R_TRIG _trigReachTempTimeOutAlarm = new R_TRIG();
  159. private R_TRIG _trigPressureConvergenceTimeOutAlarm = new R_TRIG();
  160. private R_TRIG _trigReachPressureTimeOutAlarm = new R_TRIG();
  161. private R_TRIG _trigAutoProfileTimeOutAlarm = new R_TRIG();
  162. private Dictionary<string, R_TRIG> _trigMfcToleranceAlarms;
  163. private Dictionary<string, R_TRIG> _trigMfcToleranceWarnings;
  164. private R_TRIG _trigBoatMoveToLoadPositionTimeout = new R_TRIG();
  165. private R_TRIG _trigHeaterProfileFinish = new R_TRIG();
  166. private R_TRIG _trigLeakCheckFinish = new R_TRIG();
  167. private R_TRIG _trigBoatWaitCondition = new R_TRIG();
  168. private R_TRIG _trigAPCWaitCondition = new R_TRIG();
  169. private R_TRIG _trigAUXWaitCondition = new R_TRIG();
  170. private R_TRIG _trigHeaterWaitCondition = new R_TRIG();
  171. private R_TRIG _trigMFCWaitCondition = new R_TRIG();
  172. private string _infoHeaterProfileFinish = "";
  173. private string _infoAUXWaitCondition = "";
  174. private string _infoHeaterWaitCondition = "";
  175. private string _infoMFCWaitCondition = "";
  176. private Dictionary<int, Tuple<bool, int>> _callSubSteps = new Dictionary<int, Tuple<bool, int>>();
  177. private bool _isJumpStep = false;
  178. private double _remainTimeExcludeEnd = 0;
  179. public Process(ModuleName module, PMModule pm) : base(module, pm)
  180. {
  181. Module = module.ToString();
  182. Name = "Process";
  183. _trigMfcToleranceAlarms = new Dictionary<string, R_TRIG>()
  184. {
  185. {"MFC61", new R_TRIG() },
  186. {"MFC13", new R_TRIG() },
  187. {"MFC14", new R_TRIG() },
  188. {"MFC15", new R_TRIG() },
  189. {"MFC16", new R_TRIG() },
  190. {"MFC24", new R_TRIG() },
  191. {"MFC25", new R_TRIG() },
  192. {"MFC26", new R_TRIG() },
  193. {"MFC34", new R_TRIG() },
  194. {"MFC35", new R_TRIG() },
  195. {"MFC36", new R_TRIG() },
  196. {"MFC90", new R_TRIG() },
  197. {"MFC91", new R_TRIG() },
  198. {"MFC84", new R_TRIG() },
  199. };
  200. _trigMfcToleranceWarnings = new Dictionary<string, R_TRIG>()
  201. {
  202. {"MFC61", new R_TRIG() },
  203. {"MFC13", new R_TRIG() },
  204. {"MFC14", new R_TRIG() },
  205. {"MFC15", new R_TRIG() },
  206. {"MFC16", new R_TRIG() },
  207. {"MFC24", new R_TRIG() },
  208. {"MFC25", new R_TRIG() },
  209. {"MFC26", new R_TRIG() },
  210. {"MFC34", new R_TRIG() },
  211. {"MFC35", new R_TRIG() },
  212. {"MFC36", new R_TRIG() },
  213. {"MFC90", new R_TRIG() },
  214. {"MFC91", new R_TRIG() },
  215. {"MFC84", new R_TRIG() },
  216. };
  217. _faCallback = new RecipeFACallback();
  218. _dbCallback = new RecipeDBCallback();
  219. _fdc = new Fdc(Module);
  220. }
  221. public override Result Start(params object[] param)
  222. {
  223. CurStepTotalLoopCount = 0;
  224. _currentSubRecipeStepNumber = CurSubRecipeStepTotalLoopCount = 0;
  225. if (AlarmConditionJumpStep > 0)
  226. _currentStepNumber = AlarmConditionJumpStep;
  227. else
  228. _currentStepNumber = PMModule.IsJobProcess ? 1 : 0; // 如果是从Job Process开始,从1开始,跳过standby step
  229. AlarmConditionJumpStep = -1;
  230. PMModule.RecipeRunningInfo.InnerId = Guid.NewGuid();
  231. PMModule.RecipeRunningInfo.BeginTime = DateTime.Now;
  232. PMModule.RecipeRunningInfo.TotalTime = CalcRecipeTime();
  233. if (PMModule.RecipeRunningInfo.TotalTime < 0)
  234. return Result.FAIL;
  235. PMModule.RecipeRunningInfo.RemainTimeExcludeEndStep = _remainTimeExcludeEnd;
  236. IsSubReciep = false;
  237. IsExecuteAbort = false;
  238. IsJumpStepCancelCallLoop = false;
  239. PMModule.IsPaused = false;
  240. PMModule.IsHeaterProfile = false;
  241. PMModule.IsHeaterProfileSuccess = false;
  242. PMModule.IsMainRecipeComplete = false;
  243. _loopEnd = false;
  244. _isJumpStep = false;
  245. _curStepElpasedTimeBeforePaused = 0;
  246. _waferTimeElpasedTimeBeforPaused = 0;
  247. _totalElpasedTime = 0;
  248. _holdTimeElpasedTime = 0;
  249. _jumpStepNumber = 0;
  250. _showStepNo = 0;
  251. _state = RecipeRunningState.ExecStep;
  252. _alarmAction = RecipeAlaramAction.None;
  253. _alarmNames = new List<string>();
  254. _subRecipeStartStepNumber = 1;
  255. _callSubSteps.Clear();
  256. PMModule.InitAlarmCondition(PMModule.RecipeRunningInfo.Head.AlarmCondition);
  257. PMModule.InitLeakCheck(PMModule.RecipeRunningInfo.Head.LeakCheck);
  258. PMModule.InitN2PurgeMode(PMModule.RecipeRunningInfo.Head.N2PurgeModeStr);
  259. ResetTrig();
  260. Notify($"Start");
  261. _faCallback.RecipeStart(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  262. _dbCallback.RecipeStart(PMModule.Module, 0, PMModule.RecipeRunningInfo.InnerId.ToString(), PMModule.RecipeRunningInfo.RecipeName, GetDBRecipeType(PMModule.RecipeRunningInfo.ExecRecipeType), (int)PMModule.RecipeExecEntryEnumValue);
  263. _dbCallback.RecipeUpdateStatus(PMModule.RecipeRunningInfo.InnerId.ToString(), "InProcess");
  264. _fdc.Reset();
  265. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.InProcess);
  266. PMModule.ResetFDCRecipeStepName();
  267. PMModule.HeaterEnable(true);
  268. #region 把pj_id更新到process表
  269. //从原来退出process挪到此处写入,是为了避免多个job手动abort掉当前job,而recipe继续执行导致的pj_id更新错误
  270. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  271. UpdateProcessDataPJid(firstPjId);
  272. #endregion
  273. PMModule.RecipeExecEntryEnumValue = RecipeExecEntryEnum.None;
  274. return Result.RUN;
  275. }
  276. public override Result Monitor()
  277. {
  278. if (!PMModule.CheckEnableRunProcess(out string reason))
  279. {
  280. PMModule.CheckEnableRunProcessAlarm.Set(reason);
  281. return Result.FAIL;
  282. }
  283. //MonitorRecipeAlaramAction();
  284. //if (IsExecuteAbort)
  285. // return Result.DONE;
  286. MonitorRecipePause();
  287. CheckTolerance();
  288. List<RecipeStep> curSteps;
  289. if ((IsSubReciep || PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].IsCallSubStep) && !_isJumpStep)
  290. {
  291. curSteps = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps;
  292. if (!_callSubSteps.ContainsKey(_currentStepNumber))
  293. _callSubSteps.Add(_currentStepNumber, Tuple.Create(false, 0));
  294. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].IsCallSubStep)
  295. _callSubSteps[_currentStepNumber] = Tuple.Create(true, PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount);
  296. if (!IsSubReciep)
  297. {
  298. PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount = 1;
  299. PMModule.RecipeRunningInfo.SubRecipeLoopCount = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount;
  300. PMModule.RecipeRunningInfo.SubRecipeTable = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeTableInfo;
  301. _faCallback.RecipeTriggerCallSubRecipe(Module, PMModule.RecipeRunningInfo.RecipeName, PMModule.RecipeRunningInfo.StepNumber.ToString(), PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeTableInfo);
  302. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName == "End" && PMModule.RecipeRunningInfo.RecipeStepList.Count - 1 == _currentStepNumber)
  303. {
  304. _faCallback.RecipeComplete(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  305. _hasItBeenTriggeredRecipeComplete = true;
  306. }
  307. }
  308. PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].IsCallSubStep = false;
  309. IsSubReciep = true;
  310. }
  311. else
  312. {
  313. PMModule.RecipeRunningInfo.SubRecipeTable = string.Empty;
  314. curSteps = PMModule.RecipeRunningInfo.RecipeStepList;
  315. PMModule.RecipeRunningInfo.SubRecipeLoopCount = 0;
  316. }
  317. lock (_recipeLocker)
  318. {
  319. try
  320. {
  321. switch (_state)
  322. {
  323. case RecipeRunningState.ExecStep:
  324. {
  325. PMModule.IsWait = false;
  326. _loopEnd = false;
  327. if (!_holdTimer.IsIdle())
  328. {
  329. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  330. _holdTimer.Stop();
  331. }
  332. PMModule.ResetToleranceChecker();
  333. _curStepElpasedTimeBeforePaused = 0;
  334. ContinueAction = RecipeContinueMode.None;
  335. if (IsSubReciep)
  336. {
  337. if (curSteps[_currentSubRecipeStepNumber].IsLoopStartStep)
  338. {
  339. CurrentSubRecipeLoopCount++;
  340. PMModule.RecipeRunningInfo.IsLooping = true;
  341. PMModule.RecipeRunningInfo.LoopCountCurrent = CurrentSubRecipeLoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  342. PMModule.RecipeRunningInfo.LoopCountSet = curSteps[_currentSubRecipeStepNumber].LoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  343. }
  344. if (curSteps[_currentSubRecipeStepNumber].IsJumpStep)
  345. {
  346. _faCallback.RecipeTriggerJumpStep(Module, PMModule.RecipeRunningInfo.RecipeName, _currentStepNumber.ToString(), curSteps[_currentStepNumber].JumpStepNo.ToString());
  347. _currentSubRecipeStepNumber = curSteps[_currentSubRecipeStepNumber].JumpStepNo;
  348. }
  349. PMModule.SetFDCRecipeStepName(IsSubReciep, curSteps[_currentSubRecipeStepNumber].StepName, (_currentSubRecipeStepNumber + 1).ToString());
  350. RecipeExec("Sub recipe", curSteps, _currentSubRecipeStepNumber, _curStepElpasedTimeBeforePaused, _currentSubRecipeStepNumber + 1);
  351. }
  352. else
  353. {
  354. if (curSteps[_currentStepNumber].IsLoopStartStep)
  355. {
  356. CurrentLoopCount++;
  357. PMModule.RecipeRunningInfo.IsLooping = true;
  358. PMModule.RecipeRunningInfo.LoopCountCurrent = CurrentLoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  359. PMModule.RecipeRunningInfo.LoopCountSet = curSteps[_currentStepNumber].LoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  360. }
  361. if (curSteps[_currentStepNumber].IsJumpStep)
  362. {
  363. _faCallback.RecipeTriggerJumpStep(Module, PMModule.RecipeRunningInfo.RecipeName, _currentStepNumber.ToString(), curSteps[_currentStepNumber].JumpStepNo.ToString());
  364. curSteps[_currentStepNumber].IsJumpStep = false;//只执行一次
  365. _currentStepNumber = curSteps[_currentStepNumber].JumpStepNo;
  366. }
  367. PMModule.SetFDCRecipeStepName(IsSubReciep, curSteps[_currentStepNumber].StepName, _currentStepNumber.ToString());
  368. RecipeExec("Main recipe", curSteps, _currentStepNumber, _curStepElpasedTimeBeforePaused);
  369. }
  370. }
  371. break;
  372. case RecipeRunningState.TimeWait:
  373. //if (PMModule.IsPaused)
  374. //{
  375. // _state = RecipeRunningState.Paused;
  376. // break;
  377. //}
  378. var leakCheck = PMModule.CheckLeakCheckFinish();
  379. _trigLeakCheckFinish.CLK = !leakCheck;
  380. if (_trigLeakCheckFinish.Q)
  381. LOG.Write($"Wait condition:leak check");
  382. if (_stepTimer.IsTimeout())
  383. {
  384. var heaterProfile = PMModule.CheckHeaterProfileFinish(out reason);
  385. _trigHeaterProfileFinish.CLK = !heaterProfile || _infoHeaterProfileFinish != reason;
  386. if (_trigHeaterProfileFinish.Q)
  387. LOG.Write($"Wait condition:heater profile--{reason}");
  388. _infoHeaterProfileFinish = reason;
  389. var boatWaitCondition = PMModule.CheckBoatWaitCondition(out reason);
  390. _trigBoatWaitCondition.CLK = !boatWaitCondition;
  391. if (_trigBoatWaitCondition.Q)
  392. LOG.Write($"Wait condition:boat--{reason}");
  393. var apcWaitCondition = PMModule.CheckAPCWaitCondition(out reason);
  394. _trigAPCWaitCondition.CLK = !apcWaitCondition;
  395. if (_trigAPCWaitCondition.Q)
  396. LOG.Write($"Wait condition:APC--{reason}");
  397. var auxWaitCondition = PMModule.CheckAUXWaitCondition(out reason);
  398. _trigAUXWaitCondition.CLK = !auxWaitCondition || _infoAUXWaitCondition != reason;
  399. if (_trigAUXWaitCondition.Q)
  400. LOG.Write($"Wait condition:heater profile--{reason}");
  401. _infoAUXWaitCondition = reason;
  402. var heaterWaitCondition = PMModule.CheckHeaterWaitCondition(out reason);
  403. _trigHeaterWaitCondition.CLK = !heaterWaitCondition || _infoHeaterWaitCondition != reason;
  404. if (_trigHeaterWaitCondition.Q)
  405. LOG.Write($"Wait condition:heater--{reason}");
  406. _infoHeaterWaitCondition = reason;
  407. var mfcWaitCondition = PMModule.CheckMFCWaitCondition(out reason);
  408. _trigMFCWaitCondition.CLK = !mfcWaitCondition || _infoMFCWaitCondition != reason;
  409. if (_trigMFCWaitCondition.Q)
  410. LOG.Write($"Wait condition:MFC--{reason}");
  411. _infoMFCWaitCondition = reason;
  412. if (heaterProfile &&
  413. leakCheck &&
  414. boatWaitCondition &&
  415. apcWaitCondition &&
  416. auxWaitCondition &&
  417. heaterWaitCondition &&
  418. mfcWaitCondition)
  419. {
  420. _state = RecipeRunningState.StepCompleted;
  421. }
  422. else
  423. {
  424. PMModule.IsWait = true;
  425. }
  426. }
  427. else
  428. {
  429. PMModule.CheckHeaterProfileFinish(out reason);
  430. PMModule.CheckBoatWaitCondition(out reason);
  431. PMModule.CheckAPCWaitCondition(out reason);
  432. PMModule.CheckAUXWaitCondition(out reason);
  433. PMModule.CheckHeaterWaitCondition(out reason);
  434. PMModule.CheckMFCWaitCondition(out reason);
  435. }
  436. break;
  437. case RecipeRunningState.ConditionWait:
  438. {
  439. if (!PMModule.CheckBoatState() && !PMModule.IsBoatMoveToLoadPosition)
  440. break;
  441. var heaterProfile = PMModule.CheckHeaterProfileFinish(out reason);
  442. _trigHeaterProfileFinish.CLK = !heaterProfile || _infoHeaterProfileFinish != reason;
  443. if (_trigHeaterProfileFinish.Q)
  444. LOG.Write($"Wait condition:heater profile--{reason}");
  445. _infoHeaterProfileFinish = reason;
  446. leakCheck = PMModule.CheckLeakCheckFinish();
  447. _trigLeakCheckFinish.CLK = !leakCheck;
  448. if (_trigLeakCheckFinish.Q)
  449. LOG.Write($"Wait condition:leak check");
  450. var boatWaitCondition = PMModule.CheckBoatWaitCondition(out reason);
  451. _trigBoatWaitCondition.CLK = !boatWaitCondition;
  452. if (_trigBoatWaitCondition.Q)
  453. LOG.Write($"Wait condition:boat--{reason}");
  454. var apcWaitCondition = PMModule.CheckAPCWaitCondition(out reason);
  455. _trigAPCWaitCondition.CLK = !apcWaitCondition;
  456. if (_trigAPCWaitCondition.Q)
  457. LOG.Write($"Wait condition:APC--{reason}");
  458. var auxWaitCondition = PMModule.CheckAUXWaitCondition(out reason);
  459. _trigAUXWaitCondition.CLK = !auxWaitCondition || _infoAUXWaitCondition != reason;
  460. if (_trigAUXWaitCondition.Q)
  461. LOG.Write($"Wait condition:heater profile--{reason}");
  462. _infoAUXWaitCondition = reason;
  463. var heaterWaitCondition = PMModule.CheckHeaterWaitCondition(out reason);
  464. _trigHeaterWaitCondition.CLK = !heaterWaitCondition || _infoHeaterWaitCondition != reason;
  465. if (_trigHeaterWaitCondition.Q)
  466. LOG.Write($"Wait condition:heater--{reason}");
  467. _infoHeaterWaitCondition = reason;
  468. var mfcWaitCondition = PMModule.CheckMFCWaitCondition(out reason);
  469. _trigMFCWaitCondition.CLK = !mfcWaitCondition || _infoMFCWaitCondition != reason;
  470. if (_trigMFCWaitCondition.Q)
  471. LOG.Write($"Wait condition:MFC--{reason}");
  472. _infoMFCWaitCondition = reason;
  473. if (heaterProfile &&
  474. leakCheck &&
  475. boatWaitCondition &&
  476. apcWaitCondition &&
  477. auxWaitCondition &&
  478. heaterWaitCondition &&
  479. mfcWaitCondition)
  480. {
  481. _state = RecipeRunningState.StepCompleted;
  482. }
  483. if (_stepTimer.IsTimeout())
  484. {
  485. if (PMModule.IsBoatMoveToLoadPosition)
  486. {
  487. _trigBoatMoveToLoadPositionTimeout.CLK = !boatWaitCondition;
  488. if (_trigBoatMoveToLoadPositionTimeout.Q)
  489. {
  490. LOG.Info($"stepName:{PMModule.RecipeRunningInfo.StepName},step timeout ,boatWaitCondition={boatWaitCondition}");
  491. }
  492. }
  493. //_trigInputSignalTimeOutAlarm.CLK = !PMModule.CheckExternalSensorCondition();
  494. //if (_trigInputSignalTimeOutAlarm.Q)
  495. // PMModule.InputSignalTimeOutAlarm.Set();
  496. //_trigTemperatureConvergenceTimeOutAlarm.CLK = !PMModule.CheckTempStabilizeCondition();
  497. //if (_trigTemperatureConvergenceTimeOutAlarm.Q)
  498. // PMModule.TemperatureConvergenceTimeOutAlarm.Set();
  499. //_trigReachTempTimeOutAlarm.CLK = !PMModule.CheckReachTempCondition();
  500. //if (_trigReachTempTimeOutAlarm.Q)
  501. // PMModule.TemperatureConvergenceTimeOutAlarm.Set("Reach temp condition timeout");
  502. //_trigPressureConvergenceTimeOutAlarm.CLK = !PMModule.CheckPressureStablilizeCondition();
  503. //if (_trigPressureConvergenceTimeOutAlarm.Q)
  504. // PMModule.PressureConvergenceTimeOutAlarm.Set();
  505. //_trigReachPressureTimeOutAlarm.CLK = !PMModule.CheckReachPressureCondition();
  506. //if (_trigReachPressureTimeOutAlarm.Q)
  507. // PMModule.PressureConvergenceTimeOutAlarm.Set("Reach pressure condition timeout");
  508. //_trigAutoProfileTimeOutAlarm.CLK = !PMModule.CheckFinishAutoProfileCondition();
  509. //if (_trigAutoProfileTimeOutAlarm.Q)
  510. // PMModule.AutoProfileTimeOutAlarm.Set();
  511. //_state = RecipeRunningState.StepCompleted;
  512. }
  513. else
  514. {
  515. _trigBoatMoveToLoadPositionTimeout.RST = true;
  516. }
  517. }
  518. break;
  519. case RecipeRunningState.Paused:
  520. if (!_stepTimer.IsIdle())
  521. {
  522. _curStepElpasedTimeBeforePaused += _stepTimer.GetElapseTime();
  523. _stepTimer.Stop();
  524. }
  525. if (_holdTimer.IsIdle())
  526. _holdTimer.Start(0);
  527. switch (ContinueAction)
  528. {
  529. case RecipeContinueMode.None:
  530. break;
  531. case RecipeContinueMode.StepContinue:
  532. if (!_holdTimer.IsIdle())
  533. {
  534. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  535. _holdTimer.Stop();
  536. }
  537. _state = RecipeRunningState.ExecStep;
  538. _stepTimer.Stop();
  539. break;
  540. }
  541. break;
  542. case RecipeRunningState.StepCompleted:
  543. {
  544. ResetTrig();
  545. //CloseAllValve();
  546. _curStepElpasedTimeBeforePaused = 0;
  547. var stepName = "";
  548. var stepTime = (float)_stepTimer.GetElapseTime() / 1000;//sec
  549. var thickness = 0.0f;
  550. if (IsSubReciep)
  551. {
  552. stepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName;
  553. float.TryParse(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].FilmThickFormula, out thickness);
  554. //放在前面,stepnumber后面会被更新
  555. if (!_isJumpStep)
  556. {
  557. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentSubRecipeStepNumber + 1);
  558. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentSubRecipeStepNumber + 1, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  559. }
  560. _fdc.Stop();
  561. _totalElpasedTime += curSteps[_currentSubRecipeStepNumber].StepTime;
  562. _subRecipeStartStepNumber++;
  563. if (_loopEnd)
  564. {
  565. _currentSubRecipeStepNumber++;
  566. CurrentSubRecipeLoopCount = 0;
  567. PMModule.RecipeRunningInfo.IsLooping = false;
  568. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  569. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  570. }
  571. else
  572. {
  573. SubRecipeLoopEndCheck(curSteps);
  574. }
  575. if (_currentSubRecipeStepNumber >= curSteps.Count)
  576. {
  577. PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount--;
  578. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount > 0)
  579. {
  580. IsSubReciep = true;
  581. }
  582. else
  583. {
  584. IsSubReciep = false;
  585. }
  586. _currentSubRecipeStepNumber = 0;
  587. CurrentSubRecipeLoopCount = 0;
  588. //// sub recipe执行完后,检查下是否在main recipe的loop内
  589. //RecipeLoopEndCheck();
  590. //if (_currentStepNumber >= PMModule.RecipeRunningInfo.RecipeStepList.Count)
  591. //{
  592. // _currentStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.Count - 1;
  593. // _state = RecipeRunningState.RecipeCompleted;
  594. //}
  595. }
  596. _state = RecipeRunningState.ExecStep;
  597. _stepTimer.Stop();
  598. }
  599. else
  600. {
  601. stepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName;
  602. float.TryParse(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].FilmThickFormula, out thickness);
  603. //放在前面,stepnumber后面会被更新
  604. if (!_isJumpStep)
  605. {
  606. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentStepNumber);
  607. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  608. }
  609. _fdc.Stop();
  610. if (_currentStepNumber >= 0 && !IsSubReciep)
  611. {
  612. _totalElpasedTime += PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  613. }
  614. if (IsSubReciep)
  615. IsSubReciep = false;
  616. if (_loopEnd)
  617. {
  618. _currentStepNumber++;
  619. CurrentLoopCount = 0;
  620. CurrentAbortRecipeLoopCount = 0;
  621. CurrentSubRecipeLoopCount = 0;
  622. PMModule.RecipeRunningInfo.IsLooping = false;
  623. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  624. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  625. }
  626. else
  627. {
  628. RecipeLoopEndCheck(PMModule.RecipeRunningInfo.RecipeStepList);
  629. }
  630. if (_currentStepNumber >= PMModule.RecipeRunningInfo.RecipeStepList.Count - 1)
  631. {
  632. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  633. {
  634. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  635. continue;
  636. var wafer = WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), i);
  637. if (wafer.ProcessState == EnumWaferProcessStatus.Completed ||
  638. wafer.ProcessState == EnumWaferProcessStatus.Idle)
  639. continue;
  640. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Completed);
  641. }
  642. PMModule.IsMainRecipeComplete = true;
  643. }
  644. if (_currentStepNumber >= PMModule.RecipeRunningInfo.RecipeStepList.Count)
  645. {
  646. _currentStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.Count - 1;
  647. _state = RecipeRunningState.RecipeCompleted;
  648. }
  649. else
  650. {
  651. _state = RecipeRunningState.ExecStep;
  652. _stepTimer.Stop();
  653. }
  654. }
  655. if (!_isJumpStep)
  656. {
  657. var wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Module));
  658. for (int i = 0; i < wafers.Length; i++)
  659. {
  660. if (WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(Module), i))
  661. continue;
  662. var useCount = wafers[i].UseCount;
  663. var useTime = wafers[i].UseTime + (float)stepTime;
  664. var useThick = wafers[i].UseThick + thickness;
  665. WaferManager.Instance.UpdateWaferStatistics(ModuleHelper.Converter(Module), i, useCount, (float)Math.Round(useTime, 1), useThick);
  666. }
  667. PMModule.UpdateRecipeThickness(PMModule.RecipeRunningInfo.RecipeName, thickness);
  668. PMModule.UpdateRecipeStepFre(stepName);
  669. PMModule.UpdateRecipeStepRunTime(stepName, Math.Round(stepTime, 1));
  670. PMModule.UpdateRecipeStepGroupThickness(stepName, thickness);
  671. PMModule.UpdateBoatTotalThickness(thickness);
  672. }
  673. }
  674. _isJumpStep = false;
  675. if (PMModule.IsPaused)
  676. {
  677. _state = RecipeRunningState.Paused;
  678. var step = IsSubReciep ? _currentSubRecipeStepNumber + 1 : _currentStepNumber;
  679. break;
  680. }
  681. break;
  682. case RecipeRunningState.RecipeCompleted:
  683. {
  684. var wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Module));
  685. for (int i = 0; i < wafers.Length; i++)
  686. {
  687. if (WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(Module), i))
  688. continue;
  689. var useCount = wafers[i].UseCount + 1;
  690. var useTime = wafers[i].UseTime;
  691. var useThick = wafers[i].UseThick;
  692. WaferManager.Instance.UpdateWaferStatistics(ModuleHelper.Converter(Module), i, useCount, (float)Math.Round(useTime, 1), useThick);
  693. }
  694. PMModule.UpdateSEDWafer(WaferManager.Instance.GetAllWafers());
  695. if (PMModule.IsHeaterProfile && !PMModule.IsHeaterProfileSuccess)
  696. EV.PostWarningLog(PMModule.Module, "Auto profile failed");
  697. PMModule.UpdateRecipeFre(PMModule.RecipeRunningInfo.RecipeName);
  698. PMModule.ResetFDCRecipeStepName();
  699. Notify("End");
  700. return Result.DONE;
  701. }
  702. case RecipeRunningState.Error:
  703. {
  704. return Result.DONE;
  705. }
  706. default:
  707. break;
  708. }
  709. }
  710. catch (Exception ex)
  711. {
  712. LOG.Write(ex);
  713. return Result.FAIL;
  714. }
  715. }
  716. MonitorRecipeRunInfo();
  717. return Result.RUN;
  718. }
  719. private void MonitorRecipeRunInfo()
  720. {
  721. PMModule.IsHolded = _state == RecipeRunningState.Paused;
  722. double elapseTime;
  723. double totalElapseTime;
  724. double holdTotalElapseTime;
  725. var step = 0;
  726. if (IsSubReciep)
  727. {
  728. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps != null)
  729. {
  730. if (_stepTimer.IsIdle())
  731. {
  732. elapseTime = (_curStepElpasedTimeBeforePaused / 1000) < 1 ? 0 : _curStepElpasedTimeBeforePaused / 1000;
  733. }
  734. else
  735. {
  736. elapseTime = ((_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000) < 1 ? 0 : (_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000;
  737. }
  738. if (elapseTime > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime)
  739. elapseTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime;
  740. totalElapseTime = _totalElpasedTime + elapseTime > PMModule.RecipeRunningInfo.TotalTime ? PMModule.RecipeRunningInfo.TotalTime : _totalElpasedTime + elapseTime;
  741. if (_holdTimer.IsIdle())
  742. {
  743. holdTotalElapseTime = _holdTimeElpasedTime / 1000;
  744. }
  745. else
  746. {
  747. holdTotalElapseTime = (_holdTimeElpasedTime + _holdTimer.GetElapseTime()) / 1000;
  748. }
  749. PMModule.RecipeRunningInfo.StepElapseTime = elapseTime;
  750. PMModule.RecipeRunningInfo.TotalElapseTime = totalElapseTime;
  751. PMModule.RecipeRunningInfo.HoldTime = holdTotalElapseTime;
  752. PMModule.RecipeRunningInfo.StepTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime;
  753. PMModule.RecipeRunningInfo.RecipeName = $"Sub/{PMModule.RecipeRunningInfo.Head.SubRecipe}-{PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeTableInfo}-{PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName}";
  754. PMModule.RecipeRunningInfo.ExecRecipeType = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].RecipeType;
  755. PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount = PMModule.RecipeRunningInfo.SubRecipeLoopCount - PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount + 1;
  756. PMModule.RecipeRunningInfo.SubRecipeName = PMModule.RecipeRunningInfo.Head.SubRecipe;
  757. PMModule.RecipeRunningInfo.SubRecipeTable = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeTableInfo;
  758. step = _currentSubRecipeStepNumber;
  759. if (_state == RecipeRunningState.Paused)
  760. {
  761. //pause之后,当前step执行完,显示的step要保持hold住的这一步的
  762. step--;
  763. if (step < 0)
  764. step = 0;
  765. }
  766. PMModule.RecipeRunningInfo.StepNumber = step + 1; //CurStepNum start from 0
  767. PMModule.RecipeRunningInfo.StepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].StepName;
  768. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].IsLoopEndStep)
  769. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps.Count > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].LoopStartStep ?
  770. PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].LoopStartStep].StepName : "";
  771. else
  772. {
  773. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps.Count > step + 1)
  774. {
  775. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step + 1].StepName;
  776. }
  777. else
  778. {
  779. if (PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount < PMModule.RecipeRunningInfo.SubRecipeLoopCount)
  780. {
  781. //sub 下一个循环
  782. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[0].StepName;
  783. }
  784. else
  785. {
  786. //sub执行结束
  787. if (PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber)
  788. {
  789. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName;
  790. }
  791. }
  792. }
  793. }
  794. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName.ToLower() == "standby")
  795. {
  796. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Standby.ToString();
  797. }
  798. else
  799. {
  800. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Run.ToString();
  801. }
  802. }
  803. return;
  804. }
  805. if (_stepTimer.IsIdle())
  806. {
  807. elapseTime = (_curStepElpasedTimeBeforePaused / 1000) < 1 ? 0 : _curStepElpasedTimeBeforePaused / 1000;
  808. }
  809. else
  810. {
  811. elapseTime = ((_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000) < 1 ? 0 : (_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000;
  812. }
  813. if (elapseTime > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime)
  814. elapseTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  815. totalElapseTime = _totalElpasedTime + elapseTime > PMModule.RecipeRunningInfo.TotalTime ? PMModule.RecipeRunningInfo.TotalTime : _totalElpasedTime + elapseTime;
  816. if (_holdTimer.IsIdle())
  817. {
  818. holdTotalElapseTime = _holdTimeElpasedTime / 1000;
  819. }
  820. else
  821. {
  822. holdTotalElapseTime = (_holdTimeElpasedTime + _holdTimer.GetElapseTime()) / 1000;
  823. }
  824. PMModule.RecipeRunningInfo.StepElapseTime = elapseTime;
  825. PMModule.RecipeRunningInfo.TotalElapseTime = totalElapseTime;
  826. PMModule.RecipeRunningInfo.HoldTime = holdTotalElapseTime;
  827. PMModule.RecipeRunningInfo.StepTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  828. PMModule.RecipeRunningInfo.RecipeName = PMModule.RecipeRunningInfo.MainRecipeName;
  829. PMModule.RecipeRunningInfo.ExecRecipeType = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].RecipeType;
  830. if (_state == RecipeRunningState.RecipeCompleted)
  831. {
  832. PMModule.RecipeRunningInfo.HoldTime = 0;
  833. }
  834. step = _currentStepNumber;
  835. if (_state == RecipeRunningState.Paused)
  836. {
  837. //pause之后,当前step执行完,显示的step要保持hold住的这一步的
  838. step--;
  839. if (step < 0)
  840. step = 0;
  841. }
  842. if (PMModule.RecipeRunningInfo.RecipeStepList[0].StepName.ToLower() == "standby")
  843. {
  844. PMModule.RecipeRunningInfo.StepNumber = step; //CurStepNum start from 0
  845. }
  846. else
  847. {
  848. PMModule.RecipeRunningInfo.StepNumber = step + 1; //CurStepNum start from 0
  849. }
  850. PMModule.RecipeRunningInfo.StepName = PMModule.RecipeRunningInfo.RecipeStepList[_showStepNo].StepName;
  851. if (PMModule.RecipeRunningInfo.RecipeStepList[step].IsLoopEndStep)
  852. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList.Count > PMModule.RecipeRunningInfo.RecipeStepList[step].LoopStartStep ? PMModule.RecipeRunningInfo.RecipeStepList[PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].LoopStartStep].StepName : "";
  853. else
  854. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList.Count > step + 1 ? PMModule.RecipeRunningInfo.RecipeStepList[step + 1].StepName : "";
  855. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName.ToLower() == "standby")
  856. {
  857. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Standby.ToString();
  858. }
  859. else if (PMModule.RecipeRunningInfo.RecipeStepList.Count - 1 == _currentStepNumber)
  860. {
  861. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.End.ToString();
  862. }
  863. else
  864. {
  865. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Run.ToString();
  866. }
  867. }
  868. private void MonitorRecipeAlaramAction()
  869. {
  870. if (_state != RecipeRunningState.TimeWait && _state != RecipeRunningState.ConditionWait)
  871. return;
  872. if (_alarmNames.Count == 0)
  873. return;
  874. int group = -1, temp = 0;
  875. string iAlarmConditionTable = "1:";
  876. if (IsSubReciep)
  877. {
  878. for (int i = 0; i < _alarmNames.Count; i++)
  879. {
  880. iAlarmConditionTable = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmConditionTable;
  881. temp = (int)Singleton<EventManager>.Instance.AlarmDic[iAlarmConditionTable.ToString()][_alarmNames[i]].Group;
  882. if (!PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets.ContainsKey(temp))
  883. continue;
  884. var type = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[temp].ProcessingType;
  885. if (temp >= group && (group == -1 || type != "Ignore Alarm"))
  886. group = temp;
  887. }
  888. }
  889. else
  890. {
  891. for (int i = 0; i < _alarmNames.Count; i++)
  892. {
  893. iAlarmConditionTable = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmConditionTable;
  894. temp = (int)Singleton<EventManager>.Instance.AlarmDic[iAlarmConditionTable.ToString()][_alarmNames[i]].Group;
  895. if (!PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets.ContainsKey(temp))
  896. continue;
  897. var type = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[temp].ProcessingType;
  898. if (temp >= group && (group == -1 || type != "Ignore Alarm"))
  899. group = temp;
  900. }
  901. }
  902. _alarmNames.Clear();
  903. if (group == -1)
  904. return;
  905. string alarmAction = "", alarmDetails = "";
  906. List<RecipeStep> abortRecipes = new List<RecipeStep>();
  907. if (IsSubReciep)
  908. {
  909. alarmAction = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[group].ProcessingType;
  910. alarmDetails = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[group].ProcessingDetails;
  911. abortRecipes = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[group].AbortRecipeStepList;
  912. }
  913. else
  914. {
  915. alarmAction = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[group].ProcessingType;
  916. alarmDetails = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[group].ProcessingDetails;
  917. abortRecipes = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[group].AbortRecipeStepList;
  918. }
  919. switch (alarmAction)
  920. {
  921. case "Jump Abort Recipe":
  922. alarmDetails = alarmDetails.Replace("Abort Recipe/", string.Empty);
  923. Abort();
  924. _alarmAction = RecipeAlaramAction.JumpAbortRecipe;
  925. break;
  926. case "Jump Step":
  927. alarmDetails = alarmDetails.Replace("Jump Step/", string.Empty);
  928. _jumpStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.FindIndex(x => x.StepName == alarmDetails);
  929. _alarmAction = RecipeAlaramAction.JumpStep;
  930. _state = RecipeRunningState.StepCompleted;
  931. break;
  932. case "Jump Step(Cancel Call Loop)":
  933. alarmDetails = alarmDetails.Replace("Jump Step(Cancel Call Loop)/", string.Empty);
  934. _jumpStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.FindIndex(x => x.StepName == alarmDetails);
  935. _alarmAction = RecipeAlaramAction.JumpStepCancelCallLoop;
  936. IsJumpStepCancelCallLoop = true;
  937. _state = RecipeRunningState.StepCompleted;
  938. break;
  939. case "Abort":
  940. IsExecuteAbort = true;
  941. break;
  942. case "Hold":
  943. PMModule.IsPaused = true;
  944. ContinueAction = RecipeContinueMode.None;
  945. _alarmAction = RecipeAlaramAction.Hold;
  946. break;
  947. case "Ignore Alarm":
  948. _alarmAction = RecipeAlaramAction.IgnoreAlaram;
  949. break;
  950. default:
  951. _alarmAction = RecipeAlaramAction.IgnoreAlaram;
  952. break;
  953. }
  954. }
  955. private void MonitorRecipePause()
  956. {
  957. if (_state != RecipeRunningState.TimeWait && _state != RecipeRunningState.ConditionWait)
  958. return;
  959. //if (PMModule.IsPaused)
  960. //{
  961. // _state = RecipeRunningState.Paused;
  962. //}
  963. }
  964. public override void Abort()
  965. {
  966. //PMModule.AbortRecipe();//暂时这么做
  967. PMModule.RecipeRunningInfo.IsLooping = false;
  968. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  969. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  970. IsExecuteAbort = true;
  971. IsSubReciep = false;
  972. PMModule.IsPaused = false;
  973. PMModule.IsHeaterProfile = false;
  974. PMModule.IsHeaterProfileSuccess = false;
  975. if (!_holdTimer.IsIdle())
  976. {
  977. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  978. _holdTimer.Stop();
  979. }
  980. CurrentLoopCount = 0;
  981. CurrentAbortRecipeLoopCount = 0;
  982. CurrentSubRecipeLoopCount = 0;
  983. _state = RecipeRunningState.RecipeCompleted;//暂时这么做
  984. //更新步次结束时间
  985. var step = IsSubReciep ? _currentSubRecipeStepNumber + 1 : _currentStepNumber;
  986. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), step, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  987. return;//暂时这么做
  988. //_totalElpasedTime = 0;
  989. PMModule.RecipeRunningInfo.BeginTime = DateTime.Now;
  990. double total = 0;
  991. for (int i = 0; i < PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AbortRecipeSteps.Count; i++)
  992. {
  993. total += PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AbortRecipeSteps[i].StepTime;
  994. }
  995. PMModule.RecipeRunningInfo.TotalTime = _totalElpasedTime + total;
  996. ResetTrig();
  997. //PMModule.ResetToleranceAlarm();
  998. //PMModule.ResetToleranceAlarmChecker();
  999. PMModule.ExecuteAbortRecipeWarning.Set($"from recipe name:{PMModule.RecipeRunningInfo.RecipeName} step:{_currentStepNumber} start execute abort recipe.");
  1000. _state = RecipeRunningState.ExecStep;
  1001. }
  1002. public void UpdateProcessDataPJid(string pjId)
  1003. {
  1004. _dbCallback.RecipeUpdatePjId(PMModule.RecipeRunningInfo.InnerId.ToString(), pjId);
  1005. }
  1006. public void ExitProcess()
  1007. {
  1008. if (_state == RecipeRunningState.RecipeCompleted)
  1009. {
  1010. if (!_hasItBeenTriggeredRecipeComplete)
  1011. _faCallback.RecipeComplete(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  1012. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Standby.ToString();
  1013. _dbCallback.RecipeComplete(PMModule.RecipeRunningInfo.InnerId.ToString());
  1014. _fdc.Stop();
  1015. }
  1016. else
  1017. {
  1018. if (PMModule.IsExcuteIdleRecipe)
  1019. {
  1020. if (!_hasItBeenTriggeredRecipeComplete)
  1021. _faCallback.RecipeComplete(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  1022. _dbCallback.RecipeComplete(PMModule.RecipeRunningInfo.InnerId.ToString());
  1023. _fdc.Stop();
  1024. }
  1025. else
  1026. {
  1027. _faCallback.RecipeFailed(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  1028. _dbCallback.RecipeFailed(PMModule.RecipeRunningInfo.InnerId.ToString());
  1029. _fdc.Stop();
  1030. };
  1031. }
  1032. _hasItBeenTriggeredRecipeComplete = false;
  1033. }
  1034. public void PauseRecipe()
  1035. {
  1036. PMModule.IsPaused = true;
  1037. ContinueAction = RecipeContinueMode.None;
  1038. }
  1039. public void ContinueRecipe()
  1040. {
  1041. PMModule.IsPaused = false;
  1042. ContinueAction = RecipeContinueMode.StepContinue;
  1043. var step = IsSubReciep ? _currentSubRecipeStepNumber + 1 : _currentStepNumber;
  1044. }
  1045. public void SkipCurrentRecipeStep()
  1046. {
  1047. if (_state == RecipeRunningState.ConditionWait || _state == RecipeRunningState.TimeWait || _state == RecipeRunningState.Paused)
  1048. {
  1049. _state = RecipeRunningState.StepCompleted;
  1050. _loopEnd = true;
  1051. PMModule.RecipeRunningInfo.IsLooping = false;
  1052. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1053. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1054. PMModule.IsPaused = false;
  1055. if (!_holdTimer.IsIdle())
  1056. {
  1057. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  1058. _holdTimer.Stop();
  1059. }
  1060. }
  1061. if (IsSubReciep)
  1062. {
  1063. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps, _currentSubRecipeStepNumber);
  1064. }
  1065. else
  1066. {
  1067. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList, _currentStepNumber);
  1068. }
  1069. }
  1070. private void ResetLoop(List<RecipeStep> checkRecipeSeps, int currentStepNumber)
  1071. {
  1072. if (checkRecipeSeps == null)
  1073. return;
  1074. var hasLoopStart = false;
  1075. for (int i = currentStepNumber; i >= 0; i--)
  1076. {
  1077. if (checkRecipeSeps[i].IsLoopStartStep)
  1078. {
  1079. hasLoopStart = true;
  1080. break;
  1081. }
  1082. if (checkRecipeSeps[i].IsLoopEndStep)
  1083. {
  1084. hasLoopStart = false;//前面有end,说明没有循环
  1085. break;
  1086. }
  1087. }
  1088. if (hasLoopStart)
  1089. {
  1090. for (int i = currentStepNumber; i < checkRecipeSeps.Count; i++)
  1091. {
  1092. if (checkRecipeSeps[i].IsLoopStartStep)
  1093. {
  1094. break;//没有循环
  1095. }
  1096. if (checkRecipeSeps[i].IsLoopEndStep)
  1097. {
  1098. checkRecipeSeps[i].IsLoopEndStep = false;//跳出skip step之间的循环
  1099. break;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. public void LeakCheckRetry()
  1105. {
  1106. JumpCurrentRecipeStep(_currentStepNumber - 1, PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber - 1].StepName);
  1107. }
  1108. public void JumpCurrentRecipeStep(int stepNumber, string stepName, bool isAlarmConditionCall = false)
  1109. {
  1110. PMModule.StopLeakCheckTimer();
  1111. LOG.Write($"Jump to step stepNumber={stepNumber} stepName={stepName}, currentStepNumber={_currentStepNumber}");
  1112. if (_state == RecipeRunningState.ConditionWait || _state == RecipeRunningState.TimeWait ||
  1113. _state == RecipeRunningState.Paused || _state == RecipeRunningState.ExecStep)
  1114. {
  1115. _loopEnd = true;
  1116. PMModule.RecipeRunningInfo.IsLooping = false;
  1117. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1118. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1119. CurrentLoopCount = 0;
  1120. CurrentAbortRecipeLoopCount = 0;
  1121. CurrentSubRecipeLoopCount = 0;
  1122. IsSubReciep = false;
  1123. if (IsSubReciep)
  1124. {
  1125. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentSubRecipeStepNumber + 1);
  1126. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentSubRecipeStepNumber + 1, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  1127. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps, _currentSubRecipeStepNumber);
  1128. }
  1129. else
  1130. {
  1131. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentStepNumber);
  1132. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  1133. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList, _currentStepNumber);
  1134. }
  1135. if (_callSubSteps != null)
  1136. {
  1137. foreach (var key in _callSubSteps.Keys)
  1138. {
  1139. if (PMModule.RecipeRunningInfo.RecipeStepList.Count > key)
  1140. {
  1141. PMModule.RecipeRunningInfo.RecipeStepList[key].IsCallSubStep = _callSubSteps[key].Item1;
  1142. PMModule.RecipeRunningInfo.RecipeStepList[key].SubRecipeLoopCount = _callSubSteps[key].Item2;
  1143. }
  1144. }
  1145. _currentSubRecipeStepNumber = CurSubRecipeStepTotalLoopCount = 0;
  1146. }
  1147. _isJumpStep = true;
  1148. _currentStepNumber = stepNumber - 1;
  1149. if (_currentStepNumber < 0)
  1150. _currentStepNumber = 0;
  1151. _totalElpasedTime = RefreshElpasedTime();
  1152. _state = RecipeRunningState.StepCompleted;
  1153. PMModule.IsPaused = false;
  1154. if (!_holdTimer.IsIdle())
  1155. {
  1156. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  1157. _holdTimer.Stop();
  1158. }
  1159. }
  1160. }
  1161. private double RefreshElpasedTime()
  1162. {
  1163. double total = 0;
  1164. try
  1165. {
  1166. for (int i = 0; i < _currentStepNumber; i++)
  1167. {
  1168. if (!PMModule.RecipeRunningInfo.RecipeStepList[i].IsJumpStep)
  1169. {
  1170. if (PMModule.RecipeRunningInfo.RecipeStepList[i].IsLoopEndStep)
  1171. {
  1172. int iLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[i].LoopStartStep;
  1173. for (int j = 0; j < PMModule.RecipeRunningInfo.RecipeStepList[i].LoopCount; j++)
  1174. {
  1175. for (int m = iLoopStartStep; m <= i; m++)
  1176. {
  1177. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1178. {
  1179. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1180. }
  1181. total += PMModule.RecipeRunningInfo.RecipeStepList[m].StepTime;
  1182. }
  1183. }
  1184. }
  1185. else
  1186. {
  1187. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null &&
  1188. PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1189. {
  1190. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1191. }
  1192. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1193. }
  1194. }
  1195. }
  1196. }
  1197. catch (Exception ex)
  1198. {
  1199. LOG.Write(ex);
  1200. return -1;
  1201. }
  1202. return (int)total;
  1203. }
  1204. public void RespondAlarm(string name)
  1205. {
  1206. if (!_alarmNames.Contains(name))
  1207. _alarmNames.Add(name);
  1208. }
  1209. protected int CalcRecipeTime()
  1210. {
  1211. double total = 0;
  1212. int iStart = PMModule.IsJobProcess ? 1 : 0;
  1213. try
  1214. {
  1215. for (int i = iStart; i < PMModule.RecipeRunningInfo.RecipeStepList.Count; i++)
  1216. //for (int i = PMModule.RecipeRunningInfo.RecipeStepList.Count - 1; i <= iStart; i--)
  1217. {
  1218. if (!PMModule.RecipeRunningInfo.RecipeStepList[i].IsJumpStep)
  1219. {
  1220. if (PMModule.RecipeRunningInfo.RecipeStepList[i].IsLoopEndStep)
  1221. {
  1222. int iLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[i].LoopStartStep;
  1223. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1224. for (int j = 0; j < PMModule.RecipeRunningInfo.RecipeStepList[i].LoopCount - 1; j++)
  1225. {
  1226. for (int m = iLoopStartStep; m <= i; m++)
  1227. {
  1228. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1229. {
  1230. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1231. }
  1232. total += PMModule.RecipeRunningInfo.RecipeStepList[m].StepTime;
  1233. }
  1234. }
  1235. }
  1236. else
  1237. {
  1238. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1239. {
  1240. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1241. }
  1242. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1243. }
  1244. }
  1245. else
  1246. {
  1247. i = PMModule.RecipeRunningInfo.RecipeStepList[i].JumpStepNo - 1;// -1是因为i++
  1248. }
  1249. if (i < PMModule.RecipeRunningInfo.RecipeStepList.Count - 1)
  1250. {
  1251. _remainTimeExcludeEnd = total;//获取除最后一步外的process时间,End步会cooling
  1252. }
  1253. }
  1254. }
  1255. catch (Exception ex)
  1256. {
  1257. LOG.Write(ex);
  1258. return -1;
  1259. }
  1260. return (int)total;
  1261. }
  1262. private int AbortRecipeCalTotalTime()
  1263. {
  1264. double total = 0;
  1265. List<RecipeStep> abortRecipeSteps;
  1266. abortRecipeSteps = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AbortRecipeSteps;
  1267. try
  1268. {
  1269. for (int i = 0; i < abortRecipeSteps.Count; i++)
  1270. {
  1271. if (!abortRecipeSteps[i].IsJumpStep)
  1272. {
  1273. if (abortRecipeSteps[i].IsLoopStartStep)
  1274. {
  1275. int iLoopEndStep = 0;
  1276. for (int j = 0; j < abortRecipeSteps[i].LoopCount; j++)
  1277. {
  1278. for (int m = i; m < abortRecipeSteps.Count; m++)
  1279. {
  1280. total += abortRecipeSteps[m].StepTime;
  1281. if (abortRecipeSteps[m].IsLoopEndStep)
  1282. {
  1283. iLoopEndStep = m;
  1284. break;
  1285. }
  1286. }
  1287. }
  1288. i = iLoopEndStep;
  1289. }
  1290. else
  1291. {
  1292. total += abortRecipeSteps[i].StepTime;
  1293. }
  1294. }
  1295. else
  1296. {
  1297. i = abortRecipeSteps[i].JumpStepNo - 1;// -1是因为i++
  1298. }
  1299. }
  1300. }
  1301. catch (Exception ex)
  1302. {
  1303. LOG.Write(ex);
  1304. return -1;
  1305. }
  1306. return (int)total;
  1307. }
  1308. public void SetContinue(string continueMode)
  1309. {
  1310. switch (continueMode)
  1311. {
  1312. case "Step continue":
  1313. ContinueAction = RecipeContinueMode.StepContinue;
  1314. break;
  1315. case "Step restart":
  1316. ContinueAction = RecipeContinueMode.StepRestart;
  1317. break;
  1318. case "Next step":
  1319. ContinueAction = RecipeContinueMode.NextStep;
  1320. break;
  1321. case "Recipe restart":
  1322. ContinueAction = RecipeContinueMode.RecipeRestart;
  1323. break;
  1324. case "Recipe complete":
  1325. ContinueAction = RecipeContinueMode.RecipeCompleted;
  1326. break;
  1327. case "Wafer return and job stop":
  1328. ContinueAction = RecipeContinueMode.WaferReturnAndJobStop;
  1329. break;
  1330. }
  1331. PMModule.ResetToleranceChecker();
  1332. }
  1333. private double SubRecipeCalTotalTime(int currentStepNumber)
  1334. {
  1335. double total = 0;
  1336. for (int k = _currentSubRecipeStepNumber; k < PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps.Count; k++)
  1337. {
  1338. if (!PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].IsJumpStep)
  1339. {
  1340. if (PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].IsLoopEndStep)
  1341. {
  1342. int iSystemLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].LoopStartStep;
  1343. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].StepTime;
  1344. for (int n = 0; n < PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].LoopCount - 1; n++)
  1345. {
  1346. for (int l = iSystemLoopStartStep; l <= k; l++)
  1347. {
  1348. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[l].StepTime;
  1349. }
  1350. }
  1351. }
  1352. else
  1353. {
  1354. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].StepTime;
  1355. }
  1356. }
  1357. else
  1358. {
  1359. k = PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].JumpStepNo - 1;// -1是因为k++
  1360. }
  1361. }
  1362. return total;
  1363. }
  1364. private void SubRecipeLoopEndCheck(List<RecipeStep> recipeSteps)
  1365. {
  1366. if (_alarmAction == RecipeAlaramAction.JumpStep || _alarmAction == RecipeAlaramAction.JumpStepCancelCallLoop)
  1367. {
  1368. _currentSubRecipeStepNumber = _jumpStepNumber;
  1369. _alarmAction = RecipeAlaramAction.None;
  1370. _alarmNames.Clear();
  1371. return;
  1372. }
  1373. if (recipeSteps[_currentSubRecipeStepNumber].IsLoopEndStep)
  1374. {
  1375. if (IsJumpStepCancelCallLoop)
  1376. {
  1377. _currentSubRecipeStepNumber++;
  1378. IsJumpStepCancelCallLoop = false;
  1379. return;
  1380. }
  1381. //重新读取循环的设定次数
  1382. CurSubRecipeStepTotalLoopCount = recipeSteps[_currentSubRecipeStepNumber].LoopCount;
  1383. if (CurrentSubRecipeLoopCount >= CurSubRecipeStepTotalLoopCount)
  1384. {
  1385. CurrentSubRecipeLoopCount = CurSubRecipeStepTotalLoopCount = 0;
  1386. _currentSubRecipeStepNumber++;
  1387. PMModule.RecipeRunningInfo.IsLooping = false;
  1388. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1389. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1390. }
  1391. else
  1392. {
  1393. _currentSubRecipeStepNumber = recipeSteps[_currentSubRecipeStepNumber].LoopStartStep;
  1394. }
  1395. }
  1396. else
  1397. {
  1398. _currentSubRecipeStepNumber++;
  1399. }
  1400. }
  1401. private void RecipeLoopEndCheck(List<RecipeStep> recipeSteps)
  1402. {
  1403. if (_alarmAction == RecipeAlaramAction.JumpStep || _alarmAction == RecipeAlaramAction.JumpStepCancelCallLoop)
  1404. {
  1405. _currentStepNumber = _jumpStepNumber;
  1406. _alarmAction = RecipeAlaramAction.None;
  1407. _alarmNames.Clear();
  1408. return;
  1409. }
  1410. if (recipeSteps[_currentStepNumber].IsLoopEndStep)
  1411. {
  1412. if (IsJumpStepCancelCallLoop)
  1413. {
  1414. _currentStepNumber++;
  1415. IsJumpStepCancelCallLoop = false;
  1416. return;
  1417. }
  1418. //重新读取循环的设定次数
  1419. CurStepTotalLoopCount = recipeSteps[_currentStepNumber].LoopCount;
  1420. if (CurrentLoopCount >= CurStepTotalLoopCount)
  1421. {
  1422. CurrentLoopCount = CurStepTotalLoopCount = 0;
  1423. _currentStepNumber++;
  1424. PMModule.RecipeRunningInfo.IsLooping = false;
  1425. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1426. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1427. }
  1428. else
  1429. {
  1430. _currentStepNumber = recipeSteps[_currentStepNumber].LoopStartStep;
  1431. }
  1432. }
  1433. else
  1434. {
  1435. _currentStepNumber++;
  1436. }
  1437. }
  1438. private void CheckTolerance()
  1439. {
  1440. //foreach (var key in _trigMfcToleranceAlarms.Keys)
  1441. //{
  1442. // if (PMModule.GasMFCs.ContainsKey(key) && _trigMfcToleranceWarnings.ContainsKey(key))
  1443. // {
  1444. // _trigMfcToleranceAlarms[key].CLK = PMModule.GasMFCs[key].CheckToleranceAlarm();
  1445. // if (_trigMfcToleranceAlarms[key].Q)
  1446. // PMModule.GasMFCs[key].SetToleranceAlarm();
  1447. // _trigMfcToleranceWarnings[key].CLK = PMModule.GasMFCs[key].CheckToleranceWarning();
  1448. // if (_trigMfcToleranceWarnings[key].Q && !_trigMfcToleranceAlarms[key].Q)
  1449. // PMModule.GasMFCs[key].SetToleranceWarning();
  1450. // }
  1451. //}
  1452. //_trigHeaterBottomToleranceAlarm.CLK = PMModule.CheckHeaterBottomToleranceAlaram();
  1453. //if (_trigHeaterBottomToleranceAlarm.Q)
  1454. // PMModule.SetHeaterBottomToleranceAlaram();
  1455. //_trigHeaterBottomToleranceWarning.CLK = PMModule.CheckHeaterBottomToleranceWarning();
  1456. //if (_trigHeaterBottomToleranceWarning.Q && !_trigHeaterBottomToleranceAlarm.Q)
  1457. // PMModule.SetHeaterBottomToleranceWarning();
  1458. //_trigHeaterCenterBottomToleranceAlarm.CLK = PMModule.CheckHeaterCenterBottomToleranceAlaram();
  1459. //if (_trigHeaterCenterBottomToleranceAlarm.Q)
  1460. // PMModule.SetHeaterCenterBottomToleranceAlaram();
  1461. //_trigHeaterCenterBottomToleranceWarning.CLK = PMModule.CheckHeaterCenterBottomToleranceWarning();
  1462. //if (_trigHeaterCenterBottomToleranceWarning.Q && !_trigHeaterCenterBottomToleranceAlarm.Q)
  1463. // PMModule.SetHeaterCenterBottomToleranceWarning();
  1464. //_trigHeaterCenterToleranceAlarm.CLK = PMModule.CheckHeaterCenterToleranceAlaram();
  1465. //if (_trigHeaterCenterToleranceAlarm.Q)
  1466. // PMModule.SetHeaterCenterToleranceAlaram();
  1467. //_trigHeaterCenterToleranceWarning.CLK = PMModule.CheckHeaterCenterToleranceWarning();
  1468. //if (_trigHeaterCenterToleranceWarning.Q && !_trigHeaterCenterToleranceAlarm.Q)
  1469. // PMModule.SetHeaterCenterToleranceWarning();
  1470. //_trigHeaterCenterTopToleranceAlarm.CLK = PMModule.CheckHeaterCenterTopToleranceAlaram();
  1471. //if (_trigHeaterCenterTopToleranceAlarm.Q)
  1472. // PMModule.SetHeaterCenterTopToleranceAlaram();
  1473. //_trigHeaterCenterTopToleranceWarning.CLK = PMModule.CheckHeaterCenterTopToleranceWarning();
  1474. //if (_trigHeaterCenterTopToleranceWarning.Q && !_trigHeaterCenterTopToleranceAlarm.Q)
  1475. // PMModule.SetHeaterCenterTopToleranceWarning();
  1476. //_trigHeaterTopToleranceAlarm.CLK = PMModule.CheckHeaterTopToleranceAlaram();
  1477. //if (_trigHeaterTopToleranceAlarm.Q)
  1478. // PMModule.SetHeaterTopToleranceAlaram();
  1479. //_trigHeaterTopToleranceWarning.CLK = PMModule.CheckHeaterTopToleranceWarning();
  1480. //if (_trigHeaterTopToleranceWarning.Q && !_trigHeaterTopToleranceAlarm.Q)
  1481. // PMModule.SetHeaterTopToleranceWarning();
  1482. //_trigPressureToleranceAlarm.CLK = PMModule.CheckPressureToleranceAlaram();
  1483. //if (_trigPressureToleranceAlarm.Q)
  1484. // PMModule.SetPressureToleranceAlaram();
  1485. //_trigPressureToleranceWarning.CLK = PMModule.CheckPressureToleranceWarning();
  1486. //if (_trigPressureToleranceWarning.Q && !_trigPressureToleranceAlarm.Q)
  1487. // PMModule.SetPressureToleranceWarning();
  1488. }
  1489. private void ResetTrig()
  1490. {
  1491. PMModule.ResetAlarmCondition();
  1492. foreach (var key in _trigMfcToleranceAlarms.Keys)
  1493. {
  1494. if (_trigMfcToleranceWarnings.ContainsKey(key))
  1495. {
  1496. _trigMfcToleranceAlarms[key].RST = true;
  1497. _trigMfcToleranceWarnings[key].RST = true;
  1498. }
  1499. }
  1500. _trigHeaterBottomToleranceAlarm.RST = true;
  1501. _trigHeaterBottomToleranceWarning.RST = true;
  1502. _trigHeaterCenterBottomToleranceAlarm.RST = true;
  1503. _trigHeaterCenterBottomToleranceWarning.RST = true;
  1504. _trigHeaterCenterToleranceAlarm.RST = true;
  1505. _trigHeaterCenterToleranceWarning.RST = true;
  1506. _trigHeaterCenterTopToleranceAlarm.RST = true;
  1507. _trigHeaterCenterTopToleranceWarning.RST = true;
  1508. _trigHeaterTopToleranceAlarm.RST = true;
  1509. _trigHeaterTopToleranceWarning.RST = true;
  1510. _trigPressureToleranceAlarm.RST = true;
  1511. _trigPressureToleranceWarning.RST = true;
  1512. _trigInputSignalTimeOutAlarm.RST = true;
  1513. _trigTemperatureConvergenceTimeOutAlarm.RST = true;
  1514. _trigReachTempTimeOutAlarm.RST = true;
  1515. _trigPressureConvergenceTimeOutAlarm.RST = true;
  1516. _trigReachPressureTimeOutAlarm.RST = true;
  1517. _trigAutoProfileTimeOutAlarm.RST = true;
  1518. _trigHeaterProfileFinish.RST = true;
  1519. _trigLeakCheckFinish.RST = true;
  1520. _trigBoatWaitCondition.RST = true;
  1521. _trigAPCWaitCondition.RST = true;
  1522. _trigAUXWaitCondition.RST = true;
  1523. _trigHeaterWaitCondition.RST = true;
  1524. _trigMFCWaitCondition.RST = true;
  1525. _infoHeaterProfileFinish = "";
  1526. _infoAUXWaitCondition = "";
  1527. _infoHeaterWaitCondition = "";
  1528. _infoMFCWaitCondition = "";
  1529. }
  1530. private int GetDBRecipeType(string recipeTypeName)
  1531. {
  1532. if (string.IsNullOrEmpty(recipeTypeName))
  1533. return (int)RecipeTypeEnum.none;
  1534. if (Enum.TryParse<RecipeTypeEnum>(recipeTypeName, true, out var result))
  1535. return (int)result;
  1536. return (int)RecipeTypeEnum.none;
  1537. }
  1538. private void RecipeExec(string type, List<RecipeStep> curSteps, int currentStepNumber, double curStepElpasedTimeBeforePaused, int otherRecipeStartStepNumber = 0)
  1539. {
  1540. var reason = "";
  1541. _stepTimer.Start(curSteps[currentStepNumber].StepTime * 1000 - curStepElpasedTimeBeforePaused);
  1542. _showStepNo = currentStepNumber;
  1543. Notify($"{type} running step {currentStepNumber + 1}:{curSteps[currentStepNumber].StepName}");
  1544. var stopwatch = new Stopwatch();
  1545. stopwatch.Start();
  1546. //执行工艺程序命令
  1547. foreach (var recipeCmd in curSteps[currentStepNumber].RecipeCommands.Keys)
  1548. {
  1549. if (!OP.CanDoOperation($"{_doModule}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1550. {
  1551. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1552. {
  1553. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1554. {
  1555. PMModule.CheckCanDoOperationAlarm.Set($"Can not execute {recipeCmd}, {reason}");
  1556. return;
  1557. }
  1558. else
  1559. {
  1560. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1561. }
  1562. }
  1563. else
  1564. {
  1565. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1566. }
  1567. }
  1568. else
  1569. {
  1570. OP.DoOperation($"{_doModule}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1571. }
  1572. }
  1573. LOG.Write($"step exec time {stopwatch.ElapsedMilliseconds}");
  1574. if (curSteps[currentStepNumber].EndBy == EnumEndByCondition.ByTime && !PMModule.IsBoatMoveToLoadPosition)
  1575. _state = RecipeRunningState.TimeWait;
  1576. else
  1577. _state = RecipeRunningState.ConditionWait;
  1578. _faCallback.RecipeStepStart(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber);
  1579. if (type == "Sub recipe")
  1580. _dbCallback.RecipeStepStart(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber ? PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName : "",
  1581. PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber ? (float)PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime : 0,
  1582. $"{(otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber)}", curSteps[currentStepNumber].StepName, (float)curSteps[currentStepNumber].StepTime,
  1583. $"{PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount}/{PMModule.RecipeRunningInfo.SubRecipeLoopCount}");
  1584. else
  1585. _dbCallback.RecipeStepStart(PMModule.RecipeRunningInfo.InnerId.ToString(), otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber,
  1586. curSteps[currentStepNumber].StepName, (float)curSteps[currentStepNumber].StepTime, "", "", 0, "");
  1587. _fdc.Start(curSteps[currentStepNumber].RecipeCommands);
  1588. }
  1589. public void FACallBack(string triggerModule, string recipeAction, string module, string recipeName, string recipeStep, string jumpStpeId = "", string otherRecipeName = "")
  1590. {
  1591. if (triggerModule == ConstantsCommon.AlarmConditionTrigger)
  1592. {
  1593. switch (recipeAction)
  1594. {
  1595. case UniversalEvents.AlarmConditionTriggerReset:
  1596. _faCallback.AlarmConditionTriggerReset(module, recipeName, recipeStep, otherRecipeName);
  1597. break;
  1598. case UniversalEvents.AlarmConditionTriggerEnd:
  1599. _faCallback.AlarmConditionTriggerEnd(module, recipeName, recipeStep);
  1600. break;
  1601. case UniversalEvents.AlarmConditionTriggerHold:
  1602. _faCallback.AlarmConditionTriggerHold(module, recipeName, recipeStep);
  1603. break;
  1604. case UniversalEvents.AlarmConditionTriggerJumpStep:
  1605. _faCallback.AlarmConditionTriggerJumpStep(module, recipeName, recipeStep, jumpStpeId);
  1606. break;
  1607. case UniversalEvents.AlarmConditionTriggerCallAlarmRecipe:
  1608. _faCallback.AlarmConditionTriggerCallAlarmRecipe(module, recipeName, recipeStep, otherRecipeName);
  1609. break;
  1610. case UniversalEvents.AlarmConditionTriggerCallAbortRecipe:
  1611. _faCallback.AlarmConditionTriggerCallAbortRecipe(module, recipeName, recipeStep, otherRecipeName);
  1612. break;
  1613. }
  1614. Task.Delay(1000).ContinueWith(x =>
  1615. {
  1616. PMModule.RecipeAbnormalEnd(module, recipeName, recipeStep, recipeAction);
  1617. });
  1618. }
  1619. else if (triggerModule == ConstantsCommon.LeakCheckTrigger)
  1620. {
  1621. switch (recipeAction)
  1622. {
  1623. case UniversalEvents.LeakCheckTriggerReset:
  1624. _faCallback.LeakCheckTriggerReset(module, recipeName, recipeStep, otherRecipeName);
  1625. break;
  1626. case UniversalEvents.LeakCheckTriggerEnd:
  1627. _faCallback.LeakCheckTriggerEnd(module, recipeName, recipeStep);
  1628. break;
  1629. case UniversalEvents.LeakCheckTriggerHold:
  1630. _faCallback.LeakCheckTriggerHold(module, recipeName, recipeStep);
  1631. break;
  1632. case UniversalEvents.LeakCheckTriggerJumpStep:
  1633. _faCallback.LeakCheckTriggerJumpStep(module, recipeName, recipeStep, jumpStpeId);
  1634. break;
  1635. case UniversalEvents.LeakCheckTriggerCallAlarmRecipe:
  1636. _faCallback.LeakCheckTriggerCallAlarmRecipe(module, recipeName, recipeStep, otherRecipeName);
  1637. break;
  1638. case UniversalEvents.LeakCheckTriggerCallAbortRecipe:
  1639. _faCallback.LeakCheckTriggerCallAbortRecipe(module, recipeName, recipeStep, otherRecipeName);
  1640. break;
  1641. }
  1642. Task.Delay(1000).ContinueWith(x =>
  1643. {
  1644. PMModule.RecipeAbnormalEnd(module, recipeName, recipeStep, recipeAction);
  1645. });
  1646. }
  1647. else if (triggerModule == ConstantsCommon.ManualTrigger)
  1648. {
  1649. switch (recipeAction)
  1650. {
  1651. case UniversalEvents.ManualTriggerRecipeHold:
  1652. _faCallback.ManualTriggerRecipeHold(module, recipeName, recipeStep);
  1653. break;
  1654. case UniversalEvents.ManualTriggerRecipeRelease:
  1655. _faCallback.ManualTriggerRecipeRelease(module, recipeName, recipeStep);
  1656. break;
  1657. case UniversalEvents.ManualTriggerRecipeSkip:
  1658. _faCallback.ManualTriggerRecipeSkip(module, recipeName, recipeStep);
  1659. break;
  1660. case UniversalEvents.ManualTriggerRecipeJump:
  1661. _faCallback.ManualTriggerRecipeJump(module, recipeName, recipeStep, jumpStpeId);
  1662. break;
  1663. case UniversalEvents.ManualTriggerRecipeAbort:
  1664. _faCallback.ManualTriggerRecipeAbort(module, recipeName, recipeStep, otherRecipeName);
  1665. break;
  1666. }
  1667. Task.Delay(1000).ContinueWith(x =>
  1668. {
  1669. PMModule.RecipeAbnormalEnd(module, recipeName, recipeStep, recipeAction);
  1670. });
  1671. }
  1672. else if (triggerModule == ConstantsCommon.RecipeTrigger)
  1673. {
  1674. switch (recipeAction)
  1675. {
  1676. case UniversalEvents.RecipeTriggerReset:
  1677. _faCallback.RecipeTriggerReset(module, recipeName, recipeStep, otherRecipeName);
  1678. break;
  1679. case UniversalEvents.RecipeTriggerEnd:
  1680. _faCallback.RecipeTriggerEnd(module, recipeName, recipeStep);
  1681. break;
  1682. case UniversalEvents.RecipeTriggerHold:
  1683. _faCallback.RecipeTriggerHold(module, recipeName, recipeStep);
  1684. break;
  1685. case UniversalEvents.RecipeTriggerLeakCheck:
  1686. _faCallback.RecipeTriggerLeakCheck(module, recipeName, recipeStep);
  1687. break;
  1688. case UniversalEvents.RecipeTriggerJumpStep:
  1689. _faCallback.RecipeTriggerJumpStep(module, recipeName, recipeStep, otherRecipeName);
  1690. break;
  1691. case UniversalEvents.RecipeTriggerCallSubRecipe:
  1692. _faCallback.RecipeTriggerCallSubRecipe(module, recipeName, recipeStep, otherRecipeName);
  1693. break;
  1694. }
  1695. }
  1696. }
  1697. }
  1698. }