Recipe.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Xml;
  4. using Aitex.Common.Util;
  5. using Aitex.Core.RT.Log;
  6. namespace Virgo_DRT.Modules
  7. {
  8. /// <summary>
  9. /// Recipe head
  10. /// </summary>
  11. public class RecipeHead
  12. {
  13. public string RecipeVariation { get; set; }
  14. public string CreationTime { get; set; }
  15. public string LastRevisionTime { get; set; }
  16. public string CreatedBy { get; set; }
  17. public string LastModifiedBy { get; set; }
  18. public string PressureMode { get; set; }
  19. public string Description { get; set; }
  20. public string Barcode { get; set; }
  21. public string BasePressure { get; set; }
  22. public string PumpDownLimit { get; set; }
  23. //public string ElectrodeTemp { get; set; }
  24. //public string HeaterTemp { get; set; }
  25. public string PurgeActive { get; set; }
  26. public string MatchPositionC1 { get; set; }
  27. public string MatchPositionC2 { get; set; }
  28. public string SubstrateTemp { get; set; }
  29. public string PumpingPinState { get; set; }
  30. public string PinStateAfterVent { get; set; }
  31. public string PinDownPressure { get; set; }
  32. }
  33. public class RecipeStep
  34. {
  35. public string StepName;
  36. public double StepTime;
  37. public bool IsJumpStep;
  38. public bool IsLoopStartStep;
  39. public bool IsLoopEndStep;
  40. public int LoopCount;
  41. public string EndBy;
  42. //public double EndByValue;
  43. public Dictionary<string, string> RecipeCommands = new Dictionary<string, string>();
  44. }
  45. public class Recipe
  46. {
  47. /// <summary>
  48. /// 当前Recipe Run 记录对应的Guid
  49. /// 每个Recipe Run 都对应有一个唯一的Guid
  50. /// </summary>
  51. public static Guid CurrentRecipeRunGuid;
  52. /// <summary>
  53. /// 解析工艺程序文件
  54. /// </summary>
  55. /// <param name="recipeName">工艺程序名</param>
  56. /// <param name="xmlRecipeData">xml格式的工艺数据内容</param>
  57. /// <param name="recipeData">返回解析的工艺数据变量</param>
  58. /// <returns>True:解析成功 | False:解析失败</returns>
  59. public static bool Parse(string recipe, out RecipeHead recipeHead, out List<RecipeStep> recipeData)
  60. {
  61. recipeHead = new RecipeHead();
  62. recipeData = new List<RecipeStep>();
  63. try
  64. {
  65. //获取工艺程序文件中允许的命令字符串列表
  66. //目的:如果工艺程序文件中含有规定之外的命令,则被禁止执行
  67. HashSet<string> recipeAllowedCommands = new HashSet<string>();
  68. XmlDocument rcpFormatDoc = new XmlDocument();
  69. string recipeSchema = PathManager.GetCfgDir() + "RecipeFormat.xml";
  70. rcpFormatDoc.Load(recipeSchema);
  71. XmlNodeList rcpItemNodeList = rcpFormatDoc.SelectNodes("/Aitex/TableRecipeFormat/Catalog/Group/Step");
  72. foreach (XmlElement item in rcpItemNodeList)
  73. recipeAllowedCommands.Add(item.Attributes["ControlName"].Value);
  74. //获取工艺程序文件中所有步的内容
  75. XmlDocument rcpDataDoc = new XmlDocument();
  76. rcpDataDoc.LoadXml(recipe);
  77. recipeHead.PressureMode = rcpDataDoc.DocumentElement.HasAttribute("PressureMode") ? rcpDataDoc.DocumentElement.Attributes["PressureMode"].Value : "";
  78. recipeHead.BasePressure = rcpDataDoc.DocumentElement.HasAttribute("BasePressure") ? rcpDataDoc.DocumentElement.Attributes["BasePressure"].Value : "";
  79. recipeHead.PumpDownLimit = rcpDataDoc.DocumentElement.HasAttribute("PumpDownLimit") ? rcpDataDoc.DocumentElement.Attributes["PumpDownLimit"].Value : "";
  80. recipeHead.PurgeActive = rcpDataDoc.DocumentElement.HasAttribute("PurgeActive") ? rcpDataDoc.DocumentElement.Attributes["PurgeActive"].Value : "";
  81. recipeHead.MatchPositionC1 = rcpDataDoc.DocumentElement.HasAttribute("MatchPositionC1") ? rcpDataDoc.DocumentElement.Attributes["MatchPositionC1"].Value : "";
  82. recipeHead.MatchPositionC2 = rcpDataDoc.DocumentElement.HasAttribute("MatchPositionC2") ? rcpDataDoc.DocumentElement.Attributes["MatchPositionC2"].Value : "";
  83. recipeHead.Barcode = rcpDataDoc.DocumentElement.HasAttribute("Barcode") ? rcpDataDoc.DocumentElement.Attributes["Barcode"].Value : "";
  84. recipeHead.SubstrateTemp = rcpDataDoc.DocumentElement.HasAttribute("SubstrateTemp") ? rcpDataDoc.DocumentElement.Attributes["SubstrateTemp"].Value : "";
  85. recipeHead.PinStateAfterVent = rcpDataDoc.DocumentElement.HasAttribute("PinStateAfterVent") ? rcpDataDoc.DocumentElement.Attributes["PinStateAfterVent"].Value : "";
  86. recipeHead.PumpingPinState = rcpDataDoc.DocumentElement.HasAttribute("PumpingPinState") ? rcpDataDoc.DocumentElement.Attributes["PumpingPinState"].Value : "";
  87. recipeHead.PinDownPressure = rcpDataDoc.DocumentElement.HasAttribute("PinDownPressure") ? rcpDataDoc.DocumentElement.Attributes["PinDownPressure"].Value : "1000";
  88. XmlNodeList stepNodeList = rcpDataDoc.SelectNodes("/TableRecipeData/Step");
  89. for (int i = 0; i < stepNodeList.Count; i++)
  90. {
  91. var recipeStep = new RecipeStep();
  92. recipeData.Add(recipeStep);
  93. XmlElement stepNode = stepNodeList[i] as XmlElement;
  94. Dictionary<string, string> dic = new Dictionary<string, string>();
  95. //遍历Step节点
  96. foreach (XmlAttribute att in stepNode.Attributes)
  97. {
  98. if (recipeAllowedCommands.Contains(att.Name))
  99. {
  100. dic.Add(att.Name, att.Value);
  101. }
  102. }
  103. //遍历Step子节点中所有的attribute属性节点
  104. foreach (XmlElement subStepNode in stepNode.ChildNodes)
  105. {
  106. foreach (XmlAttribute att in subStepNode.Attributes)
  107. {
  108. if (recipeAllowedCommands.Contains(att.Name))
  109. {
  110. dic.Add(att.Name, att.Value);
  111. }
  112. }
  113. //遍历Step子节点的子节点中所有的attribute属性节点
  114. foreach (XmlElement subsubStepNode in subStepNode.ChildNodes)
  115. {
  116. foreach (XmlAttribute att in subsubStepNode.Attributes)
  117. {
  118. if (recipeAllowedCommands.Contains(att.Name))
  119. {
  120. dic.Add(att.Name, att.Value);
  121. }
  122. }
  123. }
  124. }
  125. recipeStep.IsJumpStep = true;//!Convert.ToBoolean(dic["Ramp"]);
  126. recipeStep.StepName = dic["Name"];
  127. recipeStep.StepTime = TimeSpan.Parse(dic["Time"]).TotalSeconds;
  128. string loopStr = dic["Loop"];
  129. recipeStep.IsLoopStartStep = System.Text.RegularExpressions.Regex.Match(loopStr, @"Loop\x20\d+\s*$").Success;
  130. recipeStep.IsLoopEndStep = System.Text.RegularExpressions.Regex.Match(loopStr, @"Loop End$").Success;
  131. if (recipeStep.IsLoopStartStep)
  132. recipeStep.LoopCount = Convert.ToInt32(loopStr.Replace("Loop", string.Empty));
  133. else
  134. recipeStep.LoopCount = 0;
  135. //recipeStep.EndByValue = Convert.ToDouble(dic["EndValue"]);
  136. recipeStep.EndBy = dic["EndBy"];
  137. if (recipeStep.EndBy == "EndByRfTime")
  138. {
  139. recipeStep.StepTime = TimeSpan.Parse(dic["Rf.SetPowerOnTime"]).TotalSeconds;
  140. if (recipeStep.StepTime <= 0)
  141. {
  142. LOG.Error("recipe 没有定义RF Power on的时间");
  143. return false;
  144. }
  145. }
  146. int rfPower = (int)Convert.ToDouble(dic["Rf.SetPower"]);
  147. dic.Add("Rf.SetPowerOnOff", rfPower > 0 ? "true" : "false");
  148. //dic.Remove("Ramp");
  149. dic.Remove("StepNo");
  150. dic.Remove("Name");
  151. dic.Remove("Loop");
  152. dic.Remove("Time");
  153. dic.Remove("EndBy");
  154. //dic.Remove("EndValue");
  155. dic.Remove("Rf.SetPowerOnTime");
  156. foreach (string key in dic.Keys)
  157. recipeStep.RecipeCommands.Add(key, dic[key]);
  158. }
  159. }
  160. catch (Exception ex)
  161. {
  162. LOG.Write(ex);
  163. return false;
  164. }
  165. return true;
  166. }
  167. }
  168. }