SequenceInfoHelper.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.RT.RecipeCenter;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.Jobs;
  11. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
  12. namespace EfemDualSchedulerLib
  13. {
  14. public class SequenceInfoHelper
  15. {
  16. public static SequenceInfo GetInfo(string seqFile)
  17. {
  18. SequenceInfo info = new SequenceInfo(seqFile);
  19. string content = RecipeFileManager.Instance.GetSequence(seqFile, false, false);
  20. if (!string.IsNullOrEmpty(content))
  21. {
  22. try
  23. {
  24. XmlDocument dom = new XmlDocument();
  25. dom.LoadXml(content);
  26. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  27. if (lstStepNode == null)
  28. {
  29. LOG.Error($"{seqFile} has no step");
  30. return null;
  31. }
  32. foreach (var nodeModelChild in lstStepNode)
  33. {
  34. XmlElement nodeStep = nodeModelChild as XmlElement;
  35. SequenceStepInfo stepInfo = new SequenceStepInfo();
  36. foreach (XmlAttribute attr in nodeStep.Attributes)
  37. {
  38. if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection25")
  39. {
  40. if (attr.Value == "LL" || attr.Value == "PM")
  41. continue;
  42. if (!Enum.TryParse(attr.Value, out ModuleName _))
  43. continue;
  44. string[] pos = attr.Value.Split(',');
  45. if (pos.Length < 1)
  46. {
  47. LOG.Error($"{seqFile} Position {attr.Value} can not be empty");
  48. return null;
  49. }
  50. foreach (var po in pos)
  51. {
  52. if (po == "Cooling" && nodeStep.Attributes["CoolingSelection"] != null)
  53. {
  54. continue;
  55. }
  56. if (po == "Aligner" && nodeStep.Attributes["AlignerSelection"] != null)
  57. {
  58. continue;
  59. }
  60. ModuleName module = ModuleHelper.Converter(po);
  61. if (module == ModuleName.System)
  62. {
  63. LOG.Error($"{seqFile} Position {po} not valid");
  64. return null;
  65. }
  66. stepInfo.StepModules.Add(module);
  67. }
  68. continue;
  69. }
  70. if (attr.Name == "AlignerSelection")
  71. {
  72. if (string.IsNullOrEmpty(attr.Value))
  73. {
  74. if (!stepInfo.StepModules.Contains(ModuleName.Aligner1))
  75. {
  76. stepInfo.StepModules.Add(ModuleName.Aligner1);
  77. }
  78. if (!stepInfo.StepModules.Contains(ModuleName.Aligner2))
  79. {
  80. stepInfo.StepModules.Add(ModuleName.Aligner2);
  81. }
  82. continue;
  83. }
  84. string[] pos = attr.Value.Split(',');
  85. foreach (var po in pos)
  86. {
  87. ModuleName module = ModuleHelper.Converter(po);
  88. if (module == ModuleName.System)
  89. {
  90. LOG.Error($"{seqFile} Position {po} not valid");
  91. return null;
  92. }
  93. stepInfo.StepModules.Add(module);
  94. }
  95. continue;
  96. }
  97. if (attr.Name == "CoolingSelection")
  98. {
  99. if (string.IsNullOrEmpty(attr.Value))
  100. {
  101. if (!stepInfo.StepModules.Contains(ModuleName.Cooling1))
  102. {
  103. stepInfo.StepModules.Add(ModuleName.Cooling1);
  104. }
  105. if (!stepInfo.StepModules.Contains(ModuleName.Cooling2))
  106. {
  107. stepInfo.StepModules.Add(ModuleName.Cooling2);
  108. }
  109. continue;
  110. }
  111. string[] pos = attr.Value.Split(',');
  112. foreach (var po in pos)
  113. {
  114. ModuleName module = ModuleHelper.Converter(po);
  115. if (module == ModuleName.System)
  116. {
  117. LOG.Error($"{seqFile} Position {po} not valid");
  118. return null;
  119. }
  120. stepInfo.StepModules.Add(module);
  121. }
  122. continue;
  123. }
  124. if (attr.Name == "AlignerAngle")
  125. {
  126. if (!double.TryParse(attr.Value, out double angle))
  127. {
  128. LOG.Error($"{seqFile} AlignAngle {attr.Value} not valid");
  129. return null;
  130. }
  131. stepInfo.AlignAngle = angle;
  132. continue;
  133. }
  134. if ((attr.Name == "Recipe") || (attr.Name == "ProcessRecipe"))
  135. {
  136. stepInfo.RecipeName = attr.Value;
  137. continue;
  138. }
  139. if (attr.Name == "PMSelection")
  140. {
  141. if (string.IsNullOrEmpty(attr.Value))
  142. {
  143. continue;
  144. }
  145. string[] pos = attr.Value.Split(',');
  146. foreach (var po in pos)
  147. {
  148. var slotAndPm = TryParsePMAndSlot(po);
  149. if (slotAndPm == null || slotAndPm.Count == 0)
  150. {
  151. LOG.Error($"{seqFile} sequence not valid");
  152. return null;
  153. }
  154. int slot = slotAndPm.Keys.First();
  155. ModuleName moduleName = slotAndPm[slot];
  156. if (moduleName == ModuleName.System)
  157. {
  158. LOG.Error($"{seqFile} Position {po} not valid");
  159. return null;
  160. }
  161. if (!stepInfo.StepModules.Contains(moduleName))
  162. {
  163. stepInfo.StepModules.Add(moduleName);
  164. }
  165. if (!stepInfo.StepParameter.ContainsKey(moduleName.ToString()))
  166. {
  167. stepInfo.StepParameter[moduleName.ToString()] = slot.ToString();
  168. }
  169. else
  170. {
  171. var preSlot = stepInfo.StepParameter[moduleName.ToString()].ToString();
  172. stepInfo.StepParameter[moduleName.ToString()] = preSlot + $",{slot}";
  173. }
  174. }
  175. continue;
  176. }
  177. stepInfo.StepParameter[attr.Name] = attr.Value;
  178. }
  179. info.Steps.Add(stepInfo);
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. LOG.Write(ex);
  185. return null;
  186. }
  187. }
  188. return info;
  189. }
  190. public static Dictionary<int, ModuleName> TryParsePMAndSlot(string module)
  191. {
  192. Dictionary<int, ModuleName> slotAndPm = new Dictionary<int, ModuleName>();
  193. if (!string.IsNullOrWhiteSpace(module) && module.IndexOf(ModuleName.PM.ToString()) > -1 && module.Length > 3)
  194. {
  195. const int splitIndex = 3;
  196. string moduleName = module.Substring(0, splitIndex);
  197. int solt = Convert.ToInt32(module.Substring(splitIndex, 1)) - 1;
  198. slotAndPm[solt] = ModuleHelper.Converter(moduleName);
  199. }
  200. return slotAndPm;
  201. }
  202. public static EnumDualPM GetPMSlotOpt(SequenceInfo seq, ModuleName pmModuleName)
  203. {
  204. if(seq != null && ModuleHelper.IsPm(pmModuleName))
  205. {
  206. for (int i = 0; i < seq.Steps.Count; i++)
  207. {
  208. if(seq.Steps[i].StepParameter.ContainsKey(pmModuleName.ToString()))
  209. {
  210. var slots = seq.Steps[i].StepParameter[pmModuleName.ToString()].ToString();
  211. if (slots.Contains("0") && slots.Contains("1"))
  212. return EnumDualPM.Both;
  213. else if (slots.Contains("0"))
  214. return EnumDualPM.Left;
  215. else
  216. return EnumDualPM.Right;
  217. }
  218. }
  219. }
  220. return EnumDualPM.Both;
  221. }
  222. }
  223. }