SchedulerSequenceRecipeManager.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using Aitex.Core.RT.Fsm;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.Util;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.RecipeCenter;
  6. using MECF.Framework.Common.ToolLayout;
  7. using PunkHPX8_RT.Modules;
  8. using PunkHPX8_RT.Modules.Reservoir;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace PunkHPX8_RT.Schedulers
  15. {
  16. public class SchedulerSequenceRecipeManager : Singleton<SchedulerSequenceRecipeManager>
  17. {
  18. /// <summary>
  19. /// 是否存在可用的cell
  20. /// </summary>
  21. /// <param name="sequenceRecipe"></param>
  22. /// <returns></returns>
  23. public bool ExistAvaibleProcessCell(SequenceRecipe sequenceRecipe, bool showError, bool checkSrd = false)
  24. {
  25. if (sequenceRecipe == null)
  26. {
  27. if (showError)
  28. {
  29. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", "sequence recipe is null");
  30. }
  31. return false;
  32. }
  33. int count = 0;
  34. for (int i = 0; i < sequenceRecipe.Recipes.Count; i++)
  35. {
  36. string item = sequenceRecipe.Recipes[i];
  37. if (string.IsNullOrEmpty(item))
  38. {
  39. continue;
  40. }
  41. if (item.ToLower().EndsWith("srd.rcp") && !checkSrd)
  42. {
  43. continue;
  44. }
  45. if (item.ToLower().EndsWith("srd.rcp") && !checkSrd)
  46. {
  47. continue;
  48. }
  49. if (i == 0 && item.ToLower().EndsWith("qdr.rcp"))
  50. {
  51. RinseItem rinseItem = RinseItemManager.Instance.GetPrewetRinseItem();
  52. if (rinseItem == null)
  53. {
  54. if (showError)
  55. {
  56. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequence {sequenceRecipe.Ppid} has no pwt rinse cell");
  57. }
  58. return false;
  59. }
  60. }
  61. ModuleType moduleType = SequenceRecipeManager.Instance.GetModuleType(item);
  62. if (moduleType == ModuleType.None)
  63. {
  64. if (showError)
  65. {
  66. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequence {sequenceRecipe.Ppid} item {item} is invalid type");
  67. }
  68. return false;
  69. }
  70. if (moduleType == ModuleType.Metal)
  71. {
  72. DepRecipe depRecipe =(DepRecipe)SequenceRecipeManager.Instance.LoadSequenceTypeRecipe(sequenceRecipe.SequenceType,item, RecipeType.DEP);
  73. if (depRecipe == null)
  74. {
  75. if (showError)
  76. {
  77. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequece {sequenceRecipe.Ppid} metal recipe {depRecipe.Ppid} is invalid ");
  78. }
  79. return false;
  80. }
  81. }
  82. else
  83. {
  84. ModuleName moduleName= SchedulerSequenceManager.Instance.GetAvaibleModuleCell(sequenceRecipe.SequenceType,moduleType);
  85. if(moduleName==ModuleName.Unknown)
  86. {
  87. if (showError)
  88. {
  89. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequece {sequenceRecipe.Ppid} has not avaible {moduleType} module");
  90. }
  91. return false;
  92. }
  93. }
  94. count++;
  95. }
  96. if (count == 0)
  97. {
  98. if (showError)
  99. {
  100. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequece {sequenceRecipe.Ppid} not set avaible cell");
  101. }
  102. return false;
  103. }
  104. return true;
  105. }
  106. /// <summary>
  107. /// 获取sequence的化学液
  108. /// </summary>
  109. /// <param name="sequenceRecipe"></param>
  110. /// <returns></returns>
  111. public List<string> GetSequenceChemistry(SequenceRecipe sequenceRecipe)
  112. {
  113. List<string> chemistries = new List<string>();
  114. for (int i = 0; i < sequenceRecipe.Recipes.Count; i++)
  115. {
  116. string item = sequenceRecipe.Recipes[i];
  117. if (string.IsNullOrEmpty(item))
  118. {
  119. continue;
  120. }
  121. ModuleType moduleType = SequenceRecipeManager.Instance.GetModuleType(item);
  122. if (moduleType == ModuleType.Metal)
  123. {
  124. DepRecipe depRecipe = (DepRecipe)SequenceRecipeManager.Instance.LoadSequenceTypeRecipe(sequenceRecipe.SequenceType, item, RecipeType.DEP);
  125. if (!chemistries.Contains(depRecipe.Chemistry))
  126. {
  127. chemistries.Add(depRecipe.Chemistry);
  128. }
  129. }
  130. }
  131. return chemistries;
  132. }
  133. /// <summary>
  134. /// 是否Sequence Recipe是否可用
  135. /// </summary>
  136. /// <param name="sequenceRecipe"></param>
  137. /// <returns></returns>
  138. public bool CheckSequenceRecipeAvaible(SequenceRecipe sequenceRecipe,ref string reason)
  139. {
  140. if (sequenceRecipe == null)
  141. {
  142. reason = "sequence recipe is null";
  143. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", reason);
  144. return false;
  145. }
  146. for (int i = 0; i < sequenceRecipe.Recipes.Count; i++)
  147. {
  148. string item = sequenceRecipe.Recipes[i];
  149. if (string.IsNullOrEmpty(item))
  150. {
  151. continue;
  152. }
  153. RecipeType recipeType= SequenceRecipeManager.Instance.GetRecipeType(item);
  154. object recipe = SequenceRecipeManager.Instance.LoadSequenceTypeRecipe(sequenceRecipe.SequenceType, item, recipeType);
  155. if (recipe == null)
  156. {
  157. reason = $"{item} is not in {sequenceRecipe.SequenceType}";
  158. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", reason);
  159. return false;
  160. }
  161. }
  162. return true;
  163. }
  164. }
  165. }