diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index dfb1b7ff..e5b10552 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -104,7 +104,7 @@ namespace BPASmartClient.Device /// protected ConcurrentDictionary peripheralStatus = new ConcurrentDictionary(); - protected + protected /// /// 外设设备集合 @@ -145,7 +145,7 @@ namespace BPASmartClient.Device /// /// /// - public void WriteControlExact(string address, object value,int i) + public void WriteControlExact(string address, object value, int i) { if (peripherals != null) { @@ -205,7 +205,7 @@ namespace BPASmartClient.Device Status.Update($"{TypeName}.{key}", peripheral.GetAllStatus()[key]); } } - if(dicPort2peripheralStatus.ContainsKey(i)) + if (dicPort2peripheralStatus.ContainsKey(i)) { dicPort2peripheralStatus[i] = newPeripheralStatus; } @@ -361,6 +361,7 @@ namespace BPASmartClient.Device { ThreadManage.GetInstance().StopTask($"GvlStatusMonitor:{DeviceId}", new Action(() => { + ActionManage.GetInstance.Send("ClearOrders"); ResetProgram(); ResetStatus(); InitTask(); @@ -380,7 +381,7 @@ namespace BPASmartClient.Device { ReadData(); Thread.Sleep(10); - }), $"ReadData:{DeviceId}",true); + }), $"ReadData:{DeviceId}", true); #endregion #region 任务流程 diff --git a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs index 53bbb097..07f19945 100644 --- a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs +++ b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs @@ -14,36 +14,44 @@ namespace BPASmartClient.PLC ModbusTcp modbusTcp = new ModbusTcp(); public override void Init() { - Task.Run(new Action(() => { modbusTcp.ModbusTcpConnect(communicationPar.IPAddress, communicationPar.IPPort); })); //PLC 设备连接 - - Thread.Sleep(1000); - - ThreadManage.GetInstance().StartLong(new Action(() => + modbusTcp.IsReconnect = true; + Task.Run(new Action(() => { - IsConnected = modbusTcp.Connected; - if (!IsConnected) IsWork = false; - while (IsConnected) + modbusTcp.ConnectOk = new Action(() => { - IsWork = true; - foreach (var par in variables) + ThreadManage.GetInstance().StartLong(new Action(() => { - if (par?.Address.Length > 0) + IsConnected = modbusTcp.Connected; + if (!IsConnected) IsWork = false; + while (IsConnected) { - var res = modbusTcp.Read(par.Address, (ushort)par.ReadLeng); - if (status.ContainsKey(par.Address)) - { - status[par.Address] = res; - } - else + IsWork = true; + foreach (var par in variables) { - status.TryAdd(par.Address, res); + if (par?.Address.Length > 0) + { + var res = modbusTcp.Read(par.Address, (ushort)par.ReadLeng); + if (status.ContainsKey(par.Address)) + { + status[par.Address] = res; + } + else + { + status.TryAdd(par.Address, res); + } + } } + Thread.Sleep(100); } - } - Thread.Sleep(100); - } - Thread.Sleep(1000); - }), $"设备[{DeviceId}][{modbusTcp.IPAdress}]PLC读取线程", true); + Thread.Sleep(1000); + }), $"设备[{DeviceId}][{modbusTcp.IPAdress}]PLC读取线程", true); + }); + modbusTcp.ModbusTcpConnect(communicationPar.IPAddress, communicationPar.IPPort); + })); //PLC 设备连接 + + Thread.Sleep(1000); + + //写入数据 EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) diff --git a/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs b/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs index 1cc13130..a62caf77 100644 --- a/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs +++ b/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs @@ -323,6 +323,12 @@ namespace BPASmartClient.MorkSUpgradedVer mORKS.TakeBowlTaskCount = mORKS.TakeBowlTask.Count; mORKS.RBTakeNoodleTaskCount = mORKS.RBTakeNoodleTask.Count; + for (int i = 0; i < Json.Data.parSets.Count; i++) + { + mORKS.nsm.ElementAt(i).IsShield = Json.Data.parSets.ElementAt(i).IsShield; + mORKS.nsm.ElementAt(i).NoodleCookerStatus = mORKS.NoodleCookerStatus[i]; + } + } /// @@ -507,7 +513,6 @@ namespace BPASmartClient.MorkSUpgradedVer { if (!mORKS.TurntableLowPosition) { - //WriteData("M32.7", false); 定位完成复位 DeviceProcessLogShow($"执行了转台启动互锁信号复位"); } TurntableStart(loc); @@ -562,29 +567,29 @@ namespace BPASmartClient.MorkSUpgradedVer { if (mORKS.CurrentLoc == mORKS.CurrentFeedbackLoc) { - int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置 + //int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置 + int loc = mORKS.nsm.ToList().FindIndex(p => p.NoodleCookerStatus == false && p.IsShield == false);//查找煮面炉空闲位置 if (loc >= 0 && loc <= 5) { - if (!Json.Data.parSets.ElementAt(loc).IsShield)//检查该煮面篮是否被屏蔽 + //if (!Json.Data.parSets.ElementAt(loc).IsShield)//检查该煮面篮是否被屏蔽 + //{ + if (mORKS.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) { - if (mORKS.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()); - - mORKS.CurrentLoc = 0; - mORKS.CookNodelId[loc] = orderLocInfo.SuborderId; - mORKS.NoodleCookerStatus[loc] = true; - SetFallNoodleLoc((ushort)(loc + 1)); - //机器人开始取面 - OrderChange(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); - DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); - - mORKS.TakeNoodleInterlock = true; - } + //写入煮面时间 + 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()); + + mORKS.CurrentLoc = 0; + mORKS.CookNodelId[loc] = orderLocInfo.SuborderId; + mORKS.NoodleCookerStatus[loc] = true; + SetFallNoodleLoc((ushort)(loc + 1)); + //机器人开始取面 + OrderChange(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); + DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); + + mORKS.TakeNoodleInterlock = true; } } } @@ -657,7 +662,8 @@ namespace BPASmartClient.MorkSUpgradedVer } int OutMealRequstCount = mORKS.CookNoodleCom.Where(p => p == true).ToList().Count; - int mlCount = mORKS.NoodleCookerStatus.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 = mORKS.nsm.Where(p => p.NoodleCookerStatus == true && p.IsShield == false).ToList().Count; int index = Array.FindIndex(mORKS.CookNodelId, p => p == mORKS.IngredientsCompleteId); bool isok = index >= 0 && index < mORKS.CookNoodleCom.Length && mORKS.CookNoodleCom[index]; diff --git a/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs b/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs index 159574ed..e923f434 100644 --- a/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs +++ b/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs @@ -107,6 +107,8 @@ namespace BPASmartClient.MorkSUpgradedVer public List doOrderEvents { get; set; } = new List(); 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记录 diff --git a/BPASmartClient.MorkSUpgradedVer/NoodleShidModel.cs b/BPASmartClient.MorkSUpgradedVer/NoodleShidModel.cs new file mode 100644 index 00000000..6a9d27c8 --- /dev/null +++ b/BPASmartClient.MorkSUpgradedVer/NoodleShidModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkSUpgradedVer +{ + public class NoodleShidModel + { + /// + /// 是否被屏蔽,true:屏蔽,false:未屏蔽 + /// + public bool IsShield { get; set; } + + /// + /// 是否忙碌,true:忙碌,FALSE:空闲 + /// + public bool NoodleCookerStatus { get; set; } + } +} diff --git a/BPASmartClient.ViewModel/OrderStatusViewModel.cs b/BPASmartClient.ViewModel/OrderStatusViewModel.cs index fcab5843..ab3b4d1a 100644 --- a/BPASmartClient.ViewModel/OrderStatusViewModel.cs +++ b/BPASmartClient.ViewModel/OrderStatusViewModel.cs @@ -38,14 +38,14 @@ namespace BPASmartClient.ViewModel public static void Init() { //清除订单数据 - //ActionManage.GetInstance.Register(new Action(() => - //{ - // Application.Current.Dispatcher.Invoke(() => - // { - // orderStatusLists.Clear(); - // WaitTakeMeal.Clear(); - // }); - //}), "ClearOrders"); + ActionManage.GetInstance.Register(new Action(() => + { + Application.Current.Dispatcher.Invoke(() => + { + orderStatusLists.Clear(); + WaitTakeMeal.Clear(); + }); + }), "ClearOrders"); ActionManage.GetInstance.Register(new Action((o) => {