Ver código fonte

通讯库验证更新

JXJAgvReake
pry 1 ano atrás
pai
commit
694604c4f0
42 arquivos alterados com 585 adições e 125 exclusões
  1. +1
    -1
      BPASmartClient.Business/BPASmartClient.Business.csproj
  2. +1
    -1
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  3. +1
    -1
      BPASmartClient.Device/BaseDevice.cs
  4. +1
    -1
      BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj
  5. +1
    -1
      BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj
  6. +2
    -2
      BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
  7. +1
    -1
      BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj
  8. +1
    -1
      BPASmartClient.Modbus/BPASmartClient.Modbus.csproj
  9. +1
    -1
      BPASmartClient.Model/BPASmartClient.Model.csproj
  10. +1
    -1
      BPASmartClient.Nfc/BPASmartClient.Nfc.csproj
  11. +1
    -1
      BPASmartClient.S7Net/BPASmartClient.S7Net.csproj
  12. +1
    -1
      BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj
  13. +1
    -1
      BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj
  14. +1
    -1
      BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj
  15. +0
    -29
      BPASmartClient.Tourism/AddConvert.cs
  16. +118
    -2
      BPASmartClient.Tourism/Control_MorkCL.cs
  17. +78
    -0
      BPASmartClient.Tourism/ExtensionMethod.cs
  18. +2
    -0
      BPASmartClient.Tourism/GVL_MorkCL.cs
  19. +2
    -1
      BPASmartClient.Tourism/GlobalUsing.cs
  20. +1
    -1
      BPASmartClient.Tourism/Model/Control/FryingPanGet.cs
  21. +43
    -38
      BPASmartClient.Tourism/Model/Control/FryingPanSet.cs
  22. +21
    -0
      BPASmartClient.Tourism/Model/Control/OtherDeviceGet.cs
  23. +2
    -5
      BPASmartClient.Tourism/Model/Control/OtherDeviceSet.cs
  24. +12
    -0
      BPASmartClient.Tourism/Model/Control/PressureCookerGet.cs
  25. +12
    -0
      BPASmartClient.Tourism/Model/Control/PressureCookerSet.cs
  26. +23
    -3
      BPASmartClient.Tourism/Model/Control/RobotGet.cs
  27. +97
    -16
      BPASmartClient.Tourism/Model/Control/RobotSet.cs
  28. +10
    -1
      BPASmartClient.Tourism/Model/ControlData.cs
  29. +7
    -6
      BPASmartClient.Tourism/Model/EDeviceType.cs
  30. +5
    -0
      BPASmartClient.Tourism/Model/Func/FuncPar.cs
  31. +1
    -1
      BPASmartClient.Tourism/Model/Func/InitData.cs
  32. +5
    -0
      BPASmartClient.Tourism/Model/NotifyTopic.cs
  33. +14
    -0
      BPASmartClient.Tourism/Model/Result.cs
  34. +1
    -1
      BPASmartClient.Tourism/Server/ISqlite.cs
  35. +21
    -1
      BPASmartClient.Tourism/Server/OtherServer.cs
  36. +14
    -1
      BPASmartClient.Tourism/Server/PressureCookerServer.cs
  37. +48
    -0
      BPASmartClient.Tourism/Server/RobotServer.cs
  38. +1
    -1
      BPASmartClient.Tourism/Server/SqliteHelper.cs
  39. +29
    -0
      BPASmartClient.Tourism/Server/TaskServer.cs
  40. +1
    -1
      BPASmartClient.Update/BPASmartClient.Update.csproj
  41. +1
    -1
      DosingSystem/BPASmartClient.DosingSystem.csproj
  42. +1
    -1
      WpfTest/WpfTest.csproj

+ 1
- 1
BPASmartClient.Business/BPASmartClient.Business.csproj Ver arquivo

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

<ItemGroup>
<PackageReference Include="BPA.ApolloClient" Version="1.0.12" />
<PackageReference Include="BPA.Communication" Version="1.0.110" />
<PackageReference Include="BPA.Communication" Version="1.0.112" />
<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.CustomResource/BPASmartClient.CustomResource.csproj Ver arquivo

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

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="BPA.Message" Version="1.0.86" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
</ItemGroup>


