@@ -1377,7 +1377,6 @@ namespace BPASmartClient.DosingSystem
{
{
recipeProcesses.Clear();
recipeProcesses.Clear();
TaskManage.GetInstance.StartLong(() =>
TaskManage.GetInstance.StartLong(() =>
{
{
SimensSend.GetInstance.SendSimens.Write("M0.0", true);
SimensSend.GetInstance.SendSimens.Write("M0.0", true);
@@ -1391,7 +1390,7 @@ namespace BPASmartClient.DosingSystem
{
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
{
{
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 (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))
if (!doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
{
@@ -1401,20 +1400,12 @@ namespace BPASmartClient.DosingSystem
{
{
int index = 0;
int index = 0;
int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress];
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 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount< recipeProcess es.Count)
if (doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount&& doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]< RecipeNam es.Count)
{
{
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
if (index > 0 && index < Recipes.Count)
if (index >= 0 && index < Recipes.Count)
{
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
if (UserTreeWait.Count > 0)
{
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
}
}));
int maxPail = 0;
int maxPail = 0;
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
{
{
@@ -1426,6 +1417,14 @@ 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.DeletePassPail.ToAdd(), 1);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);
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]);
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(() =>
{
if (doDeviceCount.ContainsKey("192.168.2.10")&&UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count)
{
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
}
}));
}
}
}
}
@@ -1463,7 +1462,7 @@ namespace BPASmartClient.DosingSystem
{
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress) && doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress) && doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 && doD ecipeCount > 0)
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoR ecipeCount > 0)
{
{
int doCount = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount - 1));
int doCount = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount - 1));
if (doCount >= 0 && doCount < Recipes.Count)
if (doCount >= 0 && doCount < Recipes.Count)
@@ -1476,8 +1475,6 @@ namespace BPASmartClient.DosingSystem
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
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)
if (deviceSet != null && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].IsConnected == true)
{
{
//开始配料信号
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
//传送带停止
//传送带停止
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//设置下料重量
//设置下料重量
@@ -1494,6 +1491,8 @@ namespace BPASmartClient.DosingSystem
//设置料仓上下限重量
//设置料仓上下限重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
//开始配料信号
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
////设置搅拌速度
////设置搅拌速度
//DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
//DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
}
}
@@ -1514,12 +1513,24 @@ namespace BPASmartClient.DosingSystem
DeviceStatus nextDevice = new DeviceStatus();
DeviceStatus nextDevice = new DeviceStatus();
TaskManage.GetInstance.StartLong(() =>
TaskManage.GetInstance.StartLong(() =>
{
{
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
{
if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.90")
{
if (DeviceInquire.GetInstance.DeviceLists[ DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1)
{
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0);
}
else
{
SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)600);
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1);
}
}
if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"&& DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount-1) * 10}")
{
{
ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum;
ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum;
@@ -1536,13 +1547,13 @@ namespace BPASmartClient.DosingSystem
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PailArrive == 1)
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PailArrive == 1)
{
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(),(ushort) 0);
}
}
else
else
{
{
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
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(), 5 00);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 6 00);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort) 1);
}
}
}
}
else
else
@@ -1552,28 +1563,57 @@ namespace BPASmartClient.DosingSystem
}
}
}
}
else
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
}
}
}
else
else
{
{
if (SimensSend.GetInstance.sendCtrlModel.SendInfo)
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
string x = $"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}";
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey($"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}") && DeviceInquire.GetInstance.DeviceLists.ContainsKey($"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"))
{
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 500);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
if (SimensSend.GetInstance.sendCtrlModel.SendInfo)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
if (DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].deviceStatus.PailArrive == 1)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
}
else
{
if (DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.RunStatus != 2)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
if (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 - 1) * 10}"].deviceStatus.RunStatus == 2)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
}
}
}
}
}
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail != 0 && (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail))
{
}
}
}
}
}