DefaultRecipeFileContext.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Xml;
  9. using Aitex.Common.Util;
  10. using Aitex.Core.RT.Event;
  11. using Aitex.Core.RT.Log;
  12. using Aitex.Core.RT.RecipeCenter;
  13. using Aitex.Core.RT.SCCore;
  14. namespace MECF.Framework.Common.RecipeCenter
  15. {
  16. public class DefaultRecipeFileContext : IRecipeFileContext
  17. {
  18. public string GetRecipeDefiniton(string chamberType)
  19. {
  20. try
  21. {
  22. string recipeSchema = PathManager.GetCfgDir() + $@"\Recipe\{chamberType}\RecipeFormat.xml";
  23. if (chamberType=="Process")
  24. {
  25. recipeSchema = PathManager.GetCfgDir() + $@"\Recipe\{chamberType}\{SC.GetStringValue("System.SetUp.ToolType")}\RecipeFormat.xml";
  26. }
  27. XmlDocument xmlDom = new XmlDocument();
  28. xmlDom.Load(recipeSchema);
  29. return xmlDom.OuterXml;
  30. }
  31. catch (Exception ex)
  32. {
  33. LOG.Write(ex);
  34. return "";
  35. }
  36. }
  37. public IEnumerable<string> GetRecipes(string path, bool includingUsedRecipe)
  38. {
  39. try
  40. {
  41. var recipes = new List<string>();
  42. string recipePath = PathManager.GetRecipeDir() + path + "\\";
  43. if (!Directory.Exists(recipePath))
  44. return recipes;
  45. var di = new DirectoryInfo(recipePath);
  46. var fis = di.GetFiles("*.rcp", SearchOption.AllDirectories);
  47. foreach (var fi in fis)
  48. {
  49. string str = fi.FullName.Substring(di.FullName.Length);
  50. str = str.Substring(0, str.LastIndexOf('.'));
  51. if (includingUsedRecipe || (!includingUsedRecipe && !str.Contains("HistoryRecipe\\")))
  52. {
  53. recipes.Add(str);
  54. }
  55. }
  56. return recipes;
  57. }
  58. catch (Exception ex)
  59. {
  60. LOG.Write(ex);
  61. return new List<string>();
  62. }
  63. }
  64. public void PostInfoEvent(string message)
  65. {
  66. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  67. }
  68. public void PostWarningEvent(string message)
  69. {
  70. EV.PostMessage("System", EventEnum.DefaultWarning, message);
  71. }
  72. public void PostAlarmEvent(string message)
  73. {
  74. EV.PostMessage("System", EventEnum.DefaultAlarm, message);
  75. }
  76. public void PostDialogEvent(string message)
  77. {
  78. EV.PostNotificationMessage(message);
  79. }
  80. public void PostInfoDialogMessage(string message)
  81. {
  82. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  83. EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
  84. }
  85. public void PostWarningDialogMessage(string message)
  86. {
  87. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  88. EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
  89. }
  90. public void PostAlarmDialogMessage(string message)
  91. {
  92. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  93. EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
  94. }
  95. public string GetRecipeTemplate(string chamberId)
  96. {
  97. string schema = GetRecipeDefiniton(chamberId);
  98. XmlDocument dom = new XmlDocument();
  99. dom.LoadXml(schema);
  100. XmlNode nodeTemplate = dom.SelectSingleNode("/Aitex/TableRecipeData");
  101. return nodeTemplate.OuterXml;
  102. }
  103. public Dictionary<string, ObservableCollection<RecipeTemplateColumnBase>> GetGroupRecipeTemplate()
  104. {
  105. string schema = GetRecipeDefiniton("Developer");
  106. XmlDocument dom = new XmlDocument();
  107. dom.LoadXml(schema);
  108. return null;
  109. }
  110. }
  111. }