Exemple #1
0
        public static void SetCommunnicationData(CommunicationData cfgData)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(ConfigXML);
            xmlDoc.SelectSingleNode("config/system/communication/network/ip").InnerText          = cfgData.StartIP;
            xmlDoc.SelectSingleNode("config/system/communication/network/endip").InnerText       = cfgData.EndIP;
            xmlDoc.SelectSingleNode("config/system/communication/network/localport").InnerText   = cfgData.Localport;
            xmlDoc.SelectSingleNode("config/system/communication/network/remoteport").InnerText  = cfgData.Remoteport;
            xmlDoc.SelectSingleNode("config/system/communication/serialport/port").InnerText     = cfgData.Serialport;
            xmlDoc.SelectSingleNode("config/system/communication/serialport/baudrate").InnerText = cfgData.Baudrate;
            xmlDoc.SelectSingleNode("config/system/communication").Attributes["type"].Value      = cfgData.CommunicationType.ToString();
            xmlDoc.Save(ConfigXML);
            xmlDoc = null;
        }
Exemple #2
0
        public static CommunicationData GetCommunicationData()
        {
            CommunicationData cfgData = new CommunicationData();

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(ConfigXML);
            cfgData.StartIP    = xmlDoc.SelectSingleNode("config/system/communication/network/ip").InnerText;
            cfgData.EndIP      = xmlDoc.SelectSingleNode("config/system/communication/network/endip").InnerText;
            cfgData.Localport  = xmlDoc.SelectSingleNode("config/system/communication/network/localport").InnerText;
            cfgData.Remoteport = xmlDoc.SelectSingleNode("config/system/communication/network/remoteport").InnerText;
            cfgData.Serialport = xmlDoc.SelectSingleNode("config/system/communication/serialport/port").InnerText;
            cfgData.Baudrate   = xmlDoc.SelectSingleNode("config/system/communication/serialport/baudrate").InnerText;
            try
            {
                cfgData.CommunicationType = int.Parse(xmlDoc.SelectSingleNode("config/system/communication").Attributes["type"].Value);
            }
            catch { }
            xmlDoc = null;
            return(cfgData);
        }