SequenceInfo.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.Serialization;
  4. using System.Xml;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.RecipeCenter;
  7. using Aitex.Core.RT.SCCore;
  8. using MECF.Framework.Common.Equipment;
  9. namespace MECF.Framework.Common.Jobs
  10. {
  11. [Serializable]
  12. [DataContract]
  13. public class SequenceInfo
  14. {
  15. [DataMember]
  16. public List<SequenceStepInfo> Steps { get; set; }
  17. [DataMember]
  18. public string Name { get; set; }
  19. [DataMember]
  20. public List<string> SystemRecipeCommands { get; set; } = new List<string>();
  21. [DataMember]
  22. public Guid InnerId { get; set; }
  23. [DataMember]
  24. public Dictionary<string,string> Modules { get; set; }
  25. public SequenceInfo(string name)
  26. {
  27. Name = name;
  28. InnerId = Guid.NewGuid();
  29. Steps = new List<SequenceStepInfo>();
  30. Modules = new Dictionary<string, string>();
  31. }
  32. }
  33. public class SequenceInfoHelper
  34. {
  35. public static SequenceInfo GetInfo(string seqFile)
  36. {
  37. SequenceInfo info = new SequenceInfo(seqFile);
  38. string content = RecipeFileManager.Instance.GetSequence(seqFile, false);
  39. if (!string.IsNullOrEmpty(content))
  40. {
  41. try
  42. {
  43. XmlDocument dom = new XmlDocument();
  44. dom.LoadXml(content);
  45. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  46. if (lstStepNode == null)
  47. {
  48. LOG.Error($"{seqFile} has no step");
  49. return null;
  50. }
  51. foreach (var nodeModelChild in lstStepNode)
  52. {
  53. XmlElement nodeStep = nodeModelChild as XmlElement;
  54. SequenceStepInfo stepInfo = new SequenceStepInfo();
  55. foreach (XmlAttribute attr in nodeStep.Attributes)
  56. {
  57. if (attr.Name == "Position" || attr.Name=="LLSelection" || attr.Name == "PMSelection" || attr.Name == "PMSelection25")
  58. {
  59. if (attr.Value == "LL" || attr.Value=="PM")
  60. continue;
  61. if (!Enum.TryParse(attr.Value, out ModuleName _))
  62. continue;
  63. string[] pos = attr.Value.Split(',');
  64. if (pos.Length < 1)
  65. {
  66. LOG.Error($"{seqFile} Position {attr.Value} can not be empty");
  67. return null;
  68. }
  69. foreach (var po in pos)
  70. {
  71. ModuleName module = ModuleHelper.Converter(po);
  72. if (module == ModuleName.System)
  73. {
  74. LOG.Error($"{seqFile} Position {po} not valid");
  75. return null;
  76. }
  77. stepInfo.StepModules.Add(module);
  78. }
  79. continue;
  80. }
  81. if (attr.Name == "AlignerAngle")
  82. {
  83. if (!double.TryParse(attr.Value, out double angle))
  84. {
  85. LOG.Error($"{seqFile} AlignAngle {attr.Value} not valid");
  86. return null;
  87. }
  88. stepInfo.AlignAngle = angle;
  89. continue;
  90. }
  91. if ((attr.Name == "Recipe") || (attr.Name == "ProcessRecipe"))
  92. {
  93. stepInfo.RecipeName = attr.Value;
  94. continue;
  95. }
  96. stepInfo.StepParameter[attr.Name] = attr.Value;
  97. }
  98. info.Steps.Add(stepInfo);
  99. }
  100. }
  101. catch (Exception ex)
  102. {
  103. LOG.Write(ex);
  104. return null;
  105. }
  106. }
  107. return info;
  108. }
  109. public static SequenceInfo GetWaferFlowInfo(string seqFile)
  110. {
  111. SequenceInfo info = new SequenceInfo(seqFile);
  112. string content = RecipeFileManager.Instance.GetWaferFlowRecipe(seqFile, false);
  113. if (!string.IsNullOrEmpty(content))
  114. {
  115. try
  116. {
  117. XmlDocument dom = new XmlDocument();
  118. dom.LoadXml(content);
  119. var pmNode = dom.SelectSingleNode($"/Aitex/TableRecipeData/Module[@Name = 'WaferFlow']");
  120. if (null == pmNode)
  121. {
  122. LOG.Error($"Wafer flow recipe {seqFile} 无内容");
  123. return null;
  124. }
  125. var lstStepNode = pmNode.SelectNodes("Step");
  126. if (lstStepNode == null)
  127. {
  128. LOG.Error($"Wafer flow recipe {seqFile} has no step");
  129. return null;
  130. }
  131. for (int i= 0;i<lstStepNode.Count;i++)
  132. {
  133. XmlElement nodeStep = lstStepNode[i] as XmlElement;
  134. SequenceStepInfo stepInfo = new SequenceStepInfo();
  135. if(i==0||i== lstStepNode.Count-1)
  136. {
  137. if (SC.GetStringValue("System.SetUp.Block1.1") != "Reserved")
  138. stepInfo.StepModules.Add(ModuleName.Cassette1);
  139. if (SC.GetStringValue("System.SetUp.Block1.2") != "Reserved")
  140. stepInfo.StepModules.Add(ModuleName.Cassette2);
  141. if (SC.GetStringValue("System.SetUp.Block1.3") != "Reserved")
  142. stepInfo.StepModules.Add(ModuleName.Cassette3);
  143. if (SC.GetStringValue("System.SetUp.Block1.4") != "Reserved")
  144. stepInfo.StepModules.Add(ModuleName.Cassette4);
  145. if (SC.GetStringValue("System.SetUp.Block1.5") != "Reserved")
  146. stepInfo.StepModules.Add(ModuleName.Cassette5);
  147. info.Steps.Add(stepInfo);
  148. continue;
  149. }
  150. bool validStep = false;
  151. foreach (XmlAttribute attr in nodeStep.Attributes)
  152. {
  153. //ModuleName="2-2 COT,2-1 COT"
  154. if (attr.Name == "ModuleName")
  155. {
  156. if (string.IsNullOrEmpty(attr.Value.ToString()))
  157. continue;
  158. string[] pos = attr.Value.Split(',');
  159. if (pos.Length < 1)
  160. {
  161. LOG.Error($"{seqFile} Position {attr.Value} can not be empty");
  162. return null;
  163. }
  164. foreach (var po in pos)
  165. {
  166. var modulePara = po.Split(' ');
  167. if (modulePara.Length < 2)
  168. {
  169. LOG.Error($"{seqFile} module name {attr.Value} invalid");
  170. return null;
  171. }
  172. if(!Enum.TryParse($"PM{modulePara[0].Replace("-", "_")}", out ModuleName module))
  173. {
  174. continue;
  175. }
  176. module = ModuleHelper.Converter($"PM{modulePara[0].Replace("-","_")}");
  177. if (module == ModuleName.System)
  178. {
  179. LOG.Error($"{seqFile} Position PM{modulePara[0].Replace("-", "_")} not valid");
  180. return null;
  181. }
  182. info.Modules[module.ToString()] = modulePara[1].ToString();
  183. validStep = true;
  184. stepInfo.StepModules.Add(module);
  185. }
  186. }
  187. if (attr.Name == "TransControl")
  188. {
  189. stepInfo.TransferControl = attr.Value;
  190. }
  191. if (attr.Name == "RecipeName")
  192. {
  193. if (string.IsNullOrEmpty(attr.Value))
  194. continue;
  195. //RecipeName="2-2:test,2-1:test"
  196. //Cot和Dev分别是不同写recipe
  197. if (attr.Value.Contains(":"))
  198. {
  199. string[] moduleRecipes = attr.Value.Split(',');
  200. if (moduleRecipes.Length < 1)
  201. {
  202. LOG.Error($"{seqFile} recipe name {attr.Value} in invalid");
  203. return null;
  204. }
  205. foreach (var moduleRecipe in moduleRecipes)
  206. {
  207. var recipePara = moduleRecipe.Split(':');
  208. if (recipePara.Length < 2)
  209. {
  210. LOG.Error($"{seqFile} recipe name {attr.Value} invalid");
  211. return null;
  212. }
  213. ModuleName module = ModuleHelper.Converter($"PM{recipePara[0].Replace("-", "_")}");
  214. if (module == ModuleName.System)
  215. {
  216. LOG.Error($"{seqFile} Position PM{recipePara[0].Replace("-", "_")} not valid");
  217. return null;
  218. }
  219. stepInfo.RecipeNameDic.Add(module.ToString(), recipePara[1]);
  220. }
  221. }
  222. else
  223. {
  224. //其他单元一个step共用一个recipe
  225. stepInfo.RecipeName = attr.Value.ToString();
  226. }
  227. }
  228. //冷热版和ADH的recipe赋值
  229. if(!string.IsNullOrEmpty(stepInfo.RecipeName))
  230. {
  231. foreach(var module in stepInfo.StepModules)
  232. {
  233. if(!stepInfo.RecipeNameDic.ContainsKey(module.ToString()))
  234. {
  235. stepInfo.RecipeNameDic.Add(module.ToString(), stepInfo.RecipeName);
  236. }
  237. }
  238. }
  239. stepInfo.StepParameter[attr.Name] = attr.Value;
  240. }
  241. if(validStep)
  242. info.Steps.Add(stepInfo);
  243. }
  244. //解析system recipe
  245. string systemRecipe = dom.SelectSingleNode($"/Aitex/TableRecipeData/Config").Attributes["SystemRecipe"].Value;
  246. if (!string.IsNullOrEmpty(systemRecipe))
  247. {
  248. string contentSystemReicpe = RecipeFileManager.Instance.LoadRecipe($"Track\\System", systemRecipe, false);
  249. if (string.IsNullOrEmpty(contentSystemReicpe))
  250. {
  251. LOG.Error($"{systemRecipe} is not a valid system recipe file");
  252. return null;
  253. }
  254. XmlDocument rcpDataDoc = new XmlDocument();
  255. rcpDataDoc.LoadXml(contentSystemReicpe);
  256. XmlNode nodeModule = rcpDataDoc.SelectSingleNode($"/Aitex/TableRecipeData/Module[@Name='System']");
  257. if (nodeModule == null)
  258. {
  259. LOG.Error($"{systemRecipe} does not contains step");
  260. return null;
  261. }
  262. XmlNodeList stepNodeList = nodeModule.SelectNodes($"Step");
  263. for (int i = 0; i < stepNodeList.Count; i++)
  264. {
  265. XmlElement stepNode = stepNodeList[i] as XmlElement;
  266. string moduleIndex= stepNode.Attributes["ModuleName"].Value.Replace("-","_");
  267. string controlTarget = stepNode.Attributes["ControlTarget"].Value;
  268. string setValue = stepNode.Attributes["SetValue"].Value;
  269. string almMax = stepNode.Attributes["AlmMax"].Value;
  270. string almMin = stepNode.Attributes["AlmMin"].Value;
  271. string stopMax = stepNode.Attributes["StopMax"].Value;
  272. string stopMin = stepNode.Attributes["StopMin"].Value;
  273. var value = $"{moduleIndex}:{controlTarget},{setValue},{almMax},{almMin},{stopMax},{stopMin}";
  274. info.SystemRecipeCommands.Add(value);
  275. }
  276. }
  277. }
  278. catch (Exception ex)
  279. {
  280. LOG.Write(ex);
  281. return null;
  282. }
  283. }
  284. return info;
  285. }
  286. }
  287. }