|
|
@@ -122,91 +122,114 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int index = 0; |
|
|
|
private void MatchRun() |
|
|
|
{ |
|
|
|
int index = 0; |
|
|
|
string passRecipeName = ""; |
|
|
|
recipeProcesses.Clear(); |
|
|
|
TaskManage.GetInstance.StartLong(() => |
|
|
|
{ |
|
|
|
if (RecipeNames.Count > 0) |
|
|
|
{ |
|
|
|
passRecipeName = recipeProcesses[0].RecipeName; |
|
|
|
passRecipeName = recipeProcesses.Last().RecipeName; |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.MaxPassPail!=0 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices.Last().IpAddress].deviceStatus.RunStatus == 3) |
|
|
|
{ |
|
|
|
RecipeNames.TryDequeue(out passRecipeName); |
|
|
|
UserTreeCompelete.Insert(0, recipeProcesses.Last()); |
|
|
|
} |
|
|
|
foreach (var item in DeviceInquire.GetInstance.devices) |
|
|
|
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++) |
|
|
|
{ |
|
|
|
|
|
|
|
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(item.IpAddress)) |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress)) |
|
|
|
{ |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[item.IpAddress].deviceStatus.MaxPassPail == 0 && DeviceInquire.GetInstance.DeviceLists[item.IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[item.IpAddress].deviceStatus.PassPail) |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == 0 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3) |
|
|
|
{ |
|
|
|
|
|
|
|
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0)); |
|
|
|
if (index > 0 && index < Recipes.Count) |
|
|
|
|
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail) |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(new Action(() => |
|
|
|
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0)); |
|
|
|
if (index > 0 && index < Recipes.Count) |
|
|
|
{ |
|
|
|
if (UserTreeWait.Count > 0) |
|
|
|
App.Current.Dispatcher.Invoke(new Action(() => |
|
|
|
{ |
|
|
|
recipeProcesses.Insert(0, UserTreeWait[0]); |
|
|
|
UserTreeWait.RemoveAt(0); |
|
|
|
if (UserTreeWait.Count > 0) |
|
|
|
{ |
|
|
|
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(0))); |
|
|
|
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(0))); |
|
|
|
} |
|
|
|
})); |
|
|
|
int maxPail = 0; |
|
|
|
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials) |
|
|
|
{ |
|
|
|
if (rawMaterial.Loc > maxPail) |
|
|
|
{ |
|
|
|
maxPail = rawMaterial.Loc; |
|
|
|
} |
|
|
|
} |
|
|
|
})); |
|
|
|
int maxPail = 0; |
|
|
|
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials) |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
RawMaterialModel res = Recipes.ElementAt(index).RawMaterials?.ToList().Find(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); |
|
|
|
if (res != null && res.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail) |
|
|
|
{ |
|
|
|
|
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1) |
|
|
|
{ |
|
|
|
if (rawMaterial.Loc > maxPail) |
|
|
|
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); |
|
|
|
if (deviceSet!= null) |
|
|
|
{ |
|
|
|
maxPail = rawMaterial.Loc; |
|
|
|
//设置启动 |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), 1); |
|
|
|
//设置下料重量 |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<uint>(DeviceAddress.WeightSet.ToAdd(), res.RawMaterialWeight); |
|
|
|
//设置慢加重量 |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight); |
|
|
|
//设置快慢加速度 |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration); |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration); |
|
|
|
//设置提前关阀重量 |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight); |
|
|
|
//设置伺服手动速度 |
|
|
|
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed); |
|
|
|
//设置料仓上下限重量 |
|
|
|
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<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed); |
|
|
|
} |
|
|
|
|
|
|
|
//写入出货量 |
|
|
|
//下料设定参数 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DeviceInquire.GetInstance.DeviceLists[item.IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1); |
|
|
|
DeviceInquire.GetInstance.DeviceLists[item.IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++) |
|
|
|
{ |
|
|
|
RawMaterialModel res = Recipes.ElementAt(index).RawMaterials?.ToList().Find(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); |
|
|
|
if (res != null && res.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail) |
|
|
|
{ |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1) |
|
|
|
if (i <= 6) |
|
|
|
{ |
|
|
|
//写入出货量 |
|
|
|
//出料状态 |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 0) |
|
|
|
{ |
|
|
|
//出料状态 |
|
|
|
//传送带运行 |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//传送带停止 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (i <= 6) |
|
|
|
{ |
|
|
|
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 0) |
|
|
|
else |
|
|
|
{ |
|
|
|
//出料状态 |
|
|
|
//传送带运行 |
|
|
|
//传送带终点为3则传送带停止,小于3则按照出料状态运行 |
|
|
|
} |
|
|
|
else |
|
|
|
if (i == DeviceInquire.GetInstance.devices.Count - 1) |
|
|
|
{ |
|
|
|
//传送带停止 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//传送带终点为3则传送带停止,小于3则按照出料状态运行 |
|
|
|
} |
|
|
|
if (i== DeviceInquire.GetInstance.devices.Count - 1) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Thread.Sleep(100); |
|
|
|