diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index 0a299989..a384a861 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.Business/Plugin/LocalMqtt.cs b/BPASmartClient.Business/Plugin/LocalMqtt.cs index a59670ec..170c5fde 100644 --- a/BPASmartClient.Business/Plugin/LocalMqtt.cs +++ b/BPASmartClient.Business/Plugin/LocalMqtt.cs @@ -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 MqttPushdata = new Dictionary(); + 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 SetTopic(ScreenDeviceType DeviceType, Dictionary MqttPushdata ) { - running = true; - //主题初始化 - TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin().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; } /// diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj index fc0a33b0..c4203f46 100644 --- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj +++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj @@ -10,7 +10,7 @@ - +