diff --git a/HBLConsole.Factory/SimpleFactory.cs b/HBLConsole.Factory/SimpleFactory.cs index bc8f041..02bb6e2 100644 --- a/HBLConsole.Factory/SimpleFactory.cs +++ b/HBLConsole.Factory/SimpleFactory.cs @@ -11,7 +11,7 @@ using System.Threading; using System.Collections.Generic; using HBLConsole.Model; using System.Linq; -using BPA.Message; +//using BPA.Message; namespace HBLConsole.Factory diff --git a/HBLConsole.MORKS/Control_MORKS.cs b/HBLConsole.MORKS/Control_MORKS.cs index 00922bd..47cf014 100644 --- a/HBLConsole.MORKS/Control_MORKS.cs +++ b/HBLConsole.MORKS/Control_MORKS.cs @@ -76,10 +76,10 @@ namespace HBLConsole.MORKS { ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() => { - //Json.Data.orderLists.Clear(); mORKS = null; mORKS = new GVL_MORKS(); ActionManage.GetInstance.Send("ResetProgram"); + ActionManage.GetInstance.Send("ClearOrders"); ReadData(); Main(); })); @@ -130,12 +130,13 @@ namespace HBLConsole.MORKS var errorStatus = ModbusTcpHelper.GetInstance.Read((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M235.0"), ReadType.Coils, 1); if (errorStatus != null && errorStatus is bool error) mORKS.Error = error; - ModbusTcpHelper.GetInstance.Readbool(1136, 6, new Action((bools) => + ModbusTcpHelper.GetInstance.Readbool(1136, 7, new Action((bools) => { for (int i = 0; i < 6; i++) { mORKS.NoodleCookerStatus[i] = bools[i]; } + mORKS.Feeding = bools[6]; })); ModbusTcpHelper.GetInstance.Readbool(1144, 6, new Action((bools) => @@ -339,7 +340,7 @@ namespace HBLConsole.MORKS /// private void TurntableControl() { - if (mORKS.TurntableMoveInPlace && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) + if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) { var result = Json.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); if (result != null) @@ -347,6 +348,7 @@ namespace HBLConsole.MORKS var res = result.FirstOrDefault(P => P.BatchingLoc == mORKS.TurntableFeedbackloc.ToString()); if (mORKS.TurntableLowerLimit && res != null) { + //if (mORKS.RBTakeNoodleTask.ElementAt(0).Loc != mORKS.TurntableFeedbackloc) TurntableStart(mORKS.TurntableFeedbackloc); mORKS.TurntableLocLists.Clear(); mORKS.AllowTakeNoodle = true; @@ -386,12 +388,18 @@ namespace HBLConsole.MORKS //补料完成检测 if (RTrig.GetInstance("FeedComplete").Start(mORKS.FeedComplete)) { - if (!mORKS.TurntableLowerLimit && mORKS.TurntableLocLists.Count > 0 && !mORKS.AllowTakeNoodle) + if (!mORKS.AllowTakeNoodle && mORKS.TurntableLocLists.Count > 0) { mORKS.TurntableLocLists.Clear(); mORKS.TurntableInterlock = false; MessageLog.GetInstance.Show("补料完成检测"); } + //if (!mORKS.TurntableLowerLimit && mORKS.TurntableLocLists.Count > 0 && !mORKS.AllowTakeNoodle) + //{ + // mORKS.TurntableLocLists.Clear(); + // mORKS.TurntableInterlock = false; + // MessageLog.GetInstance.Show("补料完成检测"); + //} } } @@ -401,7 +409,7 @@ namespace HBLConsole.MORKS private void TakeNoodleTask() { //取面控制 - if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0) + if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.Feeding && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0) { int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置 if (loc >= 0 && loc <= 5) @@ -414,6 +422,12 @@ namespace HBLConsole.MORKS RobotTakeNoodle(); SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); + //写入煮面时间 + //List values = new List(); + //values.Add(Json.Data.parSets.ElementAt(loc).Minute); + //values.Add(Json.Data.parSets.ElementAt(loc).Second); + //ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray()); + mORKS.TakeNoodleInterlock = true; } } @@ -457,7 +471,7 @@ namespace HBLConsole.MORKS { mORKS.IngredientsCompleteId = mORKS.TakeBowlId; mORKS.TakeBowlId = string.Empty; - MessageLog.GetInstance.Show($"允许到面,{mORKS.IngredientsCompleteId}"); + MessageLog.GetInstance.Show($"碗到位,允许到面,{mORKS.IngredientsCompleteId}"); mORKS.TakeBowlInterlock = false; } diff --git a/HBLConsole.MORKS/GVL_MORKS.cs b/HBLConsole.MORKS/GVL_MORKS.cs index 0d27e46..2c15227 100644 --- a/HBLConsole.MORKS/GVL_MORKS.cs +++ b/HBLConsole.MORKS/GVL_MORKS.cs @@ -233,6 +233,14 @@ namespace HBLConsole.MORKS [VariableMonitor("煮面炉状态", "M102.0", "1136")] public bool[] NoodleCookerStatus { get; set; } = new bool[6] { false, false, false, false, false, false }; + /// + /// 补料中 + /// M102.6 + /// 1142 + /// + [VariableMonitor("补料中", "M102.6", "1142")] + public bool Feeding { get; set; } + /// /// 煮面完成,上升后给信号 /// M103.0 - M103.5 diff --git a/HBLConsole.MainConsole/Main.cs b/HBLConsole.MainConsole/Main.cs index 2a91169..119bfaa 100644 --- a/HBLConsole.MainConsole/Main.cs +++ b/HBLConsole.MainConsole/Main.cs @@ -69,7 +69,6 @@ namespace HBLConsole.MainConsole { ThreadManage.GetInstance.Start(new Action(() => { - //SimpleFactory.GetInstance.DeviceInit();//设备初始化 InternetInfo.ConfigInit();//从 consul 获取配置数据 IotReport.GetInstance.Initialize(); Topics.Clear(); diff --git a/HBLConsole/ViewModel/ViewModelBase.cs b/HBLConsole/ViewModel/ViewModelBase.cs index 24c6cb9..7a465ea 100644 --- a/HBLConsole/ViewModel/ViewModelBase.cs +++ b/HBLConsole/ViewModel/ViewModelBase.cs @@ -162,6 +162,17 @@ namespace HBLConsole.ViewModel public void MqttReceive() { Test(); + + //清除订单数据 + ActionManage.GetInstance.Register(new Action(() => + { + Application.Current.Dispatcher.Invoke(() => + { + orderStatusLists.Clear(); + WaitTakeMeal.Clear(); + }); + }), "ClearOrders"); + ActionManage.GetInstance.Register(new Action((o) => { if (o is MorkOrderPush morkOrderpush) @@ -218,17 +229,19 @@ namespace HBLConsole.ViewModel { int index = Array.FindIndex(orderStatusLists.ToArray(), p => p.OrderPush.SuborderId == orderStatusChange.SuborderId); - if (index >= 0) orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus; + //if (index >= 0) orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus; switch (orderStatusChange.CookingStatus) { case ORDER_STATUS.COOKING: - + if (index >= 0 && index < orderStatusLists.Count) + orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus; break; case ORDER_STATUS.COMPLETED_COOK: - if (index >= 0) + if (index >= 0 && index < orderStatusLists.Count) { App.Current.Dispatcher.BeginInvoke((Action)delegate { + orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus; orderStatusLists.ElementAt(index).EndDate = DateTime.Now.ToString("HH:mm:ss"); TimeSpan timeSpan = DateTime.Now.Subtract(Convert.ToDateTime(orderStatusLists.ElementAt(index).StartDate)); orderStatusLists.ElementAt(index).CompleteDate = $"{timeSpan.TotalSeconds.ToString("0.00")} S";