Process.cs 85 KB

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