diff --git a/DosingSystem/ExcuteControl .cs b/DosingSystem/ExcuteControl .cs index 2f0a5843..cfa47a53 100644 --- a/DosingSystem/ExcuteControl .cs +++ b/DosingSystem/ExcuteControl .cs @@ -35,6 +35,7 @@ using Microsoft.VisualBasic.Logging; using Org.BouncyCastle.Asn1.Utilities; using Google.Protobuf.WellKnownTypes; using System.Windows; +using Org.BouncyCastle.Asn1; namespace BPASmartClient.DosingSystem { @@ -574,9 +575,62 @@ namespace BPASmartClient.DosingSystem List device_Loc = new List();//下发桶号 int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]; var dnum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum; - if (recipeNameNum == 0) + if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RecipePail == 0) { - MessageNotify.GetInstance.ShowRunLog("执行首个配方"); + if (dnum ==18) + { + App.Current.Dispatcher.Invoke(() => + { + + RecipeModel recipe = recipeProcesses?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1)); + if (recipe != null && recipe.RecipStatus == "正在配料") + { + recipe.RecipStatus = "制作完成"; + UserTreeCompelete.Insert(0, recipe); + recipeProcesses.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1))); + } + }); + } + index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum)); + + if (index >= 0 && dnum > 0) + { + foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials) + { + if (rawMaterial.DeviceIp == DeviceInquire.GetInstance.devices[i].IpAddress) + { + device_Loc.Add(rawMaterial.Loc); + } + } + foreach (var down_Loc in device_Loc) + { + SimensSend.GetInstance.SendSimens.Write($"DB1.DBX{710 + 4 * (dnum - 1) + (int)((down_Loc - 1) / 8)}.{(down_Loc - 1) % 8}", true); + } + SimensSend.GetInstance.SendSimens.Write($"DB1.DBW{106 + 2 * (dnum - 1)}", 600); + MessageNotify.GetInstance.ShowRunLog($"设备{dnum}下发配方{RecipeNames.ElementAt(recipeNameNum)}"); + if (dnum == 1) + { + App.Current.Dispatcher.Invoke(() => + { + RecipeModel recipe = UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)); + if (recipe != null) + { + recipe.RecipStatus = "正在配料"; + recipeProcesses.Insert(0, recipe); + UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum))); + } + + }); + } + doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, recipeNameNum + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]); + } + } + + /* if (recipeNameNum ==0) + { + + + MessageNotify.GetInstance.ShowRunLog("执行首个配方"); index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum)); if (index >= 0 && dnum > 0) { @@ -612,8 +666,8 @@ namespace BPASmartClient.DosingSystem { recipe.RecipStatus = "正在配料"; recipeProcesses.Insert(0, recipe); - /*Json.Data.Recipes.Insert(0, recipe); - Json.Save();*/ + *//*Json.Data.Recipes.Insert(0, recipe); + Json.Save();*//* int removeObj = UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)); if (removeObj >= 0 && removeObj < UserTreeWait.Count()) UserTreeWait.RemoveAt(removeObj); @@ -641,23 +695,27 @@ namespace BPASmartClient.DosingSystem device_Loc.Add(rawMaterial.Loc); } } + if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RecipePail == 0) + { + MessageNotify.GetInstance.ShowRunLog($"设备{dnum}下发配方{RecipeNames.ElementAt(recipeNameNum - 1)},桶数已清零"); + } if (dnum == 18 && maxPail <= DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail) { App.Current.Dispatcher.Invoke(() => { RecipeModel recipe = recipeProcesses?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1)); - if (recipe != null && recipe.RecipStatus != "制作完成") + if (recipe != null && recipe.RecipStatus == "正在配料"&&UserTreeCompelete.Count< recipeNameNum) { - /*Json.Data.Recipes.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum))); - Json.Save();*/ + *//*Json.Data.Recipes.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum))); + Json.Save();*//* recipe.RecipStatus = "制作完成"; UserTreeCompelete.Insert(0, recipe); recipeProcesses.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1))); } }); } - if (maxPail <= DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail && recipeNameNum < RecipeNames.Count && !DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive) + if ( DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RecipePail ==0 && recipeNameNum < RecipeNames.Count && !DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive) { MessageNotify.GetInstance.ShowRunLog("下发下一个配方"); doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, recipeNameNum + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]); @@ -694,8 +752,8 @@ namespace BPASmartClient.DosingSystem { recipe.RecipStatus = "正在配料"; recipeProcesses.Insert(0, recipe); - /* Json.Data.Recipes.Insert(0, recipe); - Json.Save();*/ + *//* Json.Data.Recipes.Insert(0, recipe); + Json.Save();*//* UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1))); } @@ -703,7 +761,7 @@ namespace BPASmartClient.DosingSystem } } } - } + }*/ } else diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index cfb1704b..2a243b39 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -460,6 +460,7 @@ namespace BPASmartClient.DosingSystem { deviceStatus.PailArrive = SimensSend.GetInstance.SendSimens.Read($"DB1.DBX80{(int)((dnum.Content-1)/8)}.{(dnum.Content-1)%8}").Content; deviceStatus.PassPail = SimensSend.GetInstance.SendSimens.Read($"DB1.DBW{810 + 2 * (dnum.Content - 1)}").Content; + deviceStatus.RecipePail = SimensSend.GetInstance.SendSimens.Read($"DB1.DBW{710 + 4 * (dnum.Content - 1)}").Content; } } diff --git a/DosingSystem/Model/RawMaterialDeviceStatus.cs b/DosingSystem/Model/RawMaterialDeviceStatus.cs index 0cbb471c..7ed83e98 100644 --- a/DosingSystem/Model/RawMaterialDeviceStatus.cs +++ b/DosingSystem/Model/RawMaterialDeviceStatus.cs @@ -115,8 +115,8 @@ namespace BPASmartClient.DosingSystem /// public bool PailArrive { get; set; } /// - /// 设备执行配方数量 + /// 设置桶号 /// - public ushort DoRecipeCount { get;set; } + public int RecipePail { get;set; } } }