|
|
@@ -890,11 +890,11 @@ namespace BPASmartClient.DosingSystem |
|
|
|
} |
|
|
|
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}"); |
|
|
|
RecipeNames.Enqueue(RecipeName); |
|
|
|
|
|
|
|
var res = Recipes.FirstOrDefault(p => p.RecipeName == RecipeName); |
|
|
|
App.Current.Dispatcher.Invoke(() => { UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = RecipeName, RawMaterials = res.RawMaterials }); }); |
|
|
|
} |
|
|
|
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); }); |
|
|
|
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); }); |
|
|
|
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配方:{RecipeNames.Count}", Time = DateTime.Now.ToString() }); |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
@@ -1379,13 +1379,10 @@ namespace BPASmartClient.DosingSystem |
|
|
|
recipeProcesses.Clear(); |
|
|
|
TaskManage.GetInstance.StartLong(() => |
|
|
|
{ |
|
|
|
//起始和中转的流水线一直开启。 |
|
|
|
SimensSend.GetInstance.SendSimens.Write("M0.0", true); |
|
|
|
SimensSend.GetInstance.SendSimens.Write("M0.1", true); |
|
|
|
//已经下发在排队的配方。 |
|
|
|
if (RecipeNames.Count > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
SimensSend.GetInstance.SendSimens.Write("M0.0", true); |
|
|
|
SimensSend.GetInstance.SendSimens.Write("M0.1", true); |
|
|
|
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++) |
|
|
|
{ |
|
|
|
//判断IP是否在列表中 |
|
|
@@ -1397,23 +1394,16 @@ namespace BPASmartClient.DosingSystem |
|
|
|
//判断 |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail <= DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 0) |
|
|
|
{ |
|
|
|
//因通信差,添加该代码。 |
|
|
|
if (!doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress)) |
|
|
|
{ |
|
|
|
doDeviceCount.TryAdd(DeviceInquire.GetInstance.devices[i].IpAddress,0); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
if (doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress)) |
|
|
|
{ |
|
|
|
int index = 0; |
|
|
|
int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]; |
|
|
|
if (doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount&& doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]< RecipeNames.Count) |
|
|
|
if (recipeNameNum == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount && recipeNameNum < RecipeNames.Count) |
|
|
|
{ |
|
|
|
//查找 |
|
|
|
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum)); |
|
|
|
if (index >= 0 && index < Recipes.Count) |
|
|
|
{ |
|
|
|
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配方{RecipeNames.ElementAt(recipeNameNum)}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}",Time = DateTime.Now.ToString()}); |
|
|
|
int maxPail = 0; |
|
|
|
//查找配方的最大桶号。 |
|
|
|
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials) |
|
|
@@ -1426,21 +1416,36 @@ namespace BPASmartClient.DosingSystem |
|
|
|
//清除下位设备的最大桶号,下位设备认为配方制作完一个了。 |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1); |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail); |
|
|
|
doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]); |
|
|
|
App.Current.Dispatcher.Invoke(new Action(() => |
|
|
|
doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, recipeNameNum + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]); |
|
|
|
|
|
|
|
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方{RecipeNames.ElementAt(recipeNameNum)}{recipeNameNum}下发到设备{DeviceInquire.GetInstance.devices[i].DeviceName}"); }); |
|
|
|
|
|
|
|
if (doDeviceCount.ContainsKey("192.168.2.10") && UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count) |
|
|
|
{ |
|
|
|
//doDeviceCount 集合 键为各个设备,值为该设备执行过的配方。 |
|
|
|
if (doDeviceCount.ContainsKey("192.168.2.10")&&UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count) |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum))); |
|
|
|
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum))); |
|
|
|
} |
|
|
|
})); |
|
|
|
}); |
|
|
|
} |
|
|
|
if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.180" && recipeNameNum > 1 && recipeProcesses.Count > 0) |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
RecipeModel recipe = recipeProcesses?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)); |
|
|
|
recipe.RecipStatus = "制作完成"; |
|
|
|
UserTreeCompelete.Insert(0, recipe); |
|
|
|
recipeProcesses.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum))); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
doDeviceCount.TryAdd(DeviceInquire.GetInstance.devices[i].IpAddress, 0); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@@ -1502,9 +1507,6 @@ namespace BPASmartClient.DosingSystem |
|
|
|
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); |
|
|
|
if (deviceSet != null && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].IsConnected == true) |
|
|
|
{ |
|
|
|
|
|
|
|
var deviceModbus = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp; |
|
|
|
MessageNotify.GetInstance.ShowRunLog( $"下发配料信息{Recipes.ElementAt(doCount).RecipeName}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}"); |
|
|
|
//传送带停止 |
|
|
|
deviceModbus.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0); |
|
|
|
//设置下料重量 |
|
|
@@ -1553,11 +1555,10 @@ namespace BPASmartClient.DosingSystem |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[ DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1) |
|
|
|
{ |
|
|
|
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0); |
|
|
|
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"中转料仓正在配料,传送带停止", Time = DateTime.Now.ToString() }); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)600); |
|
|
|
SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)900); |
|
|
|
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1); |
|
|
|
} |
|
|
|
} |
|
|
@@ -1587,7 +1588,6 @@ namespace BPASmartClient.DosingSystem |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600); |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1); |
|
|
|
} |
|
|
@@ -1621,9 +1621,6 @@ namespace BPASmartClient.DosingSystem |
|
|
|
if (SimensSend.GetInstance.sendCtrlModel.SendInfo&& DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1) |
|
|
|
{ |
|
|
|
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0); |
|
|
|
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"设备{DeviceInquire.GetInstance.devices[i].DeviceName}检测到有桶,并且料仓输送阻塞" + |
|
|
|
$"" + |
|
|
|
$"", Time = DateTime.Now.ToString() }); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|