Process.cs 85 KB

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