Procházet zdrojové kódy

增加设备级参数

样式分支
applelon před 2 roky
rodič
revize
c65bf2f2f7
4 změnil soubory, kde provedl 25 přidání a 5 odebrání
  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 Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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>


Načítá se…
Zrušit
Uložit