SequenceInfo.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.GetSequence(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.Error($"{seqFile} Position {attr.Value} can not be empty");
  69. return null;
  70. }
  71. foreach (var po in pos)
  72. {
  73. if (po == "Cooling" )
  74. {
  75. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  76. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  77. continue;
  78. }
  79. if (po == "Aligner")
  80. {
  81. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  82. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  83. continue;
  84. }
  85. ModuleName module = ModuleHelper.Converter(po);
  86. if (module == ModuleName.System)
  87. {
  88. LOG.Error($"{seqFile} Position {po} not valid");
  89. return null;
  90. }
  91. stepInfo.StepModules.Add(module);
  92. }
  93. continue;
  94. }
  95. if (attr.Name == "AlignerAngle")
  96. {
  97. if (!double.TryParse(attr.Value, out double angle))
  98. {
  99. LOG.Error($"{seqFile} AlignAngle {attr.Value} not valid");
  100. return null;
  101. }
  102. stepInfo.AlignAngle = angle;
  103. continue;
  104. }
  105. }
  106. info.Steps.Add(stepInfo);
  107. }
  108. }
  109. catch (Exception ex)
  110. {
  111. LOG.Write(ex);
  112. return null;
  113. }
  114. }
  115. return info;
  116. }
  117. }
  118. }