SchedulerSequenceRecipeManager.cs 6.7 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.PlatingCell;
  9. using PunkHPX8_RT.Modules.Reservoir;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace PunkHPX8_RT.Schedulers
  16. {
  17. public class SchedulerSequenceRecipeManager : Singleton<SchedulerSequenceRecipeManager>
  18. {
  19. /// <summary>
  20. /// 是否存在可用的cell
  21. /// </summary>
  22. /// <param name="sequenceRecipe"></param>
  23. /// <returns></returns>
  24. public bool ExistAvaibleProcessCell(SequenceRecipe sequenceRecipe, bool showError, bool checkSrd = false)
  25. {
  26. if (sequenceRecipe == null)
  27. {
  28. if (showError)
  29. {
  30. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", "sequence recipe is null");
  31. }
  32. return false;
  33. }
  34. int count = 0;
  35. for (int i = 0; i < sequenceRecipe.Recipes.Count; i++)
  36. {
  37. string item = sequenceRecipe.Recipes[i];
  38. if (string.IsNullOrEmpty(item))
  39. {
  40. continue;
  41. }
  42. if (item.ToLower().EndsWith("srd.rcp") && !checkSrd)
  43. {
  44. continue;
  45. }
  46. if (item.ToLower().EndsWith("srd.rcp") && !checkSrd)
  47. {
  48. continue;
  49. }
  50. ModuleType moduleType = SequenceRecipeManager.Instance.GetModuleType(item);
  51. if (moduleType == ModuleType.None)
  52. {
  53. if (showError)
  54. {
  55. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequence {sequenceRecipe.Ppid} item {item} is invalid type");
  56. }
  57. return false;
  58. }
  59. RecipeType recipeType= SequenceRecipeManager.Instance.GetRecipeType(item);
  60. object recipe =SequenceRecipeManager.Instance.LoadSequenceTypeRecipe(sequenceRecipe.SequenceType,item, recipeType);
  61. if (recipe == null)
  62. {
  63. if (showError)
  64. {
  65. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequece {sequenceRecipe.Ppid} recipe {item} is invalid ");
  66. }
  67. return false;
  68. }
  69. if (moduleType == ModuleType.PlatingCell)
  70. {
  71. DepRecipe depRecipe=(DepRecipe)recipe;
  72. List<PlatingCellEntity> cells = SchedulerSequenceManager.Instance.GetAvaiblePlatingCellList(depRecipe.Chemistry, sequenceRecipe.SequenceType, false);
  73. if (cells.Count == 0)
  74. {
  75. if (showError)
  76. {
  77. LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"sequece {sequenceRecipe.Ppid} plating cell recipe {depRecipe.Ppid} chemistry {depRecipe.Chemistry} has not avaible cell");
  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. }