From 19ca5235449b9d2e4f571610e2ff3b0f409dc917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Tue, 9 May 2023 15:08:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0MorkM=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs | 22 +- BPASmartClient.Model/OrderLocInfo.cs | 24 + BPASmartClient.MorkMV1/Alarm.cs | 74 ++ .../BPASmartClient.MorkMV1.csproj | 30 + BPASmartClient.MorkMV1/Control_MorkMV1.cs | 864 ++++++++++++++++++ BPASmartClient.MorkMV1/DataServer.cs | 51 ++ BPASmartClient.MorkMV1/DeviceData.cs | 193 ++++ BPASmartClient.MorkMV1/GVL_MorkMV1.cs | 353 +++++++ BPASmartClient.MorkMV1/GlobalUsing.cs | 26 + BPASmartClient.MorkMV1/Model/Global.cs | 13 + BPASmartClient.MorkMV1/Model/MorksPar.cs | 16 + BPASmartClient.MorkMV1/Model/ParSet.cs | 29 + BPASmartClient.MorkMV1/Model/WritePar.cs | 14 + BPASmartClient.MorkMV1/NoodleShidModel.cs | 21 + BPASmartClient.MorkMV1/OrderLocInfo.cs | 24 + BPASmartClient.MorkMV1/View/Debug.xaml | 117 +++ BPASmartClient.MorkMV1/View/Debug.xaml.cs | 30 + BPASmartClient.MorkMV1/View/Monitor.xaml | 242 +++++ BPASmartClient.MorkMV1/View/Monitor.xaml.cs | 28 + BPASmartClient.MorkMV1/View/ParSet.xaml | 130 +++ BPASmartClient.MorkMV1/View/ParSet.xaml.cs | 28 + .../ViewModel/DebugViewModel.cs | 79 ++ .../ViewModel/MonitorViewModel.cs | 25 + .../ViewModel/ParSetViewModel.cs | 49 + BPASmartClient.MorkS/Control_Morks.cs | 82 +- BPASmartClient.MorkS/OrderLocInfo.cs | 40 +- .../Control_MorkSUpgradedVer.cs | 84 +- .../OrderLocInfo.cs | 40 +- BPASmartClient.Peripheral/BasePeripheral.cs | 2 +- BPASmartClient.Peripheral/IPeripheral.cs | 2 +- BPASmartClient/BPASmartClient.csproj | 1 + SmartClient.sln | 25 +- 32 files changed, 2620 insertions(+), 138 deletions(-) create mode 100644 BPASmartClient.Model/OrderLocInfo.cs create mode 100644 BPASmartClient.MorkMV1/Alarm.cs create mode 100644 BPASmartClient.MorkMV1/BPASmartClient.MorkMV1.csproj create mode 100644 BPASmartClient.MorkMV1/Control_MorkMV1.cs create mode 100644 BPASmartClient.MorkMV1/DataServer.cs create mode 100644 BPASmartClient.MorkMV1/DeviceData.cs create mode 100644 BPASmartClient.MorkMV1/GVL_MorkMV1.cs create mode 100644 BPASmartClient.MorkMV1/GlobalUsing.cs create mode 100644 BPASmartClient.MorkMV1/Model/Global.cs create mode 100644 BPASmartClient.MorkMV1/Model/MorksPar.cs create mode 100644 BPASmartClient.MorkMV1/Model/ParSet.cs create mode 100644 BPASmartClient.MorkMV1/Model/WritePar.cs create mode 100644 BPASmartClient.MorkMV1/NoodleShidModel.cs create mode 100644 BPASmartClient.MorkMV1/OrderLocInfo.cs create mode 100644 BPASmartClient.MorkMV1/View/Debug.xaml create mode 100644 BPASmartClient.MorkMV1/View/Debug.xaml.cs create mode 100644 BPASmartClient.MorkMV1/View/Monitor.xaml create mode 100644 BPASmartClient.MorkMV1/View/Monitor.xaml.cs create mode 100644 BPASmartClient.MorkMV1/View/ParSet.xaml create mode 100644 BPASmartClient.MorkMV1/View/ParSet.xaml.cs create mode 100644 BPASmartClient.MorkMV1/ViewModel/DebugViewModel.cs create mode 100644 BPASmartClient.MorkMV1/ViewModel/MonitorViewModel.cs create mode 100644 BPASmartClient.MorkMV1/ViewModel/ParSetViewModel.cs diff --git a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs index 6181cc29..91c238c1 100644 --- a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs +++ b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs @@ -95,17 +95,17 @@ namespace BPASmartClient.PLC modbusTcp.Write(address, value); } - public override void AddVarInfo(string add, int len) - { - if (!tempVar.ContainsKey(add) && !string.IsNullOrEmpty(add) && len > 0) - { - tempVar.TryAdd(add, new Variable() - { - Address = add, - ReadLeng = len - }); - } - } + //public override void AddVarInfo(string add, int len) + //{ + // if (!tempVar.ContainsKey(add) && !string.IsNullOrEmpty(add) && len > 0) + // { + // tempVar.TryAdd(add, new Variable() + // { + // Address = add, + // ReadLeng = len + // }); + // } + //} protected override void InitStatus() { diff --git a/BPASmartClient.Model/OrderLocInfo.cs b/BPASmartClient.Model/OrderLocInfo.cs new file mode 100644 index 00000000..1b199cb1 --- /dev/null +++ b/BPASmartClient.Model/OrderLocInfo.cs @@ -0,0 +1,24 @@ +using BPA.Message; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public class OrderLocInfo + { + public string SuborderId { get; set; } + public ushort Loc { get; set; } + public ushort RecipeNumber { get; set; } + public int BatchingId { get; set; } + public string GoodName { get; set; } + public int SortNum { get; set; } + + public int RecipeId { get; set; } + + public List Recipes { get; set; } + + } +} diff --git a/BPASmartClient.MorkMV1/Alarm.cs b/BPASmartClient.MorkMV1/Alarm.cs new file mode 100644 index 00000000..1a8c5952 --- /dev/null +++ b/BPASmartClient.MorkMV1/Alarm.cs @@ -0,0 +1,74 @@ +using BPASmartClient.Device; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMV1 +{ + public class Alarm : IAlarm + { + /// + /// 煮面机温度过低 + /// + [Alarm("煮面机温度过低")] + public bool MachineLowTemperature { get; set; } + + /// + /// 大碗数量不足 + /// + [Alarm("大碗数量不足")] + public bool Supply1_LossBowl { get; set; } + + /// + /// 一次性碗数量不足 + /// + [Alarm("一次性碗数量不足")] + public bool Supply2_LossBowl { get; set; } + + /// + /// 设备未初始化 + /// + [Alarm("设备未初始化")] + public bool DeviceNoInit { get; set; } + + /// + /// 移碗丝杆未初始化 + /// + [Alarm("移碗丝杆未初始化")] + public bool MoveScrewRodNoInit { get; set; } + + /// + /// 供碗1未初始化 + /// + [Alarm("供碗1未初始化")] + public bool SacrificialVesselNoInit { get; set; } + + /// + /// 气缸推杆未初始化 + /// + [Alarm("气缸推杆未初始化")] + public bool CylinderNoInit { get; set; } + + /// + /// 煮面机初未初始化 + /// + [Alarm("煮面机初未初始化")] + public bool NoodleCookerNoInit { get; set; } + + /// + /// 机器人未初始化 + /// + [Alarm("机器人未初始化")] + public bool RobotNoInit { get; set; } + + /// + /// 料仓未初始化 + /// + [Alarm("料仓未初始化")] + public bool SiloNoInit { get; set; } + + + } +} diff --git a/BPASmartClient.MorkMV1/BPASmartClient.MorkMV1.csproj b/BPASmartClient.MorkMV1/BPASmartClient.MorkMV1.csproj new file mode 100644 index 00000000..ed88b17f --- /dev/null +++ b/BPASmartClient.MorkMV1/BPASmartClient.MorkMV1.csproj @@ -0,0 +1,30 @@ + + + + net6.0-windows + enable + true + + + + + + + + + + + + + + Code + + + Code + + + Code + + + + diff --git a/BPASmartClient.MorkMV1/Control_MorkMV1.cs b/BPASmartClient.MorkMV1/Control_MorkMV1.cs new file mode 100644 index 00000000..d420d963 --- /dev/null +++ b/BPASmartClient.MorkMV1/Control_MorkMV1.cs @@ -0,0 +1,864 @@ +using System; +using System.Collections.Generic; +using BPA.Message.Enum; +using BPASmartClient.Device; +using BPASmartClient.EventBus; +using BPASmartClient.Model; +using BPASmartClient.Peripheral; +using static BPASmartClient.EventBus.EventBus; +using BPASmartClient.Helper; +using System.Threading; +using BPASmartClient.Message; +using BPA.Message; +using System.Linq; +using BPASmartClient.Model.PLC; +using System.Threading.Tasks; +using System.Reflection; +using BPASmartClient.MorkMV1.Model; +using System.Collections.ObjectModel; +using BPASmartClient.MorkMV1.ViewModel; +using BPASmartClient.Business; +using BPASmartClient.Model.小炒机; +using BPA.Models; +using System.Windows.Forms; +using System.Media; +using BPASmartClient.CustomResource; +//using BPA.Helper; + +namespace BPASmartClient.MorkMV1 +{ + public class Control_MorkMV1 : BaseDevice + { + public override DeviceClientType DeviceType => DeviceClientType.MORKM; + GVL_MorkMV1 mORKM = new GVL_MorkMV1(); + Alarm alarm = new Alarm(); + + public override void DoMain() + { + MonitorViewModel.DeviceId = DeviceId; + ServerInit(); + DataParse(); + Json.Read(); + Json.Read(); + if (Json.Data.parSets == null) Json.Data.parSets = new ObservableCollection(); + if (Json.Data.parSets.Count < 6) + { + Json.Data.parSets.Clear(); + for (int i = 0; i < 6; i++) + { + Json.Data.parSets.Add(new ParSet() + { + CheckBoxContext = $"煮面口{i + 1}屏蔽", + Minute = 1, + Second = 0, + IsShield = false, + TextBlockContext = $"煮面口{i + 1}时间设定" + }); + } + } + + ActionManage.GetInstance.Register(new Action((o) => + { + if (o.Length > 0) + { + Random rd = new Random(); + ThreadManage.GetInstance().StartLong(new Action(() => + { + int NoodleLoc = (int)o[0] == 0 ? rd.Next(1, 6) : (int)o[0]; + int BowlLoc = (int)o[1] == 0 ? rd.Next(10, 12) : (int)o[1]; + + string guid = new Guid().ToString(); + + mORKM.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】"); + + mORKM.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】"); + Thread.Sleep(60000); + }), "ForOrder"); + } + }), "EnableForOrder"); + + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); + }), "WriteVW"); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); + }), "WriteBools"); + ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice"); + } + + public override void ResetProgram() + { + mORKM = null; + mORKM = new GVL_MorkMV1(); + } + + public override void Stop() + { + + } + + 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 OrderChange(string subid, ORDER_STATUS oRDER_STATUS) + { + var res = mORKM.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid); + string goodName = string.Empty; + string SortNum = string.Empty; + if (res != null) + { + goodName = res.MorkOrder.GoodsName; + SortNum = res.MorkOrder.SortNum.ToString(); + } + + //if (mORKS.doe.ContainsKey(subid)) + //{ + // goodName = mORKS.doe[subid].MorkOrder.GoodsName; + // SortNum = mORKS.doe[subid].MorkOrder.SortNum.ToString(); + if (!string.IsNullOrEmpty(goodName) && !string.IsNullOrEmpty(SortNum)) + { + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); + if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) + { + if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + { + DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); + DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StopTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) + { + var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); + if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); + } + else + { + DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + } + } + else + { + DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StartTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + //mORKS.doe.Remove(subid, out _); + } + //} + + + + //var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid); + //string goodName = string.Empty; + //string SortNum = string.Empty; + //if (res != null) + //{ + // goodName = res.MorkOrder.GoodsName; + // SortNum = res.MorkOrder.SortNum.ToString(); + //} + + //EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + + //var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); + //if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) + //{ + // if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + // { + // DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); + // DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + // { + // Status = oRDER_STATUS, + // GoodName = goodName, + // SortNum = SortNum, + // StopTime = DateTime.Now.ToString("HH:mm:ss") + // }); + // } + // else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) + // { + // var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); + // if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); + // } + // else + // { + // DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + // } + //} + //else + //{ + // DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() + // { + // Status = oRDER_STATUS, + // GoodName = goodName, + // SortNum = SortNum, + // StartTime = DateTime.Now.ToString("HH:mm:ss") + // }); + //} + } + + private void GetStatus(string key, Action action) + { + if (peripheralStatus.ContainsKey(key)) + { + if (peripheralStatus[key] != null) + { + action?.Invoke(peripheralStatus[key]); + } + } + } + + public override void ReadData() + { + DataServer.GetInstance.morkS.Alarm.Clear(); + alarms.ForEach(item => + { + DataServer.GetInstance.morkS.Alarm.Add(new AlarmModel() + { + AlarmTime = $"{item.Date} {item.Time}", + AlarmMs = item.Info + }); + }); + + GetStatus("M0.1", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 7) + { + Initing = !bools[0]; + mORKM.InitComplete = bools[0]; + mORKM.MoveScrewRodInitCom = bools[1]; + mORKM.SacrificialVesselInitCom = bools[2]; + mORKM.CylinderInitCom = bools[3]; + mORKM.NoodleCookerInitCom = bools[4]; + mORKM.RobotInitCom = bools[5]; + mORKM.SiloInitCom = bools[6]; + + alarm.DeviceNoInit = !mORKM.InitComplete; + alarm.MoveScrewRodNoInit = !mORKM.MoveScrewRodInitCom; + alarm.SacrificialVesselNoInit = !mORKM.SacrificialVesselInitCom; + alarm.CylinderNoInit = !mORKM.CylinderInitCom; + alarm.NoodleCookerNoInit = !mORKM.NoodleCookerInitCom; + alarm.RobotNoInit = !mORKM.RobotInitCom; + alarm.SiloNoInit = !mORKM.SiloInitCom; + } + })); + + GetStatus("M10.0", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 2) + { + mORKM.AllowInvertedFace = bools[0]; + mORKM.DiningComplete = bools[1]; + } + })); + + GetStatus("M10.4", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 1) + { + mORKM.DropBowlMechanismStatus = bools[0]; + } + })); + + GetStatus("M12.2", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 1) + { + mORKM.FixedFlag = bools[0]; + } + })); + + GetStatus("M13.5", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 1) + { + mORKM.SiloInPlace = bools[0]; + } + })); + + GetStatus("M16.7", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 1) + { + mORKM.RobotTakeNoodleCom = bools[0]; + } + })); + + GetStatus("M17.4", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 1) + { + mORKM.RobotStatus = bools[0]; + } + })); + + GetStatus("M18.0", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 5) + { + mORKM.SmallBowlYesOrNoCheck = bools[0]; + mORKM.LargeBowYesOrNoCheck = bools[1]; + mORKM.TurntableLowPosition = bools[2]; + mORKM.TurntableHighPosition = bools[3]; + alarm.Supply2_LossBowl = !mORKM.SmallBowlYesOrNoCheck; + alarm.Supply1_LossBowl = !mORKM.LargeBowYesOrNoCheck; + } + })); + + GetStatus("VW17", new Action((obj) => + { + if (obj is ushort[] ushorts && ushorts.Length > 0 && ushorts.Length <= 1) + { + var tt = ushorts.UshortsToBytes(true).BytesToUshorts(); + + for (byte i = 0; i < 6; i++) + { + if (RTrig.GetInstance($"CookNoodleCom{i + 1}").Start(tt[0].GetBitValue((byte)(i + 1)))) + { + if (!string.IsNullOrEmpty(mORKM.CookNodelId[i])) + mORKM.CookNoodleCom[i] = true; + } + } + + //mORKS.CookNoodleCom[0] = tt[0].GetBitValue(1); + //mORKS.CookNoodleCom[1] = tt[0].GetBitValue(2); + //mORKS.CookNoodleCom[2] = tt[0].GetBitValue(3); + //mORKS.CookNoodleCom[3] = tt[0].GetBitValue(4); + //mORKS.CookNoodleCom[4] = tt[0].GetBitValue(5); + //mORKS.CookNoodleCom[5] = tt[0].GetBitValue(6); + mORKM.Heating = ushorts[0].GetBitValue(15); + mORKM.TemperatureReaches = ushorts[0].GetBitValue(16); + + alarm.MachineLowTemperature = !mORKM.TemperatureReaches; + } + + })); + + GetStatus("VW770", new Action((obj) => + { + if (obj is ushort[] ushorts && ushorts.Length > 0 && ushorts.Length <= 1) + { + mORKM.CurrentFeedbackLoc = ushorts[0]; + } + + })); + + mORKM.TakeBowlTaskCount = mORKM.TakeBowlTask.Count; + mORKM.RBTakeNoodleTaskCount = mORKM.RBTakeNoodleTask.Count; + + for (int i = 0; i < Json.Data.parSets.Count; i++) + { + mORKM.nsm.ElementAt(i).IsShield = Json.Data.parSets.ElementAt(i).IsShield; + mORKM.nsm.ElementAt(i).NoodleCookerStatus = mORKM.NoodleCookerStatus[i]; + } + + } + + /// + /// 数据解析 + /// + private void DataParse() + { + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event == null) return; + if (@event is DoOrderEvent order) + { + mORKM.doOrderEvents.Add(order); + //mORKS.doe.TryAdd(order.MorkOrder.SuborderId, order); + if (order.MorkOrder.GoodBatchings == null) return; + if (mORKM.HistorySuborderId.Contains(order.MorkOrder.SuborderId)) return; + OrderCount++; + if (DateTime.Now.Subtract(Json.Data.StatisticsTime).Days != 0) + Json.Data.Count = 0; + Json.Data.StatisticsTime = DateTime.Now; + Json.Data.Count++; + Json.Save(); + OrderChange(order.MorkOrder.SuborderId, ORDER_STATUS.WAIT); + DeviceProcessLogShow($"接收到{OrderCount}次订单,订单ID:{order.MorkOrder.SuborderId}"); + mORKM.HistorySuborderId.Add(order.MorkOrder.SuborderId); + foreach (var item in order.MorkOrder.GoodBatchings) + { + var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + if (res != null) + { + if (ushort.TryParse(res.BatchingLoc, out ushort loc)) + { + if (loc >= 1 && loc <= 5) + { + if (mORKM.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + mORKM.RBTakeNoodleTask.Enqueue(new OrderLocInfo() + { + GoodName = order.MorkOrder.GoodsName, + Loc = ushort.Parse(res.BatchingLoc), + SuborderId = order.MorkOrder.SuborderId, + SortNum = order.MorkOrder.SortNum, + BatchingId = res.BatchingId + }); + } + else if (loc >= 10 && loc <= 11) + { + int index = 0; + if (recipeBoms != null) + { + index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == order.MorkOrder.RecipeId); + index++; + } + if (mORKM.TakeBowlTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + mORKM.TakeBowlTask.Enqueue(new OrderLocInfo() + { + BatchingId = res.BatchingId, + GoodName = order.MorkOrder.GoodsName, + Loc = ushort.Parse(res.BatchingLoc), + SuborderId = order.MorkOrder.SuborderId, + SortNum = order.MorkOrder.SortNum, + RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 + }); + } + } + } + } + } + }); + } + + public override void MainTask() + { + mORKM.AllowRun = mORKM.InitComplete; + if (Json.Data.IsVerify) + IsHealth = mORKM.InitComplete; + else + IsHealth = true; + + TakeBowlTask(); + + TakeNoodleTask(); + + OutNoodleTask(); + + SingleDetect(); + + TurntableControl(); + } + + private void BowlControl(OrderLocInfo orderLocInfo) + { + if (orderLocInfo.Loc >= 10 && orderLocInfo.Loc <= 11) + { + mORKM.TakeBowlId = orderLocInfo.SuborderId; + mORKM.TakeBowName = orderLocInfo.GoodName; + mORKM.TakeBowSortNum = orderLocInfo.SortNum; + TakeBowlControl(orderLocInfo.Loc); + OrderChange(mORKM.TakeBowlId, ORDER_STATUS.COOKING); + DeviceProcessLogShow($"订单【{mORKM.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); + mORKM.TakeBowlInterlock = true; + } + } + + /// + /// 取碗控制 + /// + private void TakeBowlTask() + { + if (mORKM.AllowRun && mORKM.TakeBowlTask.Count > 0 && !mORKM.DropBowlMechanismStatus && !mORKM.TakeBowlInterlock) + { + ushort BowLoc = 0; + var res = orderMaterialDelivery?.BatchingInfo?.Where(p => p.BatchingId == mORKM.TakeBowlTask.ElementAt(0).BatchingId).ToList(); + if (res == null || res?.Count == 0) + { + if (mORKM.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) BowlControl(orderLocInfo); + } + else + { + foreach (var item in res) + { + if (ushort.TryParse(item.BatchingLoc, out ushort loc)) + { + if (loc == 10 && mORKM.SmallBowlYesOrNoCheck) + { + BowLoc = loc; + break; + } + else if (loc == 11 && mORKM.LargeBowYesOrNoCheck) + { + BowLoc = loc; + break; + } + } + } + + if (BowLoc >= 10 && BowLoc <= 11) + { + if (mORKM.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) + { + orderLocInfo.Loc = BowLoc; + BowlControl(orderLocInfo); + } + } + } + } + } + + /// + /// 转台控制 + /// + private void TurntableControl() + { + if (Global.EnableLocalSimOrder) + { + //不做轮询,直接取面,模拟订单使用 + if (mORKM.SiloInPlace && !mORKM.Feeding && mORKM.InitComplete && !mORKM.AllowTakeNoodle && mORKM.RBTakeNoodleTask.Count > 0) + { + if (mORKM.TurntableLowPosition) + { + TurntableStart(mORKM.RBTakeNoodleTask.ElementAt(0).Loc); + mORKM.TurntableLocLists.Clear(); + mORKM.AllowTakeNoodle = true; + DeviceProcessLogShow($"控制机器人去转台【{mORKM.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面"); + } + } + } + else + { + //正常轮询 + if (Delay.GetInstance("到位检测延时").Start(mORKM.SiloInPlace, 2)) + { + if (mORKM.SiloInPlace && !mORKM.Feeding && mORKM.InitComplete && !mORKM.AllowTakeNoodle && mORKM.RBTakeNoodleTask.Count > 0) + { + + var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKM.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); + if (result != null) + { + var res = result.FirstOrDefault(P => P.BatchingLoc == mORKM.CurrentFeedbackLoc.ToString()); + if (mORKM.TurntableLowPosition && res != null) + { + TurntableStart(mORKM.CurrentFeedbackLoc); + mORKM.TurntableLocLists.Clear(); + mORKM.AllowTakeNoodle = true; + DeviceProcessLogShow($"控制机器人去转台【{mORKM.CurrentFeedbackLoc}】号位置取面"); + } + else + { + if (!mORKM.TurntableInterlock) + { + foreach (var item in result) + { + if (ushort.TryParse(item.BatchingLoc, out ushort loc)) + { + if (mORKM.CurrentFeedbackLoc != loc && !mORKM.TurntableLocLists.Contains(loc)) + { + if (!mORKM.TurntableLowPosition) + { + DeviceProcessLogShow($"执行了转台启动互锁信号复位"); + } + TurntableStart(loc); + DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]"); + break; + } + else if (mORKM.CurrentFeedbackLoc == loc && !mORKM.TurntableLocLists.Contains(loc)) mORKM.TurntableLocLists.Add(loc); + } + } + } + } + } + else DeviceProcessLogShow("未找到可用的物料信息"); + } + } + } + + //补料中检测 + if (RTrig.GetInstance("mORKS.Feeding").Start(mORKM.Feeding)) + { + mORKM.AllowTakeNoodle = false; + mORKM.TakeNoodleInterlock = false; + } + + //转台到位检测 + if (RTrig.GetInstance("TurntableInPlace").Start(mORKM.SiloInPlace && mORKM.CurrentLoc == mORKM.CurrentFeedbackLoc)) + { + + mORKM.TurntableInterlock = false; + DeviceProcessLogShow("转台到位检测"); + } + + //补料完成检测 + if (RTrig.GetInstance("FeedComplete").Start(mORKM.FeedComplete)) + { + if (!mORKM.AllowTakeNoodle && mORKM.TurntableLocLists.Count > 0) + { + mORKM.TurntableLocLists.Clear(); + mORKM.TurntableInterlock = false; + DeviceProcessLogShow("补料完成检测"); + } + } + + } + + /// + /// 取面任务 + /// + private void TakeNoodleTask() + { + //取面控制 + if (mORKM.AllowRun && mORKM.RobotStatus && !mORKM.Feeding && !mORKM.RobotTaskInterlock && mORKM.AllowTakeNoodle && mORKM.SiloInPlace && !mORKM.TakeNoodleInterlock && mORKM.RBTakeNoodleTask.Count > 0) + { + if (mORKM.CurrentLoc == mORKM.CurrentFeedbackLoc) + { + //int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置 + int loc = mORKM.nsm.ToList().FindIndex(p => p.NoodleCookerStatus == false && p.IsShield == false);//查找煮面炉空闲位置 + if (loc >= 0 && loc <= 5) + { + //if (!Json.Data.parSets.ElementAt(loc).IsShield)//检查该煮面篮是否被屏蔽 + //{ + if (mORKM.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) + { + //写入煮面时间 + List values = new List(); + values.Add(Json.Data.parSets.ElementAt(loc).Minute); + values.Add(Json.Data.parSets.ElementAt(loc).Second); + WriteData($"VW{324 + (loc * 4)}", values.ToArray()); + + mORKM.CurrentLoc = 0; + mORKM.CookNodelId[loc] = orderLocInfo.SuborderId; + mORKM.NoodleCookerStatus[loc] = true; + SetFallNoodleLoc((ushort)(loc + 1)); + //机器人开始取面 + OrderChange(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); + DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); + + mORKM.TakeNoodleInterlock = true; + } + } + } + } + } + + /// + /// 出餐控制 + /// + private void OutNoodleTask() + { + if (mORKM.AllowInvertedFace && mORKM.RobotTaskInterlock && !mORKM.TakeNoodleInterlock && mORKM.RobotStatus) + { + int loc = Array.FindIndex(mORKM.CookNodelId, p => p == mORKM.IngredientsCompleteId && p.Length > 0); + if (loc >= 0 && loc <= 5) + { + if (mORKM.CookNoodleCom[loc]) + { + SetTakeNoodleLoc((ushort)(loc + 1)); + mORKM.NoodleCookerStatus[loc] = false; + WriteData($"VW260", (ushort)0);//设置出汤时间 + OrderChange(mORKM.IngredientsCompleteId, ORDER_STATUS.COMPLETED_COOK); + DeviceProcessLogShow($"订单【{mORKM.IngredientsCompleteId}】制作完成"); + mORKM.CookCompleteFlatBit = true; + mORKM.OutMealId = mORKM.IngredientsCompleteId; + mORKM.OutMealName = mORKM.IngredientsCompleteName; + mORKM.OutMealSortNum = mORKM.IngredientsCompleteSortNum; + mORKM.IngredientsCompleteId = string.Empty; + mORKM.CookNodelId[loc] = string.Empty; + DeviceProcessLogShow($"{loc + 1} 号位置出餐控制,订单ID:{mORKM.OutMealId}"); + mORKM.CookNoodleCom[loc] = false; + } + } + } + } + + /// + /// 信号检测 + /// + private void SingleDetect() + { + //允许倒面信号检测 + if (RTrig.GetInstance("AllowFallNoodle").Start(mORKM.AllowInvertedFace)) + { + mORKM.IngredientsCompleteId = mORKM.TakeBowlId; + mORKM.IngredientsCompleteName = mORKM.TakeBowName; + mORKM.IngredientsCompleteSortNum = mORKM.TakeBowSortNum; + mORKM.TakeBowSortNum = 0; + mORKM.TakeBowlId = string.Empty; + mORKM.TakeBowName = string.Empty; + DeviceProcessLogShow($"碗到位,允许到面,{mORKM.IngredientsCompleteId}"); + mORKM.TakeBowlInterlock = false; + } + + //取餐完成逻辑处理 + if (RTrig.GetInstance("CompleteChange1").Start(mORKM.DiningComplete) && mORKM.CookCompleteFlatBit == true) + { + OrderChange(mORKM.OutMealId, ORDER_STATUS.COMPLETED_TAKE); + DeviceProcessLogShow($"订单【{mORKM.OutMealId}】取餐完成"); + WriteData("M10.1", false); + DeviceProcessLogShow($"出餐订单序号【{mORKM.OutMealSortNum}】"); + VoiceAPI.Speak(mORKM.OutMealSortNum.ToString()); + //DeviceProcessLogShow($"叫号系统通知主题【MORKS/VoiceCall/{DeviceId}】"); + //Plugin.GetInstance().GetPlugin().Publish($"MORKS/VoiceCall/{DeviceId}", mORKS.OutMealSortNum.ToString()); + mORKM.CookCompleteFlatBit = false; + mORKM.OutMealId = string.Empty; + mORKM.OutMealName = string.Empty; + mORKM.OutMealSortNum = 0; + } + + //机器人取面完成信号检测 + if (RTrig.GetInstance("TakeNoodleComplete").Start(mORKM.RobotTakeNoodleCom)) + { + mORKM.TakeNoodleInterlock = false; + mORKM.AllowTakeNoodle = false; + mORKM.TurntableInterlock = false; + DeviceProcessLogShow("机器人取面完成信号检测"); + } + + int OutMealRequstCount = mORKM.CookNoodleCom.Where(p => p == true).ToList().Count; + //int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count - Json.Data.parSets.Where(x => x.IsShield == true).ToList().Count; + int mlCount = mORKM.nsm.Where(p => p.NoodleCookerStatus == true && p.IsShield == false).ToList().Count; + int index = Array.FindIndex(mORKM.CookNodelId, p => p == mORKM.IngredientsCompleteId); + + bool isok = index >= 0 && index < mORKM.CookNoodleCom.Length && mORKM.CookNoodleCom[index]; + + mORKM.PriorityJudgment = Delay.GetInstance("取餐优先级判断").Start(mORKM.TurntableLocLists.Count > 0 && !mORKM.TurntableLowPosition, 4); + //mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowInvertedFace && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment); + mORKM.RobotTaskInterlock = isok && mORKM.AllowInvertedFace && (mlCount >= 2 || mORKM.RBTakeNoodleTask.Count == 0 || mORKM.PriorityJudgment); + + + } + /// + /// 语音提醒取餐 + /// + /// + private void WaitMeaLSpeak(string meal) + { + //VoiceAPI.m_SystemPlayWav(@"Vioce\电子提示音.wav"); + //Thread.Sleep(1000); + //if (meal != null) mORKS.speech.Speak(meal); + //VoiceAPI.m_SystemPlayWav(@"Vioce\取餐通知.wav"); + } + + #region PLC 控制函数 + + private void WriteData(string address, object value) + { + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value }); + } + + /// + /// 设备初始化 + /// + public async void DeviceInit() + { + WriteData("M0.0", true); + await Task.Delay(1000); + WriteData("M0.0", false); + } + + /// + /// 取碗控制 + /// + /// + private void TakeBowlControl(ushort loc) + { + if (loc == 10)//一次性碗 + { + WriteData("M9.1", true); + } + else if (loc == 11)//大碗 + { + WriteData("M9.0", true); + } + } + + /// + /// 启动转台 + /// + /// + private void TurntableStart(ushort loc) + { + if (loc >= 1 && loc <= 5) + { + mORKM.CurrentLoc = loc; + mORKM.TurntableInterlock = true; + mORKM.TurntableLocLists.Add(loc); + WriteData($"M13.{loc - 1}", true); + } + } + + /// + /// 设置倒面位置 + /// + /// + private void SetFallNoodleLoc(ushort loc) + { + if (loc >= 1 && loc <= 6) + WriteData($"M14.{loc - 1}", true); + } + + /// + /// 设置取面位置 + /// + /// + private void SetTakeNoodleLoc(ushort loc) + { + if (loc >= 1 && loc <= 6) + WriteData($"M15.{loc - 1}", true); + } + + + + public override void SimOrder() + { + EventBus.EventBus.GetInstance().Subscribe(0, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event != null && @event is MorksSimorderModel msm) + { + string guid = Guid.NewGuid().ToString(); + if (msm.NoodleLoc >= 1 && msm.NoodleLoc <= 5) + { + mORKM.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.NoodleLoc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:面条位置【{(ushort)msm.NoodleLoc}】"); + } + + if (msm.Bowloc >= 10 && msm.Bowloc <= 11) + { + mORKM.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.Bowloc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:碗位置【{(ushort)msm.Bowloc}】"); + } + + } + }); + } + #endregion + + + } +} diff --git a/BPASmartClient.MorkMV1/DataServer.cs b/BPASmartClient.MorkMV1/DataServer.cs new file mode 100644 index 00000000..515a8ec2 --- /dev/null +++ b/BPASmartClient.MorkMV1/DataServer.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using BPASmartClient.MQTT; +using BPA.Message; +using BPASmartClient.Model; + +namespace BPASmartClient.MorkMV1 +{ + public class DataServer + { + + private volatile static DataServer _Instance; + public static DataServer GetInstance => _Instance ?? (_Instance = new DataServer()); + private DataServer() { } + + public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); + + MQTTProxy mQTTProxy = new MQTTProxy(); + public void Init() + { + mQTTProxy.Connected = new Action(() => + { + mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); + ThreadManage.GetInstance().StartLong(new Action(() => + { + morkS.MorkS_OrderCount = Json.Data.Count; + SendScreenDataModel sendScreenDataModel = new SendScreenDataModel(); + sendScreenDataModel.Name = ScreenDeviceType.煮面机; + sendScreenDataModel.Value = morkS.ToJSON(); + mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), sendScreenDataModel.ToJSON()); + Thread.Sleep(100); + }), "海科食堂大屏监听"); + }); + mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + } + + //订单信息(正在制作,等待制作,制作完成) + //煮面炉上下状态(6个煮面炉上或下) + //温度状态(煮面炉温度是否到达) + //料仓位置(当前料仓在几号位置) + //料仓上下物料检测 + //落碗机构缺碗检测 + //机器人状态 + //当日订单总量 + //报警信息 + } +} diff --git a/BPASmartClient.MorkMV1/DeviceData.cs b/BPASmartClient.MorkMV1/DeviceData.cs new file mode 100644 index 00000000..78715248 --- /dev/null +++ b/BPASmartClient.MorkMV1/DeviceData.cs @@ -0,0 +1,193 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BPASmartClient.MorkMV1 +{ + public class DeviceData : IStatus + { + /// + /// 初始化启动 + /// + [VariableMonitor("初始化启动", "M0.0", "320")] + public bool InitStart { get; set; } + + /// + /// 初始化完成 + /// + [VariableMonitor("初始化完成", "M0.1", "321")] + public bool InitComplete { get; set; } + + /// + /// 移碗丝杆初始化完成 + /// + [VariableMonitor("移碗丝杆初始化完成", "M0.2", "322")] + public bool MoveScrewRodInitCom { get; set; } + + /// + /// 供碗1初始化完成 + /// + [VariableMonitor("供碗1初始化完成", "M0.3", "323")] + public bool SacrificialVesselInitCom { get; set; } + + /// + /// 气缸推杆初始化完成 + /// + [VariableMonitor("气缸推杆初始化完成", "M0.4", "324")] + public bool CylinderInitCom { get; set; } + + /// + /// 煮面机初始化完成 + /// + [VariableMonitor("煮面机初始化完成", "M0.5", "325")] + public bool NoodleCookerInitCom { get; set; } + + /// + /// 机器人初始化完成 + /// + [VariableMonitor("机器人初始化完成", "M0.6", "326")] + public bool RobotInitCom { get; set; } + + /// + /// 料仓初始化完成 + /// + [VariableMonitor("料仓初始化完成", "M0.7", "327")] + public bool SiloInitCom { get; set; } + + /// + /// 故障复位/停止 + /// + [VariableMonitor("故障复位/停止", "M1.0", "328")] + public bool FaultResetOrStop { get; set; } + + /// + /// 落碗1,大碗 + /// + [VariableMonitor("落碗1,大碗", "M9.0", "392")] + public bool DropBowlOne { get; set; } + + /// + /// 落碗2,一次性碗 + /// + [VariableMonitor("落碗2,一次性碗", "M9.1", "393")] + public bool DropBowlTow { get; set; } + + /// + /// 允许倒面 + /// + [VariableMonitor("允许倒面", "M10.0", "400")] + public bool AllowInvertedFace { get; set; } + + /// + /// 出餐完成 + /// + [VariableMonitor("出餐完成", "M10.1", "401")] + public bool DiningComplete { get; set; } + + /// + /// 落碗机构状态,1:忙碌 0:空闲 + /// + [VariableMonitor("落碗机构状态,1:忙碌 0:空闲", "M10.4", "404")] + public bool DropBowlMechanismStatus { get; set; } + + /// + /// 定位标志,1:忙碌 0:空闲 + /// + [VariableMonitor("定位标志,1:忙碌 0:空闲", "M12.2", "418")] + public bool FixedFlag { get; set; } + + /// + /// 定位启动 + /// + [VariableMonitor("定位启动", "M12.3", "419")] + public bool FixedStart { get; set; } + + /// + /// 料仓到位 + /// + [VariableMonitor("料仓到位", "M13.5", "429")] + public bool SiloInPlace { get; set; } + + /// + /// 机器人料仓取面完成 + /// + [VariableMonitor("机器人去料仓取面完成", "M16.7", "455")] + public bool RobotTakeNoodleCom { get; set; } + + /// + /// 机器人状态 + /// + [VariableMonitor("机器人状态", "M17.4", "460")] + public bool RobotStatus { get; set; } + + /// + /// 一次性碗有无检测 + /// + [VariableMonitor("一次性碗有无检测", "M18.0", "464")] + public bool SmallBowlYesOrNoCheck { get; set; } + + /// + /// 大碗有无检测 + /// + [VariableMonitor("大碗有无检测", "M18.1", "465")] + public bool LargeBowYesOrNoCheck { get; set; } + + /// + /// 转台高位 + /// + [VariableMonitor("转台高位", "M18.2", "466")] + public bool TurntableHighPosition { get; set; } + + /// + /// 转台低位 + /// + [VariableMonitor("转台低位", "M18.3", "467")] + public bool TurntableLowPosition { get; set; } + + /// + /// 煮面完成 + /// + [VariableMonitor("煮面完成", "V17.0")] + public bool[] CookNoodleCom { get; set; } = new bool[6]; + + /// + /// 本地/远程 + /// + [VariableMonitor("本地/远程", "V18.0")] + public bool LocalOrRemote { get; set; } + + /// + /// 温度到达 + /// + [VariableMonitor("温度到达", "V18.7")] + public bool TemperatureReaches { get; set; } + + /// + /// 加热中 + /// + [VariableMonitor("加热中", "V18.6")] + public bool Heating { get; set; } + + /// + /// 转台当前位置 + /// + [VariableMonitor("转台当前位置", "VW770")] + public ushort CurrentLoc { get; set; } + + /// + /// 补料完成 + /// + [VariableMonitor("补料完成", "M101.6", "1134")] + public bool FeedComplete { get; set; } + + /// + /// 补料中 + /// + [VariableMonitor("补料中", "M102.6", "1142")] + public bool Feeding { get; set; } + + } +} diff --git a/BPASmartClient.MorkMV1/GVL_MorkMV1.cs b/BPASmartClient.MorkMV1/GVL_MorkMV1.cs new file mode 100644 index 00000000..faca957a --- /dev/null +++ b/BPASmartClient.MorkMV1/GVL_MorkMV1.cs @@ -0,0 +1,353 @@ +using BPASmartClient.Device; +using BPASmartClient.Model; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMV1 +{ + public class GVL_MorkMV1 : IStatus + { + #region 临时变量 + /// + /// 允许运行 + /// + [VariableMonitor("允许运行")] + public bool AllowRun { get; set; } + + /// + /// 优先级判断 + /// + [VariableMonitor("优先级判断条件")] + public bool PriorityJudgment { get; set; } + + /// + /// 机器人任务互锁信号,false:取面,true:出餐 + /// + [VariableMonitor("机器人任务互锁信号")] + public bool RobotTaskInterlock { get; set; } + + /// + /// 取碗互锁信号 + /// + [VariableMonitor("取碗互锁信号")] + public bool TakeBowlInterlock { get; set; } + + /// + /// 取面互锁信号 + /// + [VariableMonitor("取面互锁信号")] + public bool TakeNoodleInterlock { get; set; } + + /// + /// 出面中 + /// + [VariableMonitor("出面中")] + public bool OutNoodleing { get; set; } + + /// + /// 允许取面 + /// + [VariableMonitor("允许取面")] + public bool AllowTakeNoodle { get; set; } + + /// + /// 转台互锁信号 + /// + [VariableMonitor("转台互锁信号")] + public bool TurntableInterlock { get; set; } + + + /// + /// 煮面炉状态,True:忙碌,false:空闲 + /// + [VariableMonitor("煮面炉状态")] + public bool[] NoodleCookerStatus { get; set; } = new bool[6]; + + /// + /// 转台当前启动位置 + /// + [VariableMonitor("转台当前启动位置")] + public ushort CurrentLoc { get; set; } = 0; + + /// + /// 制作完成标志 + /// + [VariableMonitor("制作完成标志")] + public bool CookCompleteFlatBit { get; set; } + + /// + /// 取碗任务数量 + /// + [VariableMonitor("取碗任务数量")] + public int TakeBowlTaskCount { get; set; } + + /// + /// 取面任务数量 + /// + [VariableMonitor("取面任务数量")] + public int RBTakeNoodleTaskCount { get; set; } + #endregion + + #region 列表数据 + /// + /// 机器人取面位置队列 + /// + public ConcurrentQueue RBTakeNoodleTask { get; set; } = new ConcurrentQueue(); + + /// + /// 出碗队列 + /// + public ConcurrentQueue TakeBowlTask { get; set; } = new ConcurrentQueue(); + + + public List doOrderEvents { get; set; } = new List(); + + public ConcurrentDictionary doe { get; set; } = new ConcurrentDictionary(); + + public List HistorySuborderId { get; set; } = new List(); + + public NoodleShidModel[] nsm { get; set; } = new NoodleShidModel[6] { new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel() }; + #endregion + + #region 订单ID记录 + /// + /// 取碗订单ID + /// + public string TakeBowlId { get; set; } = string.Empty; + /// + /// 取碗订单名称 + /// + public string TakeBowName { get; set; } = string.Empty; + /// + /// 配料完成订单名称 + /// + public int TakeBowSortNum { get; set; } = 0; + + + /// + /// 允许倒面位置ID + /// + public string IngredientsCompleteId { get; set; } = string.Empty; + /// + /// 配料完成订单名称 + /// + public string IngredientsCompleteName { get; set; } = string.Empty; + /// + /// 配料完成订单名称 + /// + public int IngredientsCompleteSortNum { get; set; } = 0; + + + /// + /// 煮面口对应的订单ID + /// + public string[] CookNodelId { get; set; } = new string[6] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; + + /// + /// 出餐订单ID + /// + public string OutMealId { get; set; } = string.Empty; + /// + /// 出餐订单名称 + /// + public string OutMealName { get; set; } = string.Empty; + /// + /// 出餐排序号 + /// + public int OutMealSortNum { get; set; } = 0; + + + /// + /// 转台位置轮询 + /// + public List TurntableLocLists { get; set; } = new List(); + + #endregion + + #region device Data + /// + /// 初始化启动 + /// + [VariableMonitor("初始化启动", "M0.0", "320")] + public bool InitStart { get; set; } + + /// + /// 初始化完成 + /// + [VariableMonitor("初始化完成", "M0.1", "321")] + public bool InitComplete { get; set; } + + /// + /// 移碗丝杆初始化完成 + /// + [VariableMonitor("移碗丝杆初始化完成", "M0.2", "322")] + public bool MoveScrewRodInitCom { get; set; } + + /// + /// 供碗1初始化完成 + /// + [VariableMonitor("供碗1初始化完成", "M0.3", "323")] + public bool SacrificialVesselInitCom { get; set; } + + /// + /// 气缸推杆初始化完成 + /// + [VariableMonitor("气缸推杆初始化完成", "M0.4", "324")] + public bool CylinderInitCom { get; set; } + + /// + /// 煮面机初始化完成 + /// + [VariableMonitor("煮面机初始化完成", "M0.5", "325")] + public bool NoodleCookerInitCom { get; set; } + + /// + /// 机器人初始化完成 + /// + [VariableMonitor("机器人初始化完成", "M0.6", "326")] + public bool RobotInitCom { get; set; } + + /// + /// 料仓初始化完成 + /// + [VariableMonitor("料仓初始化完成", "M0.7", "327")] + public bool SiloInitCom { get; set; } + + /// + /// 故障复位/停止 + /// + [VariableMonitor("故障复位/停止", "M1.0", "328")] + public bool FaultResetOrStop { get; set; } + + /// + /// 落碗1,大碗 + /// + [VariableMonitor("落碗1,大碗", "M9.0", "392")] + public bool DropBowlOne { get; set; } + + /// + /// 落碗2,一次性碗 + /// + [VariableMonitor("落碗2,一次性碗", "M9.1", "393")] + public bool DropBowlTow { get; set; } + + /// + /// 允许倒面 + /// + [VariableMonitor("允许倒面", "M10.0", "400")] + public bool AllowInvertedFace { get; set; } + + /// + /// 出餐完成 + /// + [VariableMonitor("出餐完成", "M10.1", "401")] + public bool DiningComplete { get; set; } + + /// + /// 落碗机构状态,1:忙碌 0:空闲 + /// + [VariableMonitor("落碗机构状态,1:忙碌 0:空闲", "M10.4", "404")] + public bool DropBowlMechanismStatus { get; set; } + + /// + /// 定位标志,1:忙碌 0:空闲 + /// + [VariableMonitor("定位标志,1:忙碌 0:空闲", "M12.2", "418")] + public bool FixedFlag { get; set; } + + /// + /// 定位启动 + /// + [VariableMonitor("定位启动", "M12.3", "419")] + public bool FixedStart { get; set; } + + /// + /// 料仓到位 + /// + [VariableMonitor("料仓到位", "M13.5", "429")] + public bool SiloInPlace { get; set; } + + /// + /// 机器人料仓取面完成 + /// + [VariableMonitor("机器人去料仓取面完成", "M16.7", "455")] + public bool RobotTakeNoodleCom { get; set; } + + /// + /// 机器人状态 + /// + [VariableMonitor("机器人状态", "M17.4", "460")] + public bool RobotStatus { get; set; } + + /// + /// 一次性碗有无检测 + /// + [VariableMonitor("一次性碗有无检测", "M18.0", "464")] + public bool SmallBowlYesOrNoCheck { get; set; } + + /// + /// 大碗有无检测 + /// + [VariableMonitor("大碗有无检测", "M18.1", "465")] + public bool LargeBowYesOrNoCheck { get; set; } + + /// + /// 转台高位 + /// + [VariableMonitor("转台高位", "M18.2", "466")] + public bool TurntableHighPosition { get; set; } + + /// + /// 转台低位 + /// + [VariableMonitor("转台低位", "M18.3", "467")] + public bool TurntableLowPosition { get; set; } + + /// + /// 煮面完成 + /// + [VariableMonitor("煮面完成")] + public bool[] CookNoodleCom { get; set; } = new bool[6]; + + /// + /// 本地/远程 + /// + [VariableMonitor("本地/远程")] + public bool LocalOrRemote { get; set; } + + /// + /// 温度到达 + /// + [VariableMonitor("温度到达")] + public bool TemperatureReaches { get; set; } + + /// + /// 加热中 + /// + [VariableMonitor("加热中")] + public bool Heating { get; set; } + + /// + /// 转台当前位置 + /// + [VariableMonitor("转台当前位置", "VW770", "870")] + public ushort CurrentFeedbackLoc { get; set; } + + /// + /// 补料完成 + /// + [VariableMonitor("补料完成", "M101.6", "1134")] + public bool FeedComplete { get; set; } + + /// + /// 补料中 + /// + [VariableMonitor("补料中", "M102.6", "1142")] + public bool Feeding { get; set; } + #endregion + } +} diff --git a/BPASmartClient.MorkMV1/GlobalUsing.cs b/BPASmartClient.MorkMV1/GlobalUsing.cs new file mode 100644 index 00000000..f3573942 --- /dev/null +++ b/BPASmartClient.MorkMV1/GlobalUsing.cs @@ -0,0 +1,26 @@ +global using System; +global using System.Collections.Generic; +global using BPA.Message.Enum; +global using BPASmartClient.Device; +global using BPASmartClient.EventBus; +global using BPASmartClient.Model; +global using BPASmartClient.Peripheral; +global using static BPASmartClient.EventBus.EventBus; +global using BPASmartClient.Helper; +global using System.Threading; +global using BPASmartClient.Message; +global using BPA.Message; +global using System.Linq; +global using BPASmartClient.Model.PLC; +global using System.Threading.Tasks; +global using System.Reflection; +global using BPASmartClient.MorkMV1.Model; +global using System.Collections.ObjectModel; +global using BPASmartClient.MorkMV1.ViewModel; +global using BPASmartClient.Business; +global using BPASmartClient.Model.小炒机; +global using BPA.Models; +global using System.Windows.Forms; +global using System.Media; + + diff --git a/BPASmartClient.MorkMV1/Model/Global.cs b/BPASmartClient.MorkMV1/Model/Global.cs new file mode 100644 index 00000000..a1bfbeac --- /dev/null +++ b/BPASmartClient.MorkMV1/Model/Global.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMV1.Model +{ + public class Global + { + public static bool EnableLocalSimOrder { get; set; } + } +} diff --git a/BPASmartClient.MorkMV1/Model/MorksPar.cs b/BPASmartClient.MorkMV1/Model/MorksPar.cs new file mode 100644 index 00000000..241eddce --- /dev/null +++ b/BPASmartClient.MorkMV1/Model/MorksPar.cs @@ -0,0 +1,16 @@ +using BPASmartClient.Model; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace BPASmartClient.MorkMV1.Model +{ + internal class MorksPar + { + public ObservableCollection parSets { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.MorkMV1/Model/ParSet.cs b/BPASmartClient.MorkMV1/Model/ParSet.cs new file mode 100644 index 00000000..03261db1 --- /dev/null +++ b/BPASmartClient.MorkMV1/Model/ParSet.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public class ParSet + { + public ushort Minute { get { return _mMinute; } set { _mMinute = value; } } + private ushort _mMinute; + + public ushort Second { get { return _mSecond; } set { _mSecond = value; } } + private ushort _mSecond; + + + public bool IsShield { get { return _mIsShield; } set { _mIsShield = value; } } + private bool _mIsShield; + + + public string TextBlockContext { get { return _mTextBlockContext; } set { _mTextBlockContext = value; } } + private string _mTextBlockContext; + + public string CheckBoxContext { get { return _mCheckBoxContext; } set { _mCheckBoxContext = value; } } + private string _mCheckBoxContext; + + } +} diff --git a/BPASmartClient.MorkMV1/Model/WritePar.cs b/BPASmartClient.MorkMV1/Model/WritePar.cs new file mode 100644 index 00000000..363fb652 --- /dev/null +++ b/BPASmartClient.MorkMV1/Model/WritePar.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMV1.Model +{ + public class WritePar + { + public string Address { get; set; } + public object Value { get; set; } + } +} diff --git a/BPASmartClient.MorkMV1/NoodleShidModel.cs b/BPASmartClient.MorkMV1/NoodleShidModel.cs new file mode 100644 index 00000000..e9833f29 --- /dev/null +++ b/BPASmartClient.MorkMV1/NoodleShidModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMV1 +{ + public class NoodleShidModel + { + /// + /// 是否被屏蔽,true:屏蔽,false:未屏蔽 + /// + public bool IsShield { get; set; } + + /// + /// 是否忙碌,true:忙碌,FALSE:空闲 + /// + public bool NoodleCookerStatus { get; set; } + } +} diff --git a/BPASmartClient.MorkMV1/OrderLocInfo.cs b/BPASmartClient.MorkMV1/OrderLocInfo.cs new file mode 100644 index 00000000..33c1ffaf --- /dev/null +++ b/BPASmartClient.MorkMV1/OrderLocInfo.cs @@ -0,0 +1,24 @@ +//using BPA.Message; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; + +//namespace BPASmartClient.MorkMV1 +//{ +// public class OrderLocInfo +// { +// public string SuborderId { get; set; } +// public ushort Loc { get; set; } +// public ushort RecipeNumber { get; set; } +// public int BatchingId { get; set; } +// public string GoodName { get; set; } +// public int SortNum { get; set; } + +// public int RecipeId { get; set; } + +// public List Recipes { get; set; } + +// } +//} diff --git a/BPASmartClient.MorkMV1/View/Debug.xaml b/BPASmartClient.MorkMV1/View/Debug.xaml new file mode 100644 index 00000000..471eab46 --- /dev/null +++ b/BPASmartClient.MorkMV1/View/Debug.xaml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +