Process.cs 86 KB

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