| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 | using Aitex.Core.RT.Log;using Aitex.Core.RT.ParameterCenter;using Caliburn.Micro.Core;using MECF.Framework.Common.ParameterCenter;using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;using RecipeEditorLib.RecipeModel.Params;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Xml;namespace MECF.Framework.UI.Client.CenterViews.Parameter{    public class APCPIDParameterData : ParameterDataBase    {        private ParameterProvider _parameterProvider = new ParameterProvider();        private ParameterFormatBuilder _columnBuilder = new ParameterFormatBuilder();        private DoubleParam _slowVacP;        public DoubleParam SlowVacP        {            get => _slowVacP;            set            {                _slowVacP = value;                NotifyOfPropertyChange(nameof(SlowVacP));            }        }        private DoubleParam _slowVacI;        public DoubleParam SlowVacI        {            get => _slowVacI;            set            {                _slowVacI = value;                NotifyOfPropertyChange(nameof(SlowVacI));            }        }        private DoubleParam _slowVacD;        public DoubleParam SlowVacD        {            get => _slowVacD;            set            {                _slowVacD = value;                NotifyOfPropertyChange(nameof(SlowVacD));            }        }        private DoubleParam _slowVacA;        public DoubleParam SlowVacA        {            get => _slowVacA;            set            {                _slowVacA = value;                NotifyOfPropertyChange(nameof(SlowVacA));            }        }        private Dictionary<string, ObservableCollection<ParameterTemplateColumnBase>> ParameterTemplate;        public APCPIDParameterData() : base()        {            string vars = _parameterProvider.GetParameterFormatXml($"Parameter\\APCPID");            _columnBuilder.Build($"Parameter\\APCPID");            ParameterTemplate = _parameterProvider.GetGroupParameterTemplate();            TableNumber = _columnBuilder.TableNumber;            Version = _columnBuilder.Version;            if (ParameterTemplate.ContainsKey("Parameter Information"))            {                var template = ParameterTemplate["Parameter Information"];                var pcom = template.Where(x => x.ControlName == "P").FirstOrDefault();                if (pcom != null)                {                    DoubleParam pParam = new DoubleParam()                    {                        Name = pcom.ControlName,                        Value = pcom.Value.ToString(),                        DisplayName = pcom.DisplayName,                        Minimun = pcom.Minimun,                        Maximun = pcom.Maximun,                        Resolution = 0                    };                    SlowVacP = pParam;                }                var icom = template.Where(x => x.ControlName == "I").FirstOrDefault();                if (icom != null)                {                    DoubleParam iParam = new DoubleParam()                    {                        Name = icom.ControlName,                        Value = icom.Value.ToString(),                        DisplayName = icom.DisplayName,                        Minimun = icom.Minimun,                        Maximun = icom.Maximun,                        Resolution = 0                    };                    SlowVacI = iParam;                }                var dcom = template.Where(x => x.ControlName == "D").FirstOrDefault();                if (dcom != null)                {                    DoubleParam dParam = new DoubleParam()                    {                        Name = dcom.ControlName,                        Value = dcom.Value.ToString(),                        DisplayName = dcom.DisplayName,                        Minimun = dcom.Minimun,                        Maximun = dcom.Maximun,                        Resolution = 0                    };                    SlowVacD = dParam;                }                var acom = template.Where(x => x.ControlName == "a").FirstOrDefault();                if (acom != null)                {                    DoubleParam aParam = new DoubleParam()                    {                        Name = acom.ControlName,                        Value = acom.Value.ToString(),                        DisplayName = acom.DisplayName,                        Minimun = acom.Minimun,                        Maximun = acom.Maximun,                        Resolution = 0                    };                    SlowVacA = aParam;                }            }            for (int i = 1; i < TableNumber + 1; i++)            {                Steps.Add(CreateStep());            }        }        public override ParameterTable CreateStep(XmlNode stepNode = null)        {            APCPIDTable step = new APCPIDTable();            if (stepNode != null)            {                if (stepNode.Attributes["StepNo"] != null)                    step.StepNo = int.Parse(stepNode.Attributes["StepNo"].Value);                if (stepNode.Attributes["Name"] != null)                    step.Name = stepNode.Attributes["Name"].Value;                //if (stepNode.Attributes["UseTemp"] != null)                //    step.UseTemp = stepNode.Attributes["UseTemp"].Value;            }            else            {                step.StepNo = StepNo;                step.Name = "Name" + StepNo.ToString();              //  step.UseTemp = "0";                StepNo++;            }            foreach (var item in ParameterTemplate)            {                if (item.Key != "Parameter Information")                {                    var pcom = item.Value.Where(x => x.ControlName == "P").FirstOrDefault();                    if (pcom != null)                    {                        DoubleParam pParam = new DoubleParam()                        {                            Name = pcom.ControlName,                            Value = pcom.Value.ToString(),                            DisplayName = pcom.DisplayName,                            Minimun = pcom.Minimun,                            Maximun = pcom.Maximun,                            Resolution = 0                        };                        step.P = pParam;                    }                    var icom = item.Value.Where(x => x.ControlName == "I").FirstOrDefault();                    if (icom != null)                    {                        DoubleParam iParam = new DoubleParam()                        {                            Name = icom.ControlName,                            Value = icom.Value.ToString(),                            DisplayName = icom.DisplayName,                            Minimun = icom.Minimun,                            Maximun = icom.Maximun,                            Resolution = 0                        };                        step.I = iParam;                    }                    var dcom = item.Value.Where(x => x.ControlName == "D").FirstOrDefault();                    if (dcom != null)                    {                        DoubleParam dParam = new DoubleParam()                        {                            Name = dcom.ControlName,                            Value = dcom.Value.ToString(),                            DisplayName = dcom.DisplayName,                            Minimun = dcom.Minimun,                            Maximun = dcom.Maximun,                            Resolution = 0                        };                        step.D = dParam;                    }                    var acom = item.Value.Where(x => x.ControlName == "a").FirstOrDefault();                    if (acom != null)                    {                        DoubleParam aParam = new DoubleParam()                        {                            Name = acom.ControlName,                            Value = acom.Value.ToString(),                            DisplayName = acom.DisplayName,                            Minimun = acom.Minimun,                            Maximun = acom.Maximun,                            Resolution = 0                        };                        step.A = aParam;                    }                    var offsetcom = item.Value.Where(x => x.ControlName == "offset").FirstOrDefault();                    if (offsetcom != null)                    {                        DoubleParam offsetParam = new DoubleParam()                        {                            Name = offsetcom.ControlName,                            Value = offsetcom.Value.ToString(),                            DisplayName = offsetcom.DisplayName,                            Minimun = offsetcom.Minimun,                            Maximun = offsetcom.Maximun,                            Resolution = 0                        };                        step.Offset = offsetParam;                    }                    var chcom = item.Value.Where(x => x.ControlName == "CH").FirstOrDefault();                    if (chcom != null)                    {                        DoubleParam chParam = new DoubleParam()                        {                            Name = chcom.ControlName,                            Value = chcom.Value.ToString(),                            DisplayName = chcom.DisplayName,                            Minimun = chcom.Minimun,                            Maximun = chcom.Maximun,                            Resolution = 0                        };                        step.CH = chParam;                    }                    var clcom = item.Value.Where(x => x.ControlName == "CL").FirstOrDefault();                    if (clcom != null)                    {                        DoubleParam clParam = new DoubleParam()                        {                            Name = clcom.ControlName,                            Value = clcom.Value.ToString(),                            DisplayName = clcom.DisplayName,                            Minimun = clcom.Minimun,                            Maximun = clcom.Maximun,                            Resolution = 0                        };                        step.CL = clParam;                    }                }            }            if (stepNode != null)            {                if (stepNode.Attributes["P"] != null && step.P != null)                    step.P.Value = stepNode.Attributes["P"].Value;                if (stepNode.Attributes["I"] != null && step.I != null)                    step.I.Value = stepNode.Attributes["I"].Value;                if (stepNode.Attributes["D"] != null && step.D != null)                    step.D.Value = stepNode.Attributes["D"].Value;                if (stepNode.Attributes["a"] != null && step.A != null)                    step.A.Value = stepNode.Attributes["a"].Value;                if (stepNode.Attributes["offset"] != null && step.Offset != null)                    step.Offset.Value = stepNode.Attributes["offset"].Value;                if (stepNode.Attributes["CH"] != null && step.CH != null)                    step.CH.Value = stepNode.Attributes["CH"].Value;                if (stepNode.Attributes["CL"] != null && step.CL != null)                    step.CL.Value = stepNode.Attributes["CL"].Value;            }            return (ParameterTable)step;        }        public override string GetXmlString()        {            XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableParameterData") as XmlElement;            nodeData.SetAttribute("CreatedBy", Creator);            nodeData.SetAttribute("CreationTime", CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));            nodeData.SetAttribute("LastRevisedBy", Revisor);            nodeData.SetAttribute("LastRevisionTime", ReviseTime.ToString("yyyy-MM-dd HH:mm:ss"));            nodeData.SetAttribute("Description", Description);            nodeData.SetAttribute("ParameterChamberType", ChamberType);            nodeData.SetAttribute("Version", Version);            nodeData.SetAttribute("TableNumber", TableNumber.ToString());            nodeData.SetAttribute("Permission", Permission);            nodeData.SetAttribute("ParameterLevel", Level);            nodeData.SetAttribute("P", SlowVacP.Value);            nodeData.SetAttribute("I", SlowVacI.Value);            nodeData.SetAttribute("D", SlowVacD.Value);            nodeData.SetAttribute("a", SlowVacA.Value);            XmlNode nodeModule = _doc.SelectSingleNode($"Aitex/TableParameterData/Module[@Name='{_module}']");            if (nodeModule == null)            {                nodeModule = _doc.CreateElement("Module");                nodeData.AppendChild(nodeModule);            }            nodeModule.RemoveAll();            (nodeModule as XmlElement).SetAttribute("Name", _module);            int i = 0;            foreach (ParameterTable parameter in Steps)            {                XmlElement nodeStep = _doc.CreateElement("Step");                nodeStep.SetAttribute("StepNo", parameter.StepNo.ToString());                nodeStep.SetAttribute("Name", parameter.Name);                //nodeStep.SetAttribute("UseTemp", parameter.UseTemp);                if (parameter is APCPIDTable)                {                    var apcParam = (APCPIDTable)parameter;                    if (apcParam.P != null)                    {                        nodeStep.SetAttribute("P", apcParam.P.Value);                    }                    if (apcParam.I != null)                    {                        nodeStep.SetAttribute("I", apcParam.I.Value);                    }                    if (apcParam.D != null)                    {                        nodeStep.SetAttribute("D", apcParam.D.Value);                    }                    if (apcParam.A != null)                    {                        nodeStep.SetAttribute("a", apcParam.A.Value);                    }                    if (apcParam.Offset != null)                    {                        nodeStep.SetAttribute("offset", apcParam.Offset.Value);                    }                    if (apcParam.CH != null)                    {                        nodeStep.SetAttribute("CH", apcParam.CH.Value);                    }                    if (apcParam.CL != null)                    {                        nodeStep.SetAttribute("CL", apcParam.CL.Value);                    }                }                nodeModule.AppendChild(nodeStep);                i++;            }            return _doc.OuterXml;        }        public override void InitData(string prefixPath, string recipeName, string recipeContent, string module)        {            IsCompatibleWithCurrentFormat = false;            _module = module;            Name = recipeName;            PrefixPath = prefixPath;            try            {                _doc = new XmlDocument();                _doc.LoadXml(recipeContent);                if (!LoadHeader(_doc.SelectSingleNode("Aitex/TableParameterData")))                    return;                XmlNodeList nodeSteps = _doc.SelectNodes($"Aitex/TableParameterData/Module[@Name='{module}']/Step");                if (nodeSteps == null)                    nodeSteps = _doc.SelectNodes($"Aitex/TableParameterData/Step");                LoadSteps(nodeSteps);                var index = 1;                foreach (ParameterTable parameters in Steps)                {                    parameters.Value = index.ToString();                    index++;                }                //   ValidLoopData();                XmlNode nodeConfig =                    _doc.SelectSingleNode($"Aitex/TableParameterData/Module[@Name='{module}']/Config");                if (nodeSteps == null)                    nodeConfig = _doc.SelectSingleNode($"Aitex/TableParameterData/Config");                IsCompatibleWithCurrentFormat = true;            }            catch (Exception ex)            {                LOG.Write(ex);            }        }        public override void LoadHeaderExtend(XmlNode nodeHeader)        {            base.LoadHeaderExtend(nodeHeader);                       if (nodeHeader.Attributes["P"] != null && SlowVacP!=null)                SlowVacP.Value = nodeHeader.Attributes["P"].Value;            if (nodeHeader.Attributes["I"] != null && SlowVacI != null)                SlowVacI.Value = nodeHeader.Attributes["I"].Value;            if (nodeHeader.Attributes["D"] != null && SlowVacD != null)                SlowVacD.Value = nodeHeader.Attributes["D"].Value;            if (nodeHeader.Attributes["a"] != null && SlowVacA != null)                SlowVacA.Value = nodeHeader.Attributes["a"].Value;        }        public override void LoadSteps(XmlNodeList steps)        {            Steps.Clear();            PopSettingSteps.Clear();            StepTolerances.Clear();            StepNos.Clear();            int index = 1;            foreach (XmlNode nodeStep in steps)            {                ParameterTable stepTable = this.CreateStep(nodeStep);                StepNos.Add(stepTable.StepNo);                Steps.Add(stepTable);                index++;            }        }    }}
 |