ソースを参照

增加设备级参数

样式分支
applelon 2年前
コミット
c65bf2f2f7
4個のファイルの変更25行の追加5行の削除
  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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

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


読み込み中…
キャンセル
保存