From 4d16bdf1820cb62984064599516a7536a869c21a Mon Sep 17 00:00:00 2001 From: yaowen liu <1539177313@qq.com> Date: Tue, 10 Oct 2023 16:18:20 +0800 Subject: [PATCH] recipe --- DosingSystem/Model/DeviceAddress.cs | 4 + DosingSystem/Model/DeviceInquire.cs | 3 + DosingSystem/Model/RawMaterialDeviceStatus.cs | 4 + DosingSystem/Model/par/DeviceParModel.cs | 7 +- .../ViewModel/RecipeControlViewModel.cs | 409 +++++++++--------- 5 files changed, 223 insertions(+), 204 deletions(-) diff --git a/DosingSystem/Model/DeviceAddress.cs b/DosingSystem/Model/DeviceAddress.cs index d768e92e..62a07130 100644 --- a/DosingSystem/Model/DeviceAddress.cs +++ b/DosingSystem/Model/DeviceAddress.cs @@ -123,6 +123,10 @@ namespace BPASmartClient.DosingSystem /// 桶到位检测 /// public static string PailArrive { get; set; } = "LW61"; + /// + /// 设备执行配方计数 + /// + public static string DoRecipeCount { get; set; } = "LW64"; } diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index c28f1d1b..cadb6ff7 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -423,6 +423,9 @@ namespace BPASmartClient.DosingSystem //配料最大桶数 var max = this.modbusTcp.Read(DeviceAddress.MaxPail.ToAdd(), 1, BPA.Helper.DataFormat.CDAB); if (max.IsSuccess) deviceStatus.MaxPassPail = max.Content; + //执行配方数 + var doCount = this.modbusTcp.Read(DeviceAddress.DoRecipeCount.ToAdd(), 1, BPA.Helper.DataFormat.CDAB); + if (doCount.IsSuccess) deviceStatus.DoRecipeCount = doCount.Content; //this.DeviceName = modbusTcp.Read(DeviceAddress.DeviceName.ToAdd(), 20).Content.Trim().Replace(" ", ""); //deviceStatus.RunStatus = (ushort)this.modbusTcp.Read(DeviceAddress.RunStatus.ToAdd()).Content; //获取设备运行状态 //deviceStatus.WeightFeedback = (float)this.modbusTcp.Read(DeviceAddress.WeightFeedback.ToAdd()).Content;//获取设备料仓剩余重量 diff --git a/DosingSystem/Model/RawMaterialDeviceStatus.cs b/DosingSystem/Model/RawMaterialDeviceStatus.cs index 0dab1d01..4fa7450a 100644 --- a/DosingSystem/Model/RawMaterialDeviceStatus.cs +++ b/DosingSystem/Model/RawMaterialDeviceStatus.cs @@ -110,5 +110,9 @@ namespace BPASmartClient.DosingSystem /// 到位检测 为1有桶。0无桶 /// public uint PailArrive { get; set; } + /// + /// 设备执行配方数量 + /// + public uint DoRecipeCount { get;set; } } } diff --git a/DosingSystem/Model/par/DeviceParModel.cs b/DosingSystem/Model/par/DeviceParModel.cs index c2097445..b12a5b63 100644 --- a/DosingSystem/Model/par/DeviceParModel.cs +++ b/DosingSystem/Model/par/DeviceParModel.cs @@ -64,7 +64,10 @@ namespace BPASmartClient.DosingSystem [Newtonsoft.Json.JsonIgnore] public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } } private bool _mIsRedundant; - - + /// + /// 2023.10.10添加字段 + /// + public ushort SendSp { get { return _sendSp; } set { _sendSp = value; OnPropertyChanged(); } } + private ushort _sendSp; } } diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index 694cfe89..80201a8d 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -27,9 +27,9 @@ namespace BPASmartClient.DosingSystem.ViewModel //StartCommand = new BPARelayCommand(RecipeIssued); //ChangeRecipeStateCommand = new BPARelayCommand(ChangeRecipeState); //CancelRecipeCommand = new BPARelayCommand(CancelRecipe); - RecipeRun(); + //RecipeRun(); RecipeStatusInquire(); - + MatchRun(); StartCommand = new BPARelayCommand(new Action((o) => { if (o != null && o is string recipeName) { @@ -122,20 +122,18 @@ namespace BPASmartClient.DosingSystem.ViewModel //} - int index = 0; private void MatchRun() { - string passRecipeName = ""; recipeProcesses.Clear(); TaskManage.GetInstance.StartLong(() => { if (RecipeNames.Count > 0) { - 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); + recipeProcesses.Remove(recipeProcesses.Last()); UserTreeCompelete.Insert(0, recipeProcesses.Last()); + } for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++) { @@ -143,10 +141,12 @@ namespace BPASmartClient.DosingSystem.ViewModel { if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == 0 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3) { - + if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail) { - index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0)); + string passName = RecipeNames.ElementAt(0); + RecipeNames.TryDequeue(out passName); + int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0)); if (index > 0 && index < Recipes.Count) { App.Current.Dispatcher.Invoke(new Action(() => @@ -170,14 +170,17 @@ namespace BPASmartClient.DosingSystem.ViewModel } } - 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 (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1) + int doCount = Array.FindIndex(Recipes.ToArray(), p => p.SerialNum == (int)DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount); + RawMaterialModel res = Recipes.ElementAt(doCount).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) { DeviceParModel deviceSet = Json.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); - if (deviceSet!= null) + if (deviceSet != null) { //设置启动 DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.Start.ToAdd(), 1); @@ -198,23 +201,25 @@ namespace BPASmartClient.DosingSystem.ViewModel //设置搅拌速度 DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed); } - - //写入出货量 - //下料设定参数 } + + } + } if (i < DeviceInquire.GetInstance.devices.Count - 1) { if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 0) { - //出料状态 //传送带运行 - + DeviceParModel deviceSet = Json.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp); + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 1); } else { + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 0); //传送带停止 } } @@ -235,195 +240,195 @@ namespace BPASmartClient.DosingSystem.ViewModel /// /// 配方业务执行 /// - private void RecipeRun() - { - TaskManage.GetInstance.StartLong(new Action(() => - { - if (RecipeNames.Count > 0) - { - int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0)); - if (index >= 0 && index < Recipes.Count) - { - Recipes.ElementAt(index).Are.Reset(); - Recipes.ElementAt(index).IsEnable = false; - StockStatus.Clear(); - App.Current.Dispatcher.Invoke(new Action(() => - { - recipeProcesses.Clear(); - if (UserTreeWait.Count > 0) UserTreeWait.RemoveAt(0); - })); - CurrentRecipeName = Recipes.ElementAt(index).RecipeName; - - #region 配方下发到PLC操作相关 - //配方数据写入到输送机 - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == CurrentRecipeName); - List BarrelNum = new List(); - ConcurrentDictionary values = new(); - if (res != null) - { - var tInfo = res.RawMaterials.GroupBy(p => p.Loc);//获取桶号信息 - if (tInfo != null) - { - for (int i = 0; i < tInfo.Count(); i++) - { - int data = 0; - for (int m = 0; m < tInfo.ElementAt(i).Count(); m++) - { - var TempName = tInfo.ElementAt(i).ElementAt(m).RawMaterialName; - var tempDevice = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == TempName); - if (tempDevice != null) - { - /*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ - if (tempDevice.DeviceNum > 0) - { - // //int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); - // //byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); - // //int item = test1.ToInt(); - // int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt(); - // int item1 = SiemensDevice.GetInstance.MySiemens.Read($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}").Content; - ////prop1: - // var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item + item1); - // //var values = SiemensDevice.GetInstance.MySiemens.Read($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}"); - // //if ((values != null && values.ToString() != (item + item1).ToString()) || values == null) - // // goto prop1; - // if (RE.IsSuccess) - // MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item + item1}-{(item + item1).ToBinString()}"); - // else - // MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} 失败"); - - - - int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt(); - string tempAdd = $"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}"; - if (!values.ContainsKey(tempAdd)) values.TryAdd(tempAdd, new int[2] { 0, 0 }); - values[tempAdd][0] = values[tempAdd][0] + item; - values[tempAdd][1] = tInfo.ElementAt(i).ElementAt(m).Loc; - } - } - if (tInfo.ElementAt(i).ElementAt(m).Loc > 0) - { - if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) - { - BarrelNum.Add(tInfo.ElementAt(i).ElementAt(m).Loc); - } - } - } - } - } - } + //private void RecipeRun() + //{ + // TaskManage.GetInstance.StartLong(new Action(() => + // { + // if (RecipeNames.Count > 0) + // { + // int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0)); + // if (index >= 0 && index < Recipes.Count) + // { + // Recipes.ElementAt(index).Are.Reset(); + // Recipes.ElementAt(index).IsEnable = false; + // StockStatus.Clear(); + // App.Current.Dispatcher.Invoke(new Action(() => + // { + // recipeProcesses.Clear(); + // if (UserTreeWait.Count > 0) UserTreeWait.RemoveAt(0); + // })); + // CurrentRecipeName = Recipes.ElementAt(index).RecipeName; + + // #region 配方下发到PLC操作相关 + // //配方数据写入到输送机 + // var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == CurrentRecipeName); + // List BarrelNum = new List(); + // ConcurrentDictionary values = new(); + // if (res != null) + // { + // var tInfo = res.RawMaterials.GroupBy(p => p.Loc);//获取桶号信息 + // if (tInfo != null) + // { + // for (int i = 0; i < tInfo.Count(); i++) + // { + // int data = 0; + // for (int m = 0; m < tInfo.ElementAt(i).Count(); m++) + // { + // var TempName = tInfo.ElementAt(i).ElementAt(m).RawMaterialName; + // var tempDevice = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == TempName); + // if (tempDevice != null) + // { + // /*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ + // if (tempDevice.DeviceNum > 0) + // { + // // //int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); + // // //byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); + // // //int item = test1.ToInt(); + // // int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt(); + // // int item1 = SiemensDevice.GetInstance.MySiemens.Read($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}").Content; + // ////prop1: + // // var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item + item1); + // // //var values = SiemensDevice.GetInstance.MySiemens.Read($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}"); + // // //if ((values != null && values.ToString() != (item + item1).ToString()) || values == null) + // // // goto prop1; + // // if (RE.IsSuccess) + // // MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item + item1}-{(item + item1).ToBinString()}"); + // // else + // // MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} 失败"); + + + + // int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt(); + // string tempAdd = $"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}"; + // if (!values.ContainsKey(tempAdd)) values.TryAdd(tempAdd, new int[2] { 0, 0 }); + // values[tempAdd][0] = values[tempAdd][0] + item; + // values[tempAdd][1] = tInfo.ElementAt(i).ElementAt(m).Loc; + // } + // } + // if (tInfo.ElementAt(i).ElementAt(m).Loc > 0) + // { + // if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) + // { + // BarrelNum.Add(tInfo.ElementAt(i).ElementAt(m).Loc); + // } + // } + // } + // } + // } + // } - values?.ToList().ForEach(x => - { - SiemensDevice.GetInstance.MySiemens.Write(x.Key, x.Value[0]).OnSuccess(() => - { - MessageNotify.GetInstance.ShowRunLog($"下发配方-{x.Key} :桶数:[{x.Value[1]}]-{x.Value[0].ToBinString()}"); - }).OnFail(s => - { - MessageNotify.GetInstance.ShowRunLog($"下发配方-{x.Key} 失败"); - }); - }); + // values?.ToList().ForEach(x => + // { + // SiemensDevice.GetInstance.MySiemens.Write(x.Key, x.Value[0]).OnSuccess(() => + // { + // MessageNotify.GetInstance.ShowRunLog($"下发配方-{x.Key} :桶数:[{x.Value[1]}]-{x.Value[0].ToBinString()}"); + // }).OnFail(s => + // { + // MessageNotify.GetInstance.ShowRunLog($"下发配方-{x.Key} 失败"); + // }); + // }); - SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count);//配方使用桶数写入 + // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count);//配方使用桶数写入 - SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX0.1", true);//配方执行启动 - Stopwatch sw = new Stopwatch(); - var recipe = Recipes.ElementAt(index); - ObservableCollection RawMater = new ObservableCollection(); - foreach (var item in recipe.RawMaterials) - { - RawMater.Add(new RawMaterialModel() - { - RawMaterialName = item.RawMaterialName, - DeviceIp = item.DeviceIp, - DownLimtFeedback = item.DownLimtFeedback, - Loc = item.Loc, - RawMaterialId = item.RawMaterialId, - RawMaterialSource = item.RawMaterialSource, - RawMaterialType = item.RawMaterialType, - RawMaterialWeight = item.RawMaterialWeight, - RecipeStatus = item.RecipeStatus, - SelectIndex = item.SelectIndex, - Status = item.Status, - UpLimtFeedback = item.UpLimtFeedback, - UpLimtWeightFeedback = item.UpLimtWeightFeedback, - WeightFeedback = item.WeightFeedback, - }); - } - App.Current.Dispatcher.Invoke(() => - { - recipeProcesses.Add(new RecipeModel() - { - RawMaterials = RawMater, - IsEnable = recipe.IsEnable, - RecipeName = recipe.RecipeName, - SerialNum = recipe.SerialNum, - RecipCode = recipe.RecipCode, - }); - }); - sw.Restart(); - while (true) - { - if (sw.ElapsedMilliseconds >= 3000 && !GlobalDevice.PlcData.ResComplete) - { - MessageNotify.GetInstance.ShowRunLog("获取配方下发反馈超时"); - break; - } - if (GlobalDevice.PlcData.ResComplete) - { - SiemensDevice.GetInstance.MySiemens.Write("DB3.DBX0.1", false); - break; - } - Thread.Sleep(100); - } - #endregion + // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX0.1", true);//配方执行启动 + // Stopwatch sw = new Stopwatch(); + // var recipe = Recipes.ElementAt(index); + // ObservableCollection RawMater = new ObservableCollection(); + // foreach (var item in recipe.RawMaterials) + // { + // RawMater.Add(new RawMaterialModel() + // { + // RawMaterialName = item.RawMaterialName, + // DeviceIp = item.DeviceIp, + // DownLimtFeedback = item.DownLimtFeedback, + // Loc = item.Loc, + // RawMaterialId = item.RawMaterialId, + // RawMaterialSource = item.RawMaterialSource, + // RawMaterialType = item.RawMaterialType, + // RawMaterialWeight = item.RawMaterialWeight, + // RecipeStatus = item.RecipeStatus, + // SelectIndex = item.SelectIndex, + // Status = item.Status, + // UpLimtFeedback = item.UpLimtFeedback, + // UpLimtWeightFeedback = item.UpLimtWeightFeedback, + // WeightFeedback = item.WeightFeedback, + // }); + // } + // App.Current.Dispatcher.Invoke(() => + // { + // recipeProcesses.Add(new RecipeModel() + // { + // RawMaterials = RawMater, + // IsEnable = recipe.IsEnable, + // RecipeName = recipe.RecipeName, + // SerialNum = recipe.SerialNum, + // RecipCode = recipe.RecipCode, + // }); + // }); + // sw.Restart(); + // while (true) + // { + // if (sw.ElapsedMilliseconds >= 3000 && !GlobalDevice.PlcData.ResComplete) + // { + // MessageNotify.GetInstance.ShowRunLog("获取配方下发反馈超时"); + // break; + // } + // if (GlobalDevice.PlcData.ResComplete) + // { + // SiemensDevice.GetInstance.MySiemens.Write("DB3.DBX0.1", false); + // break; + // } + // Thread.Sleep(100); + // } + // #endregion - Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 - RecipeNames.TryDequeue(out string deviceName); - var recipeComple = Recipes.ElementAt(index); - ObservableCollection RawMaterComple = new ObservableCollection(); - foreach (var item in recipeComple.RawMaterials) - { - RawMaterComple.Add(new RawMaterialModel() - { - RawMaterialName = item.RawMaterialName, - DeviceIp = item.DeviceIp, - DownLimtFeedback = item.DownLimtFeedback, - Loc = item.Loc, - RawMaterialId = item.RawMaterialId, - RawMaterialSource = item.RawMaterialSource, - RawMaterialType = item.RawMaterialType, - RawMaterialWeight = item.RawMaterialWeight, - RecipeStatus = item.RecipeStatus, - SelectIndex = item.SelectIndex, - Status = item.Status, - UpLimtFeedback = item.UpLimtFeedback, - UpLimtWeightFeedback = item.UpLimtWeightFeedback, - WeightFeedback = item.WeightFeedback, - }); - } - App.Current.Dispatcher.Invoke(() => - { - UserTreeCompelete.Add(new RecipeModel() - { - RawMaterials = RawMaterComple, - IsEnable = recipeComple.IsEnable, - RecipeName = recipeComple.RecipeName, - SerialNum = UserTreeCompelete.Count + 1, - RecipCode = recipeComple.RecipCode, - RecipStatus = "制作完成" - }); - }); - App.Current.Dispatcher.Invoke(new Action(() => - { - recipeProcesses.Clear(); - CurrentRecipeName = string.Empty; - }));//完成后清空当前配方 - } - } - Thread.Sleep(100); - }), "启动配方下发", true); - } + // Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 + // RecipeNames.TryDequeue(out string deviceName); + // var recipeComple = Recipes.ElementAt(index); + // ObservableCollection RawMaterComple = new ObservableCollection(); + // foreach (var item in recipeComple.RawMaterials) + // { + // RawMaterComple.Add(new RawMaterialModel() + // { + // RawMaterialName = item.RawMaterialName, + // DeviceIp = item.DeviceIp, + // DownLimtFeedback = item.DownLimtFeedback, + // Loc = item.Loc, + // RawMaterialId = item.RawMaterialId, + // RawMaterialSource = item.RawMaterialSource, + // RawMaterialType = item.RawMaterialType, + // RawMaterialWeight = item.RawMaterialWeight, + // RecipeStatus = item.RecipeStatus, + // SelectIndex = item.SelectIndex, + // Status = item.Status, + // UpLimtFeedback = item.UpLimtFeedback, + // UpLimtWeightFeedback = item.UpLimtWeightFeedback, + // WeightFeedback = item.WeightFeedback, + // }); + // } + // App.Current.Dispatcher.Invoke(() => + // { + // UserTreeCompelete.Add(new RecipeModel() + // { + // RawMaterials = RawMaterComple, + // IsEnable = recipeComple.IsEnable, + // RecipeName = recipeComple.RecipeName, + // SerialNum = UserTreeCompelete.Count + 1, + // RecipCode = recipeComple.RecipCode, + // RecipStatus = "制作完成" + // }); + // }); + // App.Current.Dispatcher.Invoke(new Action(() => + // { + // recipeProcesses.Clear(); + // CurrentRecipeName = string.Empty; + // }));//完成后清空当前配方 + // } + // } + // Thread.Sleep(100); + // }), "启动配方下发", true); + //} ///