Przeglądaj źródła

morkbf

样式分支
NXX 2 lat temu
rodzic
commit
18234ca8ea
3 zmienionych plików z 35 dodań i 30 usunięć
  1. +1
    -1
      BPASmartClient.Business/BPASmartClient.Business.csproj
  2. +33
    -28
      BPASmartClient.Business/Plugin/LocalMqtt.cs
  3. +1
    -1
      BPASmartClient.MorkF/BPASmartClient.MorkF.csproj

+ 1
- 1
BPASmartClient.Business/BPASmartClient.Business.csproj Wyświetl plik

@@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="BPA.ApolloClient" Version="1.0.12" />
<PackageReference Include="BPA.Message" Version="1.0.66" />
<PackageReference Include="BPA.Message" Version="1.0.69" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />


+ 33
- 28
BPASmartClient.Business/Plugin/LocalMqtt.cs Wyświetl plik

@@ -1,4 +1,5 @@
using BPASmartClient.MQTT;
using BPA.Message;
using BPASmartClient.MQTT;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -7,45 +8,49 @@ using System.Threading.Tasks;

namespace BPASmartClient.Business.Plugin
{
public class LocalMqtt : IPlugin
public class LocalMqtt
{

//客户端ID
private int clientId;
//运行标识
private bool running = false;
//MQTT 代理
private MQTTProxy mqttProxy = new MQTTProxy();
private volatile static LocalMqtt _Instance;
public static LocalMqtt GetInstance => _Instance ?? (_Instance = new LocalMqtt());
private LocalMqtt() { }

public void Dispose()
SendScreenDataModel MqttPush = new SendScreenDataModel();

public void Init(ScreenDeviceType DeviceType)
{
Dictionary<string, string> MqttPushdata = new Dictionary<string, string>();
MqttPush.mqttDataDic.Add(DeviceType.ToString(), SetTopic(DeviceType, MqttPushdata));
MQTTProxy mQTTProxy = new MQTTProxy();
mQTTProxy.Connected = new Action(() =>
{
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(DeviceType)) ;
});
mQTTProxy.Connect("UserName", "Password", "Host", 1880, $"{DeviceType}_设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}

public void Initialize()
public void Start()
{
}

public void Start()
private Dictionary<string, string> SetTopic(ScreenDeviceType DeviceType, Dictionary<string, string> MqttPushdata )
{
running = true;
//主题初始化
TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin<DeviceMgr>().GetDevices());
//MQTT 连接成功
mqttProxy.Connected = new Action(() =>
{
mqttProxy.Subscrib();
});
//MQTT 连接成功
mqttProxy.LostConnect = new Action(() =>
switch (DeviceType)
{
mqttProxy.Subscrib();
});
//MQTT 初始化
mqttProxy.Connect();
case ScreenDeviceType.大炒:
break;
case ScreenDeviceType.小炒:
break;
case ScreenDeviceType.分餐机:
break;
case ScreenDeviceType.煮面机:
break;
default:
break;
}
return MqttPushdata;
}

/// <summary>


+ 1
- 1
BPASmartClient.MorkF/BPASmartClient.MorkF.csproj Wyświetl plik

@@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.66" />
<PackageReference Include="BPA.Message" Version="1.0.69" />
</ItemGroup>

<ItemGroup>


Ładowanie…
Anuluj
Zapisz