Process.cs 82 KB

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