+ 1
- 1
BPASmartClient.Device/BaseDevice.cs Ver arquivo

@@ -162,7 +162,7 @@ namespace BPASmartClient.Device
/// <param name="info"></param>
public void DeviceProcessLogShow(string info)
{
Log.Insert(0, new { Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Type = "流程", Text = info });
Log.Insert(0, new { Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), Type = "流程", Text = info });
MessageLog.GetInstance.DeviceProcessLogShow(DeviceId.ToString(), info);
if (Log.Count > 100) { Log.RemoveAt(Log.Count - 1); }
}


+ 1
- 1
BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj Ver arquivo

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

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="BPA.Message" Version="1.0.86" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>


+ 1
- 1
BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj Ver arquivo

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

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

<ItemGroup>


+ 2
- 2
BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj Ver arquivo

@@ -17,8 +17,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.110" />
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Communication" Version="1.0.112" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj Ver arquivo

@@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
</ItemGroup>

</Project>

+ 1
- 1
BPASmartClient.Modbus/BPASmartClient.Modbus.csproj Ver arquivo

@@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="NModbus" Version="3.0.72" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />


+ 1
- 1
BPASmartClient.Model/BPASmartClient.Model.csproj Ver arquivo

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

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="BPA.Message" Version="1.0.86" />
<PackageReference Include="log4net" Version="2.0.15" />
</ItemGroup>


+ 1
- 1
BPASmartClient.Nfc/BPASmartClient.Nfc.csproj Ver arquivo

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

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
</ItemGroup>

</Project>

+ 1
- 1
BPASmartClient.S7Net/BPASmartClient.S7Net.csproj Ver arquivo

@@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="S7netplus" Version="0.14.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />


+ 1
- 1
BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj Ver arquivo

@@ -24,7 +24,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BPA.CustomResource" Version="1.0.23" />
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1418.22" />
</ItemGroup>
<ItemGroup>


+ 1
- 1
BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj Ver arquivo

@@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.67" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
</ItemGroup>



+ 1
- 1
BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj Ver arquivo

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

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

<ItemGroup>


+ 0
- 29
BPASmartClient.Tourism/AddConvert.cs Ver arquivo

@@ -1,29 +0,0 @@
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 "";
}

/// <summary>
/// 煮面机器人地址转换
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public static string AddressConvert(string address)
{
return (Convert.ToInt32(address.Substring(1, address.Length - 1)) + 4096).ToString();
}
}
}

+ 118
- 2
BPASmartClient.Tourism/Control_MorkCL.cs Ver arquivo

@@ -1,5 +1,7 @@
using BPA.Message.Enum;
using BPASmartClient.Device;
using BPASmartClient.MorkCL.Server;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,20 +16,134 @@ namespace BPASmartClient.MorkCL

GVL_MorkCL morkCL = new GVL_MorkCL();
Alarm alarm = new Alarm();
/// <summary>
/// 设备信息集合
/// </summary>
ConcurrentDictionary<EDeviceType, IModbus> devices { get; set; } = new();

/// <summary>
/// 任务集合
/// </summary>
ConcurrentDictionary<EDeviceType, TaskServer> TaskList { get; set; } = new();

public override void DoMain()
{
MonitorViewModel.DeviceId = DeviceId;

//注册本地配方接收
ActionManage.GetInstance.Register(new Action<object>(o =>
{
if (o != null && o is ControlData cd) morkCL.cds.Enqueue(cd);
}), NotifyTopic.FormulaDistribution);

//初始化通讯对象
devices.TryAdd(EDeviceType.炒锅1, new FryingPanServer());
devices.TryAdd(EDeviceType.炒锅2, new FryingPanServer());
devices.TryAdd(EDeviceType.机器人, new RobotServer());
devices.TryAdd(EDeviceType.压力锅, new PressureCookerServer());
devices.TryAdd(EDeviceType.外部设备, new OtherServer());

devices[EDeviceType.炒锅1].Init(ConnectPar.FryingPanIP1);
devices[EDeviceType.炒锅2].Init(ConnectPar.FryingPanIP2);
devices[EDeviceType.机器人].Init(ConnectPar.RobotIP);
devices[EDeviceType.压力锅].Init(ConnectPar.PressureCookerIP);
devices[EDeviceType.外部设备].Init(ConnectPar.PPortName);
}

