diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index a384a861..7e88a063 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -8,7 +8,8 @@ - + + diff --git a/BPASmartClient.Business/LocalMqtt.cs b/BPASmartClient.Business/LocalMqtt.cs new file mode 100644 index 00000000..3db4a8bf --- /dev/null +++ b/BPASmartClient.Business/LocalMqtt.cs @@ -0,0 +1,57 @@ +using BPA.Message; +using BPASmartClient.MQTT; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Business +{ + public class LocalMqtt + { + private volatile static LocalMqtt _Instance; + public static LocalMqtt GetInstance => _Instance ?? (_Instance = new LocalMqtt()); + private LocalMqtt() { } + + /// + /// + /// + SendScreenDataModel MqttPushs = new SendScreenDataModel(); + + MQTTProxy mQTTProxy = new MQTTProxy(); + + ScreenDeviceType LocDeviceType; + + public void Init(ScreenDeviceType DeviceType) + { + MqttPushs.Name = DeviceType; + LocDeviceType = DeviceType; + mQTTProxy.Connected = new Action(() => + { + mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(DeviceType)) ; + + }); + mQTTProxy.Connect("admin", "public", "10.2.1.254", 1883, $"{DeviceType}_设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + } + + public void Start() + { + + } + + + + /// + /// MQTT消息推送 + /// + /// 主题 + /// 消息体 + public void Publish(object message) + { + MqttPushs.Value = message; + mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(LocDeviceType), JsonConvert.SerializeObject(MqttPushs)); + } + } +} diff --git a/BPASmartClient.Business/Plugin/LocalMqtt.cs b/BPASmartClient.Business/Plugin/LocalMqtt.cs deleted file mode 100644 index c8a22c3a..00000000 --- a/BPASmartClient.Business/Plugin/LocalMqtt.cs +++ /dev/null @@ -1,71 +0,0 @@ -using BPA.Message; -using BPASmartClient.MQTT; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.Business.Plugin -{ - public class LocalMqtt - { - - private volatile static LocalMqtt _Instance; - public static LocalMqtt GetInstance => _Instance ?? (_Instance = new LocalMqtt()); - private LocalMqtt() { } - - /// - /// - /// - SendScreenDataModel MqttPushs = new SendScreenDataModel(); - - MQTTProxy mQTTProxy = new MQTTProxy(); - - public void Init(ScreenDeviceType DeviceType) - { - Dictionary MqttPushdata = new Dictionary(); - MqttPushs.mqttDataDic.Add(DeviceType.ToString(), SetTopic(DeviceType, MqttPushdata)); - - 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 Start() - { - - } - - private Dictionary SetTopic(ScreenDeviceType DeviceType, Dictionary MqttPushdata ) - { - switch (DeviceType) - { - case ScreenDeviceType.大炒: - break; - case ScreenDeviceType.小炒: - break; - case ScreenDeviceType.分餐机: - break; - case ScreenDeviceType.煮面机: - break; - default: - break; - } - return MqttPushdata; - } - - /// - /// MQTT消息推送 - /// - /// 主题 - /// 消息体 - public void Publish(string topic, string message) - { - mqttProxy.Publish(topic, message); - } - } -} diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 6f74cd49..874b83ef 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -410,7 +410,7 @@ - + diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj index dc5df46f..456f5bbb 100644 --- a/BPASmartClient.Device/BPASmartClient.Device.csproj +++ b/BPASmartClient.Device/BPASmartClient.Device.csproj @@ -7,7 +7,7 @@ - + diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index 7bdaac6a..cdb1d4f7 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.Model/BPASmartClient.Model.csproj b/BPASmartClient.Model/BPASmartClient.Model.csproj index 87c447b0..6237674c 100644 --- a/BPASmartClient.Model/BPASmartClient.Model.csproj +++ b/BPASmartClient.Model/BPASmartClient.Model.csproj @@ -17,7 +17,7 @@ - + diff --git a/BPASmartClient.Model/GlobalFoodMenu.cs b/BPASmartClient.Model/GlobalFoodMenu.cs new file mode 100644 index 00000000..73bdd544 --- /dev/null +++ b/BPASmartClient.Model/GlobalFoodMenu.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public class GlobalFoodMenu + { + public static ObservableCollection LocalFoodMenus = new ObservableCollection(); + } +} diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 92c2b468..76be2fdf 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -1,4 +1,6 @@ -using BPA.Message.Enum; +using BPA.Message; +using BPA.Message.Enum; +using BPASmartClient.Business; using BPASmartClient.Device; using BPASmartClient.EventBus; using BPASmartClient.Helper; @@ -27,6 +29,7 @@ namespace BPASmartClient.MorkBF CommandRegist();//调试 ServerInit(); DataParse();//数据解析 + ScreenDataServer();//大屏数据上报 DeviceProcessLogShow("MORKF 设备初始化完成"); } @@ -754,5 +757,48 @@ namespace BPASmartClient.MorkBF #endregion + + + private void ScreenDataServer() + { + LocalMqtt.GetInstance.Init(ScreenDeviceType.大炒); + ThreadManage.GetInstance().StartLong(new Action(() => + { + List statsModels = new List(); + statsModels.Add(new StatsModel() { Name = "帝王蟹", Count = 666 }); + ScreenModelMaxWok maxWok = new ScreenModelMaxWok + { + IsRun = new Random().Next(0, 2) == 0 ? IsRun.运行 : IsRun.停止, + WorkStatus_1 = (WorkStatus)new Random().Next(0, 3), + WorkStatus_2 = (WorkStatus)new Random().Next(0, 3), + RobotStatu = (WorkStatus)new Random().Next(0, 3), + Alarm = new List(), + FailuresCount = 0, + StatsCount = statsModels, + MaxWok_Dishes_1 = "满汉全席", + MaxWok_Dishes_2 = "海鲜大餐", + MaxWok_Task_1 = "炒制菜品", + MaxWok_Task_2 = "热油", + MaxWok_Process_1 = new List(), + MaxWok_HeatGear_1 = new Random().Next(0, 5).ToString(), + MaxWok_HeatGear_2 = new Random().Next(0, 5).ToString(), + MaxWok_StirGear_1 = new Random().Next(0, 5).ToString(), + MaxWok_StirGear_2 = new Random().Next(0, 5).ToString(), + MaxWok_FlipSpeed_1 = new Random().Next(250, 450).ToString(), + MaxWok_FlipSpeed_2 = new Random().Next(250, 450).ToString(), + MaxWok_Temp_1 = new Random().Next(250, 450).ToString(), + MaxWok_Temp_2 = new Random().Next(250, 450).ToString(), + MaxWok_OrderCount_1 = 2, + MaxWok_OrderCount_2 = 2, + MaxWok_ErrorOrderCount_1 = 0, + MaxWok_ErrorOrderCount_2 = 0, + + }; + LocalMqtt.GetInstance.Publish(maxWok); + Thread.Sleep(1000); + + }), "大屏数据上报"); + + } } } diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj index c4203f46..ea0b7fa5 100644 --- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj +++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj @@ -1,4 +1,4 @@ - + net6.0-windows @@ -10,7 +10,7 @@ - + diff --git a/BPASmartClient.ViewModel/FoodMenuViewModel.cs b/BPASmartClient.ViewModel/FoodMenuViewModel.cs index 255cd3d5..0d7733f8 100644 --- a/BPASmartClient.ViewModel/FoodMenuViewModel.cs +++ b/BPASmartClient.ViewModel/FoodMenuViewModel.cs @@ -13,7 +13,7 @@ namespace BPASmartClient.ViewModel { public class FoodMenuViewModel: ObservableObject { - public ObservableCollection FoodMenus { get; set; } = new ObservableCollection(); + public ObservableCollection FoodMenus { get; set; } = GlobalFoodMenu.LocalFoodMenus; public RelayCommand StartOrder { get; set; } diff --git a/DosingSystem/BPASmartClient.DosingSystem.csproj b/DosingSystem/BPASmartClient.DosingSystem.csproj index 187e3b27..9b861ee0 100644 --- a/DosingSystem/BPASmartClient.DosingSystem.csproj +++ b/DosingSystem/BPASmartClient.DosingSystem.csproj @@ -17,7 +17,7 @@ - +