SequenceInfo.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. [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 string ThicknessType { get; set; }
  21. [DataMember]
  22. public Guid InnerId { get; set; }
  23. public SequenceInfo(string name)
  24. {
  25. Name = name;
  26. InnerId = Guid.NewGuid();
  27. Steps = new List<SequenceStepInfo>();
  28. }
  29. }
  30. public class SequenceInfoHelper
  31. {
  32. public static SequenceInfo GetInfo(string seqFile)
  33. {
  34. SequenceInfo info = new SequenceInfo(seqFile);
  35. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  36. if (!string.IsNullOrEmpty(content))
  37. {
  38. try
  39. {
  40. XmlDocument dom = new XmlDocument();
  41. dom.LoadXml(content);
  42. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  43. if (lstStepNode == null)
  44. {
  45. //LOG.Error($"{seqFile} has no step");
  46. return null;
  47. }
  48. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  49. if (nodeData != null)
  50. {
  51. var node = nodeData as XmlElement;
  52. info.ThicknessType = node.GetAttribute("ThicknessType");
  53. }
  54. foreach (var nodeModelChild in lstStepNode)
  55. {
  56. XmlElement nodeStep = nodeModelChild as XmlElement;
  57. SequenceStepInfo stepInfo = new SequenceStepInfo();
  58. foreach (XmlAttribute attr in nodeStep.Attributes)
  59. {
  60. stepInfo.StepParameter[attr.Name] = attr.Value;
  61. if (attr.Name == "Position" || attr.Name=="LLSelection" || attr.Name == "PMSelection")
  62. {
  63. if (attr.Value == "LL" || attr.Value=="PM")
  64. continue;
  65. string[] pos = attr.Value.Split(',');
  66. if (pos.Length < 1)
  67. {
  68. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  69. return null;
  70. }
  71. foreach (var po in pos)
  72. {
  73. if (po.IsEmpty())
  74. continue;
  75. if (po == "Cooling" )
  76. {
  77. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  78. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  79. continue;
  80. }
  81. if (po == "Aligner")
  82. {
  83. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  84. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  85. continue;
  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 == "AlignerAngle")
  98. {
  99. if (!double.TryParse(attr.Value, out double angle))
  100. {
  101. //LOG.Error($"{seqFile} AlignAngle {attr.Value} not valid");
  102. return null;
  103. }
  104. stepInfo.AlignAngle = angle;
  105. continue;
  106. }
  107. }
  108. info.Steps.Add(stepInfo);
  109. }
  110. }
  111. catch (Exception ex)
  112. {
  113. LOG.WriteExeption(ex);
  114. return null;
  115. }
  116. }
  117. return info;
  118. }
  119. }
  120. }