public override void MainTask()
{
//throw new NotImplementedException();
if (morkCL.cds.Count > 0 && !TaskList.ContainsKey(morkCL.cds.ElementAt(0).DeviceType))
{
if (morkCL.cds.TryDequeue(out ControlData cd))
{
TaskList.TryAdd(cd.DeviceType, new TaskServer());
TaskList[cd.DeviceType].TaskName = $"{cd.DeviceType.ToString()}-{cd.Name}";
TaskList[cd.DeviceType].RunTask = new Task(new Action(() => { FryingPanControl(cd.DeviceType, cd); }));
TaskList[cd.DeviceType].RunTask.Start();
}
}
//检查到有任务完成后将对已完成的任务进行清理
var res = TaskList.FirstOrDefault(p => p.Value.IsComplete).Key;
if (TaskList.ContainsKey(res)) TaskList.TryRemove(res, out _);
}

private void FryingPanControl(EDeviceType et, ControlData cd)
{
DeviceProcessLogShow($"开始执行-{cd.Name} 任务");
for (int i = 0; i < cd.ControlFuncs.Count; i++)
{
if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested) return;
var device = (FryingPanServer)devices[et];
var robot = (RobotServer)devices[EDeviceType.机器人];
var keyValues = cd.ControlFuncs.ElementAt(i);
int index = (ushort)et - 1;
DeviceProcessLogShow($"{cd.Name}-任务执行-{keyValues.Key.ToString()}-步骤");
switch (keyValues.Key)
{
case EFunc.搅拌启动:
device.MixingFrequencySet(keyValues.Value[0].ParValue);
device.StirStartOrStop = true;
break;
case EFunc.搅拌停止:
device.StirStartOrStop = false;
break;
case EFunc.加热启动:
device.HeatingGearSet(keyValues.Value[0].ParValue);
device.HeatStartOrStop = true;
break;
case EFunc.加热停止:
device.HeatStartOrStop = false;
break;
case EFunc.添加调料:
var Seasoning = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
if (Seasoning != null)
{
device.CuttingControl(Seasoning.Loc.ToString(), keyValues.Value[1].ParValue);
}
break;
case EFunc.添加主料:
case EFunc.添加辅料:
MaterialBase mb = new MaterialBase();
if (keyValues.Key == EFunc.添加辅料)
mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
else mb = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
robot.RobotTaskControl(mb.Loc.ToString(), et);
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置
robot.AllowPourVegetables(et);//允许机器人开始投料
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成
break;
case EFunc.炒锅回原点位:
device.FryingPanHome = true;
break;
case EFunc.出餐启动:
robot.RobotTaskControl("1", et);//取空盆
robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置
device.DiningOutStart = true;
break;
case EFunc.炒锅清洗:
device.FryingPanClear = true;
break;
case EFunc.炒锅回投料位置:
device.FryingPanFeedingLoc = true;
break;
case EFunc.去指定炒制位:
device.SetStirFryingLoc(keyValues.Value[0].ParValue);
break;
case EFunc.炒制:
if (int.TryParse(keyValues.Value[0].ParValue, out int time))
Task.Delay(time * 1000).Wait(TaskList[et].Cts.Token);
break;
default:
break;
}

}
}

public override void ReadData()
{
//throw new NotImplementedException();
}

public override void ResetProgram()


+ 78
- 0
BPASmartClient.Tourism/ExtensionMethod.cs Ver arquivo

