|
|
@@ -1,16 +1,23 @@ |
|
|
|
using BPA.Helper; |
|
|
|
using BPA.Message.Enum; |
|
|
|
using BPA.Models; |
|
|
|
using BPASmartClient.Device; |
|
|
|
using BPASmartClient.EventBus; |
|
|
|
using BPASmartClient.Modbus; |
|
|
|
using BPASmartClient.Model; |
|
|
|
using BPASmartClient.Model.PLC; |
|
|
|
using BPASmartClient.Model.订单; |
|
|
|
using BPASmartClient.Model.调酒机; |
|
|
|
using BPASmartClient.MorkMW.Model; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Org.BouncyCastle.Bcpg.OpenPgp; |
|
|
|
using System; |
|
|
|
using System.Collections.Concurrent; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Net.Http.Json; |
|
|
|
using System.Threading; |
|
|
|
using System.Windows.Documents; |
|
|
|
using static BPASmartClient.EventBus.EventBus; |
|
|
|
|
|
|
|
namespace BPASmartClient.MorkMW |
|
|
@@ -24,6 +31,23 @@ namespace BPASmartClient.MorkMW |
|
|
|
{ |
|
|
|
|
|
|
|
ConnectKlpRobot("192.168.0.100", 8001); |
|
|
|
ServerInit(); |
|
|
|
DataParse(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void ServerInit() |
|
|
|
{ |
|
|
|
//配方数据信息 |
|
|
|
EventBus.EventBus.GetInstance().Subscribe<MorkMWGoodsEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) |
|
|
|
{ |
|
|
|
if (@event == null) return; |
|
|
|
if (@event is MorkMWGoodsEvent recipe) |
|
|
|
{ |
|
|
|
listMorkMWGoods= recipe.morkMWPushMessage.MorkMWGoods; |
|
|
|
DeviceProcessLogShow($"接收到调酒机【{listMorkMWGoods.Count}】个商品配方数据"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public override void MainTask() |
|
|
@@ -38,44 +62,88 @@ namespace BPASmartClient.MorkMW |
|
|
|
/// </summary> |
|
|
|
public void ToGetWink() |
|
|
|
{ |
|
|
|
|
|
|
|
if (morkMW.RobotIdle && orderLocInfos.Count > 0 && !morkMW.TaskLock&&!morkMW.PourWinkComplete&& morkMW.CupSignal) |
|
|
|
if (!GVL_MorkMW.AllowLocalSimOrder) |
|
|
|
{ |
|
|
|
DeviceProcessLogShow("订单开始制作"); |
|
|
|
morkMW.TaskLock = true; |
|
|
|
if (orderLocInfos.TryDequeue(out OrderLocInfo res)) |
|
|
|
if (morkMW.RobotIdle && orderLocInfos.Count > 0 && !morkMW.TaskLock && !morkMW.PourWinkComplete && morkMW.CupSignal) |
|
|
|
{ |
|
|
|
foreach (var item in res.mixWink) |
|
|
|
DeviceProcessLogShow("订单开始制作"); |
|
|
|
morkMW.TaskLock = true; |
|
|
|
if (orderLocInfos.TryDequeue(out OrderLocInfo res)) |
|
|
|
{ |
|
|
|
switch (item.Loc) |
|
|
|
foreach (var item in res.mixWink) |
|
|
|
{ |
|
|
|
// case 7: ToMixWink(); break; |
|
|
|
case 1: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 2: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 3: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 4: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 5: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 6: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
switch (item.Loc) |
|
|
|
{ |
|
|
|
// case 7: ToMixWink(); break; |
|
|
|
case 1: ToSpecifiedLocTakeWink(item.Loc, item.Qty); break; |
|
|
|
case 2: ToSpecifiedLocTakeWink(item.Loc, item.Qty); break; |
|
|
|
case 3: ToSpecifiedLocTakeWink(item.Loc, item.Qty); break; |
|
|
|
case 4: ToSpecifiedLocTakeWink(item.Loc, item.Qty); break; |
|
|
|
case 5: ToSpecifiedLocTakeWink(item.Loc, item.Qty); break; |
|
|
|
case 6: ToSpecifiedLocTakeWink(item.Loc, item.Qty); break; |
|
|
|
|
|
|
|
} |
|
|
|
switch (item.Loc) |
|
|
|
{ |
|
|
|
//case 7: while (!morkMW.MixWinkComplte) { Thread.Sleep(5); } break; |
|
|
|
case 1: while (!morkMW.TakeWinkOneComplete) { Thread.Sleep(5); } break; |
|
|
|
case 2: while (!morkMW.TakeWinkTwoComplete) { Thread.Sleep(5); } break; |
|
|
|
case 3: while (!morkMW.TakeWinkThreeComplete) { Thread.Sleep(5); } break; |
|
|
|
case 4: while (!morkMW.TakeWinkFourComplete) { Thread.Sleep(5); } break; |
|
|
|
case 5: while (!morkMW.TakeWinkFiveComplete) { Thread.Sleep(5); } break; |
|
|
|
case 6: while (!morkMW.TakeWinkSixComplete) { Thread.Sleep(5); } break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
switch (item.Loc) |
|
|
|
{ |
|
|
|
//case 7: while (!morkMW.MixWinkComplte) { Thread.Sleep(5); } break; |
|
|
|
case 1: while (!morkMW.TakeWinkOneComplete) { Thread.Sleep(5); } break; |
|
|
|
case 2: while (!morkMW.TakeWinkTwoComplete) { Thread.Sleep(5); } break; |
|
|
|
case 3: while (!morkMW.TakeWinkThreeComplete) { Thread.Sleep(5); } break; |
|
|
|
case 4: while (!morkMW.TakeWinkFourComplete) { Thread.Sleep(5); } break; |
|
|
|
case 5: while (!morkMW.TakeWinkFiveComplete) { Thread.Sleep(5); } break; |
|
|
|
case 6: while (!morkMW.TakeWinkSixComplete) { Thread.Sleep(5); } break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
morkMW.AllowMixWink = true;//接酒完成,允许调酒 |
|
|
|
// morkMW.AllowPourWink = true;//调酒完成,允许倒酒 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (morkMW.RobotIdle && orderLocInfos.Count > 0 && !morkMW.TaskLock && !morkMW.PourWinkComplete && morkMW.CupSignal) |
|
|
|
{ |
|
|
|
DeviceProcessLogShow("订单开始制作"); |
|
|
|
morkMW.TaskLock = true; |
|
|
|
if (simOrderLocInfos.TryDequeue(out SimOrderLocInfo res)) |
|
|
|
{ |
|
|
|
foreach (var item in res.mixWink) |
|
|
|
{ |
|
|
|
switch (item.Loc) |
|
|
|
{ |
|
|
|
// case 7: ToMixWink(); break; |
|
|
|
case 1: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 2: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 3: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 4: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 5: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
case 6: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; |
|
|
|
|
|
|
|
} |
|
|
|
switch (item.Loc) |
|
|
|
{ |
|
|
|
//case 7: while (!morkMW.MixWinkComplte) { Thread.Sleep(5); } break; |
|
|
|
case 1: while (!morkMW.TakeWinkOneComplete) { Thread.Sleep(5); } break; |
|
|
|
case 2: while (!morkMW.TakeWinkTwoComplete) { Thread.Sleep(5); } break; |
|
|
|
case 3: while (!morkMW.TakeWinkThreeComplete) { Thread.Sleep(5); } break; |
|
|
|
case 4: while (!morkMW.TakeWinkFourComplete) { Thread.Sleep(5); } break; |
|
|
|
case 5: while (!morkMW.TakeWinkFiveComplete) { Thread.Sleep(5); } break; |
|
|
|
case 6: while (!morkMW.TakeWinkSixComplete) { Thread.Sleep(5); } break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
DeviceProcessLogShow($"所有位置接酒完成"); |
|
|
|
morkMW.AllowMixWink = true;//接酒完成,允许调酒 |
|
|
|
// morkMW.AllowPourWink = true;//调酒完成,允许倒酒 |
|
|
|
} |
|
|
|
|
|
|
|
morkMW.AllowMixWink = true;//接酒完成,允许调酒 |
|
|
|
// morkMW.AllowPourWink = true;//调酒完成,允许倒酒 |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
/// <summary> |
|
|
@@ -102,35 +170,35 @@ namespace BPASmartClient.MorkMW |
|
|
|
//发送接酒信号 |
|
|
|
switch (loc) |
|
|
|
{ |
|
|
|
case 1: modbus.WriteSingleRegister(0000, 1); break; |
|
|
|
case 2: modbus.WriteSingleRegister(0000, 2); break; |
|
|
|
case 3: modbus.WriteSingleRegister(0000, 3); break; |
|
|
|
case 4: modbus.WriteSingleRegister(0000, 4); break; |
|
|
|
case 5: modbus.WriteSingleRegister(0000, 5); break; |
|
|
|
case 6: modbus.WriteSingleRegister(0000, 6); break; |
|
|
|
case 1: modbus.WriteSingleRegister(0000, 1);DeviceProcessLogShow($"开始接【{loc}】号位置原酒"); break; |
|
|
|
case 2: modbus.WriteSingleRegister(0000, 2);DeviceProcessLogShow($"开始接【{loc}】号位置原酒"); break; |
|
|
|
case 3: modbus.WriteSingleRegister(0000, 3);DeviceProcessLogShow($"开始接【{loc}】号位置原酒"); break; |
|
|
|
case 4: modbus.WriteSingleRegister(0000, 4);DeviceProcessLogShow($"开始接【{loc}】号位置原酒"); break; |
|
|
|
case 5: modbus.WriteSingleRegister(0000, 5);DeviceProcessLogShow($"开始接【{loc}】号位置原酒"); break; |
|
|
|
case 6: modbus.WriteSingleRegister(0000, 6); DeviceProcessLogShow($"开始接【{loc}】号位置原酒"); break; |
|
|
|
|
|
|
|
} |
|
|
|
//等待机器人到达接酒位置 |
|
|
|
switch (loc) |
|
|
|
{ |
|
|
|
case 1: while (!morkMW.ArriveWinkOneLoc) { Thread.Sleep(5); } break; |
|
|
|
case 2: while (!morkMW.ArriveWinkTwoLoc) { Thread.Sleep(5); } break; |
|
|
|
case 3: while (!morkMW.ArriveWinkThreeLoc) { Thread.Sleep(5); } break; |
|
|
|
case 4: while (!morkMW.ArriveWinkFourLoc) { Thread.Sleep(5); } break; |
|
|
|
case 5: while (!morkMW.ArriveWinkFiveLoc) { Thread.Sleep(5); } break; |
|
|
|
case 6: while (!morkMW.ArriveWinkSixLoc) { Thread.Sleep(5); } break; |
|
|
|
case 1: while (!morkMW.ArriveWinkOneLoc) { Thread.Sleep(5); } DeviceProcessLogShow($"机械臂到达【{loc}】号接酒位置"); break; |
|
|
|
case 2: while (!morkMW.ArriveWinkTwoLoc) { Thread.Sleep(5); } DeviceProcessLogShow($"机械臂到达【{loc}】号接酒位置"); break; |
|
|
|
case 3: while (!morkMW.ArriveWinkThreeLoc) { Thread.Sleep(5); } DeviceProcessLogShow($"机械臂到达【{loc}】号接酒位置"); break; |
|
|
|
case 4: while (!morkMW.ArriveWinkFourLoc) { Thread.Sleep(5); } DeviceProcessLogShow($"机械臂到达【{loc}】号接酒位置"); break; |
|
|
|
case 5: while (!morkMW.ArriveWinkFiveLoc) { Thread.Sleep(5); } DeviceProcessLogShow($"机械臂到达【{loc}】号接酒位置"); break; |
|
|
|
case 6: while (!morkMW.ArriveWinkSixLoc) { Thread.Sleep(5); } DeviceProcessLogShow($"机械臂到达【{loc}】号接酒位置"); break; |
|
|
|
|
|
|
|
} |
|
|
|
Thread.Sleep(time * 1000);//接酒等待时间 |
|
|
|
//发送接酒完成信号 |
|
|
|
switch (loc) |
|
|
|
{ |
|
|
|
case 1: modbus.WriteSingleCoil(4596, true); break; |
|
|
|
case 2: modbus.WriteSingleCoil(4597, true); break; |
|
|
|
case 3: modbus.WriteSingleCoil(4598, true); break; |
|
|
|
case 4: modbus.WriteSingleCoil(4599, true); break; |
|
|
|
case 5: modbus.WriteSingleCoil(4600, true); break; |
|
|
|
case 6: modbus.WriteSingleCoil(4601, true); break; |
|
|
|
case 1: modbus.WriteSingleCoil(4596, true);DeviceProcessLogShow($"【{loc}】号位置接酒完成"); break; |
|
|
|
case 2: modbus.WriteSingleCoil(4597, true);DeviceProcessLogShow($"【{loc}】号位置接酒完成"); break; |
|
|
|
case 3: modbus.WriteSingleCoil(4598, true);DeviceProcessLogShow($"【{loc}】号位置接酒完成"); break; |
|
|
|
case 4: modbus.WriteSingleCoil(4599, true);DeviceProcessLogShow($"【{loc}】号位置接酒完成"); break; |
|
|
|
case 5: modbus.WriteSingleCoil(4600, true);DeviceProcessLogShow($"【{loc}】号位置接酒完成"); break; |
|
|
|
case 6: modbus.WriteSingleCoil(4601, true); DeviceProcessLogShow($"【{loc}】号位置接酒完成"); break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@@ -236,9 +304,10 @@ namespace BPASmartClient.MorkMW |
|
|
|
{ |
|
|
|
if (order.mixWink.Count > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
string guid = Guid.NewGuid().ToString(); |
|
|
|
orderLocInfos.Enqueue(new OrderLocInfo { mixWink = order.mixWink, SuborderId = guid }); |
|
|
|
DeviceProcessLogShow("收到订单"); |
|
|
|
simOrderLocInfos.Enqueue(new SimOrderLocInfo { mixWink = order.mixWink, SuborderId = guid }); |
|
|
|
DeviceProcessLogShow("收到模拟订单"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -278,12 +347,19 @@ namespace BPASmartClient.MorkMW |
|
|
|
|
|
|
|
if (@event != null && @event is DoOrderEvent order) |
|
|
|
{ |
|
|
|
var res= listMorkMWGoods.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.GoodsKey); |
|
|
|
if (res != null) |
|
|
|
{ |
|
|
|
string guid = Guid.NewGuid().ToString(); |
|
|
|
orderLocInfos.Enqueue(new OrderLocInfo { mixWink = res.MorkMWBoms, SuborderId = order.MorkOrder.SuborderId }); |
|
|
|
DeviceProcessLogShow($"收到小程序订单,订单号【{order.MorkOrder.SuborderId}】"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
#region 调试代码 |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 连接卡乐普机器人 |
|
|
|
/// </summary> |
|
|
@@ -303,11 +379,21 @@ namespace BPASmartClient.MorkMW |
|
|
|
modbus.ModbusTcpConnect(ip, port); |
|
|
|
|
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 调酒订单队列 |
|
|
|
/// 调酒小程序订单队列 |
|
|
|
/// </summary> |
|
|
|
public ConcurrentQueue<OrderLocInfo> orderLocInfos = new ConcurrentQueue<OrderLocInfo>(); |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 调酒模拟订单队列 |
|
|
|
/// </summary> |
|
|
|
public ConcurrentQueue<SimOrderLocInfo> simOrderLocInfos = new ConcurrentQueue<SimOrderLocInfo>(); |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 调酒机配方集合 |
|
|
|
/// </summary> |
|
|
|
public List<MORKMWGoods> listMorkMWGoods = new List<MORKMWGoods>(); |
|
|
|
|
|
|
|
} |
|
|
|
} |