SchedulerSequenceRecipeManager.cs 7.3 KB

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