Recipe.cs 9.4 KB

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