@@ -104,7 +104,7 @@ namespace BPASmartClient.Device | |||
/// </summary> | |||
protected ConcurrentDictionary<string, object> peripheralStatus = new ConcurrentDictionary<string, object>(); | |||
protected | |||
protected | |||
/// <summary> | |||
/// 外设设备集合 | |||
@@ -145,7 +145,7 @@ namespace BPASmartClient.Device | |||
/// </summary> | |||
/// <param name="address"></param> | |||
/// <param name="value"></param> | |||
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 任务流程 | |||
@@ -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<WriteModel>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
@@ -323,6 +323,12 @@ namespace BPASmartClient.MorkSUpgradedVer | |||
mORKS.TakeBowlTaskCount = mORKS.TakeBowlTask.Count; | |||
mORKS.RBTakeNoodleTaskCount = mORKS.RBTakeNoodleTask.Count; | |||
for (int i = 0; i < Json<MorksPar>.Data.parSets.Count; i++) | |||
{ | |||
mORKS.nsm.ElementAt(i).IsShield = Json<MorksPar>.Data.parSets.ElementAt(i).IsShield; | |||
mORKS.nsm.ElementAt(i).NoodleCookerStatus = mORKS.NoodleCookerStatus[i]; | |||
} | |||
} | |||
/// <summary> | |||
@@ -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<MorksPar>.Data.parSets.ElementAt(loc).IsShield)//检查该煮面篮是否被屏蔽 | |||
//if (!Json<MorksPar>.Data.parSets.ElementAt(loc).IsShield)//检查该煮面篮是否被屏蔽 | |||
//{ | |||
if (mORKS.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) | |||
{ | |||
if (mORKS.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) | |||
{ | |||
//写入煮面时间 | |||
List<ushort> values = new List<ushort>(); | |||
values.Add(Json<MorksPar>.Data.parSets.ElementAt(loc).Minute); | |||
values.Add(Json<MorksPar>.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<ushort> values = new List<ushort>(); | |||
values.Add(Json<MorksPar>.Data.parSets.ElementAt(loc).Minute); | |||
values.Add(Json<MorksPar>.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<MorksPar>.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]; | |||
@@ -107,6 +107,8 @@ namespace BPASmartClient.MorkSUpgradedVer | |||
public List<DoOrderEvent> doOrderEvents { get; set; } = new List<DoOrderEvent>(); | |||
public List<string> HistorySuborderId { get; set; } = new List<string>(); | |||
public NoodleShidModel[] nsm { get; set; } = new NoodleShidModel[6] { new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel() }; | |||
#endregion | |||
#region 订单ID记录 | |||
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 是否被屏蔽,true:屏蔽,false:未屏蔽 | |||
/// </summary> | |||
public bool IsShield { get; set; } | |||
/// <summary> | |||
/// 是否忙碌,true:忙碌,FALSE:空闲 | |||
/// </summary> | |||
public bool NoodleCookerStatus { get; set; } | |||
} | |||
} |
@@ -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<object[]>((o) => | |||
{ | |||