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