|
|
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; |
|
|
|
using System.Xml.Linq; |
|
|
|
using System.Xml.XPath; |
|
|
|
|
|
|
|
|
|
|
|
namespace BPASmartClient.Business |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
@@ -62,27 +63,80 @@ namespace BPASmartClient.Business |
|
|
|
deviceConfig.Name = device.Attribute("Name").Value; |
|
|
|
deviceConfig.Module = device.Attribute("Module").Value; |
|
|
|
deviceConfig.DeviceId = int.Parse(device.Attribute("DeviceId").Value); |
|
|
|
if (null != device.Element("Parameters")) |
|
|
|
{ |
|
|
|
foreach (var deviceParameter in device.Element("Parameters").Elements()) |
|
|
|
{ |
|
|
|
deviceConfig.Parameters.Add(deviceParameter.Name.LocalName, deviceParameter.Value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var peripheralEl in device.XPathSelectElements("//Peripheral")) |
|
|
|
var Peripherals = device.XPathSelectElements("Peripherals/Peripheral"); |
|
|
|
if (Peripherals != null) |
|
|
|
{ |
|
|
|
BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral(); |
|
|
|
peripheral.Module = peripheralEl.Attribute("Module").Value; |
|
|
|
if (null != peripheralEl.Element("Parameters")) |
|
|
|
foreach (var Per in Peripherals) |
|
|
|
{ |
|
|
|
foreach (XElement parameter in peripheralEl.Element("Parameters").Elements()) |
|
|
|
BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral(); |
|
|
|
peripheral.Module = Per.Attribute("Module").Value; |
|
|
|
|
|
|
|
var Parameters = Per.Element("Parameters").Elements(); |
|
|
|
if (Parameters != null) |
|
|
|
{ |
|
|
|
peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value); |
|
|
|
foreach (var item in Parameters) |
|
|
|
{ |
|
|
|
peripheral.Parameters.Add(item.Name.LocalName, item.Value); |
|
|
|
} |
|
|
|
} |
|
|
|
deviceConfig.Peripherals.Add(peripheral); |
|
|
|
} |
|
|
|
deviceConfig.Peripherals.Add(peripheral); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//if (null != device.Element("Parameters")) |
|
|
|
//{ |
|
|
|
// foreach (var deviceParameter in device.Element("Parameters").Elements()) |
|
|
|
// { |
|
|
|
// deviceConfig.Parameters.Add(deviceParameter.Name.LocalName, deviceParameter.Value); |
|
|
|
// } |
|
|
|
//} |
|
|
|
|
|
|
|
//var Peripheral = device.XPathSelectElements("Parameters"); |
|
|
|
//if (null != Peripheral) |
|
|
|
//{ |
|
|
|
// foreach (var deviceParameter in Peripheral) |
|
|
|
// { |
|
|
|
// deviceConfig.Parameters.Add(deviceParameter.Name.LocalName, deviceParameter.Value); |
|
|
|
// } |
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (device.Element("Peripheral") != null) |
|
|
|
//{ |
|
|
|
// foreach (var peripherals in device.Element("Peripheral").Elements()) |
|
|
|
// { |
|
|
|
// BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral(); |
|
|
|
// peripheral.Module = peripherals.Attribute("Module").Value; |
|
|
|
// if (null != peripherals.Element("Parameters")) |
|
|
|
// { |
|
|
|
// foreach (XElement parameter in peripherals.Element("Parameters").Elements()) |
|
|
|
// { |
|
|
|
// peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// deviceConfig.Peripherals.Add(peripheral); |
|
|
|
// } |
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (var peripheralEl in device.XPathSelectElements("//Peripheral")) |
|
|
|
//{ |
|
|
|
// BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral(); |
|
|
|
// peripheral.Module = peripheralEl.Attribute("Module").Value; |
|
|
|
// if (null != peripheralEl.Element("Parameters")) |
|
|
|
// { |
|
|
|
// foreach (XElement parameter in peripheralEl.Element("Parameters").Elements()) |
|
|
|
// { |
|
|
|
// peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// deviceConfig.Peripherals.Add(peripheral); |
|
|
|
//} |
|
|
|
deviceConfigs.Add(deviceConfig); |
|
|
|
} |
|
|
|
} |
|
|
|