VirgoRecipeFileContext.cs 12 KB

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