@@ -8,7 +8,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.ApolloClient" Version="1.0.12" /> | <PackageReference Include="BPA.ApolloClient" Version="1.0.12" /> | ||||
<PackageReference Include="BPA.Communication" Version="1.0.107" /> | |||||
<PackageReference Include="BPA.Communication" Version="1.0.110" /> | |||||
<PackageReference Include="BPA.Message" Version="1.0.86" /> | <PackageReference Include="BPA.Message" Version="1.0.86" /> | ||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | ||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" /> | <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" /> | ||||
@@ -33,7 +33,7 @@ namespace BPASmartClient.Business | |||||
{ | { | ||||
MqttPushs.Name = DeviceType; | MqttPushs.Name = DeviceType; | ||||
LocDeviceType = DeviceType; | LocDeviceType = DeviceType; | ||||
mQTTProxy.ConnectOk = new Action(() => | |||||
mQTTProxy.Connected = new Action(() => | |||||
{ | { | ||||
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(DeviceType)); | mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(DeviceType)); | ||||
@@ -44,7 +44,7 @@ namespace BPASmartClient.Business | |||||
//主题初始化 | //主题初始化 | ||||
TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin<DeviceMgr>().GetDevices()); | TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin<DeviceMgr>().GetDevices()); | ||||
mqttProxy.ConnectOk = () => | |||||
mqttProxy.Connected = () => | |||||
{ | { | ||||
mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray()); | mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray()); | ||||
}; | }; | ||||
@@ -16,7 +16,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Communication" Version="1.0.107" /> | |||||
<PackageReference Include="BPA.Communication" Version="1.0.110" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -185,7 +185,7 @@ namespace BPASmartClient.FoodStationTest.Model | |||||
DeviceStatus DS = new DeviceStatus(); | DeviceStatus DS = new DeviceStatus(); | ||||
DS.modbusTcp.IsReconnect = false; | DS.modbusTcp.IsReconnect = false; | ||||
DS.modbusTcp.ConnectOk = new Action(() => | |||||
DS.modbusTcp.Connected = new Action(() => | |||||
{ | { | ||||
string DeviceName = DS.modbusTcp.Read<string>(DeviceAddress.DeviceName, 20).Content.Trim()?.Replace(" ", "");//读取设备名称 | string DeviceName = DS.modbusTcp.Read<string>(DeviceAddress.DeviceName, 20).Content.Trim()?.Replace(" ", "");//读取设备名称 | ||||
if (DeviceName.Length > 0) | if (DeviceName.Length > 0) | ||||
@@ -17,7 +17,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Communication" Version="1.0.109" /> | |||||
<PackageReference Include="BPA.Communication" Version="1.0.110" /> | |||||
<PackageReference Include="BPA.Helper" Version="1.0.71" /> | <PackageReference Include="BPA.Helper" Version="1.0.71" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -23,7 +23,7 @@ namespace BPASmartClient.MorkMV1 | |||||
MqttHelper mQTTProxy = new MqttHelper(); | MqttHelper mQTTProxy = new MqttHelper(); | ||||
public void Init() | public void Init() | ||||
{ | { | ||||
mQTTProxy.ConnectOk = new Action(() => | |||||
mQTTProxy.Connected = new Action(() => | |||||
{ | { | ||||
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | ||||
TaskManage.GetInstance.StartLong(new Action(() => | TaskManage.GetInstance.StartLong(new Action(() => | ||||
@@ -23,7 +23,7 @@ namespace BPASmartClient.MorkS | |||||
MqttHelper mQTTProxy = new MqttHelper(); | MqttHelper mQTTProxy = new MqttHelper(); | ||||
public void Init() | public void Init() | ||||
{ | { | ||||
mQTTProxy.ConnectOk = new Action(() => | |||||
mQTTProxy.Connected = new Action(() => | |||||
{ | { | ||||
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | ||||
TaskManage.GetInstance.StartLong(new Action(() => | TaskManage.GetInstance.StartLong(new Action(() => | ||||
@@ -23,7 +23,7 @@ namespace BPASmartClient.MorkS3 | |||||
MqttHelper mQTTProxy = new MqttHelper(); | MqttHelper mQTTProxy = new MqttHelper(); | ||||
public void Init() | public void Init() | ||||
{ | { | ||||
mQTTProxy.ConnectOk = new Action(() => | |||||
mQTTProxy.Connected = new Action(() => | |||||
{ | { | ||||
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | ||||
TaskManage.GetInstance.StartLong(new Action(() => | TaskManage.GetInstance.StartLong(new Action(() => | ||||
@@ -22,7 +22,7 @@ namespace BPASmartClient.MorkSUpgradedVer | |||||
MqttHelper mQTTProxy = new MqttHelper(); | MqttHelper mQTTProxy = new MqttHelper(); | ||||
public void Init() | public void Init() | ||||
{ | { | ||||
mQTTProxy.ConnectOk = new Action(() => | |||||
mQTTProxy.Connected = new Action(() => | |||||
{ | { | ||||
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); | ||||
TaskManage.GetInstance.StartLong(new Action(() => | TaskManage.GetInstance.StartLong(new Action(() => | ||||
@@ -21,7 +21,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Communication" Version="1.0.107" /> | |||||
<PackageReference Include="BPA.Communication" Version="1.0.110" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -0,0 +1,19 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.MorkCL | |||||
{ | |||||
/// <summary> | |||||
/// 地址转换类 | |||||
/// </summary> | |||||
internal static class AddConvert | |||||
{ | |||||
public static string ToModbusAdd(this string add) | |||||
{ | |||||
return ""; | |||||
} | |||||
} | |||||
} |
@@ -8,5 +8,20 @@ namespace BPASmartClient.MorkCL | |||||
{ | { | ||||
public class GVL_MorkCL : IStatus | public class GVL_MorkCL : IStatus | ||||
{ | { | ||||
#region 炒锅1 | |||||
#endregion | |||||
#region 炒锅2 | |||||
#endregion | |||||
#region 压力锅 | |||||
#endregion | |||||
#region 机器人 | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -13,3 +13,6 @@ global using BPASmartClient.MorkCL.Model; | |||||
global using System.Collections.Concurrent; | global using System.Collections.Concurrent; | ||||
global using System.Collections.ObjectModel; | global using System.Collections.ObjectModel; | ||||
global using BPASmartClient.Device; | global using BPASmartClient.Device; | ||||
global using BPASmartClient.MorkCL.Model.Func; | |||||
global using System.Threading; | |||||
global using BPA.Communication.Base; |
@@ -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; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 初始化完成 | |||||
/// </summary> | |||||
public bool InitComplete { get; set; } | |||||
/// <summary> | |||||
/// 手自动状态模式 | |||||
/// </summary> | |||||
public bool StatusMode { get; set; } | |||||
/// <summary> | |||||
/// 急停 | |||||
/// </summary> | |||||
public bool EStop { get; set; } | |||||
/// <summary> | |||||
/// 炒制位置反馈(1-4) | |||||
/// </summary> | |||||
public bool[] StirFryingLocFB { get; set; } = new bool[4]; | |||||
/// <summary> | |||||
/// 炒锅在出餐位置反馈 | |||||
/// </summary> | |||||
public bool DiningOutLocFB { get; set; } | |||||
/// <summary> | |||||
/// 炒锅在投料位置反馈 | |||||
/// </summary> | |||||
public bool FeedingLocFB { get; set; } | |||||
/// <summary> | |||||
/// 炒锅在洗锅位置反馈 | |||||
/// </summary> | |||||
public bool WashingPotLocFB { get; set; } | |||||
/// <summary> | |||||
/// 通道出料完成反馈(1-3) | |||||
/// </summary> | |||||
public bool[] ChannelDisCom { get; set; } = new bool[3]; | |||||
/// <summary> | |||||
/// 当前锅底温度 | |||||
/// </summary> | |||||
public float CurrentTemperature { get; set; } | |||||
/// <summary> | |||||
/// 当前炒锅搅拌转速 | |||||
/// </summary> | |||||
public ushort CurrentSpeed { get; set; } | |||||
/// <summary> | |||||
/// 当前加热档位 | |||||
/// </summary> | |||||
public ushort HeatingGear { get; set; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 搅拌启停 | |||||
/// </summary> | |||||
public bool StirStartOrStop { get { return default; } set { MyModbus.Write("LB0".ToModbusAdd(), value); } } | |||||
/// <summary> | |||||
/// 加热启停 | |||||
/// </summary> | |||||
public bool HeatStartOrStop { get { return default; } set { MyModbus.Write("LB3".ToModbusAdd(), value); } } | |||||
/// <summary> | |||||
/// 通道下料启动控制(1-3) | |||||
/// </summary> | |||||
/// <param name="ChannelNum">通道编号,1-3</param> | |||||
/// <param name="value">通道需求值</param> | |||||
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); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 加热档位设定 | |||||
/// </summary> | |||||
/// <param name="Gear">档位,1-8挡</param> | |||||
public void HeatingGearSet(ushort Gear) | |||||
{ | |||||
if (Gear >= 1 && Gear <= 8) | |||||
{ | |||||
MyModbus.Write($"VW100".ToModbusAdd(), Gear); | |||||
MyModbus.Write($"LB9".ToModbusAdd(), true); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 搅拌频率设定 | |||||
/// </summary> | |||||
/// <param name="Frequency">频率,0-50HZ</param> | |||||
public void MixingFrequencySet(ushort Frequency) | |||||
{ | |||||
if (Frequency >= 0 && Frequency <= 50) | |||||
{ | |||||
MyModbus.Write($"VW102".ToModbusAdd(), Frequency); | |||||
MyModbus.Write($"LB10".ToModbusAdd(), true); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 翻转频率设定 | |||||
/// </summary> | |||||
/// <param name="Frequency">频率,0-50HZ</param> | |||||
public void OverturnFrequencySet(ushort Frequency) | |||||
{ | |||||
if (Frequency >= 0 && Frequency <= 50) | |||||
{ | |||||
MyModbus.Write($"VW104".ToModbusAdd(), Frequency); | |||||
MyModbus.Write($"LB11".ToModbusAdd(), true); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 炒锅回原点 | |||||
/// </summary> | |||||
public bool FryingPanHome { get { return default; } set { MyModbus.Write("LB12".ToModbusAdd(), value); } } | |||||
/// <summary> | |||||
/// 出餐启动 | |||||
/// </summary> | |||||
public bool DiningOutStart { get { return default; } set { MyModbus.Write("LB13".ToModbusAdd(), value); } } | |||||
/// <summary> | |||||
/// 炒锅清洗 | |||||
/// </summary> | |||||
public bool FryingPanClear { get { return default; } set { MyModbus.Write("LB14".ToModbusAdd(), value); } } | |||||
/// <summary> | |||||
/// 炒锅回投料位置 | |||||
/// </summary> | |||||
public bool FryingPanFeedingLoc { get { return default; } set { MyModbus.Write("LB15".ToModbusAdd(), value); } } | |||||
/// <summary> | |||||
/// 去炒制位控制 | |||||
/// </summary> | |||||
/// <param name="loc">炒锅位置,1-4</param> | |||||
public void SetStirFryingLoc(ushort loc) | |||||
{ | |||||
if (loc >= 1 && loc <= 4) | |||||
{ | |||||
MyModbus.Write($"LB{loc + 15}".ToModbusAdd(), true); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -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 = ""); | |||||
} | |||||
} |
@@ -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; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
} | |||||
} |
@@ -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, | |||||
压力锅, | |||||
机器人, | |||||
其它 | |||||
} | |||||
} |
@@ -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, | |||||
压力锅 | |||||
} | |||||
} |
@@ -11,5 +11,7 @@ namespace BPASmartClient.MorkCL.Server | |||||
/// </summary> | /// </summary> | ||||
internal class DeviceControl | internal class DeviceControl | ||||
{ | { | ||||
} | } | ||||
} | } |
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using BPASmartClient.MorkCL.Model.Control; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -9,7 +10,43 @@ namespace BPASmartClient.MorkCL.Server | |||||
/// <summary> | /// <summary> | ||||
/// 炒锅服务类 | /// 炒锅服务类 | ||||
/// </summary> | /// </summary> | ||||
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<bool[]>("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<ushort[]>("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 }); | |||||
} | |||||
} | } | ||||
} | } |
@@ -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; } | |||||
} | |||||
} |
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using BPASmartClient.MorkCL.Model.Control; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -9,7 +10,21 @@ namespace BPASmartClient.MorkCL.Server | |||||
/// <summary> | /// <summary> | ||||
/// 机器人服务类 | /// 机器人服务类 | ||||
/// </summary> | /// </summary> | ||||
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 }); | |||||
} | |||||
} | } | ||||
} | } |