SequenceInfo.cs 4.5 KB

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