From 934eb5b28ca0522fa3c477dcecb3d6345021eb55 Mon Sep 17 00:00:00 2001 From: taoye Date: Tue, 22 Nov 2022 11:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E9=85=92=E6=9C=BA=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E4=B8=8B=E5=8D=95=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPASmartClient.Business.csproj | 4 +- BPASmartClient.Business/Plugin/DeviceMgr.cs | 12 +- .../BPASmartClient.CustomResource.csproj | 2 +- .../BPASmartClient.Device.csproj | 2 +- .../BPASmartClient.JXJFoodSmallStation.csproj | 2 +- .../BPASmartClient.Model.csproj | 2 +- BPASmartClient.Model/订单/MorkMWSimOrder.cs | 3 +- .../调酒机/MorkMWGoodsEvent.cs | 15 ++ .../BPASmartClient.MorkF.csproj | 2 +- BPASmartClient.MorkF/Control_MorkF.cs | 2 +- .../BPASmartClient.MorkMW.csproj | 4 +- BPASmartClient.MorkMW/Control_MorkMW.cs | 186 +++++++++++++----- BPASmartClient.MorkMW/GVL_MorkMW.cs | 2 + BPASmartClient.MorkMW/Model/OrderLocInfo.cs | 5 +- .../Model/SimOrderLocInfo.cs | 19 ++ BPASmartClient.MorkMW/View/DebugView.xaml | 1 + BPASmartClient.MorkMW/View/DebugView.xaml.cs | 2 + .../ViewModel/DebugViewModel.cs | 15 +- .../BPASmartClient.MorkS.csproj | 4 +- .../BPASmartClient.MorkTHQ.csproj | 2 +- BPASmartClient/BPASmartClient.csproj | 2 +- .../BPASmartClient.DosingSystem.csproj | 2 +- 22 files changed, 219 insertions(+), 71 deletions(-) create mode 100644 BPASmartClient.Model/调酒机/MorkMWGoodsEvent.cs create mode 100644 BPASmartClient.MorkMW/Model/SimOrderLocInfo.cs diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index 39f36251..87d1b161 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/BPASmartClient.Business/Plugin/DeviceMgr.cs b/BPASmartClient.Business/Plugin/DeviceMgr.cs index 887ec80a..d960924c 100644 --- a/BPASmartClient.Business/Plugin/DeviceMgr.cs +++ b/BPASmartClient.Business/Plugin/DeviceMgr.cs @@ -6,6 +6,7 @@ using BPASmartClient.Http; using BPASmartClient.Message; using BPASmartClient.Model; using BPASmartClient.Model.小炒机; +using BPASmartClient.Model.调酒机; using BPASmartClient.Peripheral; using Newtonsoft.Json; using System; @@ -95,7 +96,7 @@ namespace BPASmartClient.Business #region 获取物料数据 string result = string.Empty; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 4; i++) { try { @@ -138,6 +139,15 @@ namespace BPASmartClient.Business }.Publish(); MessageLog.GetInstance.Show("接收到【 API 】获取的小炒流程信息"); } + else if (PushType == 3) + { + new MorkMWGoodsEvent() + { + DeviceId = device.DeviceId, + morkMWPushMessage = JsonConvert.DeserializeObject(result) + }.Publish(); + MessageLog.GetInstance.Show("接收到【API】获取的调酒机配方信息"); + } } catch (Exception ex) { diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 68a96d9a..b728b8dd 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -410,7 +410,7 @@ - + diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj index 34e40440..91f97e5b 100644 --- a/BPASmartClient.Device/BPASmartClient.Device.csproj +++ b/BPASmartClient.Device/BPASmartClient.Device.csproj @@ -7,7 +7,7 @@ - + diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index fc69dd26..61188e67 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.Model/BPASmartClient.Model.csproj b/BPASmartClient.Model/BPASmartClient.Model.csproj index 5c60f04d..660a436c 100644 --- a/BPASmartClient.Model/BPASmartClient.Model.csproj +++ b/BPASmartClient.Model/BPASmartClient.Model.csproj @@ -17,7 +17,7 @@ - + diff --git a/BPASmartClient.Model/订单/MorkMWSimOrder.cs b/BPASmartClient.Model/订单/MorkMWSimOrder.cs index 5f11798b..60e110fa 100644 --- a/BPASmartClient.Model/订单/MorkMWSimOrder.cs +++ b/BPASmartClient.Model/订单/MorkMWSimOrder.cs @@ -1,4 +1,5 @@ -using System; +using BPA.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/BPASmartClient.Model/调酒机/MorkMWGoodsEvent.cs b/BPASmartClient.Model/调酒机/MorkMWGoodsEvent.cs new file mode 100644 index 00000000..f9814dba --- /dev/null +++ b/BPASmartClient.Model/调酒机/MorkMWGoodsEvent.cs @@ -0,0 +1,15 @@ +using BPA.Message; +using BPA.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.调酒机 +{ + public class MorkMWGoodsEvent : BaseEvent + { + public MORKMWPushMessage morkMWPushMessage = new MORKMWPushMessage(); + } +} diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj index 2984a36c..e7ac07e7 100644 --- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj +++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj @@ -10,7 +10,7 @@ - + diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index b5c2d38e..65be85b7 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -109,7 +109,7 @@ namespace BPASmartClient.MorkF /// /// 小炒菜单集合 - /// + /// f public static List LocalstirFryGoods = new List(); /// diff --git a/BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj b/BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj index 2ebedcc7..8d76ab31 100644 --- a/BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj +++ b/BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/BPASmartClient.MorkMW/Control_MorkMW.cs b/BPASmartClient.MorkMW/Control_MorkMW.cs index b181c58a..d315de47 100644 --- a/BPASmartClient.MorkMW/Control_MorkMW.cs +++ b/BPASmartClient.MorkMW/Control_MorkMW.cs @@ -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(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 /// 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;//ɣ } + } } /// @@ -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 Դ + /// /// ӿջ /// @@ -303,11 +379,21 @@ namespace BPASmartClient.MorkMW modbus.ModbusTcpConnect(ip, port); } - #endregion + /// - /// ƶ + /// С򶩵 /// public ConcurrentQueue orderLocInfos = new ConcurrentQueue(); + /// + /// ģⶩ + /// + public ConcurrentQueue simOrderLocInfos = new ConcurrentQueue(); + + /// + /// ƻ䷽ + /// + public List listMorkMWGoods = new List(); + } } diff --git a/BPASmartClient.MorkMW/GVL_MorkMW.cs b/BPASmartClient.MorkMW/GVL_MorkMW.cs index c4d8c375..4a082c26 100644 --- a/BPASmartClient.MorkMW/GVL_MorkMW.cs +++ b/BPASmartClient.MorkMW/GVL_MorkMW.cs @@ -71,5 +71,7 @@ namespace BPASmartClient.MorkMW /// public bool PourWinkComplete { get; set; } #endregion + + public static bool AllowLocalSimOrder { get; set; } } } diff --git a/BPASmartClient.MorkMW/Model/OrderLocInfo.cs b/BPASmartClient.MorkMW/Model/OrderLocInfo.cs index e2894ed1..1da57dce 100644 --- a/BPASmartClient.MorkMW/Model/OrderLocInfo.cs +++ b/BPASmartClient.MorkMW/Model/OrderLocInfo.cs @@ -1,4 +1,5 @@ -using BPASmartClient.Model; +using BPA.Models; +using BPASmartClient.Model; using System; using System.Collections.Generic; using System.Linq; @@ -13,7 +14,7 @@ namespace BPASmartClient.MorkMW.Model /// /// 单个订单的制作流程 /// - public List mixWink=new List(); + public List mixWink=new List(); public string GoodName { get; set; } } } diff --git a/BPASmartClient.MorkMW/Model/SimOrderLocInfo.cs b/BPASmartClient.MorkMW/Model/SimOrderLocInfo.cs new file mode 100644 index 00000000..e649186e --- /dev/null +++ b/BPASmartClient.MorkMW/Model/SimOrderLocInfo.cs @@ -0,0 +1,19 @@ +using BPASmartClient.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMW.Model +{ + public class SimOrderLocInfo + { + public string SuborderId { get; set; } + /// + /// 单个订单的制作流程 + /// + public List mixWink = new List(); + public string GoodName { get; set; } + } +} diff --git a/BPASmartClient.MorkMW/View/DebugView.xaml b/BPASmartClient.MorkMW/View/DebugView.xaml index 9620dd48..71772a9f 100644 --- a/BPASmartClient.MorkMW/View/DebugView.xaml +++ b/BPASmartClient.MorkMW/View/DebugView.xaml @@ -68,6 +68,7 @@