123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.RecipeCenter;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
- namespace EfemDualSchedulerLib
- {
- public class SequenceInfoHelper
- {
- public static SequenceInfo GetInfo(string seqFile)
- {
- SequenceInfo info = new SequenceInfo(seqFile);
- string content = RecipeFileManager.Instance.GetSequence(seqFile, false, false);
- if (!string.IsNullOrEmpty(content))
- {
- try
- {
- XmlDocument dom = new XmlDocument();
- dom.LoadXml(content);
- XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
- if (lstStepNode == null)
- {
- LOG.Error($"{seqFile} has no step");
- return null;
- }
- foreach (var nodeModelChild in lstStepNode)
- {
- XmlElement nodeStep = nodeModelChild as XmlElement;
- SequenceStepInfo stepInfo = new SequenceStepInfo();
- foreach (XmlAttribute attr in nodeStep.Attributes)
- {
- if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection25")
- {
- if (attr.Value == "LL" || attr.Value == "PM")
- continue;
- if (!Enum.TryParse(attr.Value, out ModuleName _))
- continue;
- string[] pos = attr.Value.Split(',');
- if (pos.Length < 1)
- {
- LOG.Error($"{seqFile} Position {attr.Value} can not be empty");
- return null;
- }
- foreach (var po in pos)
- {
- if (po == "Cooling" && nodeStep.Attributes["CoolingSelection"] != null)
- {
- continue;
- }
- if (po == "Aligner" && nodeStep.Attributes["AlignerSelection"] != null)
- {
- continue;
- }
- ModuleName module = ModuleHelper.Converter(po);
- if (module == ModuleName.System)
- {
- LOG.Error($"{seqFile} Position {po} not valid");
- return null;
- }
- stepInfo.StepModules.Add(module);
- }
- continue;
- }
- if (attr.Name == "AlignerSelection")
- {
- if (string.IsNullOrEmpty(attr.Value))
- {
- if (!stepInfo.StepModules.Contains(ModuleName.Aligner1))
- {
- stepInfo.StepModules.Add(ModuleName.Aligner1);
- }
- if (!stepInfo.StepModules.Contains(ModuleName.Aligner2))
- {
- stepInfo.StepModules.Add(ModuleName.Aligner2);
- }
- continue;
- }
- string[] pos = attr.Value.Split(',');
- foreach (var po in pos)
- {
- ModuleName module = ModuleHelper.Converter(po);
- if (module == ModuleName.System)
- {
- LOG.Error($"{seqFile} Position {po} not valid");
- return null;
- }
- stepInfo.StepModules.Add(module);
- }
- continue;
- }
- if (attr.Name == "CoolingSelection")
- {
- if (string.IsNullOrEmpty(attr.Value))
- {
- if (!stepInfo.StepModules.Contains(ModuleName.Cooling1))
- {
- stepInfo.StepModules.Add(ModuleName.Cooling1);
- }
- if (!stepInfo.StepModules.Contains(ModuleName.Cooling2))
- {
- stepInfo.StepModules.Add(ModuleName.Cooling2);
- }
- continue;
- }
- string[] pos = attr.Value.Split(',');
- foreach (var po in pos)
- {
- ModuleName module = ModuleHelper.Converter(po);
- if (module == ModuleName.System)
- {
- LOG.Error($"{seqFile} Position {po} not valid");
- return null;
- }
- stepInfo.StepModules.Add(module);
- }
- continue;
- }
- if (attr.Name == "AlignerAngle")
- {
- if (!double.TryParse(attr.Value, out double angle))
- {
- LOG.Error($"{seqFile} AlignAngle {attr.Value} not valid");
- return null;
- }
- stepInfo.AlignAngle = angle;
- continue;
- }
- if ((attr.Name == "Recipe") || (attr.Name == "ProcessRecipe"))
- {
- stepInfo.RecipeName = attr.Value;
- continue;
- }
- if (attr.Name == "PMSelection")
- {
- if (string.IsNullOrEmpty(attr.Value))
- {
- continue;
- }
- string[] pos = attr.Value.Split(',');
- foreach (var po in pos)
- {
- var slotAndPm = TryParsePMAndSlot(po);
- if (slotAndPm == null || slotAndPm.Count == 0)
- {
- LOG.Error($"{seqFile} sequence not valid");
- return null;
- }
- int slot = slotAndPm.Keys.First();
- ModuleName moduleName = slotAndPm[slot];
- if (moduleName == ModuleName.System)
- {
- LOG.Error($"{seqFile} Position {po} not valid");
- return null;
- }
- if (!stepInfo.StepModules.Contains(moduleName))
- {
- stepInfo.StepModules.Add(moduleName);
- }
- if (!stepInfo.StepParameter.ContainsKey(moduleName.ToString()))
- {
- stepInfo.StepParameter[moduleName.ToString()] = slot.ToString();
- }
- else
- {
- var preSlot = stepInfo.StepParameter[moduleName.ToString()].ToString();
- stepInfo.StepParameter[moduleName.ToString()] = preSlot + $",{slot}";
- }
- }
- continue;
- }
- stepInfo.StepParameter[attr.Name] = attr.Value;
- }
- info.Steps.Add(stepInfo);
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- return null;
- }
- }
- return info;
- }
- public static Dictionary<int, ModuleName> TryParsePMAndSlot(string module)
- {
- Dictionary<int, ModuleName> slotAndPm = new Dictionary<int, ModuleName>();
- if (!string.IsNullOrWhiteSpace(module) && module.IndexOf(ModuleName.PM.ToString()) > -1 && module.Length > 3)
- {
- const int splitIndex = 3;
- string moduleName = module.Substring(0, splitIndex);
- int solt = Convert.ToInt32(module.Substring(splitIndex, 1)) - 1;
- slotAndPm[solt] = ModuleHelper.Converter(moduleName);
- }
- return slotAndPm;
- }
- public static EnumDualPM GetPMSlotOpt(SequenceInfo seq, ModuleName pmModuleName)
- {
- if(seq != null && ModuleHelper.IsPm(pmModuleName))
- {
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- if(seq.Steps[i].StepParameter.ContainsKey(pmModuleName.ToString()))
- {
- var slots = seq.Steps[i].StepParameter[pmModuleName.ToString()].ToString();
- if (slots.Contains("0") && slots.Contains("1"))
- return EnumDualPM.Both;
- else if (slots.Contains("0"))
- return EnumDualPM.Left;
- else
- return EnumDualPM.Right;
- }
- }
- }
- return EnumDualPM.Both;
- }
- }
- }
|