Process.cs 85 KB

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