PreProcess.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using Aitex.Core.RT.Routine;
  2. using MECF.Framework.Common.Equipment;
  3. using System;
  4. using Aitex.Core.RT.SCCore;
  5. using FurnaceRT.Equipments.PMs.Routines;
  6. using System.Collections.Generic;
  7. using FurnaceRT.Equipments.Systems;
  8. using Aitex.Core.Util;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using System.Linq;
  11. using Aitex.Core.Common;
  12. using MECF.Framework.Common.CommonData.EnumData;
  13. using MECF.Framework.Common.DataCenter;
  14. using MECF.Framework.Common.Utilities;
  15. using Aitex.Core.RT.Log;
  16. using Aitex.Sorter.Common;
  17. namespace FurnaceRT.Equipments.PMs.RecipeExecutions
  18. {
  19. public class PreProcess : PMBaseRoutine, IRoutine
  20. {
  21. public enum Routine
  22. {
  23. ToReadyProcessState,
  24. Pump,
  25. PinDown,
  26. CheckSchedule,
  27. }
  28. private string _recipeName;
  29. private int _checkTimeOut = 3600;
  30. private bool _isProcessRecipe;
  31. private bool _isJobAutoStart;
  32. public PreProcess(ModuleName module, PMModule pm) : base(module, pm)
  33. {
  34. Module = module.ToString();
  35. Name = "PreProcess";
  36. }
  37. public void Init(string recipeName, bool isProcessRecipe = true, bool IsJobAutoStart = false)
  38. {
  39. _recipeName = recipeName;
  40. _isProcessRecipe = isProcessRecipe;
  41. _isJobAutoStart = IsJobAutoStart;
  42. }
  43. private List<RecipeStep> _recipeSteps;
  44. public override Result Start(params object[] objs)
  45. {
  46. RecipeHead recipeHead;
  47. Dictionary<int, List<RecipeStep>> abortRecipe;
  48. Dictionary<int, string> abortRecipeName;
  49. Dictionary<int, List<RecipeStep>> subRecipe;
  50. Dictionary<int, string> subRecipeName;
  51. string reason = string.Empty;
  52. if (_isProcessRecipe)
  53. {
  54. if (!RecipeParser.Parse(_recipeName, Module, out recipeHead, out _recipeSteps, out reason, "Process"))
  55. {
  56. PMModule.PreprocessStartFailedWarning.Set($"Load process recipe {_recipeName} failed, {reason}");
  57. return Result.FAIL;
  58. }
  59. PMModule.RecipeRunningInfo.MainRecipeName = _recipeName;
  60. PMModule.RecipeRunningInfo.Head = recipeHead;
  61. PMModule.RecipeRunningInfo.IsProcessRecipe = _isProcessRecipe;
  62. PMModule.RecipeRunningInfo.IsJobAutoStart = _isJobAutoStart;
  63. PMModule.RecipeRunningInfo.RecipeStepList = _recipeSteps;
  64. PMModule.RecipeRunningInfo.ExecRecipeType = _recipeSteps.Count > 0 ? _recipeSteps[0].RecipeType : string.Empty;
  65. }
  66. Reset();
  67. Notify($"Start");
  68. return Result.RUN;
  69. }
  70. public override Result Monitor()
  71. {
  72. try
  73. {
  74. CheckSchedule((int)Routine.CheckSchedule, PMModule, _checkTimeOut);
  75. //ExecuteRoutine((int)Routine.Pump, _pumpRoutine);
  76. //MovePinDown((int)Routine.PinDown, PMModule, _liftTimeout);
  77. }
  78. catch (RoutineBreakException)
  79. {
  80. return Result.RUN;
  81. }
  82. catch (RoutineFaildException)
  83. {
  84. return Result.FAIL;
  85. }
  86. Singleton<EquipmentManager>.Instance.SetPJState();
  87. return Result.DONE;
  88. }
  89. public void CheckSchedule(int id, PMModule pm, int timeout)
  90. {
  91. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  92. {
  93. Notify($"prepare chamber {pm.Name} CheckSchedule");
  94. pm.GetAllDBRecord();
  95. string reason = "";
  96. return true;
  97. }, () =>
  98. {
  99. if (_isJobAutoStart|| !_isProcessRecipe)
  100. return true;
  101. pm.CheckBoatRecipeThicknessMoreThan(out var boatRecipeThicknessIsPause, out string boatRecipeThicknessJobName, false);
  102. if (boatRecipeThicknessIsPause)
  103. return false;
  104. pm.CheckRecipeThicknessMoreThan(_recipeName, out var isPause, out string jobName, false);
  105. if (isPause)
  106. return false;
  107. pm.CheckRecipeExecuteFreqMoreThan(_recipeName, out var isPause1, out string jobName1, false);
  108. if (isPause1)
  109. return false;
  110. foreach (var item in _recipeSteps)
  111. {
  112. pm.CheckRecipeStepFreqMoreThan(item.StepName, out var isPause2, out string jobName2, false);
  113. if (isPause2)
  114. return false;
  115. pm.CheckRecipeStepTimeMoreThan(item.StepName, out var isPause3, out string jobName3, false);
  116. if (isPause3)
  117. return false;
  118. pm.CheckRecipeStepGroupThicknessMoreThan(item.StepName, out var isPause4, out string jobName4, false);
  119. if (isPause4)
  120. return false;
  121. }
  122. return true;
  123. }, timeout * 1000);
  124. if (ret.Item1)
  125. {
  126. if (ret.Item2 == Result.FAIL)
  127. {
  128. throw (new RoutineFaildException());
  129. }
  130. else if (ret.Item2 == Result.TIMEOUT) //timeout
  131. {
  132. Stop($"{pm.Name} prepare process timeout, over {timeout} seconds");
  133. throw (new RoutineFaildException());
  134. }
  135. else
  136. {
  137. throw (new RoutineBreakException());
  138. }
  139. }
  140. }
  141. public override void Abort()
  142. {
  143. }
  144. }
  145. }