diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index b7492b30..bc5eae2f 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.Business/LocalMqtt.cs b/BPASmartClient.Business/LocalMqtt.cs index a629d7a9..7a8cefb9 100644 --- a/BPASmartClient.Business/LocalMqtt.cs +++ b/BPASmartClient.Business/LocalMqtt.cs @@ -33,7 +33,7 @@ namespace BPASmartClient.Business { MqttPushs.Name = DeviceType; LocDeviceType = DeviceType; - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(DeviceType)); diff --git a/BPASmartClient.Business/Plugin/MQTTMgr.cs b/BPASmartClient.Business/Plugin/MQTTMgr.cs index 3856f2bb..2479de0d 100644 --- a/BPASmartClient.Business/Plugin/MQTTMgr.cs +++ b/BPASmartClient.Business/Plugin/MQTTMgr.cs @@ -44,7 +44,7 @@ namespace BPASmartClient.Business //主题初始化 TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin().GetDevices()); - mqttProxy.ConnectOk = () => + mqttProxy.Connected = () => { mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray()); }; diff --git a/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj b/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj index 49bd8a14..88a9f643 100644 --- a/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj +++ b/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj @@ -16,7 +16,7 @@ - + diff --git a/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs index fe350ef6..e8b73391 100644 --- a/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs @@ -185,7 +185,7 @@ namespace BPASmartClient.FoodStationTest.Model DeviceStatus DS = new DeviceStatus(); DS.modbusTcp.IsReconnect = false; - DS.modbusTcp.ConnectOk = new Action(() => + DS.modbusTcp.Connected = new Action(() => { string DeviceName = DS.modbusTcp.Read(DeviceAddress.DeviceName, 20).Content.Trim()?.Replace(" ", "");//读取设备名称 if (DeviceName.Length > 0) diff --git a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj index b9be36f1..ac53015c 100644 --- a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj +++ b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj @@ -17,7 +17,7 @@ - + diff --git a/BPASmartClient.MorkMV1/DataServer.cs b/BPASmartClient.MorkMV1/DataServer.cs index 607168dc..f29653f5 100644 --- a/BPASmartClient.MorkMV1/DataServer.cs +++ b/BPASmartClient.MorkMV1/DataServer.cs @@ -23,7 +23,7 @@ namespace BPASmartClient.MorkMV1 MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index 695a772b..2eee8ea6 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -23,7 +23,7 @@ namespace BPASmartClient.MorkS MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.MorkS3/DataServer.cs b/BPASmartClient.MorkS3/DataServer.cs index 9d8f74c2..411758cf 100644 --- a/BPASmartClient.MorkS3/DataServer.cs +++ b/BPASmartClient.MorkS3/DataServer.cs @@ -23,7 +23,7 @@ namespace BPASmartClient.MorkS3 MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.MorkSUpgradedVer/DataServer.cs b/BPASmartClient.MorkSUpgradedVer/DataServer.cs index ad3b8786..124fa7e2 100644 --- a/BPASmartClient.MorkSUpgradedVer/DataServer.cs +++ b/BPASmartClient.MorkSUpgradedVer/DataServer.cs @@ -22,7 +22,7 @@ namespace BPASmartClient.MorkSUpgradedVer MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj b/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj index c436e43d..1cd718e1 100644 --- a/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj +++ b/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj @@ -21,7 +21,7 @@ - + diff --git a/BPASmartClient.Tourism/AddConvert.cs b/BPASmartClient.Tourism/AddConvert.cs new file mode 100644 index 00000000..6d870a7d --- /dev/null +++ b/BPASmartClient.Tourism/AddConvert.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL +{ + /// + /// 地址转换类 + /// + internal static class AddConvert + { + public static string ToModbusAdd(this string add) + { + return ""; + } + } +} diff --git a/BPASmartClient.Tourism/GVL_MorkCL.cs b/BPASmartClient.Tourism/GVL_MorkCL.cs index 8bd69a5d..dea67c26 100644 --- a/BPASmartClient.Tourism/GVL_MorkCL.cs +++ b/BPASmartClient.Tourism/GVL_MorkCL.cs @@ -8,5 +8,20 @@ namespace BPASmartClient.MorkCL { public class GVL_MorkCL : IStatus { + #region 炒锅1 + + #endregion + + #region 炒锅2 + + #endregion + + #region 压力锅 + + #endregion + + #region 机器人 + + #endregion } } diff --git a/BPASmartClient.Tourism/GlobalUsing.cs b/BPASmartClient.Tourism/GlobalUsing.cs index 9621b22c..9431fac0 100644 --- a/BPASmartClient.Tourism/GlobalUsing.cs +++ b/BPASmartClient.Tourism/GlobalUsing.cs @@ -13,3 +13,6 @@ global using BPASmartClient.MorkCL.Model; global using System.Collections.Concurrent; global using System.Collections.ObjectModel; global using BPASmartClient.Device; +global using BPASmartClient.MorkCL.Model.Func; +global using System.Threading; +global using BPA.Communication.Base; \ No newline at end of file diff --git a/BPASmartClient.Tourism/Model/ConnectPar.cs b/BPASmartClient.Tourism/Model/ConnectPar.cs new file mode 100644 index 00000000..5759eb83 --- /dev/null +++ b/BPASmartClient.Tourism/Model/ConnectPar.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model +{ + internal class ConnectPar + { + //1号炒锅 + public static string FryingPanIP1 { get; set; } + public static string FryingPanPort1 { get; set; } + + //2号炒锅 + public static string FryingPanIP2 { get; set; } + public static string FryingPanPort2 { get; set; } + + //压力锅 + public static string PressureCookerIP { get; set; } + public static string PressureCookerPort { get; set; } + + //机器人 + public static string RobotIP { get; set; } + public static string RobotPort { get; set; } + + //电子秤端口号 + public static string ESPortName { get; set; } + + //外设端口号 + public static string PPortName { get; set; } + } +} diff --git a/BPASmartClient.Tourism/Model/Control/FryingPanGet.cs b/BPASmartClient.Tourism/Model/Control/FryingPanGet.cs new file mode 100644 index 00000000..2bbdd18a --- /dev/null +++ b/BPASmartClient.Tourism/Model/Control/FryingPanGet.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model.Control +{ + internal class FryingPanGet : ModbusBase + { + /// + /// 初始化完成 + /// + public bool InitComplete { get; set; } + + /// + /// 手自动状态模式 + /// + public bool StatusMode { get; set; } + + /// + /// 急停 + /// + public bool EStop { get; set; } + + /// + /// 炒制位置反馈(1-4) + /// + public bool[] StirFryingLocFB { get; set; } = new bool[4]; + + /// + /// 炒锅在出餐位置反馈 + /// + public bool DiningOutLocFB { get; set; } + + /// + /// 炒锅在投料位置反馈 + /// + public bool FeedingLocFB { get; set; } + + /// + /// 炒锅在洗锅位置反馈 + /// + public bool WashingPotLocFB { get; set; } + + /// + /// 通道出料完成反馈(1-3) + /// + public bool[] ChannelDisCom { get; set; } = new bool[3]; + + /// + /// 当前锅底温度 + /// + public float CurrentTemperature { get; set; } + + /// + /// 当前炒锅搅拌转速 + /// + public ushort CurrentSpeed { get; set; } + + /// + /// 当前加热档位 + /// + public ushort HeatingGear { get; set; } + } +} diff --git a/BPASmartClient.Tourism/Model/Control/FryingPanSet.cs b/BPASmartClient.Tourism/Model/Control/FryingPanSet.cs new file mode 100644 index 00000000..5808f311 --- /dev/null +++ b/BPASmartClient.Tourism/Model/Control/FryingPanSet.cs @@ -0,0 +1,110 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model.Control +{ + internal class FryingPanSet : FryingPanGet + { + /// + /// 搅拌启停 + /// + public bool StirStartOrStop { get { return default; } set { MyModbus.Write("LB0".ToModbusAdd(), value); } } + + /// + /// 加热启停 + /// + public bool HeatStartOrStop { get { return default; } set { MyModbus.Write("LB3".ToModbusAdd(), value); } } + + /// + /// 通道下料启动控制(1-3) + /// + /// 通道编号,1-3 + /// 通道需求值 + public void CuttingControl(int ChannelNum, ushort value) + { + if (ChannelNum >= 1 && ChannelNum <= 3) + { + byte[] VWOffset = new byte[3] { 6, 8, 10 }; + byte[] LBOffset = new byte[3] { 6, 7, 0 }; + MyModbus.Write($"VW10{VWOffset[ChannelNum - 1]}".ToModbusAdd(), value); + MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), true); + } + } + + /// + /// 加热档位设定 + /// + /// 档位,1-8挡 + public void HeatingGearSet(ushort Gear) + { + if (Gear >= 1 && Gear <= 8) + { + MyModbus.Write($"VW100".ToModbusAdd(), Gear); + MyModbus.Write($"LB9".ToModbusAdd(), true); + } + } + + /// + /// 搅拌频率设定 + /// + /// 频率,0-50HZ + public void MixingFrequencySet(ushort Frequency) + { + if (Frequency >= 0 && Frequency <= 50) + { + MyModbus.Write($"VW102".ToModbusAdd(), Frequency); + MyModbus.Write($"LB10".ToModbusAdd(), true); + } + } + + /// + /// 翻转频率设定 + /// + /// 频率,0-50HZ + public void OverturnFrequencySet(ushort Frequency) + { + if (Frequency >= 0 && Frequency <= 50) + { + MyModbus.Write($"VW104".ToModbusAdd(), Frequency); + MyModbus.Write($"LB11".ToModbusAdd(), true); + } + } + + /// + /// 炒锅回原点 + /// + public bool FryingPanHome { get { return default; } set { MyModbus.Write("LB12".ToModbusAdd(), value); } } + + /// + /// 出餐启动 + /// + public bool DiningOutStart { get { return default; } set { MyModbus.Write("LB13".ToModbusAdd(), value); } } + + /// + /// 炒锅清洗 + /// + public bool FryingPanClear { get { return default; } set { MyModbus.Write("LB14".ToModbusAdd(), value); } } + + /// + /// 炒锅回投料位置 + /// + public bool FryingPanFeedingLoc { get { return default; } set { MyModbus.Write("LB15".ToModbusAdd(), value); } } + + /// + /// 去炒制位控制 + /// + /// 炒锅位置,1-4 + public void SetStirFryingLoc(ushort loc) + { + if (loc >= 1 && loc <= 4) + { + MyModbus.Write($"LB{loc + 15}".ToModbusAdd(), true); + } + } + + } +} diff --git a/BPASmartClient.Tourism/Model/Control/IModbus.cs b/BPASmartClient.Tourism/Model/Control/IModbus.cs new file mode 100644 index 00000000..5885fbf0 --- /dev/null +++ b/BPASmartClient.Tourism/Model/Control/IModbus.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model.Control +{ + internal interface IModbus + { + void Init(string IP = "", int Port = 502, string PortName = ""); + } +} diff --git a/BPASmartClient.Tourism/Model/Control/ModbusBase.cs b/BPASmartClient.Tourism/Model/Control/ModbusBase.cs new file mode 100644 index 00000000..cb23e325 --- /dev/null +++ b/BPASmartClient.Tourism/Model/Control/ModbusBase.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model.Control +{ + internal abstract class ModbusBase + { + internal ICommunication MyModbus { get; set; } + + + } +} diff --git a/BPASmartClient.Tourism/Model/Control/RobotGet.cs b/BPASmartClient.Tourism/Model/Control/RobotGet.cs new file mode 100644 index 00000000..4263b1c1 --- /dev/null +++ b/BPASmartClient.Tourism/Model/Control/RobotGet.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model.Control +{ + internal class RobotGet : ModbusBase + { + } +} diff --git a/BPASmartClient.Tourism/Model/Control/RobotSet.cs b/BPASmartClient.Tourism/Model/Control/RobotSet.cs new file mode 100644 index 00000000..2abfa9c6 --- /dev/null +++ b/BPASmartClient.Tourism/Model/Control/RobotSet.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model.Control +{ + internal class RobotSet : RobotGet + { + } +} diff --git a/BPASmartClient.Tourism/Model/ControlDeviceType.cs b/BPASmartClient.Tourism/Model/ControlDeviceType.cs new file mode 100644 index 00000000..a77fb2c9 --- /dev/null +++ b/BPASmartClient.Tourism/Model/ControlDeviceType.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model +{ + internal enum ControlDeviceType + { + 炒锅1, + 炒锅2, + 压力锅, + 机器人, + 其它 + } +} diff --git a/BPASmartClient.Tourism/Model/DeviceType.cs b/BPASmartClient.Tourism/Model/DeviceType.cs new file mode 100644 index 00000000..e58d400c --- /dev/null +++ b/BPASmartClient.Tourism/Model/DeviceType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkCL.Model +{ + internal enum DeviceType + { + 炒锅1, + 炒锅2, + 压力锅 + } +} diff --git a/BPASmartClient.Tourism/Server/DeviceControl.cs b/BPASmartClient.Tourism/Server/DeviceControl.cs index 413cba76..f9ab6eba 100644 --- a/BPASmartClient.Tourism/Server/DeviceControl.cs +++ b/BPASmartClient.Tourism/Server/DeviceControl.cs @@ -11,5 +11,7 @@ namespace BPASmartClient.MorkCL.Server /// internal class DeviceControl { + + } } diff --git a/BPASmartClient.Tourism/Server/FryingPanServer.cs b/BPASmartClient.Tourism/Server/FryingPanServer.cs index 02dc5eb1..d473becc 100644 --- a/BPASmartClient.Tourism/Server/FryingPanServer.cs +++ b/BPASmartClient.Tourism/Server/FryingPanServer.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.MorkCL.Model.Control; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,7 +10,43 @@ namespace BPASmartClient.MorkCL.Server /// /// 炒锅服务类 /// - internal class FryingPanServer + internal class FryingPanServer : FryingPanSet, IModbus { + public void Init(string IP = "", int Port = 502, string PortName = "") + { + MyModbus = new ModbusTcp(); + MyModbus.Connected = () => + { + TaskManage.GetInstance.StartLong(new Action(() => + { + var LB100 = MyModbus.Read("LB100".ToModbusAdd(), 13); + if (LB100.IsSuccess) + { + InitComplete = LB100.Content[0]; + StatusMode = LB100.Content[1]; + EStop = LB100.Content[2]; + + for (byte i = 0; i < 4; i++) StirFryingLocFB[i] = LB100.Content[i + 3]; + + DiningOutLocFB = LB100.Content[7]; + FeedingLocFB = LB100.Content[8]; + WashingPotLocFB = LB100.Content[9]; + + for (byte i = 0; i < 3; i++) ChannelDisCom[i] = LB100.Content[i + 10]; + } + + var LW20 = MyModbus.Read("LW20".ToModbusAdd(), 3); + if (LW20.IsSuccess) + { + CurrentTemperature = LW20.Content[0]; + CurrentSpeed = LW20.Content[1]; + HeatingGear = LW20.Content[2]; + } + + Thread.Sleep(10); + }), $"炒锅服务-{IP}", true); + }; + MyModbus.Connect(new ConfigurationOptions() { IpAddress = IP, Port = Port }); + } } } diff --git a/BPASmartClient.Tourism/Server/ModbusTcpBase.cs b/BPASmartClient.Tourism/Server/ModbusTcpBase.cs deleted file mode 100644 index 4f79f8f7..00000000 --- a/BPASmartClient.Tourism/Server/ModbusTcpBase.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.MorkCL.Server -{ - internal abstract class ModbusTcpBase - { - internal abstract string IP { get; set; } - internal abstract string Port { get; set; } - - } -} diff --git a/BPASmartClient.Tourism/Server/RobotServer.cs b/BPASmartClient.Tourism/Server/RobotServer.cs index e394d688..3cc6f463 100644 --- a/BPASmartClient.Tourism/Server/RobotServer.cs +++ b/BPASmartClient.Tourism/Server/RobotServer.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.MorkCL.Model.Control; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,7 +10,21 @@ namespace BPASmartClient.MorkCL.Server /// /// 机器人服务类 /// - internal class RobotServer + internal class RobotServer : RobotSet, IModbus { + public void Init(string IP = "", int Port = 502, string PortName = "") + { + MyModbus = new ModbusTcp(); + MyModbus.Connected = () => + { + TaskManage.GetInstance.StartLong(new Action(() => + { + + + Thread.Sleep(10); + }), $"机器人服务-{IP}", true); + }; + MyModbus.Connect(new ConfigurationOptions() { IpAddress = IP, Port = Port }); + } } }