SequenceRecipeManager.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using Aitex.Common.Util;
  2. using Aitex.Core.RT.RecipeCenter;
  3. using Aitex.Core.Util;
  4. using CyberX8_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("hvd.rcp"))
  31. {
  32. return RecipeType.HVD;
  33. }
  34. else if(str.EndsWith("pwt.rcp"))
  35. {
  36. return RecipeType.PWT;
  37. }
  38. else if(str.EndsWith("qdr.rcp"))
  39. {
  40. return RecipeType.QDR;
  41. }
  42. else if(str.EndsWith("dep.rcp"))
  43. {
  44. return RecipeType.DEP;
  45. }
  46. else
  47. {
  48. return RecipeType.RES;
  49. }
  50. }
  51. /// <summary>
  52. /// 获取模块类型
  53. /// </summary>
  54. /// <param name="item"></param>
  55. /// <returns></returns>
  56. public ModuleType GetModuleType(string item)
  57. {
  58. string str = item.ToLower();
  59. if (str.EndsWith("srd.rcp"))
  60. {
  61. return ModuleType.SRD;
  62. }
  63. else if (str.EndsWith("hvd.rcp"))
  64. {
  65. return ModuleType.Dryer;
  66. }
  67. else if (str.EndsWith("pwt.rcp"))
  68. {
  69. return ModuleType.Prewet;
  70. }
  71. else if (str.EndsWith("qdr.rcp"))
  72. {
  73. return ModuleType.Rinse;
  74. }
  75. else if (str.EndsWith("dep.rcp"))
  76. {
  77. return ModuleType.Metal;
  78. }
  79. else
  80. {
  81. return ModuleType.None;
  82. }
  83. }
  84. /// <summary>
  85. /// 加载Recipe对象
  86. /// </summary>
  87. /// <param name="sequenceType"></param>
  88. /// <param name="recipeName"></param>
  89. /// <returns></returns>
  90. public object LoadSequenceTypeRecipe(string sequenceType,string recipeName,RecipeType recipeType)
  91. {
  92. string strDirectory = sequenceType == PRODUCTION ? PathManager.GetProductionRecipeDir() : PathManager.GetEngineeringRecipeDir();
  93. string strProduction = strDirectory + "\\" + recipeName;
  94. switch (recipeType)
  95. {
  96. case RecipeType.HVD:
  97. return RecipeFileManager.Instance.LoadGenericityRecipe<HvdRecipe>(strProduction);
  98. case RecipeType.RES:
  99. return RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(strProduction);
  100. case RecipeType.SRD:
  101. return RecipeFileManager.Instance.LoadGenericityRecipe<SrdRecipe>(strProduction);
  102. case RecipeType.PWT:
  103. return RecipeFileManager.Instance.LoadGenericityRecipe<PwtRecipe>(strProduction);
  104. case RecipeType.QDR:
  105. return RecipeFileManager.Instance.LoadGenericityRecipe<QdrRecipe>(strProduction);
  106. case RecipeType.DEP:
  107. return RecipeFileManager.Instance.LoadGenericityRecipe<DepRecipe>(strProduction);
  108. case RecipeType.RDS:
  109. return RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(strProduction);
  110. default:
  111. return null;
  112. }
  113. }
  114. /// <summary>
  115. /// 是否包含SRD
  116. /// </summary>
  117. /// <param name="recipe"></param>
  118. /// <returns></returns>
  119. public bool IsContainedSrd(SequenceRecipe recipe)
  120. {
  121. return recipe.Recipes.FindIndex(O => O.ToLower().Contains("srd.rcp")) >=0;
  122. }
  123. /// <summary>
  124. /// 是否包含PWT
  125. /// </summary>
  126. /// <param name="recipe"></param>
  127. /// <returns></returns>
  128. public bool IsContainedPwt(SequenceRecipe recipe)
  129. {
  130. return recipe.Recipes.FindIndex(O => O.ToLower().Contains("pwt.rcp")) >= 0;
  131. }
  132. /// <summary>
  133. /// 获取SRD recipe
  134. /// </summary>
  135. /// <param name="recipe"></param>
  136. /// <returns></returns>
  137. public SrdRecipe GetSrdRecipeBySequenceRecipe(SequenceRecipe recipe)
  138. {
  139. int index = recipe.Recipes.FindIndex(O => O.ToLower().Contains("srd.rcp"));
  140. if(index>=0)
  141. {
  142. string srd=recipe.Recipes[index];
  143. string strProduction = (recipe.SequenceType == PRODUCTION ? PathManager.GetProductionRecipeDir() : PathManager.GetEngineeringRecipeDir()) + "\\" + srd;
  144. return RecipeFileManager.Instance.LoadGenericityRecipe<SrdRecipe>(strProduction);
  145. }
  146. else
  147. {
  148. return null;
  149. }
  150. }
  151. }
  152. }