Process.cs 85 KB

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