@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL
{
/// <summary>
/// 地址转换类
/// </summary>
internal static class ExtensionMethod
{
/// <summary>
/// Modbus 地址转换
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public static string ToModbusAdd(this string address)
{
if (address == null) return "";
if (address.Length > 0)
{
address = address.Trim();
if (address.ToUpper().Contains("GM") && address.Length >= 3)
{
var res = address.Remove(0, 2);
if (res != null && res.Length > 0) return (int.Parse(res) + 4096).ToString();
}
else if (address.ToUpper().Contains("M") && address.Length >= 4)
{
var res = address.Substring(1).Split('.');
if (res != null && res.Length == 2)
{
if (int.TryParse(res[0], out int firstAddress) && int.TryParse(res[1], out int ExitAddress))
{
if (ExitAddress >= 0 && ExitAddress <= 7)
{
return ((firstAddress * 8) + 320 + ExitAddress).ToString();
}
}
}
}
else if (address.ToUpper().Contains("GI") && address.Length >= 3)
{
var res = address.Remove(0, 2);
if (res != null && res.Length > 0) return res;
}
else if (address.ToUpper().Contains("LB") && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && res.Length > 0)
{
if (int.TryParse(res, out int firstAddress)) return firstAddress.ToString();
}
}
else if ((address.ToUpper().Contains("VW") || address.ToUpper().Contains("VD")) && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && int.TryParse(res, out int tempAddress))
{
return ((tempAddress / 2) + 100).ToString();
}
}
else if (address.ToUpper().Contains("LW") && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && int.TryParse(res, out int LwAddress))
{
return LwAddress.ToString();
}
}
}
return "";
}
}
}

+ 2
- 0
BPASmartClient.Tourism/GVL_MorkCL.cs Ver arquivo

