Process.cs 84 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. ResetTrig();
  242. Notify($"Start");
  243. _faCallback.RecipeStart(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  244. _dbCallback.RecipeStart(PMModule.Module, 0, PMModule.RecipeRunningInfo.InnerId.ToString(), PMModule.RecipeRunningInfo.RecipeName);
  245. _dbCallback.RecipeUpdateStatus(PMModule.RecipeRunningInfo.InnerId.ToString(), "InProcess");
  246. _fdc.Reset();
  247. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), 0, EnumWaferProcessStatus.InProcess);
  248. PMModule.HeaterEnable(true);
  249. return Result.RUN;
  250. }
  251. public override Result Monitor()
  252. {
  253. if (!PMModule.CheckEnableRunProcess(out string reason))
  254. {
  255. PMModule.CheckEnableRunProcessAlarm.Set(reason);
  256. return Result.FAIL;
  257. }
  258. //MonitorRecipeAlaramAction();
  259. //if (IsExecuteAbort)
  260. // return Result.DONE;
  261. MonitorRecipePause();
  262. CheckTolerance();
  263. List<RecipeStep> curSteps;
  264. if ((IsSubReciep || PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].IsCallSubStep) && !_isJumpStep)
  265. {
  266. curSteps = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps;
  267. if (!_callSubSteps.ContainsKey(_currentStepNumber))
  268. _callSubSteps.Add(_currentStepNumber, Tuple.Create(false, 0));
  269. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].IsCallSubStep)
  270. _callSubSteps[_currentStepNumber] = Tuple.Create(true, PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount);
  271. if (!IsSubReciep)
  272. {
  273. PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount = 1;
  274. PMModule.RecipeRunningInfo.SubRecipeLoopCount = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount;
  275. }
  276. PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].IsCallSubStep = false;
  277. IsSubReciep = true;
  278. }
  279. else
  280. {
  281. curSteps = PMModule.RecipeRunningInfo.RecipeStepList;
  282. PMModule.RecipeRunningInfo.SubRecipeLoopCount = 0;
  283. }
  284. lock (_recipeLocker)
  285. {
  286. try
  287. {
  288. switch (_state)
  289. {
  290. case RecipeRunningState.ExecStep:
  291. {
  292. PMModule.IsWait = false;
  293. _loopEnd = false;
  294. if (!_holdTimer.IsIdle())
  295. {
  296. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  297. _holdTimer.Stop();
  298. }
  299. PMModule.ResetToleranceChecker();
  300. _curStepElpasedTimeBeforePaused = 0;
  301. ContinueAction = RecipeContinueMode.None;
  302. if (IsSubReciep)
  303. {
  304. if (curSteps[_currentSubRecipeStepNumber].IsLoopStartStep)
  305. {
  306. CurrentSubRecipeLoopCount++;
  307. PMModule.RecipeRunningInfo.IsLooping = true;
  308. PMModule.RecipeRunningInfo.LoopCountCurrent = CurrentSubRecipeLoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  309. PMModule.RecipeRunningInfo.LoopCountSet = curSteps[_currentSubRecipeStepNumber].LoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  310. }
  311. if (curSteps[_currentSubRecipeStepNumber].IsJumpStep)
  312. {
  313. _currentSubRecipeStepNumber = curSteps[_currentSubRecipeStepNumber].JumpStepNo;
  314. }
  315. RecipeExec("Sub recipe", curSteps, _currentSubRecipeStepNumber, _curStepElpasedTimeBeforePaused, _currentSubRecipeStepNumber + 1);
  316. }
  317. else
  318. {
  319. if (curSteps[_currentStepNumber].IsLoopStartStep)
  320. {
  321. CurrentLoopCount++;
  322. PMModule.RecipeRunningInfo.IsLooping = true;
  323. PMModule.RecipeRunningInfo.LoopCountCurrent = CurrentLoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  324. PMModule.RecipeRunningInfo.LoopCountSet = curSteps[_currentStepNumber].LoopCount - 1;//即使不循环,本身也有一次。本身的一次不算,所以减1
  325. }
  326. if (curSteps[_currentStepNumber].IsJumpStep)
  327. {
  328. curSteps[_currentStepNumber].IsJumpStep = false;//只执行一次
  329. _currentStepNumber = curSteps[_currentStepNumber].JumpStepNo;
  330. }
  331. RecipeExec("Main recipe", curSteps, _currentStepNumber, _curStepElpasedTimeBeforePaused);
  332. }
  333. }
  334. break;
  335. case RecipeRunningState.TimeWait:
  336. //if (PMModule.IsPaused)
  337. //{
  338. // _state = RecipeRunningState.Paused;
  339. // break;
  340. //}
  341. var leakCheck = PMModule.CheckLeakCheckFinish();
  342. _trigLeakCheckFinish.CLK = !leakCheck;
  343. if (_trigLeakCheckFinish.Q)
  344. LOG.Write($"Wait condition:leak check");
  345. if (_stepTimer.IsTimeout())
  346. {
  347. var heaterProfile = PMModule.CheckHeaterProfileFinish(out reason);
  348. _trigHeaterProfileFinish.CLK = !heaterProfile || _infoHeaterProfileFinish != reason;
  349. if (_trigHeaterProfileFinish.Q)
  350. LOG.Write($"Wait condition:heater profile--{reason}");
  351. _infoHeaterProfileFinish = reason;
  352. var boatWaitCondition = PMModule.CheckBoatWaitCondition(out reason);
  353. _trigBoatWaitCondition.CLK = !boatWaitCondition;
  354. if (_trigBoatWaitCondition.Q)
  355. LOG.Write($"Wait condition:boat--{reason}");
  356. var apcWaitCondition = PMModule.CheckAPCWaitCondition(out reason);
  357. _trigAPCWaitCondition.CLK = !apcWaitCondition;
  358. if (_trigAPCWaitCondition.Q)
  359. LOG.Write($"Wait condition:APC--{reason}");
  360. var auxWaitCondition = PMModule.CheckAUXWaitCondition(out reason);
  361. _trigAUXWaitCondition.CLK = !auxWaitCondition || _infoAUXWaitCondition != reason;
  362. if (_trigAUXWaitCondition.Q)
  363. LOG.Write($"Wait condition:heater profile--{reason}");
  364. _infoAUXWaitCondition = reason;
  365. var heaterWaitCondition = PMModule.CheckHeaterWaitCondition(out reason);
  366. _trigHeaterWaitCondition.CLK = !heaterWaitCondition || _infoHeaterWaitCondition != reason;
  367. if (_trigHeaterWaitCondition.Q)
  368. LOG.Write($"Wait condition:heater--{reason}");
  369. _infoHeaterWaitCondition = reason;
  370. var mfcWaitCondition = PMModule.CheckMFCWaitCondition(out reason);
  371. _trigMFCWaitCondition.CLK = !mfcWaitCondition || _infoMFCWaitCondition != reason;
  372. if (_trigMFCWaitCondition.Q)
  373. LOG.Write($"Wait condition:MFC--{reason}");
  374. _infoMFCWaitCondition = reason;
  375. if (heaterProfile &&
  376. leakCheck &&
  377. boatWaitCondition &&
  378. apcWaitCondition &&
  379. auxWaitCondition &&
  380. heaterWaitCondition &&
  381. mfcWaitCondition)
  382. {
  383. _state = RecipeRunningState.StepCompleted;
  384. }
  385. else
  386. {
  387. PMModule.IsWait = true;
  388. }
  389. }
  390. else
  391. {
  392. PMModule.CheckHeaterProfileFinish(out reason);
  393. PMModule.CheckBoatWaitCondition(out reason);
  394. PMModule.CheckAPCWaitCondition(out reason);
  395. PMModule.CheckAUXWaitCondition(out reason);
  396. PMModule.CheckHeaterWaitCondition(out reason);
  397. PMModule.CheckMFCWaitCondition(out reason);
  398. }
  399. break;
  400. case RecipeRunningState.ConditionWait:
  401. {
  402. if (!PMModule.CheckBoatState() && !PMModule.IsBoatMoveToLoadPosition)
  403. break;
  404. var heaterProfile = PMModule.CheckHeaterProfileFinish(out reason);
  405. _trigHeaterProfileFinish.CLK = !heaterProfile || _infoHeaterProfileFinish != reason;
  406. if (_trigHeaterProfileFinish.Q)
  407. LOG.Write($"Wait condition:heater profile--{reason}");
  408. _infoHeaterProfileFinish = reason;
  409. leakCheck = PMModule.CheckLeakCheckFinish();
  410. _trigLeakCheckFinish.CLK = !leakCheck;
  411. if (_trigLeakCheckFinish.Q)
  412. LOG.Write($"Wait condition:leak check");
  413. var boatWaitCondition = PMModule.CheckBoatWaitCondition(out reason);
  414. _trigBoatWaitCondition.CLK = !boatWaitCondition;
  415. if (_trigBoatWaitCondition.Q)
  416. LOG.Write($"Wait condition:boat--{reason}");
  417. var apcWaitCondition = PMModule.CheckAPCWaitCondition(out reason);
  418. _trigAPCWaitCondition.CLK = !apcWaitCondition;
  419. if (_trigAPCWaitCondition.Q)
  420. LOG.Write($"Wait condition:APC--{reason}");
  421. var auxWaitCondition = PMModule.CheckAUXWaitCondition(out reason);
  422. _trigAUXWaitCondition.CLK = !auxWaitCondition || _infoAUXWaitCondition != reason;
  423. if (_trigAUXWaitCondition.Q)
  424. LOG.Write($"Wait condition:heater profile--{reason}");
  425. _infoAUXWaitCondition = reason;
  426. var heaterWaitCondition = PMModule.CheckHeaterWaitCondition(out reason);
  427. _trigHeaterWaitCondition.CLK = !heaterWaitCondition || _infoHeaterWaitCondition != reason;
  428. if (_trigHeaterWaitCondition.Q)
  429. LOG.Write($"Wait condition:heater--{reason}");
  430. _infoHeaterWaitCondition = reason;
  431. var mfcWaitCondition = PMModule.CheckMFCWaitCondition(out reason);
  432. _trigMFCWaitCondition.CLK = !mfcWaitCondition || _infoMFCWaitCondition != reason;
  433. if (_trigMFCWaitCondition.Q)
  434. LOG.Write($"Wait condition:MFC--{reason}");
  435. _infoMFCWaitCondition = reason;
  436. if (heaterProfile &&
  437. leakCheck &&
  438. boatWaitCondition &&
  439. apcWaitCondition &&
  440. auxWaitCondition &&
  441. heaterWaitCondition &&
  442. mfcWaitCondition)
  443. {
  444. _state = RecipeRunningState.StepCompleted;
  445. }
  446. if (_stepTimer.IsTimeout())
  447. {
  448. if (PMModule.IsBoatMoveToLoadPosition)
  449. {
  450. _trigBoatMoveToLoadPositionTimeout.CLK = !boatWaitCondition;
  451. if (_trigBoatMoveToLoadPositionTimeout.Q)
  452. PMModule.BoatMoveToLoadPositionTimeoutWarning.Set();
  453. }
  454. //_trigInputSignalTimeOutAlarm.CLK = !PMModule.CheckExternalSensorCondition();
  455. //if (_trigInputSignalTimeOutAlarm.Q)
  456. // PMModule.InputSignalTimeOutAlarm.Set();
  457. //_trigTemperatureConvergenceTimeOutAlarm.CLK = !PMModule.CheckTempStabilizeCondition();
  458. //if (_trigTemperatureConvergenceTimeOutAlarm.Q)
  459. // PMModule.TemperatureConvergenceTimeOutAlarm.Set();
  460. //_trigReachTempTimeOutAlarm.CLK = !PMModule.CheckReachTempCondition();
  461. //if (_trigReachTempTimeOutAlarm.Q)
  462. // PMModule.TemperatureConvergenceTimeOutAlarm.Set("Reach temp condition timeout");
  463. //_trigPressureConvergenceTimeOutAlarm.CLK = !PMModule.CheckPressureStablilizeCondition();
  464. //if (_trigPressureConvergenceTimeOutAlarm.Q)
  465. // PMModule.PressureConvergenceTimeOutAlarm.Set();
  466. //_trigReachPressureTimeOutAlarm.CLK = !PMModule.CheckReachPressureCondition();
  467. //if (_trigReachPressureTimeOutAlarm.Q)
  468. // PMModule.PressureConvergenceTimeOutAlarm.Set("Reach pressure condition timeout");
  469. //_trigAutoProfileTimeOutAlarm.CLK = !PMModule.CheckFinishAutoProfileCondition();
  470. //if (_trigAutoProfileTimeOutAlarm.Q)
  471. // PMModule.AutoProfileTimeOutAlarm.Set();
  472. //_state = RecipeRunningState.StepCompleted;
  473. }
  474. else
  475. {
  476. _trigBoatMoveToLoadPositionTimeout.RST = true;
  477. }
  478. }
  479. break;
  480. case RecipeRunningState.Paused:
  481. if (!_stepTimer.IsIdle())
  482. {
  483. _curStepElpasedTimeBeforePaused += _stepTimer.GetElapseTime();
  484. _stepTimer.Stop();
  485. }
  486. if (_holdTimer.IsIdle())
  487. _holdTimer.Start(0);
  488. switch (ContinueAction)
  489. {
  490. case RecipeContinueMode.None:
  491. break;
  492. case RecipeContinueMode.StepContinue:
  493. if (!_holdTimer.IsIdle())
  494. {
  495. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  496. _holdTimer.Stop();
  497. }
  498. _state = RecipeRunningState.ExecStep;
  499. _stepTimer.Stop();
  500. break;
  501. }
  502. break;
  503. case RecipeRunningState.StepCompleted:
  504. {
  505. ResetTrig();
  506. //CloseAllValve();
  507. _curStepElpasedTimeBeforePaused = 0;
  508. var stepName = "";
  509. var stepTime = (float)_stepTimer.GetElapseTime() / 1000;//sec
  510. var thickness = 0.0f;
  511. if (IsSubReciep)
  512. {
  513. stepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName;
  514. float.TryParse(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].FilmThickFormula, out thickness);
  515. //放在前面,stepnumber后面会被更新
  516. if (!_isJumpStep)
  517. {
  518. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentSubRecipeStepNumber + 1);
  519. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentSubRecipeStepNumber + 1, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  520. }
  521. _fdc.Stop();
  522. _totalElpasedTime += curSteps[_currentSubRecipeStepNumber].StepTime;
  523. _subRecipeStartStepNumber++;
  524. if (_loopEnd)
  525. {
  526. _currentSubRecipeStepNumber++;
  527. CurrentSubRecipeLoopCount = 0;
  528. PMModule.RecipeRunningInfo.IsLooping = false;
  529. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  530. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  531. }
  532. else
  533. {
  534. SubRecipeLoopEndCheck(curSteps);
  535. }
  536. if (_currentSubRecipeStepNumber >= curSteps.Count)
  537. {
  538. PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount--;
  539. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount > 0)
  540. {
  541. IsSubReciep = true;
  542. }
  543. else
  544. {
  545. IsSubReciep = false;
  546. }
  547. _currentSubRecipeStepNumber = 0;
  548. CurrentSubRecipeLoopCount = 0;
  549. //// sub recipe执行完后,检查下是否在main recipe的loop内
  550. //RecipeLoopEndCheck();
  551. //if (_currentStepNumber >= PMModule.RecipeRunningInfo.RecipeStepList.Count)
  552. //{
  553. // _currentStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.Count - 1;
  554. // _state = RecipeRunningState.RecipeCompleted;
  555. //}
  556. }
  557. _state = RecipeRunningState.ExecStep;
  558. _stepTimer.Stop();
  559. }
  560. else
  561. {
  562. stepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName;
  563. float.TryParse(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].FilmThickFormula, out thickness);
  564. //放在前面,stepnumber后面会被更新
  565. if (!_isJumpStep)
  566. {
  567. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentStepNumber);
  568. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  569. }
  570. _fdc.Stop();
  571. if (_currentStepNumber >= 0 && !IsSubReciep)
  572. {
  573. _totalElpasedTime += PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  574. }
  575. if (IsSubReciep)
  576. IsSubReciep = false;
  577. if (_loopEnd)
  578. {
  579. _currentStepNumber++;
  580. CurrentLoopCount = 0;
  581. CurrentAbortRecipeLoopCount = 0;
  582. CurrentSubRecipeLoopCount = 0;
  583. PMModule.RecipeRunningInfo.IsLooping = false;
  584. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  585. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  586. }
  587. else
  588. {
  589. RecipeLoopEndCheck(PMModule.RecipeRunningInfo.RecipeStepList);
  590. }
  591. if (_currentStepNumber >= PMModule.RecipeRunningInfo.RecipeStepList.Count - 1)
  592. {
  593. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  594. {
  595. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  596. continue;
  597. var wafer = WaferManager.Instance.GetWafer(ModuleHelper.Converter(Module), i);
  598. if (wafer.ProcessState == EnumWaferProcessStatus.Completed ||
  599. wafer.ProcessState == EnumWaferProcessStatus.Idle)
  600. continue;
  601. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Completed);
  602. }
  603. PMModule.IsMainRecipeComplete = true;
  604. }
  605. if (_currentStepNumber >= PMModule.RecipeRunningInfo.RecipeStepList.Count)
  606. {
  607. _currentStepNumber = PMModule.RecipeRunningInfo.RecipeStepList.Count - 1;
  608. _state = RecipeRunningState.RecipeCompleted;
  609. }
  610. else
  611. {
  612. _state = RecipeRunningState.ExecStep;
  613. _stepTimer.Stop();
  614. }
  615. }
  616. if (!_isJumpStep)
  617. {
  618. PMModule.UpdateRecipeStepThicknessAndTime(stepName, thickness, stepTime);
  619. var wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Module));
  620. for (int i = 0; i < wafers.Length; i++)
  621. {
  622. if (WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(Module), i))
  623. continue;
  624. var useCount = wafers[i].UseCount;
  625. var useTime = wafers[i].UseTime + (float)stepTime;
  626. var useThick = wafers[i].UseThick + thickness;
  627. WaferManager.Instance.UpdateWaferStatistics(ModuleHelper.Converter(Module), i, useCount, useTime, useThick);
  628. }
  629. }
  630. }
  631. _isJumpStep = false;
  632. if (PMModule.IsPaused)
  633. {
  634. _state = RecipeRunningState.Paused;
  635. break;
  636. }
  637. break;
  638. case RecipeRunningState.RecipeCompleted:
  639. {
  640. var wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Module));
  641. for (int i = 0; i < wafers.Length; i++)
  642. {
  643. if (WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(Module), i))
  644. continue;
  645. var useCount = wafers[i].UseCount + 1;
  646. var useTime = wafers[i].UseTime;
  647. var useThick = wafers[i].UseThick;
  648. WaferManager.Instance.UpdateWaferStatistics(ModuleHelper.Converter(Module), i, useCount, useTime, useThick);
  649. }
  650. if (PMModule.IsHeaterProfile && !PMModule.IsHeaterProfileSuccess)
  651. EV.PostWarningLog(PMModule.Module, "Auto profile failed");
  652. Notify("End");
  653. return Result.DONE;
  654. }
  655. case RecipeRunningState.Error:
  656. {
  657. return Result.DONE;
  658. }
  659. default:
  660. break;
  661. }
  662. }
  663. catch (Exception ex)
  664. {
  665. LOG.Write(ex);
  666. return Result.FAIL;
  667. }
  668. }
  669. MonitorRecipeRunInfo();
  670. return Result.RUN;
  671. }
  672. private void MonitorRecipeRunInfo()
  673. {
  674. PMModule.IsHolded = _state == RecipeRunningState.Paused;
  675. double elapseTime;
  676. double totalElapseTime;
  677. double holdTotalElapseTime;
  678. var step = 0;
  679. if (IsSubReciep)
  680. {
  681. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps != null)
  682. {
  683. if (_stepTimer.IsIdle())
  684. {
  685. elapseTime = (_curStepElpasedTimeBeforePaused / 1000) < 1 ? 0 : _curStepElpasedTimeBeforePaused / 1000;
  686. }
  687. else
  688. {
  689. elapseTime = ((_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000) < 1 ? 0 : (_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000;
  690. }
  691. if (elapseTime > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime)
  692. elapseTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime;
  693. totalElapseTime = _totalElpasedTime + elapseTime > PMModule.RecipeRunningInfo.TotalTime ? PMModule.RecipeRunningInfo.TotalTime : _totalElpasedTime + elapseTime;
  694. if (_holdTimer.IsIdle())
  695. {
  696. holdTotalElapseTime = _holdTimeElpasedTime / 1000;
  697. }
  698. else
  699. {
  700. holdTotalElapseTime = (_holdTimeElpasedTime + _holdTimer.GetElapseTime()) / 1000;
  701. }
  702. PMModule.RecipeRunningInfo.StepElapseTime = elapseTime;
  703. PMModule.RecipeRunningInfo.TotalElapseTime = totalElapseTime;
  704. PMModule.RecipeRunningInfo.HoldTime = holdTotalElapseTime;
  705. PMModule.RecipeRunningInfo.StepTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepTime;
  706. PMModule.RecipeRunningInfo.RecipeName = $"Sub/{PMModule.RecipeRunningInfo.Head.SubRecipe}-{PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeTableInfo}-{PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName}";
  707. PMModule.RecipeRunningInfo.ExecRecipeType = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].RecipeType;
  708. PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount = PMModule.RecipeRunningInfo.SubRecipeLoopCount - PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeLoopCount + 1;
  709. PMModule.RecipeRunningInfo.SubRecipeName = PMModule.RecipeRunningInfo.Head.SubRecipe;
  710. step = _currentSubRecipeStepNumber;
  711. if (_state == RecipeRunningState.Paused)
  712. {
  713. //pause之后,当前step执行完,显示的step要保持hold住的这一步的
  714. step--;
  715. if (step < 0)
  716. step = 0;
  717. }
  718. PMModule.RecipeRunningInfo.StepNumber = step + 1; //CurStepNum start from 0
  719. PMModule.RecipeRunningInfo.StepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].StepName;
  720. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].IsLoopEndStep)
  721. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps.Count > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].LoopStartStep ?
  722. PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step].LoopStartStep].StepName : "";
  723. else
  724. {
  725. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps.Count > step + 1)
  726. {
  727. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[step + 1].StepName;
  728. }
  729. else
  730. {
  731. if (PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount < PMModule.RecipeRunningInfo.SubRecipeLoopCount)
  732. {
  733. //sub 下一个循环
  734. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[0].StepName;
  735. }
  736. else
  737. {
  738. //sub执行结束
  739. if (PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber)
  740. {
  741. PMModule.RecipeRunningInfo.NextStepName = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName;
  742. }
  743. }
  744. }
  745. }
  746. if (PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps[_currentSubRecipeStepNumber].StepName.ToLower() == "standby")
  747. {
  748. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Standby.ToString();
  749. }
  750. else
  751. {
  752. PMModule.StringProcessFlowState = PMModule.ProcessFlowState.Run.ToString();
  753. }
  754. }
  755. return;
  756. }
  757. if (_stepTimer.IsIdle())
  758. {
  759. elapseTime = (_curStepElpasedTimeBeforePaused / 1000) < 1 ? 0 : _curStepElpasedTimeBeforePaused / 1000;
  760. }
  761. else
  762. {
  763. elapseTime = ((_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000) < 1 ? 0 : (_curStepElpasedTimeBeforePaused + _stepTimer.GetElapseTime()) / 1000;
  764. }
  765. if (elapseTime > PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime)
  766. elapseTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  767. totalElapseTime = _totalElpasedTime + elapseTime > PMModule.RecipeRunningInfo.TotalTime ? PMModule.RecipeRunningInfo.TotalTime : _totalElpasedTime + elapseTime;
  768. if (_holdTimer.IsIdle())
  769. {
  770. holdTotalElapseTime = _holdTimeElpasedTime / 1000;
  771. }
  772. else
  773. {
  774. holdTotalElapseTime = (_holdTimeElpasedTime + _holdTimer.GetElapseTime()) / 1000;
  775. }
  776. PMModule.RecipeRunningInfo.StepElapseTime = elapseTime;
  777. PMModule.RecipeRunningInfo.TotalElapseTime = totalElapseTime;
  778. PMModule.RecipeRunningInfo.HoldTime = holdTotalElapseTime;
  779. PMModule.RecipeRunningInfo.StepTime = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime;
  780. PMModule.RecipeRunningInfo.RecipeName = PMModule.RecipeRunningInfo.MainRecipeName;
  781. PMModule.RecipeRunningInfo.ExecRecipeType = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].RecipeType;
  782. if (_state == RecipeRunningState.RecipeCompleted)
  783. {
  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. _faCallback.RecipeComplete(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  960. _dbCallback.RecipeComplete(PMModule.RecipeRunningInfo.InnerId.ToString());
  961. _fdc.Stop();
  962. }
  963. else
  964. {
  965. if (PMModule.IsExcuteIdleRecipe)
  966. {
  967. _faCallback.RecipeComplete(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  968. _dbCallback.RecipeComplete(PMModule.RecipeRunningInfo.InnerId.ToString());
  969. _fdc.Stop();
  970. }
  971. else
  972. {
  973. _faCallback.RecipeFailed(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName);
  974. _dbCallback.RecipeFailed(PMModule.RecipeRunningInfo.InnerId.ToString());
  975. _fdc.Stop();
  976. };
  977. }
  978. }
  979. public void PauseRecipe()
  980. {
  981. PMModule.IsPaused = true;
  982. ContinueAction = RecipeContinueMode.None;
  983. }
  984. public void ContinueRecipe()
  985. {
  986. PMModule.IsPaused = false;
  987. ContinueAction = RecipeContinueMode.StepContinue;
  988. }
  989. public void SkipCurrentRecipeStep()
  990. {
  991. if (_state == RecipeRunningState.ConditionWait || _state == RecipeRunningState.TimeWait || _state == RecipeRunningState.Paused)
  992. {
  993. _state = RecipeRunningState.StepCompleted;
  994. _loopEnd = true;
  995. PMModule.RecipeRunningInfo.IsLooping = false;
  996. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  997. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  998. PMModule.IsPaused = false;
  999. if (!_holdTimer.IsIdle())
  1000. {
  1001. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  1002. _holdTimer.Stop();
  1003. }
  1004. }
  1005. if (IsSubReciep)
  1006. {
  1007. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps, _currentSubRecipeStepNumber);
  1008. }
  1009. else
  1010. {
  1011. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList, _currentStepNumber);
  1012. }
  1013. }
  1014. private void ResetLoop(List<RecipeStep> checkRecipeSeps, int currentStepNumber)
  1015. {
  1016. if (checkRecipeSeps == null)
  1017. return;
  1018. var hasLoopStart = false;
  1019. for (int i = currentStepNumber; i >= 0; i--)
  1020. {
  1021. if (checkRecipeSeps[i].IsLoopStartStep)
  1022. {
  1023. hasLoopStart = true;
  1024. break;
  1025. }
  1026. if (checkRecipeSeps[i].IsLoopEndStep)
  1027. {
  1028. hasLoopStart = false;//前面有end,说明没有循环
  1029. break;
  1030. }
  1031. }
  1032. if (hasLoopStart)
  1033. {
  1034. for (int i = currentStepNumber; i < checkRecipeSeps.Count; i++)
  1035. {
  1036. if (checkRecipeSeps[i].IsLoopStartStep)
  1037. {
  1038. break;//没有循环
  1039. }
  1040. if (checkRecipeSeps[i].IsLoopEndStep)
  1041. {
  1042. checkRecipeSeps[i].IsLoopEndStep = false;//跳出skip step之间的循环
  1043. break;
  1044. }
  1045. }
  1046. }
  1047. }
  1048. public void LeakCheckRetry()
  1049. {
  1050. JumpCurrentRecipeStep(_currentStepNumber - 1, PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber - 1].StepName);
  1051. }
  1052. public void JumpCurrentRecipeStep(int stepNumber, string stepName, bool isAlarmConditionCall = false)
  1053. {
  1054. PMModule.AbortLeakCheck();
  1055. LOG.Write($"Jump to step stepNumber={stepNumber} stepName={stepName}, currentStepNumber={_currentStepNumber}");
  1056. if (_state == RecipeRunningState.ConditionWait || _state == RecipeRunningState.TimeWait ||
  1057. _state == RecipeRunningState.Paused || _state == RecipeRunningState.ExecStep)
  1058. {
  1059. _loopEnd = true;
  1060. PMModule.RecipeRunningInfo.IsLooping = false;
  1061. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1062. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1063. CurrentLoopCount = 0;
  1064. CurrentAbortRecipeLoopCount = 0;
  1065. CurrentSubRecipeLoopCount = 0;
  1066. IsSubReciep = false;
  1067. if (IsSubReciep)
  1068. {
  1069. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentSubRecipeStepNumber + 1);
  1070. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentSubRecipeStepNumber + 1, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  1071. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].SubRecipeSteps, _currentSubRecipeStepNumber);
  1072. }
  1073. else
  1074. {
  1075. _faCallback.RecipeStepEnd(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, _currentStepNumber);
  1076. _dbCallback.RecipeStepEnd(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, _fdc.DataList, SC.GetStringValue("PM1.TempCorrection"), SC.GetStringValue("PM1.Heater.PID"));
  1077. ResetLoop(PMModule.RecipeRunningInfo.RecipeStepList, _currentStepNumber);
  1078. }
  1079. if (_callSubSteps != null)
  1080. {
  1081. foreach (var key in _callSubSteps.Keys)
  1082. {
  1083. if (PMModule.RecipeRunningInfo.RecipeStepList.Count > key)
  1084. {
  1085. PMModule.RecipeRunningInfo.RecipeStepList[key].IsCallSubStep = _callSubSteps[key].Item1;
  1086. PMModule.RecipeRunningInfo.RecipeStepList[key].SubRecipeLoopCount = _callSubSteps[key].Item2;
  1087. }
  1088. }
  1089. _currentSubRecipeStepNumber = CurSubRecipeStepTotalLoopCount = 0;
  1090. }
  1091. _isJumpStep = true;
  1092. _currentStepNumber = stepNumber - 1;
  1093. if (_currentStepNumber < 0)
  1094. _currentStepNumber = 0;
  1095. _totalElpasedTime = RefreshElpasedTime();
  1096. _state = RecipeRunningState.StepCompleted;
  1097. PMModule.IsPaused = false;
  1098. if (!_holdTimer.IsIdle())
  1099. {
  1100. _holdTimeElpasedTime += _holdTimer.GetElapseTime();
  1101. _holdTimer.Stop();
  1102. }
  1103. }
  1104. }
  1105. private double RefreshElpasedTime()
  1106. {
  1107. double total = 0;
  1108. try
  1109. {
  1110. for (int i = 0; i < _currentStepNumber; i++)
  1111. {
  1112. if (!PMModule.RecipeRunningInfo.RecipeStepList[i].IsJumpStep)
  1113. {
  1114. if (PMModule.RecipeRunningInfo.RecipeStepList[i].IsLoopEndStep)
  1115. {
  1116. int iLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[i].LoopStartStep;
  1117. for (int j = 0; j < PMModule.RecipeRunningInfo.RecipeStepList[i].LoopCount; j++)
  1118. {
  1119. for (int m = iLoopStartStep; m <= i; m++)
  1120. {
  1121. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1122. {
  1123. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1124. }
  1125. total += PMModule.RecipeRunningInfo.RecipeStepList[m].StepTime;
  1126. }
  1127. }
  1128. }
  1129. else
  1130. {
  1131. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null &&
  1132. PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1133. {
  1134. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1135. }
  1136. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1137. }
  1138. }
  1139. }
  1140. }
  1141. catch (Exception ex)
  1142. {
  1143. LOG.Write(ex);
  1144. return -1;
  1145. }
  1146. return (int)total;
  1147. }
  1148. public void RespondAlarm(string name)
  1149. {
  1150. if (!_alarmNames.Contains(name))
  1151. _alarmNames.Add(name);
  1152. }
  1153. protected int CalcRecipeTime()
  1154. {
  1155. double total = 0;
  1156. int iStart = PMModule.IsJobProcess ? 1 : 0;
  1157. try
  1158. {
  1159. for (int i = iStart; i < PMModule.RecipeRunningInfo.RecipeStepList.Count; i++)
  1160. //for (int i = PMModule.RecipeRunningInfo.RecipeStepList.Count - 1; i <= iStart; i--)
  1161. {
  1162. if (!PMModule.RecipeRunningInfo.RecipeStepList[i].IsJumpStep)
  1163. {
  1164. if (PMModule.RecipeRunningInfo.RecipeStepList[i].IsLoopEndStep)
  1165. {
  1166. int iLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[i].LoopStartStep;
  1167. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1168. for (int j = 0; j < PMModule.RecipeRunningInfo.RecipeStepList[i].LoopCount - 1; j++)
  1169. {
  1170. for (int m = iLoopStartStep; m <= i; m++)
  1171. {
  1172. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1173. {
  1174. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1175. }
  1176. total += PMModule.RecipeRunningInfo.RecipeStepList[m].StepTime;
  1177. }
  1178. }
  1179. }
  1180. else
  1181. {
  1182. if (PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps != null && PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeSteps.Count > _currentSubRecipeStepNumber)
  1183. {
  1184. total += SubRecipeCalTotalTime(i) * PMModule.RecipeRunningInfo.RecipeStepList[i].SubRecipeLoopCount;
  1185. }
  1186. total += PMModule.RecipeRunningInfo.RecipeStepList[i].StepTime;
  1187. }
  1188. }
  1189. else
  1190. {
  1191. i = PMModule.RecipeRunningInfo.RecipeStepList[i].JumpStepNo - 1;// -1是因为i++
  1192. }
  1193. }
  1194. }
  1195. catch (Exception ex)
  1196. {
  1197. LOG.Write(ex);
  1198. return -1;
  1199. }
  1200. return (int)total;
  1201. }
  1202. private int AbortRecipeCalTotalTime()
  1203. {
  1204. double total = 0;
  1205. List<RecipeStep> abortRecipeSteps;
  1206. abortRecipeSteps = PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].AbortRecipeSteps;
  1207. try
  1208. {
  1209. for (int i = 0; i < abortRecipeSteps.Count; i++)
  1210. {
  1211. if (!abortRecipeSteps[i].IsJumpStep)
  1212. {
  1213. if (abortRecipeSteps[i].IsLoopStartStep)
  1214. {
  1215. int iLoopEndStep = 0;
  1216. for (int j = 0; j < abortRecipeSteps[i].LoopCount; j++)
  1217. {
  1218. for (int m = i; m < abortRecipeSteps.Count; m++)
  1219. {
  1220. total += abortRecipeSteps[m].StepTime;
  1221. if (abortRecipeSteps[m].IsLoopEndStep)
  1222. {
  1223. iLoopEndStep = m;
  1224. break;
  1225. }
  1226. }
  1227. }
  1228. i = iLoopEndStep;
  1229. }
  1230. else
  1231. {
  1232. total += abortRecipeSteps[i].StepTime;
  1233. }
  1234. }
  1235. else
  1236. {
  1237. i = abortRecipeSteps[i].JumpStepNo - 1;// -1是因为i++
  1238. }
  1239. }
  1240. }
  1241. catch (Exception ex)
  1242. {
  1243. LOG.Write(ex);
  1244. return -1;
  1245. }
  1246. return (int)total;
  1247. }
  1248. public void SetContinue(string continueMode)
  1249. {
  1250. switch (continueMode)
  1251. {
  1252. case "Step continue":
  1253. ContinueAction = RecipeContinueMode.StepContinue;
  1254. break;
  1255. case "Step restart":
  1256. ContinueAction = RecipeContinueMode.StepRestart;
  1257. break;
  1258. case "Next step":
  1259. ContinueAction = RecipeContinueMode.NextStep;
  1260. break;
  1261. case "Recipe restart":
  1262. ContinueAction = RecipeContinueMode.RecipeRestart;
  1263. break;
  1264. case "Recipe complete":
  1265. ContinueAction = RecipeContinueMode.RecipeCompleted;
  1266. break;
  1267. case "Wafer return and job stop":
  1268. ContinueAction = RecipeContinueMode.WaferReturnAndJobStop;
  1269. break;
  1270. }
  1271. PMModule.ResetToleranceChecker();
  1272. }
  1273. private double SubRecipeCalTotalTime(int currentStepNumber)
  1274. {
  1275. double total = 0;
  1276. for (int k = _currentSubRecipeStepNumber; k < PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps.Count; k++)
  1277. {
  1278. if (!PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].IsJumpStep)
  1279. {
  1280. if (PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].IsLoopEndStep)
  1281. {
  1282. int iSystemLoopStartStep = PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].LoopStartStep;
  1283. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].StepTime;
  1284. for (int n = 0; n < PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].LoopCount - 1; n++)
  1285. {
  1286. for (int l = iSystemLoopStartStep; l <= k; l++)
  1287. {
  1288. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[l].StepTime;
  1289. }
  1290. }
  1291. }
  1292. else
  1293. {
  1294. total += PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].StepTime;
  1295. }
  1296. }
  1297. else
  1298. {
  1299. k = PMModule.RecipeRunningInfo.RecipeStepList[currentStepNumber].SubRecipeSteps[k].JumpStepNo - 1;// -1是因为k++
  1300. }
  1301. }
  1302. return total;
  1303. }
  1304. private void SubRecipeLoopEndCheck(List<RecipeStep> recipeSteps)
  1305. {
  1306. if (_alarmAction == RecipeAlaramAction.JumpStep || _alarmAction == RecipeAlaramAction.JumpStepCancelCallLoop)
  1307. {
  1308. _currentSubRecipeStepNumber = _jumpStepNumber;
  1309. _alarmAction = RecipeAlaramAction.None;
  1310. _alarmNames.Clear();
  1311. return;
  1312. }
  1313. if (recipeSteps[_currentSubRecipeStepNumber].IsLoopEndStep)
  1314. {
  1315. if (IsJumpStepCancelCallLoop)
  1316. {
  1317. _currentSubRecipeStepNumber++;
  1318. IsJumpStepCancelCallLoop = false;
  1319. return;
  1320. }
  1321. //重新读取循环的设定次数
  1322. CurSubRecipeStepTotalLoopCount = recipeSteps[_currentSubRecipeStepNumber].LoopCount;
  1323. if (CurrentSubRecipeLoopCount >= CurSubRecipeStepTotalLoopCount)
  1324. {
  1325. CurrentSubRecipeLoopCount = CurSubRecipeStepTotalLoopCount = 0;
  1326. _currentSubRecipeStepNumber++;
  1327. PMModule.RecipeRunningInfo.IsLooping = false;
  1328. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1329. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1330. }
  1331. else
  1332. {
  1333. _currentSubRecipeStepNumber = recipeSteps[_currentSubRecipeStepNumber].LoopStartStep;
  1334. }
  1335. }
  1336. else
  1337. {
  1338. _currentSubRecipeStepNumber++;
  1339. }
  1340. }
  1341. private void RecipeLoopEndCheck(List<RecipeStep> recipeSteps)
  1342. {
  1343. if (_alarmAction == RecipeAlaramAction.JumpStep || _alarmAction == RecipeAlaramAction.JumpStepCancelCallLoop)
  1344. {
  1345. _currentStepNumber = _jumpStepNumber;
  1346. _alarmAction = RecipeAlaramAction.None;
  1347. _alarmNames.Clear();
  1348. return;
  1349. }
  1350. if (recipeSteps[_currentStepNumber].IsLoopEndStep)
  1351. {
  1352. if (IsJumpStepCancelCallLoop)
  1353. {
  1354. _currentStepNumber++;
  1355. IsJumpStepCancelCallLoop = false;
  1356. return;
  1357. }
  1358. //重新读取循环的设定次数
  1359. CurStepTotalLoopCount = recipeSteps[_currentStepNumber].LoopCount;
  1360. if (CurrentLoopCount >= CurStepTotalLoopCount)
  1361. {
  1362. CurrentLoopCount = CurStepTotalLoopCount = 0;
  1363. _currentStepNumber++;
  1364. PMModule.RecipeRunningInfo.IsLooping = false;
  1365. PMModule.RecipeRunningInfo.LoopCountCurrent = 0;
  1366. PMModule.RecipeRunningInfo.LoopCountSet = 0;
  1367. }
  1368. else
  1369. {
  1370. _currentStepNumber = recipeSteps[_currentStepNumber].LoopStartStep;
  1371. }
  1372. }
  1373. else
  1374. {
  1375. _currentStepNumber++;
  1376. }
  1377. }
  1378. private void CheckTolerance()
  1379. {
  1380. //foreach (var key in _trigMfcToleranceAlarms.Keys)
  1381. //{
  1382. // if (PMModule.GasMFCs.ContainsKey(key) && _trigMfcToleranceWarnings.ContainsKey(key))
  1383. // {
  1384. // _trigMfcToleranceAlarms[key].CLK = PMModule.GasMFCs[key].CheckToleranceAlarm();
  1385. // if (_trigMfcToleranceAlarms[key].Q)
  1386. // PMModule.GasMFCs[key].SetToleranceAlarm();
  1387. // _trigMfcToleranceWarnings[key].CLK = PMModule.GasMFCs[key].CheckToleranceWarning();
  1388. // if (_trigMfcToleranceWarnings[key].Q && !_trigMfcToleranceAlarms[key].Q)
  1389. // PMModule.GasMFCs[key].SetToleranceWarning();
  1390. // }
  1391. //}
  1392. //_trigHeaterBottomToleranceAlarm.CLK = PMModule.CheckHeaterBottomToleranceAlaram();
  1393. //if (_trigHeaterBottomToleranceAlarm.Q)
  1394. // PMModule.SetHeaterBottomToleranceAlaram();
  1395. //_trigHeaterBottomToleranceWarning.CLK = PMModule.CheckHeaterBottomToleranceWarning();
  1396. //if (_trigHeaterBottomToleranceWarning.Q && !_trigHeaterBottomToleranceAlarm.Q)
  1397. // PMModule.SetHeaterBottomToleranceWarning();
  1398. //_trigHeaterCenterBottomToleranceAlarm.CLK = PMModule.CheckHeaterCenterBottomToleranceAlaram();
  1399. //if (_trigHeaterCenterBottomToleranceAlarm.Q)
  1400. // PMModule.SetHeaterCenterBottomToleranceAlaram();
  1401. //_trigHeaterCenterBottomToleranceWarning.CLK = PMModule.CheckHeaterCenterBottomToleranceWarning();
  1402. //if (_trigHeaterCenterBottomToleranceWarning.Q && !_trigHeaterCenterBottomToleranceAlarm.Q)
  1403. // PMModule.SetHeaterCenterBottomToleranceWarning();
  1404. //_trigHeaterCenterToleranceAlarm.CLK = PMModule.CheckHeaterCenterToleranceAlaram();
  1405. //if (_trigHeaterCenterToleranceAlarm.Q)
  1406. // PMModule.SetHeaterCenterToleranceAlaram();
  1407. //_trigHeaterCenterToleranceWarning.CLK = PMModule.CheckHeaterCenterToleranceWarning();
  1408. //if (_trigHeaterCenterToleranceWarning.Q && !_trigHeaterCenterToleranceAlarm.Q)
  1409. // PMModule.SetHeaterCenterToleranceWarning();
  1410. //_trigHeaterCenterTopToleranceAlarm.CLK = PMModule.CheckHeaterCenterTopToleranceAlaram();
  1411. //if (_trigHeaterCenterTopToleranceAlarm.Q)
  1412. // PMModule.SetHeaterCenterTopToleranceAlaram();
  1413. //_trigHeaterCenterTopToleranceWarning.CLK = PMModule.CheckHeaterCenterTopToleranceWarning();
  1414. //if (_trigHeaterCenterTopToleranceWarning.Q && !_trigHeaterCenterTopToleranceAlarm.Q)
  1415. // PMModule.SetHeaterCenterTopToleranceWarning();
  1416. //_trigHeaterTopToleranceAlarm.CLK = PMModule.CheckHeaterTopToleranceAlaram();
  1417. //if (_trigHeaterTopToleranceAlarm.Q)
  1418. // PMModule.SetHeaterTopToleranceAlaram();
  1419. //_trigHeaterTopToleranceWarning.CLK = PMModule.CheckHeaterTopToleranceWarning();
  1420. //if (_trigHeaterTopToleranceWarning.Q && !_trigHeaterTopToleranceAlarm.Q)
  1421. // PMModule.SetHeaterTopToleranceWarning();
  1422. //_trigPressureToleranceAlarm.CLK = PMModule.CheckPressureToleranceAlaram();
  1423. //if (_trigPressureToleranceAlarm.Q)
  1424. // PMModule.SetPressureToleranceAlaram();
  1425. //_trigPressureToleranceWarning.CLK = PMModule.CheckPressureToleranceWarning();
  1426. //if (_trigPressureToleranceWarning.Q && !_trigPressureToleranceAlarm.Q)
  1427. // PMModule.SetPressureToleranceWarning();
  1428. }
  1429. private void ResetTrig()
  1430. {
  1431. PMModule.ResetAlarmCondition();
  1432. foreach (var key in _trigMfcToleranceAlarms.Keys)
  1433. {
  1434. if (_trigMfcToleranceWarnings.ContainsKey(key))
  1435. {
  1436. _trigMfcToleranceAlarms[key].RST = true;
  1437. _trigMfcToleranceWarnings[key].RST = true;
  1438. }
  1439. }
  1440. _trigHeaterBottomToleranceAlarm.RST = true;
  1441. _trigHeaterBottomToleranceWarning.RST = true;
  1442. _trigHeaterCenterBottomToleranceAlarm.RST = true;
  1443. _trigHeaterCenterBottomToleranceWarning.RST = true;
  1444. _trigHeaterCenterToleranceAlarm.RST = true;
  1445. _trigHeaterCenterToleranceWarning.RST = true;
  1446. _trigHeaterCenterTopToleranceAlarm.RST = true;
  1447. _trigHeaterCenterTopToleranceWarning.RST = true;
  1448. _trigHeaterTopToleranceAlarm.RST = true;
  1449. _trigHeaterTopToleranceWarning.RST = true;
  1450. _trigPressureToleranceAlarm.RST = true;
  1451. _trigPressureToleranceWarning.RST = true;
  1452. _trigInputSignalTimeOutAlarm.RST = true;
  1453. _trigTemperatureConvergenceTimeOutAlarm.RST = true;
  1454. _trigReachTempTimeOutAlarm.RST = true;
  1455. _trigPressureConvergenceTimeOutAlarm.RST = true;
  1456. _trigReachPressureTimeOutAlarm.RST = true;
  1457. _trigAutoProfileTimeOutAlarm.RST = true;
  1458. _trigHeaterProfileFinish.RST = true;
  1459. _trigLeakCheckFinish.RST = true;
  1460. _trigBoatWaitCondition.RST = true;
  1461. _trigAPCWaitCondition.RST = true;
  1462. _trigAUXWaitCondition.RST = true;
  1463. _trigHeaterWaitCondition.RST = true;
  1464. _trigMFCWaitCondition.RST = true;
  1465. _infoHeaterProfileFinish = "";
  1466. _infoAUXWaitCondition = "";
  1467. _infoHeaterWaitCondition = "";
  1468. _infoMFCWaitCondition = "";
  1469. }
  1470. private void RecipeExec(string type, List<RecipeStep> curSteps, int currentStepNumber, double curStepElpasedTimeBeforePaused, int otherRecipeStartStepNumber = 0)
  1471. {
  1472. var reason = "";
  1473. _stepTimer.Start(curSteps[currentStepNumber].StepTime * 1000 - curStepElpasedTimeBeforePaused);
  1474. _showStepNo = currentStepNumber;
  1475. Notify($"{type} running step {currentStepNumber + 1}:{curSteps[currentStepNumber].StepName}");
  1476. var stopwatch = new Stopwatch();
  1477. stopwatch.Start();
  1478. //执行工艺程序命令
  1479. foreach (var recipeCmd in curSteps[currentStepNumber].RecipeCommands.Keys)
  1480. {
  1481. if (!OP.CanDoOperation($"{_doModule}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1482. {
  1483. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1484. {
  1485. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, curSteps[currentStepNumber].RecipeCommands[recipeCmd]))
  1486. {
  1487. PMModule.CheckCanDoOperationAlarm.Set($"Can not execute {recipeCmd}, {reason}");
  1488. return;
  1489. }
  1490. else
  1491. {
  1492. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1493. }
  1494. }
  1495. else
  1496. {
  1497. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1498. }
  1499. }
  1500. else
  1501. {
  1502. OP.DoOperation($"{_doModule}.{recipeCmd}", out string reason1, 0, curSteps[currentStepNumber].RecipeCommands[recipeCmd]);
  1503. }
  1504. }
  1505. LOG.Write($"step exec time {stopwatch.ElapsedMilliseconds}");
  1506. if (curSteps[currentStepNumber].EndBy == EnumEndByCondition.ByTime && !PMModule.IsBoatMoveToLoadPosition)
  1507. _state = RecipeRunningState.TimeWait;
  1508. else
  1509. _state = RecipeRunningState.ConditionWait;
  1510. _faCallback.RecipeStepStart(PMModule.Module, PMModule.RecipeRunningInfo.RecipeName, otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber);
  1511. if (type == "Sub recipe")
  1512. _dbCallback.RecipeStepStart(PMModule.RecipeRunningInfo.InnerId.ToString(), _currentStepNumber, PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber ? PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepName : "",
  1513. PMModule.RecipeRunningInfo.RecipeStepList.Count > _currentStepNumber ? (float)PMModule.RecipeRunningInfo.RecipeStepList[_currentStepNumber].StepTime : 0,
  1514. $"{(otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber)}", curSteps[currentStepNumber].StepName, (float)curSteps[currentStepNumber].StepTime,
  1515. $"{PMModule.RecipeRunningInfo.SubRecipeCurrentLoopCount}/{PMModule.RecipeRunningInfo.SubRecipeLoopCount}");
  1516. else
  1517. _dbCallback.RecipeStepStart(PMModule.RecipeRunningInfo.InnerId.ToString(), otherRecipeStartStepNumber != 0 ? otherRecipeStartStepNumber : currentStepNumber,
  1518. curSteps[currentStepNumber].StepName, (float)curSteps[currentStepNumber].StepTime, "", "", 0, "");
  1519. _fdc.Start(curSteps[currentStepNumber].RecipeCommands);
  1520. }
  1521. }
  1522. }