Exemplo n.º 1
0
        public CoreEnvelopeArithmetic Clone()
        {
            CoreEnvelopeArithmetic weight = new CoreEnvelopeArithmetic();

            weight.DataName       = this.DataName;
            weight.Name           = this.Name;
            weight.CreateTime     = this.CreateTime;
            weight.LastModifyTime = this.LastModifyTime;
            weight.Remark         = this.Remark;

            List <NodeFormula> lstWeightFormula = new List <NodeFormula>();

            foreach (NodeFormula formula in FormulaList)
            {
                lstWeightFormula.Add(new NodeFormula(formula.NodeName, formula.XFormula.Clone(), formula.YFormula.Clone()));
            }
            weight.FormulaList = lstWeightFormula;

            return(weight);
        }
Exemplo n.º 2
0
        static public CoreEnvelopeArithmetic ReadArithmeticData(string filename)
        {
            List <List <WeightParameter> > WeightParaList = WeightParameter.GetWeightParameterList();

            System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(filename);
            }
            catch
            {
                MessageBox.Show("打开文件错误!");
                XCommon.XLog.Write("打开文件错误");
                return(null);
            }


            XmlNode xmlnode = doc.SelectSingleNode("重量算法/算法名称");

            if (xmlnode == null)
            {
                MessageBox.Show("错误的算法文件!");
                XCommon.XLog.Write("错误的算法文件!");
                return(null);
            }

            CoreEnvelopeArithmetic wa = new CoreEnvelopeArithmetic();

            wa.Name = xmlnode.InnerText;

            xmlnode       = doc.SelectSingleNode("重量算法/算法创建时间");
            wa.CreateTime = xmlnode.InnerText;
            //xmlnode = doc.SelectSingleNode("重量算法/重量分类");
            //wa.SortName = xmlnode.InnerText;
            xmlnode           = doc.SelectSingleNode("重量算法/算法最后修改时间");
            wa.LastModifyTime = xmlnode.InnerText;
            xmlnode           = doc.SelectSingleNode("重量算法/算法备注");
            wa.Remark         = xmlnode.InnerText;
            xmlnode           = doc.SelectSingleNode("重量算法/节点列表");

            Dictionary <WeightParameter, WeightParameter> wpDict = new Dictionary <WeightParameter, WeightParameter>();

            foreach (XmlNode xmlsubnode in xmlnode.ChildNodes)
            {
                NodeFormula nf = new NodeFormula();
                nf.NodeName = xmlsubnode.ChildNodes[0].InnerText;

                for (int i = 0; i < 2; ++i)
                {
                    WeightFormula wf     = nf[i];
                    XmlNode       wfNode = xmlsubnode.SelectSingleNode(wf.NodePath);;
                    if (wfNode == null)
                    {
                        MessageBox.Show("错误的算法文件!");
                        return(null);
                    }

                    wf.Formula = wfNode.ChildNodes[0].InnerText;

                    foreach (XmlNode paranode in wfNode.ChildNodes[1].ChildNodes)
                    {
                        string name = paranode.ChildNodes[0].InnerText;
                        string unit = paranode.ChildNodes[2].InnerText;

                        WeightParameter wpGlobal = WeightArithmetic.FindGlobleParameters(name, unit)[0];

                        WeightParameter wp = null;
                        if (wpGlobal == null)
                        {
                            wp            = new WeightParameter();
                            wp.ParaName   = name;
                            wp.ParaUnit   = unit;
                            wp.ParaType   = 10;// int.Parse(paranode.ChildNodes[2].InnerText);
                            wp.ParaValue  = double.Parse(paranode.ChildNodes[1].InnerText);
                            wp.ParaRemark = paranode.ChildNodes[4].InnerText;

                            WeightParameter temp10wp = new WeightParameter(wp);

                            WeightParaList[10].Add(temp10wp);

                            wpDict.Add(temp10wp, wp);
                        }
                        else
                        {
                            if (!wpDict.ContainsKey(wpGlobal))
                            {
                                wp = new WeightParameter(wpGlobal);
                                wpDict.Add(wpGlobal, wp);
                            }
                            else
                            {
                                wp = wpDict[wpGlobal];
                            }
                        }
                        wf.ParaList.Add(wp);
                    }

                    wf.Value = double.Parse(wfNode.ChildNodes[2].InnerText);
                }

                wa.FormulaList.Add(nf);
            }

            return(wa);
        }