Process.cs 96 KB

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