RtRecipeFileContext.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.RT.RecipeCenter;
  4. using Aitex.Common.Util;
  5. using System.Xml;
  6. using Aitex.Core.RT.SCCore;
  7. using System.IO;
  8. using Aitex.Core.RT.Log;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.RT.Properties;
  11. namespace Aitex.RT.Module
  12. {
  13. class RtRecipeFileContext : IRecipeFileContext
  14. {
  15. private Dictionary<string, string> _dicDisplayName = new Dictionary<string, string>()
  16. {
  17. {"StepInfo", "步骤信息"},
  18. {"Set", "设置"},
  19. {"No.", "步数"},
  20. {"Name", "名称"},
  21. {"Loop", "循环"},
  22. {"Loop 10", "循环 10"},
  23. {"Loop End", "循环结束"},
  24. {"Step Mode", "步骤结束模式"},
  25. {"Step Time Mode", "按步骤设定时间"},
  26. {"RF Time Mode", "按射频时间"},
  27. {"Step Time", "步骤时间"},
  28. {"Chamber Pressure Setting", "压力设定"},
  29. {"Chamber Pressure", "腔体压力"},
  30. {"ValveMode", "球阀模式"},
  31. {"Pressure", "压力模式"},
  32. {"Position", "位置模式"},
  33. {"Valve Position", "球阀位置"},
  34. {"TVPressure", "球阀压力"},
  35. {"RF Setting", "射频设置"},
  36. {"RF", "射频"},
  37. {"RF Time", "射频时间"},
  38. {"RFMode", "射频模式"},
  39. {"Continuous", "持续模式"},
  40. {"Pulsing", "脉冲模式"},
  41. {"Pulsing Frequency", "脉冲频率"},
  42. {"Pulsing Duty", "脉冲频次Duty"},
  43. {"RFPower", "射频功率"},
  44. {"GasFlow", "气体流量设置"},
  45. {"MFC", "气流"},
  46. };
  47. public string GetRecipeDefiniton(string chamberId)
  48. {
  49. try
  50. {
  51. string recipeSchema = PathManager.GetCfgDir() + @"\RecipeFormat.xml";
  52. XmlDocument xmlDom = new XmlDocument();
  53. xmlDom.Load(recipeSchema);
  54. if (Resources.Culture.Name.ToLower() == "zh-cn")
  55. {
  56. foreach (var nodeCatalog in xmlDom.SelectNodes("/Aitex/TableRecipeFormat/Catalog"))
  57. {
  58. XmlElement catalog = nodeCatalog as XmlElement;
  59. if (catalog != null)
  60. {
  61. if (catalog.HasAttribute("DisplayName"))
  62. {
  63. if (_dicDisplayName.ContainsKey(catalog.GetAttribute("DisplayName")))
  64. {
  65. catalog.SetAttribute("DisplayName", _dicDisplayName[catalog.GetAttribute("DisplayName")]);
  66. }
  67. }
  68. }
  69. }
  70. foreach (var node in xmlDom.SelectNodes("/Aitex/TableRecipeFormat/Catalog/Group/Step"))
  71. {
  72. XmlElement step = node as XmlElement;
  73. if (step != null)
  74. {
  75. if (step.HasAttribute("DisplayName"))
  76. {
  77. if (_dicDisplayName.ContainsKey(step.GetAttribute("DisplayName")))
  78. {
  79. step.SetAttribute("DisplayName", _dicDisplayName[step.GetAttribute("DisplayName")]);
  80. }
  81. }
  82. }
  83. }
  84. foreach (var node in xmlDom.SelectNodes("/Aitex/TableRecipeFormat/Catalog/Group/Step/Item"))
  85. {
  86. XmlElement item = node as XmlElement;
  87. if (item != null)
  88. {
  89. if (item.HasAttribute("DisplayName"))
  90. {
  91. if (_dicDisplayName.ContainsKey(item.GetAttribute("DisplayName")))
  92. {
  93. item.SetAttribute("DisplayName", _dicDisplayName[item.GetAttribute("DisplayName")]);
  94. }
  95. }
  96. }
  97. }
  98. }
  99. double rfPowerRange = SC.GetValue<double>(SCName.RfConfig_PowerRange);
  100. bool rfEnablePulsing = SC.GetValue<bool>(SCName.RfConfig_EnablePulsingFunction);
  101. var nodeRfPower = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPower']")) as XmlElement;
  102. if (nodeRfPower != null)
  103. {
  104. nodeRfPower.SetAttribute("Max", (int)rfPowerRange + "");
  105. }
  106. if (!rfEnablePulsing)
  107. {
  108. var node1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPulsingFrequency']")) as XmlElement;
  109. if (node1 != null)
  110. node1.ParentNode.RemoveChild(node1);
  111. var node2 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='Rf.SetPulsingDuty']")) as XmlElement;
  112. if (node2 != null)
  113. node2.ParentNode.RemoveChild(node2);
  114. var node3 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step/Item[@ControlName='PulsingMode']")) as XmlElement;
  115. if (node3 != null)
  116. node3.ParentNode.RemoveChild(node3);
  117. }
  118. string gas1Name = (string)SC.GetItemValue(SCName.GasLineConfig_Gas1Name);
  119. bool gas1Enable = SC.GetValue<bool>(SCName.GasLineConfig_Gas1Enable);
  120. double gas1N2Scale = SC.GetValue<double>(SCName.GasLineConfig_Gas1MfcN2Scale);
  121. double gas1ScaleFactor = SC.GetValue<double>(SCName.GasLineConfig_Gas1MfcScaleFactor);
  122. var nodeGas1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas1']")) as XmlElement;
  123. if (nodeGas1 != null)
  124. {
  125. nodeGas1.SetAttribute("DisplayName", string.Format("MFC1({0})", gas1Name));
  126. nodeGas1.SetAttribute("Max", (int)(gas1N2Scale * gas1ScaleFactor) + "");
  127. if (!gas1Enable)
  128. nodeGas1.ParentNode.RemoveChild(nodeGas1);
  129. }
  130. string gas2Name = (string)SC.GetItemValue(SCName.GasLineConfig_Gas2Name);
  131. bool gas2Enable = SC.GetValue<bool>(SCName.GasLineConfig_Gas2Enable);
  132. double gas2N2Scale = SC.GetValue<double>(SCName.GasLineConfig_Gas2MfcN2Scale);
  133. double gas2ScaleFactor = SC.GetValue<double>(SCName.GasLineConfig_Gas2MfcScaleFactor);
  134. var nodeGas2 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas2']")) as XmlElement;
  135. if (nodeGas2 != null)
  136. {
  137. nodeGas2.SetAttribute("DisplayName", string.Format("MFC2({0})", gas2Name));
  138. nodeGas2.SetAttribute("Max", (int)(gas2N2Scale * gas2ScaleFactor) + "");
  139. if (!gas2Enable)
  140. nodeGas2.ParentNode.RemoveChild(nodeGas2);
  141. }
  142. string gas3Name = (string)SC.GetItemValue(SCName.GasLineConfig_Gas3Name);
  143. bool gas3Enable = SC.GetValue<bool>(SCName.GasLineConfig_Gas3Enable);
  144. double gas3N2Scale = SC.GetValue<double>(SCName.GasLineConfig_Gas3MfcN2Scale);
  145. double gas3ScaleFactor = SC.GetValue<double>(SCName.GasLineConfig_Gas3MfcScaleFactor);
  146. var nodeGas3 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas3']")) as XmlElement;
  147. if (nodeGas3 != null)
  148. {
  149. nodeGas3.SetAttribute("DisplayName", string.Format("MFC3({0})", gas3Name));
  150. nodeGas3.SetAttribute("Max", (int)(gas3N2Scale * gas3ScaleFactor) + "");
  151. if (!gas3Enable)
  152. nodeGas3.ParentNode.RemoveChild(nodeGas3);
  153. }
  154. string gas4Name = (string)SC.GetItemValue(SCName.GasLineConfig_Gas4Name);
  155. bool gas4Enable = SC.GetValue<bool>(SCName.GasLineConfig_Gas4Enable);
  156. double gas4N2Scale = SC.GetValue<double>(SCName.GasLineConfig_Gas4MfcN2Scale);
  157. double gas4ScaleFactor = SC.GetValue<double>(SCName.GasLineConfig_Gas4MfcScaleFactor);
  158. var nodeGas4 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas4']")) as XmlElement;
  159. if (nodeGas4 != null)
  160. {
  161. nodeGas4.SetAttribute("DisplayName", string.Format("MFC4({0})", gas4Name));
  162. nodeGas4.SetAttribute("Max", (int)(gas4N2Scale * gas4ScaleFactor) + "");
  163. if (!gas4Enable)
  164. nodeGas4.ParentNode.RemoveChild(nodeGas4);
  165. }
  166. string gas5Name = (string)SC.GetItemValue(SCName.GasLineConfig_Gas5Name);
  167. bool gas5Enable = SC.GetValue<bool>(SCName.GasLineConfig_Gas5Enable);
  168. double gas5N2Scale = SC.GetValue<double>(SCName.GasLineConfig_Gas5MfcN2Scale);
  169. double gas5ScaleFactor = SC.GetValue<double>(SCName.GasLineConfig_Gas5MfcScaleFactor);
  170. var nodeGas5 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='MfcGas5']")) as XmlElement;
  171. if (nodeGas5 != null)
  172. {
  173. nodeGas5.SetAttribute("DisplayName", string.Format("MFC5({0})", gas5Name));
  174. nodeGas5.SetAttribute("Max", (int)(gas5N2Scale * gas5ScaleFactor) + "");
  175. if (!gas5Enable)
  176. nodeGas5.ParentNode.RemoveChild(nodeGas5);
  177. }
  178. bool isTvInstalled = SC.GetValue<bool>(SCName.PressureControlConfig_EnableThrottleValve);
  179. if (!isTvInstalled)
  180. {
  181. var nodeSetMode = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='PressureControl.SetTVMode']"))
  182. as XmlElement;
  183. if (nodeSetMode != null)
  184. {
  185. nodeSetMode.ParentNode.RemoveChild(nodeSetMode);
  186. }
  187. var nodeSetPosition = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='PressureControl.SetTVPosition']")) as XmlElement;
  188. if (nodeSetPosition != null)
  189. {
  190. nodeSetPosition.ParentNode.RemoveChild(nodeSetPosition);
  191. }
  192. var nodeSetPressure = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='PressureControl.SetTVPressure']")) as XmlElement;
  193. if (nodeSetPressure != null)
  194. {
  195. nodeSetPressure.ParentNode.RemoveChild(nodeSetPressure);
  196. }
  197. }
  198. bool isBoostInstalled = SC.GetValue<bool>(SCName.PressureControlConfig_EnableBoosterPump);
  199. if (!isBoostInstalled)
  200. {
  201. var nodeSetPressure =
  202. xmlDom.SelectSingleNode(
  203. string.Format(
  204. "/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='PressureControl.SetBoostPressure']"))
  205. as XmlElement;
  206. if (nodeSetPressure != null)
  207. {
  208. nodeSetPressure.ParentNode.RemoveChild(nodeSetPressure);
  209. }
  210. }
  211. double maxChamberPressure = SC.GetValue<double>(SCName.ProcessConfig_ChamberPressureMaxValue);
  212. var nodeSetPressure1 = xmlDom.SelectSingleNode(string.Format("/Aitex/TableRecipeFormat/Catalog/Group/Step[@ControlName='PressureControl.SetChamberPressure']")) as XmlElement;
  213. if (nodeSetPressure1 != null)
  214. {
  215. if (isTvInstalled || isBoostInstalled)
  216. nodeSetPressure1.ParentNode.RemoveChild(nodeSetPressure1);
  217. else
  218. {
  219. nodeSetPressure1.SetAttribute("Max", maxChamberPressure.ToString());
  220. }
  221. }
  222. return xmlDom.OuterXml;
  223. }
  224. catch (Exception ex)
  225. {
  226. LOG.Write(ex);
  227. return "";
  228. }
  229. }
  230. public IEnumerable<string> GetRecipes(string chamberId, bool includingUsedRecipe)
  231. {
  232. try
  233. {
  234. string recipePath = PathManager.GetRecipeDir() + chamberId + "\\";
  235. var di = new DirectoryInfo(recipePath);
  236. var fis = di.GetFiles("*.rcp", SearchOption.AllDirectories);
  237. var recipes = new List<string>();
  238. foreach (var fi in fis)
  239. {
  240. string str = fi.FullName.Substring(recipePath.Length);
  241. str = str.Substring(0, str.LastIndexOf('.'));
  242. if (includingUsedRecipe || (!str.Contains("HistoryRecipe\\")))
  243. {
  244. recipes.Add(str);
  245. }
  246. }
  247. return recipes;
  248. }
  249. catch (Exception ex)
  250. {
  251. LOG.Write(ex);
  252. return new List<string>();
  253. }
  254. }
  255. public void PostInfoEvent(string message)
  256. {
  257. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  258. }
  259. public void PostWarningEvent(string message)
  260. {
  261. EV.PostMessage("System", EventEnum.DefaultWarning, message);
  262. }
  263. public void PostAlarmEvent(string message)
  264. {
  265. EV.PostMessage("System", EventEnum.DefaultAlarm, message);
  266. }
  267. public void PostDialogEvent(string message)
  268. {
  269. EV.PostNotificationMessage(message);
  270. }
  271. public void PostInfoDialogMessage(string message)
  272. {
  273. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  274. EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
  275. }
  276. public void PostWarningDialogMessage(string message)
  277. {
  278. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  279. EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
  280. }
  281. public void PostAlarmDialogMessage(string message)
  282. {
  283. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  284. EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
  285. }
  286. public string GetRecipeTemplate(string chamberId)
  287. {
  288. string schema = GetRecipeDefiniton(chamberId);
  289. XmlDocument dom = new XmlDocument();
  290. dom.LoadXml(schema);
  291. XmlNode nodeTemplate = dom.SelectSingleNode("/Aitex/TableRecipeData");
  292. if (nodeTemplate.Attributes["BasePressure"] != null)
  293. nodeTemplate.Attributes["BasePressure"].Value = SC.GetValue<double>(SCName.System_PumpBasePressure).ToString("F0");
  294. if (nodeTemplate.Attributes["PumpDownLimit"] != null)
  295. nodeTemplate.Attributes["PumpDownLimit"].Value = SC.GetValue<double>(SCName.System_PumpTimeLimit).ToString("F0");
  296. if (nodeTemplate.Attributes["PurgeActive"] != null)
  297. nodeTemplate.Attributes["PurgeActive"].Value = "true";
  298. if (nodeTemplate.Attributes["ElectrodeTemp"] != null)
  299. nodeTemplate.Attributes["ElectrodeTemp"].Value = "20";
  300. if (nodeTemplate.Attributes["MatchPositionC1"] != null)
  301. nodeTemplate.Attributes["MatchPositionC1"].Value = SC.GetValue<double>(SCName.System_MatchPositionC1).ToString("F0");
  302. if (nodeTemplate.Attributes["MatchPositionC2"] != null)
  303. nodeTemplate.Attributes["MatchPositionC2"].Value = SC.GetValue<double>(SCName.System_MatchPositionC2).ToString("F0");
  304. return nodeTemplate.OuterXml;
  305. }
  306. }
  307. }