DefaultRecipeFileContext.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using Aitex.Common.Util;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.RecipeCenter;
  5. using Aitex.Core.RT.SCCore;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Xml;
  10. namespace MECF.Framework.Common.RecipeCenter
  11. {
  12. public class DefaultRecipeFileContext : IRecipeFileContext
  13. {
  14. public string GetRecipeDefiniton(string chamberId)
  15. {
  16. try
  17. {
  18. string recipeSchema = PathManager.GetCfgDir() + @"\RecipeFormat.xml";
  19. XmlDocument xmlDom = new XmlDocument();
  20. xmlDom.Load(recipeSchema);
  21. bool epdInstalled = SC.ContainsItem("System.SetUp.EPDInstalled") && SC.GetValue<bool>($"System.SetUp.EPDInstalled");
  22. if (!epdInstalled)
  23. {
  24. var nodeEndPoint =
  25. xmlDom.SelectSingleNode(
  26. string.Format(
  27. "/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='System.SetUp.EPDInstalled']"))
  28. as XmlElement;
  29. if (nodeEndPoint != null)
  30. {
  31. nodeEndPoint.ParentNode.RemoveChild(nodeEndPoint);
  32. }
  33. }
  34. double rfPowerRange = SC.GetValue<double>($"{chamberId}.Rf.PowerRange");
  35. double rfPowerRangeBias = SC.GetValue<double>($"{chamberId}.BiasRf.PowerRange");
  36. bool rfEnablePulsing = SC.GetValue<bool>($"{chamberId}.Rf.EnablePulsingFunction");
  37. bool rfEnableBias = SC.GetValue<bool>($"{chamberId}.BiasRf.EnableBiasRF");
  38. var nodeRfPowerBias = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='BiasRf.SetPower']")) as XmlElement;
  39. var nodeMatchModeBias = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='BiasRf.SetMatchProcessMode']")) as XmlElement;
  40. var nodeMatchC1Bias = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='BiasRf.SetMatchPositionC1']")) as XmlElement;
  41. var nodeMatchC2Bias = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='BiasRf.SetMatchPositionC2']")) as XmlElement;
  42. var nodeRfPower = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPower']")) as XmlElement;
  43. if (nodeRfPower != null)
  44. {
  45. nodeRfPower.SetAttribute("Max", (int)rfPowerRange + "");
  46. }
  47. if (nodeRfPowerBias != null)
  48. {
  49. nodeRfPowerBias.SetAttribute("Max", (int)rfPowerRangeBias + "");
  50. if (!rfEnableBias)
  51. {
  52. nodeRfPowerBias.ParentNode.RemoveChild(nodeRfPowerBias);
  53. nodeMatchModeBias.ParentNode.RemoveChild(nodeMatchModeBias);
  54. nodeMatchC1Bias.ParentNode.RemoveChild(nodeMatchC1Bias);
  55. nodeMatchC2Bias.ParentNode.RemoveChild(nodeMatchC2Bias);
  56. }
  57. }
  58. if (!rfEnablePulsing)
  59. {
  60. var node1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPulsingFrequency']")) as XmlElement;
  61. if (node1 != null)
  62. node1.ParentNode.RemoveChild(node1);
  63. var node2 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPulsingDuty']")) as XmlElement;
  64. if (node2 != null)
  65. node2.ParentNode.RemoveChild(node2);
  66. var node3 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step/Item[@ControlName='PulsingMode']")) as XmlElement;
  67. if (node3 != null)
  68. node3.ParentNode.RemoveChild(node3);
  69. }
  70. string gas1Name = SC.GetStringValue($"{chamberId}.MfcGas1.GasName");
  71. bool gas1Enable = SC.GetValue<bool>($"{chamberId}.MfcGas1.Enable");
  72. int gas1N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas1.MfcN2Scale");
  73. double gas1ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas1.MfcScaleFactor");
  74. var nodeGas1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas1']")) as XmlElement;
  75. if (nodeGas1 != null)
  76. {
  77. nodeGas1.SetAttribute("DisplayName", gas1Name);
  78. nodeGas1.SetAttribute("Max", (int)(gas1N2Scale * gas1ScaleFactor) + "");
  79. if (!gas1Enable)
  80. nodeGas1.ParentNode.RemoveChild(nodeGas1);
  81. }
  82. string gas2Name = SC.GetStringValue($"{chamberId}.MfcGas2.GasName");
  83. bool gas2Enable = SC.GetValue<bool>($"{chamberId}.MfcGas2.Enable");
  84. int gas2N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas2.MfcN2Scale");
  85. double gas2ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas2.MfcScaleFactor");
  86. var nodeGas2 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas2']")) as XmlElement;
  87. if (nodeGas2 != null)
  88. {
  89. nodeGas2.SetAttribute("DisplayName", gas2Name);
  90. nodeGas2.SetAttribute("Max", (int)(gas2N2Scale * gas2ScaleFactor) + "");
  91. if (!gas2Enable)
  92. nodeGas2.ParentNode.RemoveChild(nodeGas2);
  93. }
  94. string gas3Name = SC.GetStringValue($"{chamberId}.MfcGas3.GasName");
  95. bool gas3Enable = SC.GetValue<bool>($"{chamberId}.MfcGas3.Enable");
  96. int gas3N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas3.MfcN2Scale");
  97. double gas3ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas3.MfcScaleFactor");
  98. var nodeGas3 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas3']")) as XmlElement;
  99. if (nodeGas3 != null)
  100. {
  101. nodeGas3.SetAttribute("DisplayName", gas3Name);
  102. nodeGas3.SetAttribute("Max", (int)(gas3N2Scale * gas3ScaleFactor) + "");
  103. if (!gas3Enable)
  104. nodeGas3.ParentNode.RemoveChild(nodeGas3);
  105. }
  106. string gas4Name = SC.GetStringValue($"{chamberId}.MfcGas4.GasName");
  107. bool gas4Enable = SC.GetValue<bool>($"{chamberId}.MfcGas4.Enable");
  108. int gas4N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas4.MfcN2Scale");
  109. double gas4ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas4.MfcScaleFactor");
  110. var nodeGas4 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas4']")) as XmlElement;
  111. if (nodeGas4 != null)
  112. {
  113. nodeGas4.SetAttribute("DisplayName", gas4Name);
  114. nodeGas4.SetAttribute("Max", (int)(gas4N2Scale * gas4ScaleFactor) + "");
  115. if (!gas4Enable)
  116. nodeGas4.ParentNode.RemoveChild(nodeGas4);
  117. }
  118. string gas5Name = SC.GetStringValue($"{chamberId}.MfcGas5.GasName");
  119. bool gas5Enable = SC.GetValue<bool>($"{chamberId}.MfcGas5.Enable");
  120. int gas5N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas5.MfcN2Scale");
  121. double gas5ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas5.MfcScaleFactor");
  122. var nodeGas5 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas5']")) as XmlElement;
  123. if (nodeGas5 != null)
  124. {
  125. nodeGas5.SetAttribute("DisplayName", gas5Name);
  126. nodeGas5.SetAttribute("Max", (int)(gas5N2Scale * gas5ScaleFactor) + "");
  127. if (!gas5Enable)
  128. nodeGas5.ParentNode.RemoveChild(nodeGas5);
  129. }
  130. //xmlDom.Save(recipeSchema);
  131. return xmlDom.OuterXml;
  132. }
  133. catch (Exception ex)
  134. {
  135. //LOG.Write(ex);
  136. return "";
  137. }
  138. }
  139. public IEnumerable<string> GetRecipes(string chamberId, bool includingUsedRecipe)
  140. {
  141. try
  142. {
  143. string recipePath = PathManager.GetRecipeDir() + chamberId + "\\";
  144. var di = new DirectoryInfo(recipePath);
  145. var fis = di.GetFiles("*.rcp", SearchOption.AllDirectories);
  146. var recipes = new List<string>();
  147. foreach (var fi in fis)
  148. {
  149. string str = fi.FullName.Substring(recipePath.Length);
  150. str = str.Substring(0, str.LastIndexOf('.'));
  151. if (includingUsedRecipe || (!includingUsedRecipe && !str.Contains("HistoryRecipe\\")))
  152. {
  153. recipes.Add(str);
  154. }
  155. }
  156. return recipes;
  157. }
  158. catch (Exception ex)
  159. {
  160. //LOG.Write(ex);
  161. return new List<string>();
  162. }
  163. }
  164. public void PostInfoEvent(string message)
  165. {
  166. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  167. }
  168. public void PostWarningEvent(string message)
  169. {
  170. EV.PostMessage("System", EventEnum.DefaultWarning, message);
  171. }
  172. public void PostAlarmEvent(string message)
  173. {
  174. EV.PostMessage("System", EventEnum.DefaultAlarm, message);
  175. }
  176. public void PostDialogEvent(string message)
  177. {
  178. EV.PostNotificationMessage(message);
  179. }
  180. public void PostInfoDialogMessage(string message)
  181. {
  182. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  183. EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
  184. }
  185. public void PostWarningDialogMessage(string message)
  186. {
  187. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  188. EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
  189. }
  190. public void PostAlarmDialogMessage(string message)
  191. {
  192. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  193. EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
  194. }
  195. public string GetRecipeTemplate(string chamberId)
  196. {
  197. string schema = GetRecipeDefiniton(chamberId);
  198. XmlDocument dom = new XmlDocument();
  199. dom.LoadXml(schema);
  200. XmlNode nodeTemplate = dom.SelectSingleNode("/Aitex/TableRecipeData");
  201. return nodeTemplate.OuterXml;
  202. }
  203. public bool EnableEdit(string recipeName)
  204. {
  205. return true;
  206. }
  207. }
  208. }