SequenceInfo.cs 6.4 KB

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