@@ -8,6 +8,8 @@ namespace BPASmartClient.MorkCL
{
public class GVL_MorkCL : IStatus
{
public ConcurrentQueue<ControlData> cds { get; set; } = new ConcurrentQueue<ControlData>();

#region 炒锅1

#endregion


+ 2
- 1
BPASmartClient.Tourism/GlobalUsing.cs Ver arquivo

@@ -15,4 +15,5 @@ global using System.Collections.ObjectModel;
global using BPASmartClient.Device;
global using BPASmartClient.MorkCL.Model.Func;
global using System.Threading;
global using BPA.Communication.Base;
global using BPA.Communication.Base;
global using BPASmartClient.MorkCL.Model.Control;

+ 1
- 1
BPASmartClient.Tourism/Model/Control/FryingPanGet.cs Ver arquivo

@@ -36,7 +36,7 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <summary>
/// 炒锅在投料位置反馈
/// </summary>
public bool FeedingLocFB { get; set; }
public bool FeedingLocFB;

/// <summary>
/// 炒锅在洗锅位置反馈


+ 43
- 38
BPASmartClient.Tourism/Model/Control/FryingPanSet.cs Ver arquivo

@@ -22,56 +22,60 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <summary>
/// 通道下料启动控制(1-3)
/// </summary>
/// <param name="ChannelNum">通道编号,1-3</param>
/// <param name="value">通道需求值</param>
public void CuttingControl(int ChannelNum, ushort value)
/// <param name="Num">通道编号,1-3</param>
/// <param name="demandValue">通道需求值</param>
public void CuttingControl(string Num, string demandValue)
{
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);
}
if (ushort.TryParse(Num, out ushort ChannelNum) && ushort.TryParse(demandValue, out 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)
/// <param name="value">档位,1-8挡</param>
public void HeatingGearSet(string value)
{
if (Gear >= 1 && Gear <= 8)
{
MyModbus.Write($"VW100".ToModbusAdd(), Gear);
MyModbus.Write($"LB9".ToModbusAdd(), true);
}
if (ushort.TryParse(value, out 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)
/// <param name="value">频率,0-50HZ</param>
public void MixingFrequencySet(string value)
{
if (Frequency >= 0 && Frequency <= 50)
{
MyModbus.Write($"VW102".ToModbusAdd(), Frequency);
MyModbus.Write($"LB10".ToModbusAdd(), true);
}
if (ushort.TryParse(value, out 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)
/// <param name="value">频率,0-50HZ</param>
public void OverturnFrequencySet(string value)
{
if (Frequency >= 0 && Frequency <= 50)
{
MyModbus.Write($"VW104".ToModbusAdd(), Frequency);
MyModbus.Write($"LB11".ToModbusAdd(), true);
}
if (ushort.TryParse(value, out ushort Frequency))
if (Frequency >= 0 && Frequency <= 50)
{
MyModbus.Write($"VW104".ToModbusAdd(), Frequency);
MyModbus.Write($"LB11".ToModbusAdd(), true);
}
}

/// <summary>
@@ -90,20 +94,21 @@ namespace BPASmartClient.MorkCL.Model.Control
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)
/// <param name="value">炒锅位置,1-4</param>
public void SetStirFryingLoc(string value)
{
if (loc >= 1 && loc <= 4)
{
MyModbus.Write($"LB{loc + 15}".ToModbusAdd(), true);
}
if (ushort.TryParse(value, out ushort loc))
if (loc >= 1 && loc <= 4)
{
MyModbus.Write($"LB{loc + 15}".ToModbusAdd(), true);
}
}

}


+ 21
- 0
BPASmartClient.Tourism/Model/Control/OtherDeviceGet.cs Ver arquivo

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Model.Control
{
internal class OtherDeviceGet : ModbusBase
{
/// <summary>
/// 电子秤当前重量
/// </summary>
public float CurrentWeight { get; set; }

/// <summary>
/// 空箱子检测
/// </summary>
public bool[] BoxDetection { get; set; } = new bool[4];
}
}

BPASmartClient.Tourism/Model/DeviceType.cs → BPASmartClient.Tourism/Model/Control/OtherDeviceSet.cs Ver arquivo

@@ -4,12 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.Control
{
internal enum DeviceType
internal class OtherDeviceSet : OtherDeviceGet
{
炒锅1,
炒锅2,
压力锅
}
}

+ 12
- 0
BPASmartClient.Tourism/Model/Control/PressureCookerGet.cs Ver arquivo

@@ -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 PressureCookerGet : ModbusBase
{
}
}

+ 12
- 0
BPASmartClient.Tourism/Model/Control/PressureCookerSet.cs Ver arquivo

@@ -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 PressureCookerSet : PressureCookerGet
{
}
}

+ 23
- 3
BPASmartClient.Tourism/Model/Control/RobotGet.cs Ver arquivo

@@ -14,12 +14,12 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <summary>
/// 倒料请求
/// </summary>
public bool[] MaterialPouringRequest { get; set; } = new bool[3];
public bool[] MaterialPouringRequest = new bool[3];

/// <summary>
/// 倒料完成
/// </summary>
public bool[] MaterialPouringComplete { get; set; } = new bool[3];
public bool[] MaterialPouringComplete = new bool[3];

/// <summary>
/// 出餐请求,机器人到位请求炒锅出餐
@@ -29,7 +29,27 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <summary>
/// 入库完成
/// </summary>
public bool[] WarehousingComplete { get; set; } = new bool[3];
public bool[] WarehousingComplete { get; set; } = new bool[12];

/// <summary>
/// 机器人原点状态
/// </summary>
public bool Home { get; set; }

/// <summary>
/// 机器人使能状态
/// </summary>
public bool EnableState { get; set; }

/// <summary>
/// 机器人远程模式
/// </summary>
public bool RemoteMode { get; set; }

/// <summary>
/// 机器人程序运行中
/// </summary>
public bool ProgramRuning { get; set; }

/// <summary>
/// 机器人任务反馈


+ 97
- 16
BPASmartClient.Tourism/Model/Control/RobotSet.cs Ver arquivo

@@ -11,48 +11,129 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <summary>
/// 机器人任务控制
/// </summary>
/// <param name="mainTask"></param>
/// <param name="subTask"></param>
public void RobotTaskControl(ushort mainTask, ushort subTask)
/// <param name="MainTask"></param>
/// <param name="SubTask"></param>
public void RobotTaskControl(string MainTask, EDeviceType SubTask)
{
MyModbus.Write("", mainTask);
MyModbus.Write("", subTask);
if (ushort.TryParse(MainTask, out ushort mainTask))
if (mainTask >= 0 && mainTask <= 24)
{
MyModbus.Write("GI1".ToModbusAdd(), (ushort)SubTask);
MyModbus.Write("GI0".ToModbusAdd(), mainTask);
}
}

/// <summary>
/// 入库控制
/// </summary>
/// <param name="loc"></param>
public void WarehousingControl(ushort loc)
/// <param name="Loc"></param>
public void WarehousingControl(string Loc)
{
if (ushort.TryParse(Loc, out ushort loc))
if (loc >= 1 && loc <= 12) MyModbus.Write("GI0".ToModbusAdd(), (ushort)(loc + 29));
}

/// <summary>
/// 机器人到位允许倒菜到炒锅
/// </summary>
/// <param name="num">炒锅类型</param>
public void AllowPourVegetables(EDeviceType num)
{
switch (num)
{
case EDeviceType.炒锅1:
MyModbus.Write("GM500".ToModbusAdd(), true);
break;
case EDeviceType.炒锅2:
MyModbus.Write("GM501".ToModbusAdd(), true);
break;
case EDeviceType.压力锅:
MyModbus.Write("GM502".ToModbusAdd(), true);
break;
default:
break;
}
}

/// <summary>
/// 运行倒菜
/// 出餐减速到位
/// </summary>
/// <param name="num">炒锅编号</param>
public void AllowPourVegetables(ushort num)
/// <param name="num">炒锅类型</param>
public void ModerateInPlace(EDeviceType num)
{
switch (num)
{
case EDeviceType.炒锅1:
MyModbus.Write("GM503".ToModbusAdd(), true);
break;
case EDeviceType.炒锅2:
MyModbus.Write("GM505".ToModbusAdd(), true);
break;
case EDeviceType.压力锅:
MyModbus.Write("GM507".ToModbusAdd(), true);
break;
default:
break;
}
}

/// <summary>
/// 出餐倒菜完成
/// </summary>
/// <param name="num">炒锅类型</param>
public void DiningOutComplete(EDeviceType num)
{
switch (num)
{
case EDeviceType.炒锅1:
MyModbus.Write("GM504".ToModbusAdd(), true);
break;
case EDeviceType.炒锅2:
MyModbus.Write("GM506".ToModbusAdd(), true);
break;
case EDeviceType.压力锅:
MyModbus.Write("GM508".ToModbusAdd(), true);
break;
default:
break;
}
}

/// <summary>
/// 出餐减速到位
/// 设置远程启动(暂停后也可以启动) M702
/// </summary>
/// <param name="num">炒锅编号</param>
public void ModerateInPlace(ushort num)
public bool RobotStart
{
get { return MyModbus.Read<bool>("GM702".ToModbusAdd()).Content; }
set { MyModbus.Write("GM702".ToModbusAdd(), value); }
}

/// <summary>
/// 设置远程暂停 M703
/// </summary>
public bool RobotSuspend
{
get { return MyModbus.Read<bool>("GM703".ToModbusAdd()).Content; }
set { MyModbus.Write("GM703".ToModbusAdd(), value); }
}

/// <summary>
/// 出餐倒菜完成
/// 设置使能 M700
/// </summary>
/// <param name="num">炒锅编号</param>
public void DiningOutComplete(ushort num)
public bool RobotEnable
{
get { return MyModbus.Read<bool>("GM700".ToModbusAdd()).Content; }
set { MyModbus.Write("GM700".ToModbusAdd(), value); }
}

/// <summary>
/// 机器人复位
/// </summary>
public bool RobotReset
{
get { return MyModbus.Read<bool>("GM701".ToModbusAdd()).Content; }
set { MyModbus.Write("GM701".ToModbusAdd(), value); }
}

}
}

