From 0e8d79d2759e70642b2b80be2826660ae86b37c1 Mon Sep 17 00:00:00 2001 From: yaowen liu <1539177313@qq.com> Date: Mon, 9 Oct 2023 18:01:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E6=96=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DosingSystem/ExcuteControl .cs | 2 +- DosingSystem/Model/DeviceInquire.cs | 7 +- .../ViewModel/RecipeControlViewModel.cs | 125 +++++++++++------- 3 files changed, 79 insertions(+), 55 deletions(-) diff --git a/DosingSystem/ExcuteControl .cs b/DosingSystem/ExcuteControl .cs index ae18e0bb..76375476 100644 --- a/DosingSystem/ExcuteControl .cs +++ b/DosingSystem/ExcuteControl .cs @@ -100,7 +100,7 @@ namespace BPASmartClient.DosingSystem }), "取消配方"); - AliYunInit(); + //AliYunInit(); RecipeRun(); BusinessExcute(); ConveyerPropertyReport(); diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index c8627d6f..4a5fc23c 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -150,7 +150,7 @@ namespace BPASmartClient.DosingSystem { if (!string.IsNullOrEmpty(Json.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json.Data.BaseParModel.NetworkSegAddress; else Json.Data.BaseParModel.NetworkSegAddress = IPSegment; - TestData(); + //TestData(); IpAddressLines(); Task.Factory.StartNew(() => { @@ -210,8 +210,9 @@ namespace BPASmartClient.DosingSystem stockCount = Json.Data.BaseParModel.StockCount; for (int i = 0; i < stockCount; i++) { - //IPLists.Add($"{IPSegment}{(i + 1) * 10}"); - IPLists.Add($"{IPSegment}{this.devices[i].DeviceNum}"); + aa((i + 1) * 10, "A" + i.ToString()); + IPLists.Add($"{IPSegment}{(i + 1) * 10}"); + //IPLists.Add($"{IPSegment}{this.devices[i].DeviceNum}"); } IPLists.ForEach((item) => diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index 160139a1..8375249f 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -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(DeviceAddress.DeletePassPail.ToAdd(), 1); + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(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.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(DeviceAddress.Start.ToAdd(), 1); + //设置下料重量 + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), res.RawMaterialWeight); + //设置慢加重量 + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight); + //设置快慢加速度 + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration); + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration); + //设置提前关阀重量 + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight); + //设置伺服手动速度 + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed); + //设置料仓上下限重量 + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight); + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo); + //设置搅拌速度 + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed); } + + //写入出货量 + //下料设定参数 } - - - DeviceInquire.GetInstance.DeviceLists[item.IpAddress].modbusTcp.Write(DeviceAddress.DeletePassPail.ToAdd(), 1); - DeviceInquire.GetInstance.DeviceLists[item.IpAddress].modbusTcp.Write(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);