VirgoRecipeFileContext.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. var nodeRfPowerBiasSoft = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='BiasRf.SoftTolerance']")) as XmlElement;
  48. var nodeRfPowerBiasHard = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='BiasRf.HardTolerance']")) as XmlElement;
  49. if (nodeRfPower != null)
  50. {
  51. nodeRfPower.SetAttribute("Max", (int)rfPowerRange + "");
  52. }
  53. if (nodeRfPowerBias != null)
  54. {
  55. nodeRfPowerBias.SetAttribute("Max", (int)rfPowerRangeBias + "");
  56. if (!rfEnableBias)
  57. {
  58. nodeRfPowerBias.ParentNode.RemoveChild(nodeRfPowerBias);
  59. nodeMatchModeBias.ParentNode.RemoveChild(nodeMatchModeBias);
  60. nodeMatchC1Bias.ParentNode.RemoveChild(nodeMatchC1Bias);
  61. nodeMatchC2Bias.ParentNode.RemoveChild(nodeMatchC2Bias);
  62. nodeRfPowerBiasSoft?.ParentNode.RemoveChild(nodeRfPowerBiasSoft);
  63. nodeRfPowerBiasHard?.ParentNode.RemoveChild(nodeRfPowerBiasHard);
  64. }
  65. }
  66. if (!rfEnablePulsing)
  67. {
  68. var node1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPulsingFrequency']")) as XmlElement;
  69. if (node1 != null)
  70. node1.ParentNode.RemoveChild(node1);
  71. var node2 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPulsingDuty']")) as XmlElement;
  72. if (node2 != null)
  73. node2.ParentNode.RemoveChild(node2);
  74. var node3 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step/Item[@ControlName='PulsingMode']")) as XmlElement;
  75. if (node3 != null)
  76. node3.ParentNode.RemoveChild(node3);
  77. }
  78. string gas1Name = SC.GetStringValue($"{chamberId}.MfcGas1.GasName");
  79. bool gas1Enable = SC.GetValue<bool>($"{chamberId}.MfcGas1.Enable");
  80. int gas1N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas1.MfcN2Scale");
  81. double gas1ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas1.MfcScaleFactor");
  82. var nodeGas1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas1']")) as XmlElement;
  83. var nodeGas1Soft = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas1.SoftTolerance']")) as XmlElement;
  84. var nodeGas1Hard = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas1.HardTolerance']")) as XmlElement;
  85. if (nodeGas1 != null)
  86. {
  87. if (!gas1Enable)
  88. {
  89. nodeGas1.ParentNode.RemoveChild(nodeGas1);
  90. nodeGas1Soft.ParentNode.RemoveChild(nodeGas1Soft);
  91. nodeGas1Hard.ParentNode.RemoveChild(nodeGas1Hard);
  92. }
  93. else
  94. {
  95. nodeGas1.SetAttribute("DisplayName", "Gas1 " + $"({gas1Name})" + " " + (int)(gas1N2Scale * gas1ScaleFactor) + " " + "sccm");
  96. nodeGas1.SetAttribute("Max", (int)(gas1N2Scale * gas1ScaleFactor) + "");
  97. nodeGas1Soft.SetAttribute("DisplayName", $"{gas1Name} (Soft)(%)");
  98. nodeGas1Hard.SetAttribute("DisplayName", $"{gas1Name} (Hard)(%)");
  99. }
  100. }
  101. string gas2Name = SC.GetStringValue($"{chamberId}.MfcGas2.GasName");
  102. bool gas2Enable = SC.GetValue<bool>($"{chamberId}.MfcGas2.Enable");
  103. int gas2N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas2.MfcN2Scale");
  104. double gas2ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas2.MfcScaleFactor");
  105. var nodeGas2 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas2']")) as XmlElement;
  106. var nodeGas2Soft = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas2.SoftTolerance']")) as XmlElement;
  107. var nodeGas2Hard = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas2.HardTolerance']")) as XmlElement;
  108. if (nodeGas2 != null)
  109. {
  110. if (!gas2Enable)
  111. {
  112. nodeGas2.ParentNode.RemoveChild(nodeGas2);
  113. nodeGas2Soft.ParentNode.RemoveChild(nodeGas2Soft);
  114. nodeGas2Hard.ParentNode.RemoveChild(nodeGas2Hard);
  115. }
  116. else
  117. {
  118. nodeGas2.SetAttribute("DisplayName", "Gas2 " + $"({gas2Name})" + " " + (int)(gas2N2Scale * gas2ScaleFactor) + " " + "sccm");
  119. nodeGas2.SetAttribute("Max", (int)(gas2N2Scale * gas2ScaleFactor) + "");
  120. nodeGas2Soft.SetAttribute("DisplayName", $"{gas2Name} (Soft)(%)");
  121. nodeGas2Hard.SetAttribute("DisplayName", $"{gas2Name} (Hard)(%)");
  122. }
  123. }
  124. string gas3Name = SC.GetStringValue($"{chamberId}.MfcGas3.GasName");
  125. bool gas3Enable = SC.GetValue<bool>($"{chamberId}.MfcGas3.Enable");
  126. int gas3N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas3.MfcN2Scale");
  127. double gas3ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas3.MfcScaleFactor");
  128. var nodeGas3 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas3']")) as XmlElement;
  129. var nodeGas3Soft = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas3.SoftTolerance']")) as XmlElement;
  130. var nodeGas3Hard = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas3.HardTolerance']")) as XmlElement;
  131. if (nodeGas3 != null)
  132. {
  133. if (!gas3Enable)
  134. {
  135. nodeGas3.ParentNode.RemoveChild(nodeGas3);
  136. nodeGas3Soft.ParentNode.RemoveChild(nodeGas3Soft);
  137. nodeGas3Hard.ParentNode.RemoveChild(nodeGas3Hard);
  138. }
  139. else
  140. {
  141. nodeGas3.SetAttribute("DisplayName", "Gas3 " + $"({gas3Name})" + " " + (int)(gas3N2Scale * gas3ScaleFactor) + " " + "sccm");
  142. nodeGas3.SetAttribute("Max", (int)(gas3N2Scale * gas3ScaleFactor) + "");
  143. nodeGas3Soft.SetAttribute("DisplayName", $"{gas3Name} (Soft)(%)");
  144. nodeGas3Hard.SetAttribute("DisplayName", $"{gas3Name} (Hard)(%)");
  145. }
  146. }
  147. string gas4Name = SC.GetStringValue($"{chamberId}.MfcGas4.GasName");
  148. bool gas4Enable = SC.GetValue<bool>($"{chamberId}.MfcGas4.Enable");
  149. int gas4N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas4.MfcN2Scale");
  150. double gas4ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas4.MfcScaleFactor");
  151. var nodeGas4 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas4']")) as XmlElement;
  152. var nodeGas4Soft = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas4.SoftTolerance']")) as XmlElement;
  153. var nodeGas4Hard = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas4.HardTolerance']")) as XmlElement;
  154. if (nodeGas4 != null)
  155. {
  156. if (!gas4Enable)
  157. {
  158. nodeGas4.ParentNode.RemoveChild(nodeGas4);
  159. nodeGas4Soft.ParentNode.RemoveChild(nodeGas4Soft);
  160. nodeGas4Hard.ParentNode.RemoveChild(nodeGas4Hard);
  161. }
  162. else
  163. {
  164. nodeGas4.SetAttribute("DisplayName", "Gas4 " + $"({gas4Name})" + " " + gas4N2Scale + " " + "sccm");
  165. nodeGas4.SetAttribute("Max", (int)(gas4N2Scale * gas4ScaleFactor) + "");
  166. nodeGas4Soft.SetAttribute("DisplayName", $"{gas4Name} (Soft)(%)");
  167. nodeGas4Hard.SetAttribute("DisplayName", $"{gas4Name} (Hard)(%)");
  168. }
  169. }
  170. string gas5Name = SC.GetStringValue($"{chamberId}.MfcGas5.GasName");
  171. bool gas5Enable = SC.GetValue<bool>($"{chamberId}.MfcGas5.Enable");
  172. int gas5N2Scale = SC.GetValue<int>($"{chamberId}.MfcGas5.MfcN2Scale");
  173. double gas5ScaleFactor = SC.GetValue<double>($"{chamberId}.MfcGas5.MfcScaleFactor");
  174. var nodeGas5 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas5']")) as XmlElement;
  175. var nodeGas5Soft = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas5.SoftTolerance']")) as XmlElement;
  176. var nodeGas5Hard = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas5.HardTolerance']")) as XmlElement;
  177. if (nodeGas5 != null)
  178. {
  179. if (!gas5Enable)
  180. {
  181. nodeGas5.ParentNode.RemoveChild(nodeGas5);
  182. nodeGas5Soft.ParentNode.RemoveChild(nodeGas5Soft);
  183. nodeGas5Hard.ParentNode.RemoveChild(nodeGas5Hard);
  184. }
  185. else
  186. {
  187. nodeGas5.SetAttribute("DisplayName", "Gas5 " + $"({gas5Name})" + " " + (int)(gas5N2Scale * gas5ScaleFactor) + " " + "sccm");
  188. nodeGas5.SetAttribute("Max", (int)(gas5N2Scale * gas5ScaleFactor) + "");
  189. nodeGas5Soft.SetAttribute("DisplayName", $"{gas5Name} (Soft)(%)");
  190. nodeGas5Hard.SetAttribute("DisplayName", $"{gas5Name} (Hard)(%)");
  191. }
  192. }
  193. //xmlDom.Save(recipeSchema);
  194. return xmlDom.OuterXml;
  195. }
  196. catch (Exception ex)
  197. {
  198. LOG.Write(ex);
  199. return "";
  200. }
  201. }
  202. public IEnumerable<string> GetRecipes(string chamberId, bool includingUsedRecipe)
  203. {
  204. try
  205. {
  206. string recipePath = PathManager.GetRecipeDir() + chamberId + "\\";
  207. var di = new DirectoryInfo(recipePath);
  208. var fis = di.GetFiles("*.rcp", SearchOption.AllDirectories);
  209. var recipes = new List<string>();
  210. foreach (var fi in fis)
  211. {
  212. string str = fi.FullName.Substring(recipePath.Length);
  213. str = str.Substring(0, str.LastIndexOf('.'));
  214. if (includingUsedRecipe || (!includingUsedRecipe && !str.Contains("HistoryRecipe\\")))
  215. {
  216. if (SC.GetValue<bool>("System.RecipeSplit"))
  217. {
  218. if(str.StartsWith("Process")||str.StartsWith("Clean"))
  219. recipes.Add(str);
  220. }
  221. else
  222. {
  223. recipes.Add(str);
  224. }
  225. }
  226. }
  227. return recipes;
  228. }
  229. catch (Exception ex)
  230. {
  231. LOG.Write(ex);
  232. return new List<string>();
  233. }
  234. }
  235. public void PostInfoEvent(string message)
  236. {
  237. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  238. }
  239. public void PostWarningEvent(string message)
  240. {
  241. EV.PostMessage("System", EventEnum.DefaultWarning, message);
  242. }
  243. public void PostAlarmEvent(string message)
  244. {
  245. EV.PostMessage("System", EventEnum.DefaultAlarm, message);
  246. }
  247. public void PostDialogEvent(string message)
  248. {
  249. EV.PostNotificationMessage(message);
  250. }
  251. public void PostInfoDialogMessage(string message)
  252. {
  253. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  254. EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
  255. }
  256. public void PostWarningDialogMessage(string message)
  257. {
  258. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  259. EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
  260. }
  261. public void PostAlarmDialogMessage(string message)
  262. {
  263. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  264. EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
  265. }
  266. public string GetRecipeTemplate(string chamberId)
  267. {
  268. string schema = GetRecipeDefiniton(chamberId);
  269. XmlDocument dom = new XmlDocument();
  270. dom.LoadXml(schema);
  271. XmlNode nodeTemplate = dom.SelectSingleNode("/Aitex/TableRecipeData");
  272. return nodeTemplate.OuterXml;
  273. }
  274. public bool EnableEdit(string recipeName)
  275. {
  276. if (Singleton<RouteManager>.Instance.CheckRecipeUsedInJob(recipeName))
  277. {
  278. EV.PostWarningLog("System", "Recipe is used in auto running jobs, can not be modified");
  279. return false;
  280. }
  281. return true;
  282. }
  283. }
  284. }