From 7bf99987c0ba7133e6254d43a7fd28456e0f7ef3 Mon Sep 17 00:00:00 2001 From: NXX <447201003@qq> Date: Thu, 3 Nov 2022 09:55:00 +0800 Subject: [PATCH] morkf --- BPASmartClient.Device/BaseDevice.cs | 16 + .../View/RecipeConfige.xaml.cs | 4 +- .../BPASmartClient.MorkBF.csproj | 17 + BPASmartClient.MorkBF/Class1.cs | 8 + BPASmartClient.MorkBF/Control_MorkBF.cs | 136 +++++++ BPASmartClient.MorkBF/GVL_MorkBF.cs | 33 ++ BPASmartClient.MorkBF/Model/BF_Food.cs | 65 ++++ BPASmartClient.MorkBF/OrderLocInfo.cs | 12 + BPASmartClient.MorkBF/VIew/DebugView.xaml | 46 +++ BPASmartClient.MorkBF/VIew/DebugView.xaml.cs | 28 ++ .../VIew/FoodManagerView.xaml | 50 +++ .../VIew/FoodManagerView.xaml.cs | 27 ++ BPASmartClient.MorkF/Control_MorkF.cs | 351 +++++++++--------- .../ViewModel/DebugViewModel.cs | 1 - BPASmartClient/BPASmartClient.csproj | 1 + SmartClient.sln | 23 ++ 16 files changed, 636 insertions(+), 182 deletions(-) create mode 100644 BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj create mode 100644 BPASmartClient.MorkBF/Class1.cs create mode 100644 BPASmartClient.MorkBF/Control_MorkBF.cs create mode 100644 BPASmartClient.MorkBF/GVL_MorkBF.cs create mode 100644 BPASmartClient.MorkBF/Model/BF_Food.cs create mode 100644 BPASmartClient.MorkBF/OrderLocInfo.cs create mode 100644 BPASmartClient.MorkBF/VIew/DebugView.xaml create mode 100644 BPASmartClient.MorkBF/VIew/DebugView.xaml.cs create mode 100644 BPASmartClient.MorkBF/VIew/FoodManagerView.xaml create mode 100644 BPASmartClient.MorkBF/VIew/FoodManagerView.xaml.cs diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index 6f085378..1487cdc3 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -127,6 +127,22 @@ namespace BPASmartClient.Device } } } + /// + /// 多设备分开写控制 + /// + /// + /// + public void WriteControlExact(string address, object value,int i) + { + if (peripherals != null) + { + if (peripherals.Count > i) + { + peripherals.ElementAt(i).WriteData(address, value); + } + } + } + /// /// 设备过程日志显示 diff --git a/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs b/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs index abaf3f39..8b7e2679 100644 --- a/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs +++ b/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs @@ -43,6 +43,8 @@ namespace BPASmartClient.MilkWithTea.View private void Button_Click(object sender, RoutedEventArgs e) { this.Close(); + + } @@ -69,7 +71,7 @@ namespace BPASmartClient.MilkWithTea.View private bool IsMouseOverTarget(Visual target, GetPositionDelegate getPosition) { Rect bounds = VisualTreeHelper.GetDescendantBounds(target); - Point mousePos = getPosition((IInputElement)target); + Point mousePos = getPosition((IInputElement)target); return bounds.Contains(mousePos); } diff --git a/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj b/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj new file mode 100644 index 00000000..7b8b195f --- /dev/null +++ b/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj @@ -0,0 +1,17 @@ + + + + net6.0-windows + enable + true + + + + + + + + + + + diff --git a/BPASmartClient.MorkBF/Class1.cs b/BPASmartClient.MorkBF/Class1.cs new file mode 100644 index 00000000..cb4f64cb --- /dev/null +++ b/BPASmartClient.MorkBF/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace BPASmartClient.MorkBF +{ + public class Class1 + { + } +} diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs new file mode 100644 index 00000000..04cdf982 --- /dev/null +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -0,0 +1,136 @@ +using BPA.Message.Enum; +using BPASmartClient.Device; +using BPASmartClient.EventBus; +using BPASmartClient.Helper; +using BPASmartClient.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using static BPASmartClient.EventBus.EventBus; + +namespace BPASmartClient.MorkBF +{ + public class Control_MorkBF : BaseDevice + { + GVL_MorkBF morkBF = new GVL_MorkBF(); + + public override DeviceClientType DeviceType => DeviceClientType.MORKCS; + + public override void DoMain() + { + CommandRegist();//调试 + ServerInit(); + DataParse();//数据解析 + DeviceProcessLogShow("MORKF 设备初始化完成"); + } + + private void DataParse() + { + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event == null) return; + if (@event is DoOrderEvent order) + { + if (order.MorkOrder.GoodBatchings == null) return; + OrderCount++; + DeviceProcessLogShow($"接收到{OrderCount}次订单"); + + + + } + + }); + } + + private void ServerInit() + { + //物料信息 + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + if (@event is MaterialDeliveryEvent material) + { + orderMaterialDelivery = material.orderMaterialDelivery; + + } + }); + + //配方数据信息 + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + if (@event is RecipeBomEvent recipe) + { + recipeBoms = recipe.recipeBoms; + } + }); + } + /// + /// 调试 + /// + /// + private void CommandRegist() + { + + } + + public override void MainTask() + { + if(morkBF.FirePan1_Order.Count == 0&&!morkBF.FirePan1_Busy) + { + ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1主进程"); + } + + if (morkBF.FirePan2_Order.Count == 0 && !morkBF.FirePan2_Busy) + { + ThreadManage.GetInstance().Start(FirePot2_Process, "炒锅2主进程"); + } + } + + private void FirePot1_Process() + { + morkBF.FirePan1_Busy = true; + morkBF.FirePan1_Date = DateTime.Now; + while (morkBF.FirePan1_Date.AddMinutes(1)> DateTime.Now) + { + Thread.Sleep(500); + } + ThreadManage.GetInstance().StopTask("炒锅1主进程"); + } + + private void FirePot2_Process() + { + morkBF.FirePan2_Busy = true; + morkBF.FirePan2_Date = DateTime.Now; + while (morkBF.FirePan2_Date.AddMinutes(1) > DateTime.Now) + { + Thread.Sleep(500); + } + ThreadManage.GetInstance().StopTask("炒锅2主进程"); + } + + public override void ReadData() + { + + } + + public override void ResetProgram() + { + morkBF = null; + morkBF = new GVL_MorkBF(); + } + + public override void SimOrder() + { + + } + + public override void Stop() + { + + } + } +} diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs new file mode 100644 index 00000000..0dedfe7a --- /dev/null +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -0,0 +1,33 @@ +using BPASmartClient.MorkBF.Model; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkBF +{ + internal class GVL_MorkBF + { + /// + /// 炒锅1订单队列 + /// + public ConcurrentQueue FirePan1_Order { get; set; } = new ConcurrentQueue(); + /// + /// 炒锅2订单队列 + /// + public ConcurrentQueue FirePan2_Order { get; set; } = new ConcurrentQueue(); + /// + /// 炒锅1忙碌 + /// + public bool FirePan1_Busy = false; + /// + /// 炒锅2忙碌 + /// + public bool FirePan2_Busy = false; + + public DateTime FirePan1_Date; + public DateTime FirePan2_Date; + } +} diff --git a/BPASmartClient.MorkBF/Model/BF_Food.cs b/BPASmartClient.MorkBF/Model/BF_Food.cs new file mode 100644 index 00000000..6891c445 --- /dev/null +++ b/BPASmartClient.MorkBF/Model/BF_Food.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkBF.Model +{ + public class BF_Food + { + /// + /// 菜品名称 + /// + public string FoodName { get; set; } + /// + /// 菜品ID + /// + public string FoodID { get; set; } + + } + + public class BF_PotAction + { + /// + /// 步骤 + /// + public int FryTime + { + get; + set; + } + /// + /// 时间 + /// + public int During + { + get; + set; + } + /// + /// 动作 + /// + public string Actions + { + get; + set; + } + /// + /// 调料 + /// + public List SeasoningLists + { + get; + set; + } + /// + /// 菜品 + /// + public List MaterialLists + { + get; + set; + } + } +} diff --git a/BPASmartClient.MorkBF/OrderLocInfo.cs b/BPASmartClient.MorkBF/OrderLocInfo.cs new file mode 100644 index 00000000..00aed4ba --- /dev/null +++ b/BPASmartClient.MorkBF/OrderLocInfo.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkBF +{ + internal class OrderLocInfo + { + } +} diff --git a/BPASmartClient.MorkBF/VIew/DebugView.xaml b/BPASmartClient.MorkBF/VIew/DebugView.xaml new file mode 100644 index 00000000..f05554f1 --- /dev/null +++ b/BPASmartClient.MorkBF/VIew/DebugView.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + +