SequenceRecipeManager.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. /// 获取模块类型
  45. /// </summary>
  46. /// <param name="item"></param>
  47. /// <returns></returns>
  48. public ModuleType GetModuleType(string item)
  49. {
  50. string str = item.ToLower();
  51. if (str.EndsWith("srd.rcp"))
  52. {
  53. return ModuleType.SRD;
  54. }
  55. else if (str.EndsWith("vpw.rcp"))
  56. {
  57. return ModuleType.VPW;
  58. }
  59. else if (str.EndsWith("dep.rcp"))
  60. {
  61. return ModuleType.PlatingCell;
  62. }
  63. else
  64. {
  65. return ModuleType.None;
  66. }
  67. }
  68. /// <summary>
  69. /// 加载Recipe对象
  70. /// </summary>
  71. /// <param name="sequenceType"></param>
  72. /// <param name="recipeName"></param>
  73. /// <returns></returns>
  74. public object LoadSequenceTypeRecipe(string sequenceType,string recipeName,RecipeType recipeType)
  75. {
  76. string strDirectory = sequenceType == PRODUCTION ? PathManager.GetProductionRecipeDir() : PathManager.GetEngineeringRecipeDir();
  77. string strProduction = strDirectory + "\\" + recipeName;
  78. switch (recipeType)
  79. {
  80. case RecipeType.HVD:
  81. return RecipeFileManager.Instance.LoadGenericityRecipe<HvdRecipe>(strProduction);
  82. case RecipeType.RES:
  83. return RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(strProduction);
  84. case RecipeType.SRD:
  85. return RecipeFileManager.Instance.LoadGenericityRecipe<SrdRecipe>(strProduction);
  86. case RecipeType.VPW:
  87. return RecipeFileManager.Instance.LoadGenericityRecipe<VpwRecipe>(strProduction);
  88. case RecipeType.QDR:
  89. return RecipeFileManager.Instance.LoadGenericityRecipe<QdrRecipe>(strProduction);
  90. case RecipeType.DEP:
  91. return RecipeFileManager.Instance.LoadGenericityRecipe<DepRecipe>(strProduction);
  92. case RecipeType.RDS:
  93. return RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(strProduction);
  94. default:
  95. return null;
  96. }
  97. }
  98. /// <summary>
  99. /// 是否包含SRD
  100. /// </summary>
  101. /// <param name="recipe"></param>
  102. /// <returns></returns>
  103. public bool IsContainedSrd(SequenceRecipe recipe)
  104. {
  105. return recipe.Recipes.FindIndex(O => O.ToLower().Contains("srd.rcp")) >=0;
  106. }
  107. /// <summary>
  108. /// 是否包含PWT
  109. /// </summary>
  110. /// <param name="recipe"></param>
  111. /// <returns></returns>
  112. public bool IsContainedPwt(SequenceRecipe recipe)
  113. {
  114. return recipe.Recipes.FindIndex(O => O.ToLower().Contains("pwt.rcp")) >= 0;
  115. }
  116. /// <summary>
  117. /// 获取SRD recipe
  118. /// </summary>
  119. /// <param name="recipe"></param>
  120. /// <returns></returns>
  121. public SrdRecipe GetSrdRecipeBySequenceRecipe(SequenceRecipe recipe)
  122. {
  123. int index = recipe.Recipes.FindIndex(O => O.ToLower().Contains("srd.rcp"));
  124. if(index>=0)
  125. {
  126. string srd=recipe.Recipes[index];
  127. string strProduction = (recipe.SequenceType == PRODUCTION ? PathManager.GetProductionRecipeDir() : PathManager.GetEngineeringRecipeDir()) + "\\" + srd;
  128. return RecipeFileManager.Instance.LoadGenericityRecipe<SrdRecipe>(strProduction);
  129. }
  130. else
  131. {
  132. return null;
  133. }
  134. }
  135. }
  136. }