// 加载xml文件
        public static bool ReadXml(string node, Frm_main main)
        {
            try
            {
                XmlAttributeCollection abconGroup;
                XmlAttributeCollection abconTag;
                XmlDocument            doc = new XmlDocument();
                doc.Load(xmlPath);
                XmlNode xmlGroup = doc.SelectSingleNode(node);
                foreach (XmlNode group in xmlGroup)
                {
                    // 添加

                    class_treeNode tn = null;
                    abconGroup = group.Attributes;
                    tn         = main.AddGroup(abconGroup["name"].Value);

                    foreach (XmlNode tag in group)
                    {
                        abconTag = tag.Attributes;
                        tn.AddItem(abconTag["bindName"].Value.ToString(), abconTag["sendName"].Value.ToString(), abconTag["name"].Value.ToString(), abconTag["vt"].Value.ToString()
                                   , abconTag["value"].Value.ToString(), Convert.ToInt16(abconTag["status"].Value));
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }
        public static bool WriteXml(Frm_main main)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                XmlElement  xe  = doc.CreateElement("", main.rootGroup.Text, "");
                doc.AppendChild(xe);

                class_treeNode group = (class_treeNode)main.rootGroup.FirstNode;
                while (group != null)
                {
                    // 保存Group
                    XmlNode      xmlGroup     = doc.CreateNode(XmlNodeType.Element, "group", "");
                    XmlAttribute xmlGroupName = doc.CreateAttribute("name");
                    xmlGroupName.Value = group.Text;
                    xmlGroup.Attributes.Append(xmlGroupName);

                    // 保存Tag
                    for (int i = 0; i < group.dtList.Rows.Count; i++)
                    {
                        XmlNode      xmlTag     = doc.CreateNode(XmlNodeType.Element, "tag", "");
                        XmlAttribute xmlTagName = doc.CreateAttribute("name");
                        xmlTagName.Value = group.dtList.Rows[i]["name"].ToString();
                        xmlTag.Attributes.Append(xmlTagName);

                        XmlAttribute xmlTagBindName = doc.CreateAttribute("bindName");
                        xmlTagBindName.Value = group.dtList.Rows[i]["bindName"].ToString();
                        xmlTag.Attributes.Append(xmlTagBindName);

                        XmlAttribute xmlTagSendName = doc.CreateAttribute("sendName");
                        xmlTagSendName.Value = group.dtList.Rows[i]["sendName"].ToString();
                        xmlTag.Attributes.Append(xmlTagSendName);

                        XmlAttribute xmlTagVt = doc.CreateAttribute("vt");
                        xmlTagVt.Value = group.dtList.Rows[i]["vt"].ToString();
                        xmlTag.Attributes.Append(xmlTagVt);

                        XmlAttribute xmlTagValue = doc.CreateAttribute("value");
                        xmlTagValue.Value = group.dtList.Rows[i]["value"].ToString();
                        xmlTag.Attributes.Append(xmlTagValue);

                        XmlAttribute xmlTagStatus = doc.CreateAttribute("status");
                        string       status       = group.dtList.Rows[i]["status"].ToString();
                        xmlTagStatus.Value = class_opcDll.stringToshort(status).ToString();
                        xmlTag.Attributes.Append(xmlTagStatus);

                        xmlGroup.AppendChild(xmlTag);
                    }

                    xe.AppendChild(xmlGroup);
                    group = (class_treeNode)group.NextNode;
                }
                doc.Save(xmlPath);
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }