SequenceInfo.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. public SequenceInfo(string name)
  38. {
  39. Name = name;
  40. InnerId = Guid.NewGuid();
  41. LLInOutPath = SequenceLLInOutPath.DInDOut;
  42. Steps = new List<SequenceStepInfo>();
  43. }
  44. public string GetRecipe(ModuleName pm)
  45. {
  46. string attr = $"{pm}Recipe";
  47. foreach (var step in Steps)
  48. {
  49. if(step.StepModules.Contains(pm))
  50. {
  51. return (string)step.StepParameter[attr];
  52. }
  53. }
  54. return string.Empty;
  55. }
  56. }
  57. public class SequenceInfoHelper
  58. {
  59. public static SequenceInfo GetInfo(string seqFile)
  60. {
  61. SequenceInfo info = new SequenceInfo(seqFile);
  62. info.PMs = new List<ModuleName>();
  63. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  64. if (!string.IsNullOrEmpty(content))
  65. {
  66. try
  67. {
  68. XmlDocument dom = new XmlDocument();
  69. dom.LoadXml(content);
  70. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  71. if (lstStepNode == null)
  72. {
  73. //LOG.Error($"{seqFile} has no step");
  74. return null;
  75. }
  76. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  77. if (nodeData != null)
  78. {
  79. var node = nodeData as XmlElement;
  80. info.ThicknessType = node.GetAttribute("ThicknessType");
  81. }
  82. foreach (var nodeModelChild in lstStepNode)
  83. {
  84. XmlElement nodeStep = nodeModelChild as XmlElement;
  85. SequenceStepInfo stepInfo = new SequenceStepInfo();
  86. foreach (XmlAttribute attr in nodeStep.Attributes)
  87. {
  88. stepInfo.StepParameter[attr.Name] = attr.Value;
  89. if (attr.Name == "Position" || attr.Name=="LLSelection" || attr.Name == "PMSelection")
  90. {
  91. if (attr.Value == "LL" || attr.Value=="PM")
  92. continue;
  93. string[] pos = attr.Value.Split(',');
  94. if (pos.Length < 1)
  95. {
  96. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  97. return null;
  98. }
  99. foreach (var po in pos)
  100. {
  101. if (po.IsEmpty())
  102. continue;
  103. if(attr.Name == "PMSelection")
  104. {
  105. info.PMs.Add(ModuleHelper.Converter(po));
  106. }
  107. if (po == "Aligner")
  108. {
  109. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  110. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  111. continue;
  112. }
  113. ModuleName module = ModuleHelper.Converter(po);
  114. if (module == ModuleName.System)
  115. {
  116. //LOG.Error($"{seqFile} Position {po} not valid");
  117. return null;
  118. }
  119. stepInfo.StepModules.Add(module);
  120. }
  121. continue;
  122. }
  123. if (attr.Name == "AlignerAngle")
  124. {
  125. if (!double.TryParse(attr.Value, out double angle))
  126. {
  127. //LOG.Error($"{seqFile} AlignAngle {attr.Value} not valid");
  128. return null;
  129. }
  130. stepInfo.AlignAngle = angle;
  131. continue;
  132. }
  133. if(attr.Name == "WTWClean")
  134. {
  135. info.WTWCleanRecipe = attr.Value;
  136. }
  137. }
  138. info.Steps.Add(stepInfo);
  139. }
  140. }
  141. catch (Exception ex)
  142. {
  143. LOG.WriteExeption(ex);
  144. return null;
  145. }
  146. }
  147. return info;
  148. }
  149. }
  150. }