Process.cs 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035
  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. if (!PMModule.RecipeRunningInfo.IsJobAutoStart && PMModule.RecipeRunningInfo.IsProcessRecipe)
  700. CheckScheduleMaintenanceModule(PMModule.RecipeRunningInfo.RecipeName);
  701. PMModule.ResetFDCRecipeStepName();
  702. Notify("End");
  703. return Result.DONE;
  704. }
  705. case RecipeRunningState.Error:
  706. {
  707. return Result.DONE;
  708. }
  709. default:
  710. break;
  711. }
  712. }
  713. catch (Exception ex)
  714. {
  715. LOG.Write(ex);
  716. return Result.FAIL;
  717. }
  718. }
  719. MonitorRecipeRunInfo();
  720. return Result.RUN;
  721. }
  722. public void CheckScheduleMaintenanceModule(string processName)
  723. {
  724. #region MyRegion
  725. var isScheduleMaintenance = SC.ContainsItem("System.EnableScheduleMaintenance") && SC.GetValue<bool>("System.EnableScheduleMaintenance");
  726. if (isScheduleMaintenance)
  727. {
  728. var pm = (Singleton<EquipmentManager>.Instance.Modules[ModuleName.PM1] as PMModule);
  729. pm.GetAllDBRecord();
  730. pm.CheckBoatRecipeThicknessMoreThan(out var boatRecipeThicknessIsPause, out var boatRecipeThicknessIsPauseJobName);
  731. if (boatRecipeThicknessIsPause)
  732. LOG.Info($"boatRecipeThicknessIsPause trigger JobAutoStart,JobName:{boatRecipeThicknessIsPauseJobName}");
  733. pm.CheckRecipeThicknessMoreThan(processName, out var recipeThicknessMoreThanisPause, out var recipeThicknessMoreThanJobName);
  734. if (recipeThicknessMoreThanisPause)
  735. LOG.Info($"CheckRecipeThicknessMoreThan trigger JobAutoStart,JobName:{recipeThicknessMoreThanJobName}");
  736. pm.CheckRecipeExecuteFreqMoreThan(processName, out var recipeExecuteFreqMoreThanIsPause, out var recipeExecuteFreqMoreThanJobName);
  737. if (recipeExecuteFreqMoreThanIsPause)
  738. LOG.Info($"CheckRecipeExecuteFreqMoreThan trigger JobAutoStart,JobName:{recipeExecuteFreqMoreThanJobName}");
  739. if (RecipeParser.Parse(processName, Module, out var recipeHead, out var recipeSteps, out var reason, "Process"))
  740. {
  741. foreach (var item in recipeSteps)
  742. {
  743. pm.CheckRecipeStepFreqMoreThan(item.StepName, out var recipeStepFreqMoreThanIsPause, out var recipeStepFreqMoreThanJobName);
  744. if (recipeStepFreqMoreThanIsPause)
  745. LOG.Info($"CheckRecipeStepFreqMoreThan trigger JobAutoStart,JobName:{recipeStepFreqMoreThanJobName}");
  746. pm.CheckRecipeStepTimeMoreThan(item.StepName, out var recipeStepTimeMoreThanIsPause, out var recipeStepTimeMoreThanJobName);
  747. if (recipeStepTimeMoreThanIsPause)
  748. LOG.Info($"CheckRecipeStepTimeMoreThan trigger JobAutoStart,JobName:{recipeStepTimeMoreThanJobName}");
  749. pm.CheckRecipeStepGroupThicknessMoreThan(item.StepName, out var recipeStepGroupThicknessMoreThanIsPause, out var recipeStepGroupThicknessMoreThanJobName);
  750. if (recipeStepGroupThicknessMoreThanIsPause)
  751. LOG.Info($"CheckRecipeStepGroupThicknessMoreThan trigger JobAutoStart,JobName:{recipeStepGroupThicknessMoreThanJobName}");
  752. }
  753. }
  754. }
  755. #endregion
  756. }
  757. private void MonitorRecipeRunInfo()
  758. {
  759. PMModule.IsHolded = _state == RecipeRunningState.Paused;
  760. double elapseTime;
  761. double totalElapseTime;
  762. double holdTotalElapseTime;
  763. var step = 0;
  764. if (IsSubReciep)
  765. {
  766. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps != null)
  767. {
  768. if (_stepTimer.IsIdle())
  769. {
  770. elapseTime = (_curStepElpasedTimeBeforePaused / 1000) < 1 ? 0 : _curStepElpasedTimeBeforePaused / 1000;
  771. }
  772. else
  773. {
  774. elapseTime = ((_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000) < 1 ? 0 : (_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000;
  775. }
  776. if (elapseTime > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime)
  777. elapseTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime;
  778. totalElapseTime = _totalElpasedTime + elapseTime > PMModule.RecipeRunningInfo.TotalTime ? PMModule.RecipeRunningInfo.TotalTime : _totalElpasedTime + elapseTime;
  779. if (_holdTimer.IsIdle())
  780. {
  781. holdTotalElapseTime = _holdTimeElpasedTime / 1000;
  782. }
  783. else
  784. {
  785. holdTotalElapseTime = (_holdTimeElpasedTime + _holdTimer.GetElapseTime()) / 1000;
  786. }
  787. PMModule.RecipeRunningInfo.StepElapseTime = elapseTime;
  788. PMModule.RecipeRunningInfo.TotalElapseTime = totalElapseTime;
  789. PMModule.RecipeRunningInfo.HoldTime = holdTotalElapseTime;
  790. PMModule.RecipeRunningInfo.StepTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime;
  791. PMModule.RecipeRunningInfo.RecipeName = $"Sub/{PMModule.RecipeRunningInfo.Head.SubRecipe}-{PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeTableInfo}-{PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName}";
  792. PMModule.RecipeRunningInfo.ExecRecipeType = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].RecipeType;
  793. PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount = PMModule.RecipeRunningInfo.SubRecipeLoopCount - PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount + 1;
  794. PMModule.RecipeRunningInfo.SubRecipeName = PMModule.RecipeRunningInfo.Head.SubRecipe;
  795. PMModule.RecipeRunningInfo.SubRecipeTable = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeTableInfo;
  796. step = _currentSubRecipeStepNumber;
  797. if (_state == RecipeRunningState.Paused)
  798. {
  799. //pause之后,当前step执行完,显示的step要保持hold住的这一步的
  800. step--;
  801. if (step < 0)
  802. step = 0;
  803. }
  804. PMModule.RecipeRunningInfo.StepNumber = step + 1; //CurStepNum start from 0
  805. PMModule.RecipeRunningInfo.StepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].StepName;
  806. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].IsLoopEndStep)
  807. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps.Count > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].LoopStartStep ?
  808. PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].LoopStartStep].StepName : "";
  809. else
  810. {
  811. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps.Count > step + 1)
  812. {
  813. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step + 1].StepName;
  814. }
  815. else
  816. {
  817. if (PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount < PMModule.RecipeRunningInfo.SubRecipeLoopCount)
  818. {
  819. //sub 下一个循环
  820. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[0].StepName;
  821. }
  822. else
  823. {
  824. //sub执行结束
  825. if (PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber)
  826. {
  827. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName;
  828. }
  829. }
  830. }
  831. }
  832. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName.ToLower() == "standby")
  833. {
  834. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Standby.ToString();
  835. }
  836. else
  837. {
  838. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Run.ToString();
  839. }
  840. }
  841. return;
  842. }
  843. if (_stepTimer.IsIdle())
  844. {
  845. elapseTime = (_curStepElpasedTimeBeforePaused / 1000) < 1 ? 0 : _curStepElpasedTimeBeforePaused / 1000;
  846. }
  847. else
  848. {
  849. elapseTime = ((_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000) < 1 ? 0 : (_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000;
  850. }
  851. if (elapseTime > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime)
  852. elapseTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  853. totalElapseTime = _totalElpasedTime + elapseTime > PMModule.RecipeRunningInfo.TotalTime ? PMModule.RecipeRunningInfo.TotalTime : _totalElpasedTime + elapseTime;
  854. if (_holdTimer.IsIdle())
  855. {
  856. holdTotalElapseTime = _holdTimeElpasedTime / 1000;
  857. }
  858. else
  859. {
  860. holdTotalElapseTime = (_holdTimeElpasedTime + _holdTimer.GetElapseTime()) / 1000;
  861. }
  862. PMModule.RecipeRunningInfo.StepElapseTime = elapseTime;
  863. PMModule.RecipeRunningInfo.TotalElapseTime = totalElapseTime;
  864. PMModule.RecipeRunningInfo.HoldTime = holdTotalElapseTime;
  865. PMModule.RecipeRunningInfo.StepTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  866. PMModule.RecipeRunningInfo.RecipeName = PMModule.RecipeRunningInfo.MainRecipeName;
  867. PMModule.RecipeRunningInfo.ExecRecipeType = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].RecipeType;
  868. if (_state == RecipeRunningState.RecipeCompleted)
  869. {
  870. PMModule.RecipeRunningInfo.HoldTime = 0;
  871. }
  872. step = _currentStepNumber;
  873. if (_state == RecipeRunningState.Paused)
  874. {
  875. //pause之后,当前step执行完,显示的step要保持hold住的这一步的
  876. step--;
  877. if (step < 0)
  878. step = 0;
  879. }
  880. if (PMModule.RecipeRunningInfo.RecipeStepList[0].StepName.ToLower() == "standby")
  881. {
  882. PMModule.RecipeRunningInfo.StepNumber = step; //CurStepNum start from 0
  883. }
  884. else
  885. {
  886. PMModule.RecipeRunningInfo.StepNumber = step + 1; //CurStepNum start from 0
  887. }
  888. PMModule.RecipeRunningInfo.StepName = PMModule.RecipeRunningInfo.RecipeStepList[_showStepNo].StepName;
  889. if (PMModule.RecipeRunningInfo.RecipeStepList[step].IsLoopEndStep)
  890. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList.Count > PMModule.RecipeRunningInfo.RecipeStepList[step].LoopStartStep ? PMModule.RecipeRunningInfo.RecipeStepList[PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].LoopStartStep].StepName : "";
  891. else
  892. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList.Count > step + 1 ? PMModule.RecipeRunningInfo.RecipeStepList[step + 1].StepName : "";
  893. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName.ToLower() == "standby")
  894. {
  895. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Standby.ToString();
  896. }
  897. else if (PMModule.RecipeRunningInfo.RecipeStepList.Count - 1 == _currentStepNumber)
  898. {
  899. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.End.ToString();
  900. }
  901. else
  902. {
  903. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Run.ToString();
  904. }
  905. }
  906. private void MonitorRecipeAlaramAction()
  907. {
  908. if (_state != RecipeRunningState.TimeWait && _state != RecipeRunningState.ConditionWait)
  909. return;
  910. if (_alarmNames.Count == 0)
  911. return;
  912. int group = -1, temp = 0;
  913. string iAlarmConditionTable = "1:";
  914. if (IsSubReciep)
  915. {
  916. for (int i = 0; i < _alarmNames.Count; i++)
  917. {
  918. iAlarmConditionTable = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmConditionTable;
  919. temp = (int)Singleton<EventManager>.Instance.AlarmDic[iAlarmConditionTable.ToString()][_alarmNames[i]].Group;
  920. if (!PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets.ContainsKey(temp))
  921. continue;
  922. var type = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[temp].ProcessingType;
  923. if (temp >= group && (group == -1 || type != "Ignore Alarm"))
  924. group = temp;
  925. }
  926. }
  927. else
  928. {
  929. for (int i = 0; i < _alarmNames.Count; i++)
  930. {
  931. iAlarmConditionTable = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmConditionTable;
  932. temp = (int)Singleton<EventManager>.Instance.AlarmDic[iAlarmConditionTable.ToString()][_alarmNames[i]].Group;
  933. if (!PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets.ContainsKey(temp))
  934. continue;
  935. var type = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[temp].ProcessingType;
  936. if (temp >= group && (group == -1 || type != "Ignore Alarm"))
  937. group = temp;
  938. }
  939. }
  940. _alarmNames.Clear();
  941. if (group == -1)
  942. return;
  943. string alarmAction = "", alarmDetails = "";
  944. List<RecipeStep> abortRecipes = new List<RecipeStep>();
  945. if (IsSubReciep)
  946. {
  947. alarmAction = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[group].ProcessingType;
  948. alarmDetails = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[group].ProcessingDetails;
  949. abortRecipes = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].AlarmActionSets[group].AbortRecipeStepList;
  950. }
  951. else
  952. {
  953. alarmAction = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[group].ProcessingType;
  954. alarmDetails = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[group].ProcessingDetails;
  955. abortRecipes = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AlarmActionSets[group].AbortRecipeStepList;
  956. }
  957. switch (alarmAction)
  958. {
  959. case "Jump Abort Recipe":
  960. alarmDetails = alarmDetails.Replace("Abort Recipe/", string.Empty);
  961. Abort();
  962. _alarmAction = RecipeAlaramAction.JumpAbortRecipe;
  963. break;
  964. case "Jump Step":
  965. alarmDetails = alarmDetails.Replace("Jump Step/", string.Empty);
  966. _jumpStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.FindIndex(x => x.StepName == alarmDetails);
  967. _alarmAction = RecipeAlaramAction.JumpStep;
  968. _state = RecipeRunningState.StepCompleted;
  969. break;
  970. case "Jump Step(Cancel Call Loop)":
  971. alarmDetails = alarmDetails.Replace("Jump Step(Cancel Call Loop)/", string.Empty);
  972. _jumpStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.FindIndex(x => x.StepName == alarmDetails);
  973. _alarmAction = RecipeAlaramAction.JumpStepCancelCallLoop;
  974. IsJumpStepCancelCallLoop = true;
  975. _state = RecipeRunningState.StepCompleted;
  976. break;
  977. case "Abort":
  978. IsExecuteAbort = true;
  979. break;
  980. case "Hold":
  981. PMModule.IsPaused = true;
  982. ContinueAction = RecipeContinueMode.None;
  983. _alarmAction = RecipeAlaramAction.Hold;
  984. break;
  985. case "Ignore Alarm":
  986. _alarmAction = RecipeAlaramAction.IgnoreAlaram;
  987. break;
  988. default:
  989. _alarmAction = RecipeAlaramAction.IgnoreAlaram;
  990. break;
  991. }
  992. }
  993. private void MonitorRecipePause()
  994. {
  995. if (_state != RecipeRunningState.TimeWait && _state != RecipeRunningState.ConditionWait)
  996. return;
  997. //if (PMModule.IsPaused)
  998. //{
  999. // _state = RecipeRunningState.Paused;
  1000. //}
  1001. }
  1002. public override void Abort()
  1003. {
  1004. //PMModule.AbortRecipe();//暂时这么做
  1005. PMModule.RecipeRunningInfo.IsLooping = false;
  1006. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1007. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1008. IsExecuteAbort = true;
  1009. IsSubReciep = false;
  1010. PMModule.IsPaused = false;
  1011. PMModule.IsHeaterProfile = false;
  1012. PMModule.IsHeaterProfileSuccess = false;
  1013. if (!_holdTimer.IsIdle())
  1014. {
  1015. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  1016. _holdTimer.Stop();
  1017. }
  1018. CurrentLoopCount = 0;
  1019. CurrentAbortRecipeLoopCount = 0;
  1020. CurrentSubRecipeLoopCount = 0;
  1021. _state = RecipeRunningState.RecipeCompleted;//暂时这么做
  1022. //更新步次结束时间
  1023. var step = IsSubReciep ? _currentSubRecipeStepNumber + 1 : _currentStepNumber;
  1024. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), step, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  1025. return;//暂时这么做
  1026. //_totalElpasedTime = 0;
  1027. PMModule.RecipeRunningInfo.BeginTime = DateTime.Now;
  1028. double total = 0;
  1029. for (int i = 0; i < PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AbortRecipeSteps.Count; i++)
  1030. {
  1031. total += PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AbortRecipeSteps[i].StepTime;
  1032. }
  1033. PMModule.RecipeRunningInfo.TotalTime = _totalElpasedTime + total;
  1034. ResetTrig();
  1035. //PMModule.ResetToleranceAlarm();
  1036. //PMModule.ResetToleranceAlarmChecker();
  1037. PMModule.ExecuteAbortRecipeWarning.Set($"from recipe name:{PMModule.RecipeRunningInfo.RecipeName} step:{_currentStepNumber} start execute abort recipe.");
  1038. _state = RecipeRunningState.ExecStep;
  1039. }
  1040. public void UpdateProcessDataPJid(string pjId)
  1041. {
  1042. _dbCallback.RecipeUpdatePjId(PMModule.RecipeRunningInfo.InnerId.ToString(), pjId);
  1043. }
  1044. public void ExitProcess()
  1045. {
  1046. if (_state == RecipeRunningState.RecipeCompleted)
  1047. {
  1048. if (!_hasItBeenTriggeredRecipeComplete)
  1049. _faCallback.RecipeComplete(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  1050. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Standby.ToString();
  1051. _dbCallback.RecipeComplete(PMModule.RecipeRunningInfo.InnerId.ToString());
  1052. _fdc.Stop();
  1053. }
  1054. else
  1055. {
  1056. if (PMModule.IsExcuteIdleRecipe)
  1057. {
  1058. if (!_hasItBeenTriggeredRecipeComplete)
  1059. _faCallback.RecipeComplete(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  1060. _dbCallback.RecipeComplete(PMModule.RecipeRunningInfo.InnerId.ToString());
  1061. _fdc.Stop();
  1062. }
  1063. else
  1064. {
  1065. _faCallback.RecipeFailed(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  1066. _dbCallback.RecipeFailed(PMModule.RecipeRunningInfo.InnerId.ToString());
  1067. _fdc.Stop();
  1068. };
  1069. }
  1070. _hasItBeenTriggeredRecipeComplete = false;
  1071. }
  1072. public void PauseRecipe()
  1073. {
  1074. PMModule.IsPaused = true;
  1075. ContinueAction = RecipeContinueMode.None;
  1076. }
  1077. public void ContinueRecipe()
  1078. {
  1079. PMModule.IsPaused = false;
  1080. ContinueAction = RecipeContinueMode.StepContinue;
  1081. var step = IsSubReciep ? _currentSubRecipeStepNumber + 1 : _currentStepNumber;
  1082. }
  1083. public void SkipCurrentRecipeStep()
  1084. {
  1085. if (_state == RecipeRunningState.ConditionWait || _state == RecipeRunningState.TimeWait || _state == RecipeRunningState.Paused)
  1086. {
  1087. _state = RecipeRunningState.StepCompleted;
  1088. _loopEnd = true;
  1089. PMModule.RecipeRunningInfo.IsLooping = false;
  1090. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1091. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1092. PMModule.IsPaused = false;
  1093. if (!_holdTimer.IsIdle())
  1094. {
  1095. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  1096. _holdTimer.Stop();
  1097. }
  1098. }
  1099. if (IsSubReciep)
  1100. {
  1101. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps, _currentSubRecipeStepNumber);
  1102. }
  1103. else
  1104. {
  1105. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList, _currentStepNumber);
  1106. }
  1107. }
  1108. private void ResetLoop(List<RecipeStep> checkRecipeSeps, int currentStepNumber)
  1109. {
  1110. if (checkRecipeSeps == null)
  1111. return;
  1112. var hasLoopStart = false;
  1113. for (int i = currentStepNumber; i >= 0; i--)
  1114. {
  1115. if (checkRecipeSeps[i].IsLoopStartStep)
  1116. {
  1117. hasLoopStart = true;
  1118. break;
  1119. }
  1120. if (checkRecipeSeps[i].IsLoopEndStep)
  1121. {
  1122. hasLoopStart = false;//前面有end,说明没有循环
  1123. break;
  1124. }
  1125. }
  1126. if (hasLoopStart)
  1127. {
  1128. for (int i = currentStepNumber; i < checkRecipeSeps.Count; i++)
  1129. {
  1130. if (checkRecipeSeps[i].IsLoopStartStep)
  1131. {
  1132. break;//没有循环
  1133. }
  1134. if (checkRecipeSeps[i].IsLoopEndStep)
  1135. {
  1136. checkRecipeSeps[i].IsLoopEndStep = false;//跳出skip step之间的循环
  1137. break;
  1138. }
  1139. }
  1140. }
  1141. }
  1142. public void LeakCheckRetry()
  1143. {
  1144. JumpCurrentRecipeStep(_currentStepNumber - 1, PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber - 1].StepName);
  1145. }
  1146. public void JumpCurrentRecipeStep(int stepNumber, string stepName, bool isAlarmConditionCall = false)
  1147. {
  1148. PMModule.StopLeakCheckTimer();
  1149. LOG.Write($"Jump to step stepNumber={stepNumber} stepName={stepName}, currentStepNumber={_currentStepNumber}");
  1150. if (_state == RecipeRunningState.ConditionWait || _state == RecipeRunningState.TimeWait ||
  1151. _state == RecipeRunningState.Paused || _state == RecipeRunningState.ExecStep)
  1152. {
  1153. _loopEnd = true;
  1154. PMModule.RecipeRunningInfo.IsLooping = false;
  1155. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1156. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1157. CurrentLoopCount = 0;
  1158. CurrentAbortRecipeLoopCount = 0;
  1159. CurrentSubRecipeLoopCount = 0;
  1160. IsSubReciep = false;
  1161. if (IsSubReciep)
  1162. {
  1163. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentSubRecipeStepNumber + 1);
  1164. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentSubRecipeStepNumber + 1, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  1165. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps, _currentSubRecipeStepNumber);
  1166. }
  1167. else
  1168. {
  1169. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentStepNumber);
  1170. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  1171. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList, _currentStepNumber);
  1172. }
  1173. if (_callSubSteps != null)
  1174. {
  1175. foreach (var key in _callSubSteps.Keys)
  1176. {
  1177. if (PMModule.RecipeRunningInfo.RecipeStepList.Count > key)
  1178. {
  1179. PMModule.RecipeRunningInfo.RecipeStepList[key].IsCallSubStep = _callSubSteps[key].Item1;
  1180. PMModule.RecipeRunningInfo.RecipeStepList[key].SubRecipeLoopCount = _callSubSteps[key].Item2;
  1181. }
  1182. }
  1183. _currentSubRecipeStepNumber = CurSubRecipeStepTotalLoopCount = 0;
  1184. }
  1185. _isJumpStep = true;
  1186. _currentStepNumber = stepNumber - 1;
  1187. if (_currentStepNumber < 0)
  1188. _currentStepNumber = 0;
  1189. _totalElpasedTime = RefreshElpasedTime();
  1190. _state = RecipeRunningState.StepCompleted;
  1191. PMModule.IsPaused = false;
  1192. if (!_holdTimer.IsIdle())
  1193. {
  1194. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  1195. _holdTimer.Stop();
  1196. }
  1197. }
  1198. }
  1199. private double RefreshElpasedTime()
  1200. {
  1201. double total = 0;
  1202. try
  1203. {
  1204. for (int i = 0; i < _currentStepNumber; i++)
  1205. {
  1206. if (!PMModule.RecipeRunningInfo.RecipeStepList[i].IsJumpStep)
  1207. {
  1208. if (PMModule.RecipeRunningInfo.RecipeStepList[i].IsLoopEndStep)
  1209. {
  1210. int iLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[i].LoopStartStep;
  1211. for (int j = 0; j < PMModule.RecipeRunningInfo.RecipeStepList[i].LoopCount; j++)
  1212. {
  1213. for (int m = iLoopStartStep; m <= i; m++)
  1214. {
  1215. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1216. {
  1217. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1218. }
  1219. total += PMModule.RecipeRunningInfo.RecipeStepList[m].StepTime;
  1220. }
  1221. }
  1222. }
  1223. else
  1224. {
  1225. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null &&
  1226. PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1227. {
  1228. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1229. }
  1230. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1231. }
  1232. }
  1233. }
  1234. }
  1235. catch (Exception ex)
  1236. {
  1237. LOG.Write(ex);
  1238. return -1;
  1239. }
  1240. return (int)total;
  1241. }
  1242. public void RespondAlarm(string name)
  1243. {
  1244. if (!_alarmNames.Contains(name))
  1245. _alarmNames.Add(name);
  1246. }
  1247. protected int CalcRecipeTime()
  1248. {
  1249. double total = 0;
  1250. int iStart = PMModule.IsJobProcess ? 1 : 0;
  1251. try
  1252. {
  1253. for (int i = iStart; i < PMModule.RecipeRunningInfo.RecipeStepList.Count; i++)
  1254. //for (int i = PMModule.RecipeRunningInfo.RecipeStepList.Count - 1; i <= iStart; i--)
  1255. {
  1256. if (!PMModule.RecipeRunningInfo.RecipeStepList[i].IsJumpStep)
  1257. {
  1258. if (PMModule.RecipeRunningInfo.RecipeStepList[i].IsLoopEndStep)
  1259. {
  1260. int iLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[i].LoopStartStep;
  1261. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1262. for (int j = 0; j < PMModule.RecipeRunningInfo.RecipeStepList[i].LoopCount - 1; j++)
  1263. {
  1264. for (int m = iLoopStartStep; m <= i; m++)
  1265. {
  1266. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1267. {
  1268. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1269. }
  1270. total += PMModule.RecipeRunningInfo.RecipeStepList[m].StepTime;
  1271. }
  1272. }
  1273. }
  1274. else
  1275. {
  1276. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1277. {
  1278. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1279. }
  1280. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1281. }
  1282. }
  1283. else
  1284. {
  1285. i = PMModule.RecipeRunningInfo.RecipeStepList[i].JumpStepNo - 1;// -1是因为i++
  1286. }
  1287. if (i < PMModule.RecipeRunningInfo.RecipeStepList.Count - 1)
  1288. {
  1289. _remainTimeExcludeEnd = total;//获取除最后一步外的process时间,End步会cooling
  1290. }
  1291. }
  1292. }
  1293. catch (Exception ex)
  1294. {
  1295. LOG.Write(ex);
  1296. return -1;
  1297. }
  1298. return (int)total;
  1299. }
  1300. private int AbortRecipeCalTotalTime()
  1301. {
  1302. double total = 0;
  1303. List<RecipeStep> abortRecipeSteps;
  1304. abortRecipeSteps = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AbortRecipeSteps;
  1305. try
  1306. {
  1307. for (int i = 0; i < abortRecipeSteps.Count; i++)
  1308. {
  1309. if (!abortRecipeSteps[i].IsJumpStep)
  1310. {
  1311. if (abortRecipeSteps[i].IsLoopStartStep)
  1312. {
  1313. int iLoopEndStep = 0;
  1314. for (int j = 0; j < abortRecipeSteps[i].LoopCount; j++)
  1315. {
  1316. for (int m = i; m < abortRecipeSteps.Count; m++)
  1317. {
  1318. total += abortRecipeSteps[m].StepTime;
  1319. if (abortRecipeSteps[m].IsLoopEndStep)
  1320. {
  1321. iLoopEndStep = m;
  1322. break;
  1323. }
  1324. }
  1325. }
  1326. i = iLoopEndStep;
  1327. }
  1328. else
  1329. {
  1330. total += abortRecipeSteps[i].StepTime;
  1331. }
  1332. }
  1333. else
  1334. {
  1335. i = abortRecipeSteps[i].JumpStepNo - 1;// -1是因为i++
  1336. }
  1337. }
  1338. }
  1339. catch (Exception ex)
  1340. {
  1341. LOG.Write(ex);
  1342. return -1;
  1343. }
  1344. return (int)total;
  1345. }
  1346. public void SetContinue(string continueMode)
  1347. {
  1348. switch (continueMode)
  1349. {
  1350. case "Step continue":
  1351. ContinueAction = RecipeContinueMode.StepContinue;
  1352. break;
  1353. case "Step restart":
  1354. ContinueAction = RecipeContinueMode.StepRestart;
  1355. break;
  1356. case "Next step":
  1357. ContinueAction = RecipeContinueMode.NextStep;
  1358. break;
  1359. case "Recipe restart":
  1360. ContinueAction = RecipeContinueMode.RecipeRestart;
  1361. break;
  1362. case "Recipe complete":
  1363. ContinueAction = RecipeContinueMode.RecipeCompleted;
  1364. break;
  1365. case "Wafer return and job stop":
  1366. ContinueAction = RecipeContinueMode.WaferReturnAndJobStop;
  1367. break;
  1368. }
  1369. PMModule.ResetToleranceChecker();
  1370. }
  1371. private double SubRecipeCalTotalTime(int currentStepNumber)
  1372. {
  1373. double total = 0;
  1374. for (int k = _currentSubRecipeStepNumber; k < PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps.Count; k++)
  1375. {
  1376. if (!PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].IsJumpStep)
  1377. {
  1378. if (PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].IsLoopEndStep)
  1379. {
  1380. int iSystemLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].LoopStartStep;
  1381. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].StepTime;
  1382. for (int n = 0; n < PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].LoopCount - 1; n++)
  1383. {
  1384. for (int l = iSystemLoopStartStep; l <= k; l++)
  1385. {
  1386. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[l].StepTime;
  1387. }
  1388. }
  1389. }
  1390. else
  1391. {
  1392. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].StepTime;
  1393. }
  1394. }
  1395. else
  1396. {
  1397. k = PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].JumpStepNo - 1;// -1是因为k++
  1398. }
  1399. }
  1400. return total;
  1401. }
  1402. private void SubRecipeLoopEndCheck(List<RecipeStep> recipeSteps)
  1403. {
  1404. if (_alarmAction == RecipeAlaramAction.JumpStep || _alarmAction == RecipeAlaramAction.JumpStepCancelCallLoop)
  1405. {
  1406. _currentSubRecipeStepNumber = _jumpStepNumber;
  1407. _alarmAction = RecipeAlaramAction.None;
  1408. _alarmNames.Clear();
  1409. return;
  1410. }
  1411. if (recipeSteps[_currentSubRecipeStepNumber].IsLoopEndStep)
  1412. {
  1413. if (IsJumpStepCancelCallLoop)
  1414. {
  1415. _currentSubRecipeStepNumber++;
  1416. IsJumpStepCancelCallLoop = false;
  1417. return;
  1418. }
  1419. //重新读取循环的设定次数
  1420. CurSubRecipeStepTotalLoopCount = recipeSteps[_currentSubRecipeStepNumber].LoopCount;
  1421. if (CurrentSubRecipeLoopCount >= CurSubRecipeStepTotalLoopCount)
  1422. {
  1423. CurrentSubRecipeLoopCount = CurSubRecipeStepTotalLoopCount = 0;
  1424. _currentSubRecipeStepNumber++;
  1425. PMModule.RecipeRunningInfo.IsLooping = false;
  1426. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1427. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1428. }
  1429. else
  1430. {
  1431. _currentSubRecipeStepNumber = recipeSteps[_currentSubRecipeStepNumber].LoopStartStep;
  1432. }
  1433. }
  1434. else
  1435. {
  1436. _currentSubRecipeStepNumber++;
  1437. }
  1438. }
  1439. private void RecipeLoopEndCheck(List<RecipeStep> recipeSteps)
  1440. {
  1441. if (_alarmAction == RecipeAlaramAction.JumpStep || _alarmAction == RecipeAlaramAction.JumpStepCancelCallLoop)
  1442. {
  1443. _currentStepNumber = _jumpStepNumber;
  1444. _alarmAction = RecipeAlaramAction.None;
  1445. _alarmNames.Clear();
  1446. return;
  1447. }
  1448. if (recipeSteps[_currentStepNumber].IsLoopEndStep)
  1449. {
  1450. if (IsJumpStepCancelCallLoop)
  1451. {
  1452. _currentStepNumber++;
  1453. IsJumpStepCancelCallLoop = false;
  1454. return;
  1455. }
  1456. //重新读取循环的设定次数
  1457. CurStepTotalLoopCount = recipeSteps[_currentStepNumber].LoopCount;
  1458. if (CurrentLoopCount >= CurStepTotalLoopCount)
  1459. {
  1460. CurrentLoopCount = CurStepTotalLoopCount = 0;
  1461. _currentStepNumber++;
  1462. PMModule.RecipeRunningInfo.IsLooping = false;
  1463. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1464. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1465. }
  1466. else
  1467. {
  1468. _currentStepNumber = recipeSteps[_currentStepNumber].LoopStartStep;
  1469. }
  1470. }
  1471. else
  1472. {
  1473. _currentStepNumber++;
  1474. }
  1475. }
  1476. private void CheckTolerance()
  1477. {
  1478. //foreach (var key in _trigMfcToleranceAlarms.Keys)
  1479. //{
  1480. // if (PMModule.GasMFCs.ContainsKey(key) && _trigMfcToleranceWarnings.ContainsKey(key))
  1481. // {
  1482. // _trigMfcToleranceAlarms[key].CLK = PMModule.GasMFCs[key].CheckToleranceAlarm();
  1483. // if (_trigMfcToleranceAlarms[key].Q)
  1484. // PMModule.GasMFCs[key].SetToleranceAlarm();
  1485. // _trigMfcToleranceWarnings[key].CLK = PMModule.GasMFCs[key].CheckToleranceWarning();
  1486. // if (_trigMfcToleranceWarnings[key].Q && !_trigMfcToleranceAlarms[key].Q)
  1487. // PMModule.GasMFCs[key].SetToleranceWarning();
  1488. // }
  1489. //}
  1490. //_trigHeaterBottomToleranceAlarm.CLK = PMModule.CheckHeaterBottomToleranceAlaram();
  1491. //if (_trigHeaterBottomToleranceAlarm.Q)
  1492. // PMModule.SetHeaterBottomToleranceAlaram();
  1493. //_trigHeaterBottomToleranceWarning.CLK = PMModule.CheckHeaterBottomToleranceWarning();
  1494. //if (_trigHeaterBottomToleranceWarning.Q && !_trigHeaterBottomToleranceAlarm.Q)
  1495. // PMModule.SetHeaterBottomToleranceWarning();
  1496. //_trigHeaterCenterBottomToleranceAlarm.CLK = PMModule.CheckHeaterCenterBottomToleranceAlaram();
  1497. //if (_trigHeaterCenterBottomToleranceAlarm.Q)
  1498. // PMModule.SetHeaterCenterBottomToleranceAlaram();
  1499. //_trigHeaterCenterBottomToleranceWarning.CLK = PMModule.CheckHeaterCenterBottomToleranceWarning();
  1500. //if (_trigHeaterCenterBottomToleranceWarning.Q && !_trigHeaterCenterBottomToleranceAlarm.Q)
  1501. // PMModule.SetHeaterCenterBottomToleranceWarning();
  1502. //_trigHeaterCenterToleranceAlarm.CLK = PMModule.CheckHeaterCenterToleranceAlaram();
  1503. //if (_trigHeaterCenterToleranceAlarm.Q)
  1504. // PMModule.SetHeaterCenterToleranceAlaram();
  1505. //_trigHeaterCenterToleranceWarning.CLK = PMModule.CheckHeaterCenterToleranceWarning();
  1506. //if (_trigHeaterCenterToleranceWarning.Q && !_trigHeaterCenterToleranceAlarm.Q)
  1507. // PMModule.SetHeaterCenterToleranceWarning();
  1508. //_trigHeaterCenterTopToleranceAlarm.CLK = PMModule.CheckHeaterCenterTopToleranceAlaram();
  1509. //if (_trigHeaterCenterTopToleranceAlarm.Q)
  1510. // PMModule.SetHeaterCenterTopToleranceAlaram();
  1511. //_trigHeaterCenterTopToleranceWarning.CLK = PMModule.CheckHeaterCenterTopToleranceWarning();
  1512. //if (_trigHeaterCenterTopToleranceWarning.Q && !_trigHeaterCenterTopToleranceAlarm.Q)
  1513. // PMModule.SetHeaterCenterTopToleranceWarning();
  1514. //_trigHeaterTopToleranceAlarm.CLK = PMModule.CheckHeaterTopToleranceAlaram();
  1515. //if (_trigHeaterTopToleranceAlarm.Q)
  1516. // PMModule.SetHeaterTopToleranceAlaram();
  1517. //_trigHeaterTopToleranceWarning.CLK = PMModule.CheckHeaterTopToleranceWarning();
  1518. //if (_trigHeaterTopToleranceWarning.Q && !_trigHeaterTopToleranceAlarm.Q)
  1519. // PMModule.SetHeaterTopToleranceWarning();
  1520. //_trigPressureToleranceAlarm.CLK = PMModule.CheckPressureToleranceAlaram();
  1521. //if (_trigPressureToleranceAlarm.Q)
  1522. // PMModule.SetPressureToleranceAlaram();
  1523. //_trigPressureToleranceWarning.CLK = PMModule.CheckPressureToleranceWarning();
  1524. //if (_trigPressureToleranceWarning.Q && !_trigPressureToleranceAlarm.Q)
  1525. // PMModule.SetPressureToleranceWarning();
  1526. }
  1527. private void ResetTrig()
  1528. {
  1529. PMModule.ResetAlarmCondition();
  1530. foreach (var key in _trigMfcToleranceAlarms.Keys)
  1531. {
  1532. if (_trigMfcToleranceWarnings.ContainsKey(key))
  1533. {
  1534. _trigMfcToleranceAlarms[key].RST = true;
  1535. _trigMfcToleranceWarnings[key].RST = true;
  1536. }
  1537. }
  1538. _trigHeaterBottomToleranceAlarm.RST = true;
  1539. _trigHeaterBottomToleranceWarning.RST = true;
  1540. _trigHeaterCenterBottomToleranceAlarm.RST = true;
  1541. _trigHeaterCenterBottomToleranceWarning.RST = true;
  1542. _trigHeaterCenterToleranceAlarm.RST = true;
  1543. _trigHeaterCenterToleranceWarning.RST = true;
  1544. _trigHeaterCenterTopToleranceAlarm.RST = true;
  1545. _trigHeaterCenterTopToleranceWarning.RST = true;
  1546. _trigHeaterTopToleranceAlarm.RST = true;
  1547. _trigHeaterTopToleranceWarning.RST = true;
  1548. _trigPressureToleranceAlarm.RST = true;
  1549. _trigPressureToleranceWarning.RST = true;
  1550. _trigInputSignalTimeOutAlarm.RST = true;
  1551. _trigTemperatureConvergenceTimeOutAlarm.RST = true;
  1552. _trigReachTempTimeOutAlarm.RST = true;
  1553. _trigPressureConvergenceTimeOutAlarm.RST = true;
  1554. _trigReachPressureTimeOutAlarm.RST = true;
  1555. _trigAutoProfileTimeOutAlarm.RST = true;
  1556. _trigHeaterProfileFinish.RST = true;
  1557. _trigLeakCheckFinish.RST = true;
  1558. _trigBoatWaitCondition.RST = true;
  1559. _trigAPCWaitCondition.RST = true;
  1560. _trigAUXWaitCondition.RST = true;
  1561. _trigHeaterWaitCondition.RST = true;
  1562. _trigMFCWaitCondition.RST = true;
  1563. _infoHeaterProfileFinish = "";
  1564. _infoAUXWaitCondition = "";
  1565. _infoHeaterWaitCondition = "";
  1566. _infoMFCWaitCondition = "";
  1567. }
  1568. private int GetDBRecipeType(string recipeTypeName)
  1569. {
  1570. if (string.IsNullOrEmpty(recipeTypeName))
  1571. return (int)RecipeTypeEnum.none;
  1572. if (Enum.TryParse<RecipeTypeEnum>(recipeTypeName, true, out var result))
  1573. return (int)result;
  1574. return (int)RecipeTypeEnum.none;
  1575. }
  1576. private void RecipeExec(string type, List<RecipeStep> curSteps, int currentStepNumber, double curStepElpasedTimeBeforePaused, int otherRecipeStartStepNumber = 0)
  1577. {
  1578. var reason = "";
  1579. _stepTimer.Start(curSteps[currentStepNumber].StepTime * 1000 - curStepElpasedTimeBeforePaused);
  1580. _showStepNo = currentStepNumber;
  1581. Notify($"{type} running step {currentStepNumber + 1}:{curSteps[currentStepNumber].StepName}");
  1582. var stopwatch = new Stopwatch();
  1583. stopwatch.Start();
  1584. //执行工艺程序命令
  1585. foreach (var recipeCmd in curSteps[currentStepNumber].RecipeCommands.Keys)
  1586. {
  1587. if (!OP.CanDoOperation($"{_doModule}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1588. {
  1589. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1590. {
  1591. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1592. {
  1593. PMModule.CheckCanDoOperationAlarm.Set($"Can not execute {recipeCmd}, {reason}");
  1594. return;
  1595. }
  1596. else
  1597. {
  1598. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1599. }
  1600. }
  1601. else
  1602. {
  1603. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1604. }
  1605. }
  1606. else
  1607. {
  1608. OP.DoOperation($"{_doModule}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1609. }
  1610. }
  1611. LOG.Write($"step exec time {stopwatch.ElapsedMilliseconds}");
  1612. if (curSteps[currentStepNumber].EndBy == EnumEndByCondition.ByTime && !PMModule.IsBoatMoveToLoadPosition)
  1613. _state = RecipeRunningState.TimeWait;
  1614. else
  1615. _state = RecipeRunningState.ConditionWait;
  1616. _faCallback.RecipeStepStart(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber);
  1617. if (type == "Sub recipe")
  1618. _dbCallback.RecipeStepStart(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber ? PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName : "",
  1619. PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber ? (float)PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime : 0,
  1620. $"{(otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber)}", curSteps[currentStepNumber].StepName, (float)curSteps[currentStepNumber].StepTime,
  1621. $"{PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount}/{PMModule.RecipeRunningInfo.SubRecipeLoopCount}");
  1622. else
  1623. _dbCallback.RecipeStepStart(PMModule.RecipeRunningInfo.InnerId.ToString(), otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber,
  1624. curSteps[currentStepNumber].StepName, (float)curSteps[currentStepNumber].StepTime, "", "", 0, "");
  1625. _fdc.Start(curSteps[currentStepNumber].RecipeCommands);
  1626. }
  1627. public void FACallBack(string triggerModule, string recipeAction, string module, string recipeName, string recipeStep, string jumpStpeId = "", string otherRecipeName = "")
  1628. {
  1629. if (triggerModule == ConstantsCommon.AlarmConditionTrigger)
  1630. {
  1631. switch (recipeAction)
  1632. {
  1633. case UniversalEvents.AlarmConditionTriggerReset:
  1634. _faCallback.AlarmConditionTriggerReset(module, recipeName, recipeStep, otherRecipeName);
  1635. break;
  1636. case UniversalEvents.AlarmConditionTriggerEnd:
  1637. _faCallback.AlarmConditionTriggerEnd(module, recipeName, recipeStep);
  1638. break;
  1639. case UniversalEvents.AlarmConditionTriggerHold:
  1640. _faCallback.AlarmConditionTriggerHold(module, recipeName, recipeStep);
  1641. break;
  1642. case UniversalEvents.AlarmConditionTriggerJumpStep:
  1643. _faCallback.AlarmConditionTriggerJumpStep(module, recipeName, recipeStep, jumpStpeId);
  1644. break;
  1645. case UniversalEvents.AlarmConditionTriggerCallAlarmRecipe:
  1646. _faCallback.AlarmConditionTriggerCallAlarmRecipe(module, recipeName, recipeStep, otherRecipeName);
  1647. break;
  1648. case UniversalEvents.AlarmConditionTriggerCallAbortRecipe:
  1649. _faCallback.AlarmConditionTriggerCallAbortRecipe(module, recipeName, recipeStep, otherRecipeName);
  1650. break;
  1651. }
  1652. Task.Delay(1000).ContinueWith(x =>
  1653. {
  1654. PMModule.RecipeAbnormalEnd(module, recipeName, recipeStep, recipeAction);
  1655. });
  1656. }
  1657. else if (triggerModule == ConstantsCommon.LeakCheckTrigger)
  1658. {
  1659. switch (recipeAction)
  1660. {
  1661. case UniversalEvents.LeakCheckTriggerReset:
  1662. _faCallback.LeakCheckTriggerReset(module, recipeName, recipeStep, otherRecipeName);
  1663. break;
  1664. case UniversalEvents.LeakCheckTriggerEnd:
  1665. _faCallback.LeakCheckTriggerEnd(module, recipeName, recipeStep);
  1666. break;
  1667. case UniversalEvents.LeakCheckTriggerHold:
  1668. _faCallback.LeakCheckTriggerHold(module, recipeName, recipeStep);
  1669. break;
  1670. case UniversalEvents.LeakCheckTriggerJumpStep:
  1671. _faCallback.LeakCheckTriggerJumpStep(module, recipeName, recipeStep, jumpStpeId);
  1672. break;
  1673. case UniversalEvents.LeakCheckTriggerCallAlarmRecipe:
  1674. _faCallback.LeakCheckTriggerCallAlarmRecipe(module, recipeName, recipeStep, otherRecipeName);
  1675. break;
  1676. case UniversalEvents.LeakCheckTriggerCallAbortRecipe:
  1677. _faCallback.LeakCheckTriggerCallAbortRecipe(module, recipeName, recipeStep, otherRecipeName);
  1678. break;
  1679. }
  1680. Task.Delay(1000).ContinueWith(x =>
  1681. {
  1682. PMModule.RecipeAbnormalEnd(module, recipeName, recipeStep, recipeAction);
  1683. });
  1684. }
  1685. else if (triggerModule == ConstantsCommon.ManualTrigger)
  1686. {
  1687. switch (recipeAction)
  1688. {
  1689. case UniversalEvents.ManualTriggerRecipeHold:
  1690. _faCallback.ManualTriggerRecipeHold(module, recipeName, recipeStep);
  1691. break;
  1692. case UniversalEvents.ManualTriggerRecipeRelease:
  1693. _faCallback.ManualTriggerRecipeRelease(module, recipeName, recipeStep);
  1694. break;
  1695. case UniversalEvents.ManualTriggerRecipeSkip:
  1696. _faCallback.ManualTriggerRecipeSkip(module, recipeName, recipeStep);
  1697. break;
  1698. case UniversalEvents.ManualTriggerRecipeJump:
  1699. _faCallback.ManualTriggerRecipeJump(module, recipeName, recipeStep, jumpStpeId);
  1700. break;
  1701. case UniversalEvents.ManualTriggerRecipeAbort:
  1702. _faCallback.ManualTriggerRecipeAbort(module, recipeName, recipeStep, otherRecipeName);
  1703. break;
  1704. }
  1705. Task.Delay(1000).ContinueWith(x =>
  1706. {
  1707. PMModule.RecipeAbnormalEnd(module, recipeName, recipeStep, recipeAction);
  1708. });
  1709. }
  1710. else if (triggerModule == ConstantsCommon.RecipeTrigger)
  1711. {
  1712. switch (recipeAction)
  1713. {
  1714. case UniversalEvents.RecipeTriggerReset:
  1715. _faCallback.RecipeTriggerReset(module, recipeName, recipeStep, otherRecipeName);
  1716. break;
  1717. case UniversalEvents.RecipeTriggerEnd:
  1718. _faCallback.RecipeTriggerEnd(module, recipeName, recipeStep);
  1719. break;
  1720. case UniversalEvents.RecipeTriggerHold:
  1721. _faCallback.RecipeTriggerHold(module, recipeName, recipeStep);
  1722. break;
  1723. case UniversalEvents.RecipeTriggerLeakCheck:
  1724. _faCallback.RecipeTriggerLeakCheck(module, recipeName, recipeStep);
  1725. break;
  1726. case UniversalEvents.RecipeTriggerJumpStep:
  1727. _faCallback.RecipeTriggerJumpStep(module, recipeName, recipeStep, otherRecipeName);
  1728. break;
  1729. case UniversalEvents.RecipeTriggerCallSubRecipe:
  1730. _faCallback.RecipeTriggerCallSubRecipe(module, recipeName, recipeStep, otherRecipeName);
  1731. break;
  1732. }
  1733. }
  1734. }
  1735. }
  1736. }