+ 10
- 1
BPASmartClient.Tourism/Model/ControlData.cs Ver arquivo

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.RightsManagement;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.MorkCL.Model.DataInfo;
@@ -8,8 +9,16 @@ using BPASmartClient.MorkCL.Model.Func;

namespace BPASmartClient.MorkCL.Model
{
internal class ControlData : RawMaterial
public class ControlData : RawMaterial
{
/// <summary>
/// 选择设备类型
/// </summary>
public EDeviceType DeviceType { get; set; }

/// <summary>
/// 功能配方
/// </summary>
public ConcurrentDictionary<EFunc, List<FuncPar>> ControlFuncs { get; set; } = new ConcurrentDictionary<EFunc, List<FuncPar>>();
}
}

BPASmartClient.Tourism/Model/ControlDeviceType.cs → BPASmartClient.Tourism/Model/EDeviceType.cs Ver arquivo

@@ -6,12 +6,13 @@ using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Model
{
internal enum ControlDeviceType
public enum EDeviceType : ushort
{
炒锅1,
炒锅2,
压力锅,
机器人,
其它
无 = 0,
炒锅1 = 1,
炒锅2 = 2,
压力锅 = 3,
机器人 = 4,
外部设备 = 5,
}
}

+ 5
- 0
BPASmartClient.Tourism/Model/Func/FuncPar.cs Ver arquivo

