From 8e7aec3c18260775232b56c9a92640e0903d8171 Mon Sep 17 00:00:00 2001 From: Mr_z <1047577696@qqcom> Date: Wed, 28 Jun 2023 10:29:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E6=96=99=E7=8A=B6=E6=80=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/RecipeControlViewModel.cs | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index 3c744cba..327133db 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -28,7 +28,6 @@ namespace BPASmartClient.DosingSystem.ViewModel static ObservableCollection StockStatus = new ObservableCollection(); public RecipeControlViewModel() { - StartCommand = new BPARelayCommand(RecipeIssued); ChangeRecipeStateCommand = new BPARelayCommand(ChangeRecipeState); CancelRecipeCommand = new BPARelayCommand(CancelRecipe); @@ -295,7 +294,7 @@ namespace BPASmartClient.DosingSystem.ViewModel Thread.Sleep(100); }), "启动配方下发", true); } - + int ComCount = 0; /// /// 配方执行状态监听 /// @@ -733,13 +732,13 @@ namespace BPASmartClient.DosingSystem.ViewModel if (recIndex >= 0 && recIndex < recipeProcesses.Count) { int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName); - int a11= recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName&&p.RecipeStatus==2); - int a112 = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName && p.RecipeStatus == 3); - if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count) - { - //测试使用 - recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; - } + + //if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count) + //{ + // //测试使用 + // recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; + + //} for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++) { if (GlobalDevice.PlcData.IsAllowIngredients[j]) @@ -814,29 +813,38 @@ namespace BPASmartClient.DosingSystem.ViewModel { StockStatus.ElementAt(St_index).IssueStatus = 1; DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); + recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus = 2; MessageNotify.GetInstance.ShowRunLog($"设备执行状态:{rrr}"); MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); } if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) { //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 + recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus = 3; + ComCount++; StockStatus.ElementAt(St_index).IssueStatus = 2; DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); - int a = 0.SetBitValue((byte)(DeviceNum), true); - byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); - int item = test1.ToInt(); + //int a = 0.SetBitValue((byte)(DeviceNum), true); + //byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); + //int item = test1.ToInt(); //prop1: // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item); - SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true); - //var values = SiemensDevice.GetInstance.MySiemens.Read("DB4.DBD130").Content; - //if ((values != null && values.ToString() != item.ToString()) || values == null) - // goto prop1; + SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true).OnSuccess(() => + { + MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!DB4.DBX130.{{DeviceNum - 1}}:true\""); + }).OnFail(s => + { + MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}"); + }); + //var values = SiemensDevice.GetInstance.MySiemens.Read("DB4.DBD130").Content; + //if ((values != null && values.ToString() != item.ToString()) || values == null) + // goto prop1; - MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!状态值 {item}"); - //SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item).OnSuccess(() => + + //SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", true).OnSuccess(() => //{ // MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!"); - //}).OnFail(s => + //}).OnFail(s => //{ // MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}"); //}); @@ -1137,9 +1145,10 @@ namespace BPASmartClient.DosingSystem.ViewModel //} } //int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count(); - int Finish_Count = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).Count(); - if ( Finish_Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && + //int Finish_Count = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).Count(); + if ( ComCount >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && { + ComCount = 0; StockStatus.Clear(); MessageNotify.GetInstance.ShowUserLog($"配方:{recipeProcesses.ElementAt(recIndex).RecipeName},配料完成"); foreach (var item in recipeProcesses.ElementAt(recIndex).RawMaterials)