ParameterFileContext.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using Aitex.Common.Util;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.ParameterCenter;
  5. using Aitex.Core.RT.SCCore;
  6. using MECF.Framework.Common.ParameterCenter;
  7. using MECF.Framework.Common.RecipeCenter;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Collections.ObjectModel;
  11. using System.IO;
  12. using System.Xml;
  13. namespace FurnaceRT.Parameter
  14. {
  15. public class ParameterFileContext : IParameterFileContext
  16. {
  17. public string GetParameterDefiniton(string chamberType)
  18. {
  19. try
  20. {
  21. string type = "";
  22. if (string.IsNullOrEmpty(chamberType))
  23. { type = "Parameter\\TempPID"; }
  24. else
  25. {
  26. type = chamberType;
  27. }
  28. string recipeSchema = PathManager.GetCfgDir() + $"{type}\\ParameterFormat.xml";
  29. XmlDocument xmlDom = new XmlDocument();
  30. xmlDom.Load(recipeSchema);
  31. return xmlDom.OuterXml;
  32. }
  33. catch (Exception ex)
  34. {
  35. LOG.Write(ex);
  36. return "";
  37. }
  38. }
  39. public string GetSingleNodePath(int sourceIndex, int gasIndex)
  40. {
  41. return $"/Aitex/TableParameterFormat/Catalog[@DisplayName=\"Source{sourceIndex}\"]/Group/Step/Item[@ControlName=\"Gas{gasIndex}\"]";
  42. }
  43. public IEnumerable<string> GetParameters(string path, bool includingUsedRecipe)
  44. {
  45. try
  46. {
  47. var recipes = new List<string>();
  48. string recipePath = PathManager.GetRecipeDir() + path + "\\";
  49. if (!Directory.Exists(recipePath))
  50. return recipes;
  51. var di = new DirectoryInfo(recipePath);
  52. var fis = di.GetFiles("*.rcp", SearchOption.AllDirectories);
  53. foreach (var fi in fis)
  54. {
  55. string str = fi.FullName.Substring(di.FullName.Length);
  56. str = str.Substring(0, str.LastIndexOf('.'));
  57. if (includingUsedRecipe || (!includingUsedRecipe && !str.Contains("HistoryParameter\\")))
  58. {
  59. recipes.Add(str);
  60. }
  61. }
  62. return recipes;
  63. }
  64. catch (Exception ex)
  65. {
  66. LOG.Write(ex);
  67. return new List<string>();
  68. }
  69. }
  70. public void PostInfoEvent(string message)
  71. {
  72. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  73. }
  74. public void PostWarningEvent(string message)
  75. {
  76. EV.PostMessage("System", EventEnum.DefaultWarning, message);
  77. }
  78. public void PostAlarmEvent(string message)
  79. {
  80. EV.PostMessage("System", EventEnum.DefaultAlarm, message);
  81. }
  82. public void PostDialogEvent(string message)
  83. {
  84. EV.PostNotificationMessage(message);
  85. }
  86. public void PostInfoDialogMessage(string message)
  87. {
  88. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  89. EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
  90. }
  91. public void PostWarningDialogMessage(string message)
  92. {
  93. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  94. EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
  95. }
  96. public void PostAlarmDialogMessage(string message)
  97. {
  98. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  99. EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
  100. }
  101. public string GetParameterTemplate(string chamberId)
  102. {
  103. string schema = GetParameterDefiniton(chamberId);
  104. XmlDocument dom = new XmlDocument();
  105. dom.LoadXml(schema);
  106. XmlNode nodeTemplate = dom.SelectSingleNode("/Aitex/TableRecipeData");
  107. return nodeTemplate.OuterXml;
  108. }
  109. public Dictionary<string, ObservableCollection<ParameterTemplateColumnBase>> GetGroupParameterTemplate()
  110. {
  111. throw new NotImplementedException();
  112. }
  113. }
  114. }