| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 | using System;using System.Collections.Generic;using System.Runtime.Serialization;using System.Xml;using Aitex.Core.RT.Log;using Aitex.Core.RT.RecipeCenter;using Aitex.Core.RT.SCCore;using MECF.Framework.Common.Equipment;namespace MECF.Framework.Common.Jobs{    [Serializable]    [DataContract]    public class SequenceInfo    {        [DataMember]        public List<SequenceStepInfo> Steps { get; set; }        [DataMember]        public string Name { get; set; }        [DataMember]        public List<string> SystemRecipeCommands { get; set; } = new List<string>();        [DataMember]        public Guid InnerId { get; set; }        [DataMember]        public Dictionary<string,string> Modules { get; set; }         public SequenceInfo(string name)        {            Name = name;            InnerId = Guid.NewGuid();            Steps = new List<SequenceStepInfo>();            Modules = new Dictionary<string, string>();        }    }    public class SequenceInfoHelper    {        public static SequenceInfo GetInfo(string seqFile)        {            SequenceInfo info = new SequenceInfo(seqFile);             string content = RecipeFileManager.Instance.GetSequence(seqFile, 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 == "PMSelection" || 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)                                {                                    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;                            }                            stepInfo.StepParameter[attr.Name] = attr.Value;                        }                        info.Steps.Add(stepInfo);                    }                }                catch (Exception ex)                {                    LOG.Write(ex);                    return null;                }            }            return info;        }        public static SequenceInfo GetWaferFlowInfo(string seqFile)        {            SequenceInfo info = new SequenceInfo(seqFile);            string content = RecipeFileManager.Instance.GetWaferFlowRecipe(seqFile, false);            if (!string.IsNullOrEmpty(content))            {                try                {                    XmlDocument dom = new XmlDocument();                    dom.LoadXml(content);                    var pmNode = dom.SelectSingleNode($"/Aitex/TableRecipeData/Module[@Name = 'WaferFlow']");                    if (null == pmNode)                    {                        LOG.Error($"Wafer flow recipe {seqFile} 无内容");                        return null;                    }                    var lstStepNode = pmNode.SelectNodes("Step");                    if (lstStepNode == null)                    {                        LOG.Error($"Wafer flow recipe {seqFile} has no step");                        return null;                    }                    for (int i= 0;i<lstStepNode.Count;i++)                    {                        XmlElement nodeStep = lstStepNode[i] as XmlElement;                        SequenceStepInfo stepInfo = new SequenceStepInfo();                        if(i==0||i== lstStepNode.Count-1)                        {                            if (SC.GetStringValue("System.SetUp.Block1.1") != "Reserved")                            stepInfo.StepModules.Add(ModuleName.Cassette1);                            if (SC.GetStringValue("System.SetUp.Block1.2") != "Reserved")                                stepInfo.StepModules.Add(ModuleName.Cassette2);                            if (SC.GetStringValue("System.SetUp.Block1.3") != "Reserved")                                stepInfo.StepModules.Add(ModuleName.Cassette3);                            if (SC.GetStringValue("System.SetUp.Block1.4") != "Reserved")                                stepInfo.StepModules.Add(ModuleName.Cassette4);                            if (SC.GetStringValue("System.SetUp.Block1.5") != "Reserved")                                stepInfo.StepModules.Add(ModuleName.Cassette5);                            info.Steps.Add(stepInfo);                            continue;                        }                        bool validStep = false;                        foreach (XmlAttribute attr in nodeStep.Attributes)                        {                            //ModuleName="2-2 COT,2-1 COT"                            if (attr.Name == "ModuleName")                            {                                if (string.IsNullOrEmpty(attr.Value.ToString()))                                    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)                                {                                    var modulePara = po.Split(' ');                                    if (modulePara.Length < 2)                                    {                                        LOG.Error($"{seqFile} module name {attr.Value} invalid");                                        return null;                                    }                                    if(!Enum.TryParse($"PM{modulePara[0].Replace("-", "_")}", out ModuleName module))                                    {                                        continue;                                    }                                    module = ModuleHelper.Converter($"PM{modulePara[0].Replace("-","_")}");                                    if (module == ModuleName.System)                                    {                                        LOG.Error($"{seqFile} Position PM{modulePara[0].Replace("-", "_")} not valid");                                        return null;                                    }                                    info.Modules[module.ToString()] = modulePara[1].ToString();                                    validStep = true;                                    stepInfo.StepModules.Add(module);                                }                            }                            if (attr.Name == "TransControl")                            {                                stepInfo.TransferControl = attr.Value;                            }                            if (attr.Name == "RecipeName")                            {                                if (string.IsNullOrEmpty(attr.Value))                                    continue;                                //RecipeName="2-2:test,2-1:test"                                //Cot和Dev分别是不同写recipe                                if (attr.Value.Contains(":"))                                {                                    string[] moduleRecipes = attr.Value.Split(',');                                    if (moduleRecipes.Length < 1)                                    {                                        LOG.Error($"{seqFile} recipe name {attr.Value} in invalid");                                        return null;                                    }                                    foreach (var moduleRecipe in moduleRecipes)                                    {                                        var recipePara = moduleRecipe.Split(':');                                        if (recipePara.Length < 2)                                        {                                            LOG.Error($"{seqFile} recipe name {attr.Value} invalid");                                            return null;                                        }                                        ModuleName module = ModuleHelper.Converter($"PM{recipePara[0].Replace("-", "_")}");                                        if (module == ModuleName.System)                                        {                                            LOG.Error($"{seqFile} Position PM{recipePara[0].Replace("-", "_")} not valid");                                            return null;                                        }                                        stepInfo.RecipeNameDic.Add(module.ToString(), recipePara[1]);                                    }                                }                                else                                {                                    //其他单元一个step共用一个recipe                                    stepInfo.RecipeName = attr.Value.ToString();                                }                            }                            //冷热版和ADH的recipe赋值                            if(!string.IsNullOrEmpty(stepInfo.RecipeName))                            {                                foreach(var module in stepInfo.StepModules)                                {                                    if(!stepInfo.RecipeNameDic.ContainsKey(module.ToString()))                                    {                                        stepInfo.RecipeNameDic.Add(module.ToString(), stepInfo.RecipeName);                                    }                                }                            }                            stepInfo.StepParameter[attr.Name] = attr.Value;                        }                        if(validStep)                            info.Steps.Add(stepInfo);                    }                    //解析system recipe                    string systemRecipe = dom.SelectSingleNode($"/Aitex/TableRecipeData/Config").Attributes["SystemRecipe"].Value;                                       if (!string.IsNullOrEmpty(systemRecipe))                    {                        string contentSystemReicpe = RecipeFileManager.Instance.LoadRecipe($"Track\\System", systemRecipe, false);                        if (string.IsNullOrEmpty(contentSystemReicpe))                        {                            LOG.Error($"{systemRecipe} is not a valid system recipe file");                            return null;                        }                        XmlDocument rcpDataDoc = new XmlDocument();                        rcpDataDoc.LoadXml(contentSystemReicpe);                        XmlNode nodeModule = rcpDataDoc.SelectSingleNode($"/Aitex/TableRecipeData/Module[@Name='System']");                        if (nodeModule == null)                        {                            LOG.Error($"{systemRecipe} does not contains step");                            return null;                        }                        XmlNodeList stepNodeList = nodeModule.SelectNodes($"Step");                        for (int i = 0; i < stepNodeList.Count; i++)                        {                            XmlElement stepNode = stepNodeList[i] as XmlElement;                            string moduleIndex= stepNode.Attributes["ModuleName"].Value.Replace("-","_");                            string controlTarget = stepNode.Attributes["ControlTarget"].Value;                            string setValue = stepNode.Attributes["SetValue"].Value;                            string almMax = stepNode.Attributes["AlmMax"].Value;                            string almMin = stepNode.Attributes["AlmMin"].Value;                            string stopMax = stepNode.Attributes["StopMax"].Value;                            string stopMin = stepNode.Attributes["StopMin"].Value;                            var value = $"{moduleIndex}:{controlTarget},{setValue},{almMax},{almMin},{stopMax},{stopMin}";                            info.SystemRecipeCommands.Add(value);                        }                    }                }                catch (Exception ex)                {                    LOG.Write(ex);                    return null;                }            }            return info;        }    }}
 |