Process.cs 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764
  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. 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. }