Process.cs 85 KB

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