Selaa lähdekoodia

炒锅通讯添加

JXJAgvReake
pry 1 vuosi sitten
vanhempi
commit
3cddfb6317
27 muutettua tiedostoa jossa 399 lisäystä ja 30 poistoa
  1. +1
    -1
      BPASmartClient.Business/BPASmartClient.Business.csproj
  2. +1
    -1
      BPASmartClient.Business/LocalMqtt.cs
  3. +1
    -1
      BPASmartClient.Business/Plugin/MQTTMgr.cs
  4. +1
    -1
      BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj
  5. +1
    -1
      BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs
  6. +1
    -1
      BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
  7. +1
    -1
      BPASmartClient.MorkMV1/DataServer.cs
  8. +1
    -1
      BPASmartClient.MorkS/DataServer.cs
  9. +1
    -1
      BPASmartClient.MorkS3/DataServer.cs
  10. +1
    -1
      BPASmartClient.MorkSUpgradedVer/DataServer.cs
  11. +1
    -1
      BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj
  12. +19
    -0
      BPASmartClient.Tourism/AddConvert.cs
  13. +15
    -0
      BPASmartClient.Tourism/GVL_MorkCL.cs
  14. +3
    -0
      BPASmartClient.Tourism/GlobalUsing.cs
  15. +33
    -0
      BPASmartClient.Tourism/Model/ConnectPar.cs
  16. +66
    -0
      BPASmartClient.Tourism/Model/Control/FryingPanGet.cs
  17. +110
    -0
      BPASmartClient.Tourism/Model/Control/FryingPanSet.cs
  18. +13
    -0
      BPASmartClient.Tourism/Model/Control/IModbus.cs
  19. +15
    -0
      BPASmartClient.Tourism/Model/Control/ModbusBase.cs
  20. +12
    -0
      BPASmartClient.Tourism/Model/Control/RobotGet.cs
  21. +12
    -0
      BPASmartClient.Tourism/Model/Control/RobotSet.cs
  22. +17
    -0
      BPASmartClient.Tourism/Model/ControlDeviceType.cs
  23. +15
    -0
      BPASmartClient.Tourism/Model/DeviceType.cs
  24. +2
    -0
      BPASmartClient.Tourism/Server/DeviceControl.cs
  25. +39
    -2
      BPASmartClient.Tourism/Server/FryingPanServer.cs
  26. +0
    -15
      BPASmartClient.Tourism/Server/ModbusTcpBase.cs
  27. +17
    -2
      BPASmartClient.Tourism/Server/RobotServer.cs

+ 1
- 1
BPASmartClient.Business/BPASmartClient.Business.csproj Näytä tiedosto

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

<ItemGroup>
<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="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />


+ 1
- 1
BPASmartClient.Business/LocalMqtt.cs Näytä tiedosto

@@ -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));



+ 1
- 1
BPASmartClient.Business/Plugin/MQTTMgr.cs Näytä tiedosto

@@ -44,7 +44,7 @@ namespace BPASmartClient.Business
//主题初始化
TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin<DeviceMgr>().GetDevices());

mqttProxy.ConnectOk = () =>
mqttProxy.Connected = () =>
{
mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray());
};


+ 1
- 1
BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj Näytä tiedosto

@@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.107" />
<PackageReference Include="BPA.Communication" Version="1.0.110" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs Näytä tiedosto

@@ -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<string>(DeviceAddress.DeviceName, 20).Content.Trim()?.Replace(" ", "");//读取设备名称
if (DeviceName.Length > 0)


+ 1
- 1
BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj Näytä tiedosto

@@ -17,7 +17,7 @@
</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" />
</ItemGroup>



+ 1
- 1
BPASmartClient.MorkMV1/DataServer.cs Näytä tiedosto

@@ -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(() =>


+ 1
- 1
BPASmartClient.MorkS/DataServer.cs Näytä tiedosto

@@ -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(() =>


+ 1
- 1
BPASmartClient.MorkS3/DataServer.cs Näytä tiedosto

@@ -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(() =>


+ 1
- 1
BPASmartClient.MorkSUpgradedVer/DataServer.cs Näytä tiedosto

@@ -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(() =>


+ 1
- 1
BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj Näytä tiedosto

@@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.107" />
<PackageReference Include="BPA.Communication" Version="1.0.110" />
</ItemGroup>

<ItemGroup>


+ 19
- 0
BPASmartClient.Tourism/AddConvert.cs Näytä tiedosto

@@ -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 "";
}
}
}

+ 15
- 0
BPASmartClient.Tourism/GVL_MorkCL.cs Näytä tiedosto

@@ -8,5 +8,20 @@ namespace BPASmartClient.MorkCL
{
public class GVL_MorkCL : IStatus
{
#region 炒锅1

#endregion

#region 炒锅2

#endregion

#region 压力锅

#endregion

#region 机器人

#endregion
}
}

+ 3
- 0
BPASmartClient.Tourism/GlobalUsing.cs Näytä tiedosto

@@ -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;

+ 33
- 0
BPASmartClient.Tourism/Model/ConnectPar.cs Näytä tiedosto

@@ -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; }
}
}

+ 66
- 0
BPASmartClient.Tourism/Model/Control/FryingPanGet.cs Näytä tiedosto

@@ -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; }
}
}

+ 110
- 0
BPASmartClient.Tourism/Model/Control/FryingPanSet.cs Näytä tiedosto

@@ -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);
}
}

}
}

+ 13
- 0
BPASmartClient.Tourism/Model/Control/IModbus.cs Näytä tiedosto

@@ -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 = "");
}
}

+ 15
- 0
BPASmartClient.Tourism/Model/Control/ModbusBase.cs Näytä tiedosto

@@ -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; }


}
}

+ 12
- 0
BPASmartClient.Tourism/Model/Control/RobotGet.cs Näytä tiedosto

@@ -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
{
}
}

+ 12
- 0
BPASmartClient.Tourism/Model/Control/RobotSet.cs Näytä tiedosto

@@ -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
{
}
}

+ 17
- 0
BPASmartClient.Tourism/Model/ControlDeviceType.cs Näytä tiedosto

@@ -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,
压力锅,
机器人,
其它
}
}

+ 15
- 0
BPASmartClient.Tourism/Model/DeviceType.cs Näytä tiedosto

@@ -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,
压力锅
}
}

+ 2
- 0
BPASmartClient.Tourism/Server/DeviceControl.cs Näytä tiedosto

@@ -11,5 +11,7 @@ namespace BPASmartClient.MorkCL.Server
/// </summary>
internal class DeviceControl
{


}
}

+ 39
- 2
BPASmartClient.Tourism/Server/FryingPanServer.cs Näytä tiedosto

@@ -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
/// <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 });
}
}
}

+ 0
- 15
BPASmartClient.Tourism/Server/ModbusTcpBase.cs Näytä tiedosto

@@ -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; }

}
}

+ 17
- 2
BPASmartClient.Tourism/Server/RobotServer.cs Näytä tiedosto

@@ -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
/// <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 });
}
}
}

Ladataan…
Peruuta
Tallenna