SequenceInfo.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 MECF.Framework.Common.Equipment;
  8. using SciChart.Core.Extensions;
  9. namespace MECF.Framework.Common.Jobs
  10. {
  11. public enum SequenceLLInOutPath
  12. {
  13. AInBOut,
  14. BInAOut,
  15. DInDOut,
  16. AInAOut,
  17. BInBOut,
  18. }
  19. [Serializable]
  20. [DataContract]
  21. public class SequenceInfo
  22. {
  23. [DataMember]
  24. public List<SequenceStepInfo> Steps { get; set; }
  25. [DataMember]
  26. public string Name { get; set; }
  27. [DataMember]
  28. public string WTWCleanRecipe { get; set; }
  29. [DataMember]
  30. public List<ModuleName> PMs { get; set; }
  31. [DataMember]
  32. public string ThicknessType { get; set; }
  33. [DataMember]
  34. public Guid InnerId { get; set; }
  35. [DataMember]
  36. public SequenceLLInOutPath LLInOutPath { get; set; }
  37. [DataMember]
  38. public int LLDelayTime { get; set; }
  39. public SequenceInfo(string name)
  40. {
  41. Name = name;
  42. InnerId = Guid.NewGuid();
  43. LLInOutPath = SequenceLLInOutPath.DInDOut;
  44. LLDelayTime = 0;
  45. Steps = new List<SequenceStepInfo>();
  46. }
  47. public string GetRecipe(ModuleName pm)
  48. {
  49. if (!ModuleHelper.IsPm(pm))
  50. return string.Empty;
  51. string attr = $"{pm}Recipe";
  52. foreach (var step in Steps)
  53. {
  54. if(step.StepModules.Contains(pm))
  55. {
  56. return (string)step.StepParameter[attr];
  57. }
  58. }
  59. return string.Empty;
  60. }
  61. }
  62. public class SequenceInfoHelper
  63. {
  64. public static SequenceInfo GetInfo(string seqFile)
  65. {
  66. SequenceInfo info = new SequenceInfo(seqFile);
  67. info.PMs = new List<ModuleName>();
  68. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  69. if (!string.IsNullOrEmpty(content))
  70. {
  71. try
  72. {
  73. XmlDocument dom = new XmlDocument();
  74. dom.LoadXml(content);
  75. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  76. if (lstStepNode == null)
  77. {
  78. //LOG.Error($"{seqFile} has no step");
  79. return null;
  80. }
  81. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  82. if (nodeData != null)
  83. {
  84. var node = nodeData as XmlElement;
  85. info.ThicknessType = node.GetAttribute("ThicknessType");
  86. }
  87. foreach (var nodeModelChild in lstStepNode)
  88. {
  89. XmlElement nodeStep = nodeModelChild as XmlElement;
  90. SequenceStepInfo stepInfo = new SequenceStepInfo();
  91. foreach (XmlAttribute attr in nodeStep.Attributes)
  92. {
  93. stepInfo.StepParameter[attr.Name] = attr.Value;
  94. if (attr.Name == "Position" || attr.Name=="LLSelection" || attr.Name == "PMSelection")
  95. {
  96. if (attr.Value == "LL" || attr.Value=="PM")
  97. continue;
  98. string[] pos = attr.Value.Split(',');
  99. if (pos.Length < 1)
  100. {
  101. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  102. return null;
  103. }
  104. foreach (var po in pos)
  105. {
  106. if (po.IsEmpty())
  107. continue;
  108. if(attr.Name == "PMSelection")
  109. {
  110. info.PMs.Add(ModuleHelper.Converter(po));
  111. }
  112. if (po == "Cooling" )
  113. {
  114. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  115. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  116. continue;
  117. }
  118. if (po == "Aligner")
  119. {
  120. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  121. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  122. continue;
  123. }
  124. ModuleName module = ModuleHelper.Converter(po);
  125. if (module == ModuleName.System)
  126. {
  127. //LOG.Error($"{seqFile} Position {po} not valid");
  128. return null;
  129. }
  130. stepInfo.StepModules.Add(module);
  131. }
  132. continue;
  133. }
  134. if(attr.Name == "WTWClean")
  135. {
  136. info.WTWCleanRecipe = attr.Value;
  137. }
  138. }
  139. info.Steps.Add(stepInfo);
  140. }
  141. // Loadlock Single In Single Out property check
  142. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  143. if (llSteps.Count == 2)
  144. {
  145. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  146. {
  147. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  148. {
  149. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  150. }
  151. else
  152. {
  153. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  154. }
  155. }
  156. if(llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  157. {
  158. if(int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  159. {
  160. info.LLDelayTime = delay;
  161. }
  162. }
  163. }
  164. }
  165. catch (Exception ex)
  166. {
  167. LOG.WriteExeption(ex);
  168. return null;
  169. }
  170. return info;
  171. }
  172. else
  173. {
  174. return null;
  175. }
  176. }
  177. }
  178. }