DefaultRecipeFileContext.cs 3.5 KB

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