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