SequenceRecipeManager.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using Aitex.Common.Util;
  2. using Aitex.Core.RT.RecipeCenter;
  3. using Aitex.Core.Util;
  4. using PunkHPX8_Core;
  5. using MECF.Framework.Common.Equipment;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace MECF.Framework.Common.RecipeCenter
  12. {
  13. public class SequenceRecipeManager : Singleton<SequenceRecipeManager>
  14. {
  15. #region 常量
  16. private const string PRODUCTION = "Production";
  17. #endregion
  18. /// <summary>
  19. /// 获取Recipe类型
  20. /// </summary>
  21. /// <param name="item"></param>
  22. /// <returns></returns>
  23. public RecipeType GetRecipeType(string item)
  24. {
  25. string str = item.ToLower();
  26. if (str.EndsWith("srd.rcp"))
  27. {
  28. return RecipeType.SRD;
  29. }
  30. else if(str.EndsWith("vpw.rcp"))
  31. {
  32. return RecipeType.VPW;
  33. }
  34. else if(str.EndsWith("dep.rcp"))
  35. {
  36. return RecipeType.DEP;
  37. }
  38. else
  39. {
  40. return RecipeType.RES;
  41. }
  42. }
  43. /// <summary>
  44. /// 根据dep获取dummy recipe
  45. /// </summary>
  46. /// <param name="depRecipe"></param>
  47. /// <returns></returns>
  48. public DqdrRecipe GetDqdrRecipeByDepRecipe(string depRecipe)
  49. {
  50. List<DqdrRecipe> recipes = RecipeFileManager.Instance.GetProctionDqdrRecipes();
  51. if (recipes.Count > 0)
  52. {
  53. return recipes.Find(O=>O.LinkedDepRecipeName == depRecipe);
  54. }
  55. else
  56. {
  57. return null;
  58. }
  59. }
  60. /// <summary>
  61. /// 获取模块类型
  62. /// </summary>
  63. /// <param name="item"></param>
  64. /// <returns></returns>
  65. public ModuleType GetModuleType(string item)
  66. {
  67. string str = item.ToLower();
  68. if (str.EndsWith("srd.rcp"))
  69. {
  70. return ModuleType.SRD;
  71. }
  72. else if (str.EndsWith("vpw.rcp"))
  73. {
  74. return ModuleType.VPW;
  75. }
  76. else if (str.EndsWith("dep.rcp"))
  77. {
  78. return ModuleType.PlatingCell;
  79. }
  80. else
  81. {
  82. return ModuleType.None;
  83. }
  84. }
  85. /// <summary>
  86. /// 加载Recipe对象
  87. /// </summary>
  88. /// <param name="sequenceType"></param>
  89. /// <param name="recipeName"></param>
  90. /// <returns></returns>
  91. public object LoadSequenceTypeRecipe(string sequenceType,string recipeName,RecipeType recipeType)
  92. {
  93. string strDirectory = sequenceType == PRODUCTION ? PathManager.GetProductionRecipeDir() : PathManager.GetEngineeringRecipeDir();
  94. string strProduction = strDirectory + "\\" + recipeName;
  95. switch (recipeType)
  96. {
  97. case RecipeType.HVD:
  98. return RecipeFileManager.Instance.LoadGenericityRecipe<HvdRecipe>(strProduction);
  99. case RecipeType.RES:
  100. return RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(strProduction);
  101. case RecipeType.SRD:
  102. return RecipeFileManager.Instance.LoadGenericityRecipe<SrdRecipe>(strProduction);
  103. case RecipeType.VPW:
  104. return RecipeFileManager.Instance.LoadGenericityRecipe<VpwRecipe>(strProduction);
  105. case RecipeType.QDR:
  106. return RecipeFileManager.Instance.LoadGenericityRecipe<QdrRecipe>(strProduction);
  107. case RecipeType.DEP:
  108. return RecipeFileManager.Instance.LoadGenericityRecipe<DepRecipe>(strProduction);
  109. case RecipeType.RDS:
  110. return RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(strProduction);
  111. default:
  112. return null;
  113. }
  114. }
  115. /// <summary>
  116. /// 是否包含SRD
  117. /// </summary>
  118. /// <param name="recipe"></param>
  119. /// <returns></returns>
  120. public bool IsContainedSrd(SequenceRecipe recipe)
  121. {
  122. return recipe.Recipes.FindIndex(O => O.ToLower().Contains("srd.rcp")) >=0;
  123. }
  124. /// <summary>
  125. /// 是否包含PWT
  126. /// </summary>
  127. /// <param name="recipe"></param>
  128. /// <returns></returns>
  129. public bool IsContainedPwt(SequenceRecipe recipe)
  130. {
  131. return recipe.Recipes.FindIndex(O => O.ToLower().Contains("pwt.rcp")) >= 0;
  132. }
  133. /// <summary>
  134. /// 获取SRD recipe
  135. /// </summary>
  136. /// <param name="recipe"></param>
  137. /// <returns></returns>
  138. public SrdRecipe GetSrdRecipeBySequenceRecipe(SequenceRecipe recipe)
  139. {
  140. int index = recipe.Recipes.FindIndex(O => O.ToLower().Contains("srd.rcp"));
  141. if(index>=0)
  142. {
  143. string srd=recipe.Recipes[index];
  144. string strProduction = (recipe.SequenceType == PRODUCTION ? PathManager.GetProductionRecipeDir() : PathManager.GetEngineeringRecipeDir()) + "\\" + srd;
  145. return RecipeFileManager.Instance.LoadGenericityRecipe<SrdRecipe>(strProduction);
  146. }
  147. else
  148. {
  149. return null;
  150. }
  151. }
  152. }
  153. }