DefaultRecipeFileContext.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. using Aitex.Core.RT.SCCore;
  13. namespace MECF.Framework.Common.RecipeCenter
  14. {
  15. public class DefaultRecipeFileContext : IRecipeFileContext
  16. {
  17. public string GetRecipeDefiniton(string chamberId)
  18. {
  19. try
  20. {
  21. string recipeSchema = PathManager.GetCfgDir() + @"\RecipeFormat.xml";
  22. XmlDocument xmlDom = new XmlDocument();
  23. xmlDom.Load(recipeSchema);
  24. int count = (int)SC.GetValue<int>($"PMA.GasCount");
  25. string gas1Name = SC.GetStringValue($"PMA.MfcGas1.GasName");
  26. int gas1N2Scale = SC.GetValue<int>($"PMA.MfcGas1.MfcN2Scale");
  27. double gas1ScaleFactor = SC.GetValue<double>($"PMA.MfcGas1.MfcScaleFactor");
  28. var nodeGas1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas1']")) as XmlElement;
  29. if (nodeGas1 != null)
  30. {
  31. if (count < 1)
  32. {
  33. nodeGas1.ParentNode.RemoveChild(nodeGas1);
  34. }
  35. else
  36. {
  37. nodeGas1.SetAttribute("DisplayName", gas1Name + " " + gas1N2Scale * gas1ScaleFactor + " " + "sccm");
  38. nodeGas1.SetAttribute("Max", (int)(gas1N2Scale * gas1ScaleFactor) + "");
  39. }
  40. }
  41. string gas2Name = SC.GetStringValue($"PMA.MfcGas2.GasName");
  42. int gas2N2Scale = SC.GetValue<int>($"PMA.MfcGas2.MfcN2Scale");
  43. double gas2ScaleFactor = SC.GetValue<double>($"PMA.MfcGas2.MfcScaleFactor");
  44. var nodeGas2 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas2']")) as XmlElement;
  45. if (nodeGas2 != null)
  46. {
  47. if (count < 2)
  48. {
  49. nodeGas2.ParentNode.RemoveChild(nodeGas2);
  50. }
  51. else
  52. {
  53. nodeGas2.SetAttribute("DisplayName",gas2Name + " " + gas2N2Scale * gas2ScaleFactor + " " + "sccm");
  54. nodeGas2.SetAttribute("Max", (int)(gas2N2Scale * gas2ScaleFactor) + "");
  55. }
  56. }
  57. string gas3Name = SC.GetStringValue($"PMA.MfcGas3.GasName");
  58. int gas3N2Scale = SC.GetValue<int>($"PMA.MfcGas3.MfcN2Scale");
  59. double gas3ScaleFactor = SC.GetValue<double>($"PMA.MfcGas3.MfcScaleFactor");
  60. var nodeGas3 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas3']")) as XmlElement;
  61. if (nodeGas3 != null)
  62. {
  63. if (count < 3)
  64. {
  65. nodeGas3.ParentNode.RemoveChild(nodeGas3);
  66. }
  67. else
  68. {
  69. nodeGas3.SetAttribute("DisplayName",gas3Name + " " + gas3N2Scale * gas3ScaleFactor + " " + "sccm");
  70. nodeGas3.SetAttribute("Max", (int)(gas3N2Scale * gas3ScaleFactor) + "");
  71. }
  72. }
  73. string gas4Name = SC.GetStringValue($"PMA.MfcGas4.GasName");
  74. int gas4N2Scale = SC.GetValue<int>($"PMA.MfcGas4.MfcN2Scale");
  75. double gas4ScaleFactor = SC.GetValue<double>($"PMA.MfcGas4.MfcScaleFactor");
  76. var nodeGas4 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas4']")) as XmlElement;
  77. if (nodeGas4 != null)
  78. {
  79. if (count < 4)
  80. {
  81. nodeGas4.ParentNode.RemoveChild(nodeGas4);
  82. }
  83. else
  84. {
  85. nodeGas4.SetAttribute("DisplayName",gas4Name + " " + gas4N2Scale * gas4ScaleFactor + " " + "sccm");
  86. nodeGas4.SetAttribute("Max", (int)(gas4N2Scale * gas4ScaleFactor) + "");
  87. }
  88. }
  89. return xmlDom.OuterXml;
  90. }
  91. catch (Exception ex)
  92. {
  93. LOG.Write(ex);
  94. return "";
  95. }
  96. }
  97. public IEnumerable<string> GetRecipes(string chamberId, bool includingUsedRecipe)
  98. {
  99. try
  100. {
  101. string recipePath = PathManager.GetRecipeDir() + chamberId + "\\";
  102. var di = new DirectoryInfo(recipePath);
  103. var fis = di.GetFiles("*.rcp", SearchOption.AllDirectories);
  104. var recipes = new List<string>();
  105. foreach (var fi in fis)
  106. {
  107. string str = fi.FullName.Substring(recipePath.Length);
  108. str = str.Substring(0, str.LastIndexOf('.'));
  109. if (includingUsedRecipe || (!includingUsedRecipe && !str.Contains("HistoryRecipe\\")))
  110. {
  111. recipes.Add(str);
  112. }
  113. }
  114. return recipes;
  115. }
  116. catch (Exception ex)
  117. {
  118. LOG.Write(ex);
  119. return new List<string>();
  120. }
  121. }
  122. public void PostInfoEvent(string message)
  123. {
  124. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  125. }
  126. public void PostWarningEvent(string message)
  127. {
  128. EV.PostMessage("System", EventEnum.DefaultWarning, message);
  129. }
  130. public void PostAlarmEvent(string message)
  131. {
  132. EV.PostMessage("System", EventEnum.DefaultAlarm, message);
  133. }
  134. public void PostDialogEvent(string message)
  135. {
  136. EV.PostNotificationMessage(message);
  137. }
  138. public void PostInfoDialogMessage(string message)
  139. {
  140. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  141. EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
  142. }
  143. public void PostWarningDialogMessage(string message)
  144. {
  145. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  146. EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
  147. }
  148. public void PostAlarmDialogMessage(string message)
  149. {
  150. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  151. EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
  152. }
  153. public string GetRecipeTemplate(string chamberId)
  154. {
  155. string schema = GetRecipeDefiniton(chamberId);
  156. XmlDocument dom = new XmlDocument();
  157. dom.LoadXml(schema);
  158. XmlNode nodeTemplate = dom.SelectSingleNode("/Aitex/TableRecipeData");
  159. return nodeTemplate.OuterXml;
  160. }
  161. }
  162. }