SequenceInfo.cs 4.3 KB

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