Sfoglia il codice sorgente

增加设备级参数

样式分支
applelon 2 anni fa
parent
commit
c65bf2f2f7
4 ha cambiato i file con 25 aggiunte e 5 eliminazioni
  1. +15
    -5
      BPASmartClient.Business/Plugin/ConfigMgr.cs
  2. +4
    -0
      BPASmartClient.Business/Plugin/DeviceMgr.cs
  3. +2
    -0
      BPASmartClient.Model/DeviceConfigModel.cs
  4. +4
    -0
      BPASmartClient/DeviceInfo.xml

+ 15
- 5
BPASmartClient.Business/Plugin/ConfigMgr.cs Vedi File

@@ -33,8 +33,8 @@ namespace BPASmartClient.Business
{
ClientId = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ClientId"]);
apolloUri = System.Configuration.ConfigurationManager.AppSettings["ApolloUri"].ToString();
InternetInfo.OrderServer= System.Configuration.ConfigurationManager.AppSettings["OrderServiceUri"].ToString();
InternetInfo.StockServer= System.Configuration.ConfigurationManager.AppSettings["StockServiceUri"].ToString();
InternetInfo.OrderServer = System.Configuration.ConfigurationManager.AppSettings["OrderServiceUri"].ToString();
InternetInfo.StockServer = System.Configuration.ConfigurationManager.AppSettings["StockServiceUri"].ToString();

InitDeviceModel();
InitMQTT();
@@ -61,15 +61,25 @@ namespace BPASmartClient.Business
DeviceConfig deviceConfig = new DeviceConfig();
deviceConfig.Name = device.Attribute("Name").Value;
deviceConfig.Module = device.Attribute("Module").Value;
deviceConfig.DeviceId =int.Parse(device.Attribute("DeviceId").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"))
{
BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral();
peripheral.Module = peripheralEl.Attribute("Module").Value;
foreach (XElement parameter in peripheralEl.Element("Parameters").Elements())
if (null != peripheralEl.Element("Parameters"))
{
peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value);
foreach (XElement parameter in peripheralEl.Element("Parameters").Elements())
{
peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value);
}
}
deviceConfig.Peripherals.Add(peripheral);
}


+ 4
- 0
BPASmartClient.Business/Plugin/DeviceMgr.cs Vedi File

@@ -53,6 +53,10 @@ namespace BPASmartClient.Business
var deviceTemp = Assembly.Load(device.Module.Substring(0, device.Module.LastIndexOf('.'))).CreateInstance(device.Module) as IDevice;
deviceTemp.Name = device.Name;
deviceTemp.DeviceId = device.DeviceId;
foreach (var pars in device.Parameters)
{
deviceTemp.GetType().GetProperty(pars.Key).SetValue(deviceTemp, Convert.ChangeType(pars.Value, deviceTemp.GetType().GetProperty(pars.Key).PropertyType));
}

List<IPeripheral> peripherals = new List<IPeripheral>();
foreach (var peripheral in device.Peripherals)


+ 2
- 0
BPASmartClient.Model/DeviceConfigModel.cs Vedi File

@@ -16,6 +16,8 @@ namespace BPASmartClient.Model
public string Name { get; set; }
public string Module { get; set; }
public int DeviceId { get; set; }
public Dictionary<string, string> Parameters { get; set; } = new Dictionary<string, string>();

public List<Peripheral> Peripherals { get; set; } = new List<Peripheral>();
}



+ 4
- 0
BPASmartClient/DeviceInfo.xml Vedi File

@@ -20,6 +20,10 @@
</Device>-->

<Device Name="MorkS" Module="BPASmartClient.MorkS.Control" DeviceId="2">
<Parameters>
<IpAddress>127.0.10.1</IpAddress>
<Port>11</Port>
</Parameters>
<Peripherals>
<Peripheral Module="BPASmartClient.PLC.MorksMachine">
<Parameters>


Caricamento…
Annulla
Salva