public static List <WeightParameter> FindGlobleParameters(string name, string unit)
        {
            List <List <WeightParameter> > WeightParaList = WeightParameter.GetWeightParameterList();
            List <WeightParameter>         lstPara        = new List <WeightParameter>();

            for (int i = 0; i < WeightParaList.Count; ++i)
            {
                foreach (WeightParameter temp in WeightParaList[i])
                {
                    if (temp.ParaName == name)
                    {
                        if (unit == null || (temp.ParaUnit == unit))
                        {
                            lstPara.Add(temp);
                        }
                    }
                }
            }

            if (lstPara.Count == 0)
            {
                lstPara.Add(null);
            }

            return(lstPara);
        }
 public WeightParameter(WeightParameter wp)
 {
     ParaName   = wp.ParaName;
     ParaUnit   = wp.ParaUnit;
     ParaType   = wp.ParaType;
     ParaRemark = wp.ParaRemark;
     ParaValue  = wp.ParaValue;
 }
        public WeightParameter Clone()
        {
            WeightParameter para = new WeightParameter();

            para.ParaName   = this.ParaName;
            para.ParaUnit   = this.ParaUnit;
            para.ParaType   = this.ParaType;
            para.ParaValue  = this.ParaValue;
            para.ParaRemark = this.ParaRemark;

            return(para);
        }
        static public List <List <WeightParameter> > GetWeightParameterList()
        {
            if (WeightParaList != null)
            {
                return(WeightParaList);
            }

            WeightParaList = new List <List <WeightParameter> >();
            for (int i = 0; i < ParaTypeList.Length; ++i)
            {
                WeightParaList.Add(new List <WeightParameter>());
            }

            System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
            string strname = "ParameterCollection\\ParameterCollection.PMC";

            if (!System.IO.File.Exists(strname))
            {
                System.Windows.Forms.MessageBox.Show("文件 " + strname + " 不存在!");
            }
            else
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(strname);
                XmlNode xmlnode = doc.SelectSingleNode("PMC/参数列表");

                for (int i = 0; i < xmlnode.ChildNodes.Count; ++i)
                {
                    WeightParameter para       = new WeightParameter();
                    XmlNode         curxmlnode = xmlnode.ChildNodes[i];
                    para.ParaName   = curxmlnode.ChildNodes[0].InnerText;
                    para.ParaUnit   = curxmlnode.ChildNodes[1].InnerText;
                    para.ParaValue  = double.Parse(curxmlnode.ChildNodes[3].InnerText);
                    para.ParaRemark = curxmlnode.ChildNodes[4].InnerText;

                    para.ParaType = int.Parse(curxmlnode.ChildNodes[2].InnerText);

                    WeightParaList[para.ParaType].Add(para);
                }
            }
            return(WeightParaList);
        }
        static public WeightArithmetic ReadArithmeticData(string filename)
        {
            System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

            XmlDocument doc = new XmlDocument();

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


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

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

            WeightArithmetic wa = new WeightArithmetic();

            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)
            {
                WeightFormula wf = new WeightFormula();
                wf.NodePath = xmlsubnode.ChildNodes[0].InnerText;
                wf.Formula  = xmlsubnode.ChildNodes[1].InnerText;

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

                    WeightParameter wpGlobal = 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);

                        WeightParameter.GetWeightParameterList()[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);
                }

                if (xmlsubnode.ChildNodes.Count >= 4)
                {
                    wf.Value = double.Parse(xmlsubnode.ChildNodes[3].InnerText);
                }

                wa.FormulaList.Add(wf);
            }

            return(wa);
        }