@@ -11,6 +11,11 @@ namespace BPASmartClient.MorkCL.Model.Func
/// </summary>
public class FuncPar
{
/// <summary>
/// 物料ID
/// </summary>
public string Id { get; set; }

/// <summary>
/// 参数名
/// </summary>


+ 1
- 1
BPASmartClient.Tourism/Model/Func/InitData.cs Ver arquivo

@@ -31,7 +31,7 @@ namespace BPASmartClient.MorkCL.Model.Func
{ EFunc.出餐启动,new FuncPar[0] },
{ EFunc.炒锅清洗,new FuncPar[0] },
{ EFunc.炒锅回投料位置,new FuncPar[0] },
{ EFunc.去指定炒制位,new FuncPar[] { new FuncPar() { ParName="设置炒制位", ParDescribe="请输入 1--3 选择一个合适的炒制位置"} } },
{ EFunc.去指定炒制位,new FuncPar[] { new FuncPar() { ParName="设置炒制位", ParDescribe="请输入 1--4 选择一个合适的炒制位置"} } },
{ EFunc.炒制,new FuncPar[] { new FuncPar() { ParName="设置炒制时间",ParUnit="秒", ParDescribe="请设置一个合适的炒制时间"} } },
};
}


+ 5
- 0
BPASmartClient.Tourism/Model/NotifyTopic.cs Ver arquivo

@@ -17,5 +17,10 @@ namespace BPASmartClient.MorkCL.Model
/// 机器人初始化
/// </summary>
public static string RobotInit => $"{Header}RobotInit";

/// <summary>
/// 本地配方下发通知
/// </summary>
public static string FormulaDistribution => $"{Header}FormulaDistribution";
}
}

+ 14
- 0
BPASmartClient.Tourism/Model/Result.cs Ver arquivo

@@ -0,0 +1,14 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace BPASmartClient.MorkCL.Model
//{
// public class Result
// {
// public bool IsSuccess { get; set; }
// public string Message { get; set; }
// }
//}

BPASmartClient.Tourism/Server/ISqlLIte.cs → BPASmartClient.Tourism/Server/ISqlite.cs Ver arquivo

@@ -7,7 +7,7 @@ using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Server
{
internal interface ISqlLIte : IServer
internal interface ISqlite : IServer
{
//主料
bool AddIngredients(IngredientsTB mb);

+ 21
- 1
BPASmartClient.Tourism/Server/OtherServer.cs Ver arquivo

@@ -3,13 +3,33 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace BPASmartClient.MorkCL.Server
{
/// <summary>
/// 其它服务类
/// </summary>
internal class OtherServer
internal class OtherServer : OtherDeviceSet, IModbus
{
public void Init(string IP = "", int Port = 502, string PortName = "")
{
MyModbus = new ModbusRtu();
MyModbus.Connected = () =>
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
var box = MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 4);
if (box.IsSuccess)
{
for (byte i = 0; i < box.Content.Length; i++) BoxDetection[i] = box.Content[i];
}
var weight = MyModbus.Read<float>("LW20".ToModbusAdd());
if (weight.IsSuccess) CurrentWeight = weight.Content;
Thread.Sleep(10);
}), $"其它外部设备-{PortName}", true);
};
MyModbus.Connect(new ConfigurationOptions() { PortName = PortName });
}
}
}

