Esempio n. 1
0
        //从StationInf_Table.xml中获取子站信息,再从sPrjName中获取对应的端口名称
        public bool GetStationsFromXML()//获取子站信息
        {
            XmlDocument MyXmlDoc = new XmlDocument();

            MyXmlDoc.Load(sIOPath);

            string     xpath     = "IO/StationInf_Table";
            XmlElement childNode = (XmlElement)MyXmlDoc.SelectSingleNode(xpath);

            foreach (XmlElement node in childNode.ChildNodes)
            {
                string sPortName = node.GetAttribute("PortName");
                foreach (CPort nPort in ListPort)
                {
                    if (sPortName == nPort.PortName)
                    {
                        CStation nSta = (CStation)CDAModule.CreateStation(nPort.PortType, nPort.PortProtocol);
                        if (nSta == null)
                        {
                            break;
                        }
                        nSta.LoadFromNode(node);
                        nSta.staAlarm = staAlarm;
                        ListStation.Add(nSta);
                        nPort.ListStation.Add(nSta);
                        nSta.iPortIndex = ListPort.IndexOf(nPort);
                        nSta.iStaIndex  = nPort.ListStation.IndexOf(nSta);
                        break;
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        //从PortInf_Table.xml中获取端口信息,存入ListPort
        public bool GetPortsFromXML()//获取端口信息
        {
            ListPort.Clear();
            XmlDocument MyXmlDoc = new XmlDocument();

            MyXmlDoc.Load(sIOPath);

            string     xpath     = "IO/PortInf_Table";
            XmlElement childNode = (XmlElement)MyXmlDoc.SelectSingleNode(xpath);

            foreach (XmlElement item in childNode.ChildNodes)
            {
                string sPortType     = item.GetAttribute("PortType");
                string sPortProtocol = item.GetAttribute("PortProtocol");
                CPort  nPort         = (CPort)CDAModule.CreatePort(sPortType, sPortProtocol);
                if (nPort == null)
                {
                    continue;
                }
                nPort.LoadFromNode(item);
                ListPort.Add(nPort);
            }
            return(true);
        }