Ejemplo n.º 1
0
 static void ReadModbus(ModbusConfiguration config, XmlNode node)
 {
     foreach (XmlNode child in node.ChildNodes)
     {
         if (child.Name == "pollinginterval")
         {
             int  value = 0;
             bool r     = int.TryParse(child.InnerText, out value);
             if (!r)
             {
                 value = 10;
             }
             config.PollingInterval = value;
         }
         else if (child.Name == "mapping")
         {
             var dm = new DeviceTypeMapping();
             ReadDeviceTypeMapping(dm, child);
             config.DeviceTypes.Add(dm);
         }
         else if (child.Name == "device")
         {
             var dd = new DeviceDescription();
             ReadDeviceDescription(config, dd, child);
             config.Devices.Add(dd);
         }
     }
 }
Ejemplo n.º 2
0
        static void ReadDeviceTypeMapping(DeviceTypeMapping dm, XmlNode node)
        {
            dm.Name = node.Attributes["name"].Value;

            if (node.Attributes["offset"] != null)
            {
                dm.Offset = ParseInt(node.Attributes["offset"].Value, 0);
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.Name == "field")
                {
                    var fm = new FieldMapping();
                    ReadFieldMapping(fm, child);
                    dm.FieldList.Add(fm);
                }
            }
        }