+ 14
- 1
BPASmartClient.Tourism/Server/PressureCookerServer.cs Ver arquivo

@@ -9,7 +9,20 @@ namespace BPASmartClient.MorkCL.Server
/// <summary>
/// 压力锅服务类
/// </summary>
internal class PressureCookerServer
internal class PressureCookerServer : PressureCookerSet, 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 });
}
}
}

+ 48
- 0
BPASmartClient.Tourism/Server/RobotServer.cs Ver arquivo

@@ -19,7 +19,25 @@ namespace BPASmartClient.MorkCL.Server
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
var m600 = MyModbus.Read<bool[]>("M600".ToModbusAdd(), 9);
if (m600.IsSuccess)
{
for (byte i = 0; i < 3; i++)
{
MaterialPouringRequest[i] = m600.Content[i * 3];
MaterialPouringComplete[i] = m600.Content[i * 3 + 1];
DiningOutRequest[i] = m600.Content[i * 3 + 2];
}
}

var m630 = MyModbus.Read<bool[]>("M630".ToModbusAdd(), 12);
if (m630.IsSuccess)
{
for (byte i = 0; i < m630.Content.Length; i++) WarehousingComplete[i] = m630.Content[i];
}

var gi = MyModbus.Read<ushort>("GI5".ToModbusAdd(), 1);
if (gi.IsSuccess) TaskFeedback = (RobotMainTask)gi.Content;

Thread.Sleep(10);
}), $"机器人服务-{IP}", true);
@@ -29,7 +47,37 @@ namespace BPASmartClient.MorkCL.Server

private void RobotInit()
{
if (EnableState && ProgramRuning) return;
//if (!CR_Data.Home)
//{
// Noticer.GetInstance().Show("煮面机器人初始化失败,机器人不在原点");
// return;
//}

while (!EnableState || !ProgramRuning)
{
//复位
RobotReset = true;
Thread.Sleep(1000);
RobotReset = false;
Thread.Sleep(500);

if (!EnableState)
{
//上使能
RobotEnable = true;
Thread.Sleep(1000);
RobotEnable = false;
Thread.Sleep(500);
}

//启动
RobotStart = true;
Thread.Sleep(1000);
RobotStart = false;

Thread.Sleep(1000);
}
}
}
}

+ 1
- 1
BPASmartClient.Tourism/Server/SqliteHelper.cs Ver arquivo

@@ -10,7 +10,7 @@ using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Server
{
internal class SqliteHelper : ISqlLIte
internal class SqliteHelper : ISqlite
{

private volatile static SqliteHelper _Instance;


+ 29
- 0
BPASmartClient.Tourism/Server/TaskServer.cs Ver arquivo

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Server
{
public class TaskServer
{
/// <summary>
/// 获取任务是否执行完成
/// </summary>
public bool IsComplete => RunTask == null ? false : RunTask.IsCompleted;

/// <summary>
/// 任务取消标识
/// </summary>
public CancellationTokenSource Cts { get; set; } = new CancellationTokenSource();

/// <summary>
/// 任务名称
/// </summary>
public string TaskName { get; set; }


public Task RunTask { get; set; }
}
}

+ 1
- 1
BPASmartClient.Update/BPASmartClient.Update.csproj Ver arquivo

@@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
</ItemGroup>

</Project>

+ 1
- 1
DosingSystem/BPASmartClient.DosingSystem.csproj Ver arquivo

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

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
<PackageReference Include="BPA.Message" Version="1.0.86" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>


+ 1
- 1
WpfTest/WpfTest.csproj Ver arquivo

@@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="BPA.CustomResource" Version="1.0.16" />
<PackageReference Include="BPA.Helper" Version="1.0.71" />
<PackageReference Include="BPA.Helper" Version="1.0.73" />
</ItemGroup>

</Project>

Carregando…
Cancelar
Salvar