From bd32efda18b965297db9e6aecae0f78bd76930bd Mon Sep 17 00:00:00 2001 From: lyw <刘耀文@DESKTOP-E1TI268> Date: Sun, 18 Feb 2024 21:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DosingSystem/App.xaml.cs | 8 +- DosingSystem/Converter/RunStatusConvert.cs | 38 +++- DosingSystem/ExcuteControl .cs | 11 +- DosingSystem/Model/DeviceAddress.cs | 2 +- DosingSystem/Model/DeviceInquire.cs | 6 +- DosingSystem/Model/RawMaterialDeviceStatus.cs | 8 + DosingSystem/Model/par/LocalRecipe.cs | 6 + DosingSystem/View/MaterialDosageView.xaml | 192 ++++++++++++++++++ DosingSystem/View/MaterialDosageView.xaml.cs | 44 ++++ .../ViewModel/MaterialDosageViewModel.cs | 34 ++++ .../ViewModel/RecipeControlViewModel.cs | 2 +- 11 files changed, 344 insertions(+), 7 deletions(-) create mode 100644 DosingSystem/View/MaterialDosageView.xaml create mode 100644 DosingSystem/View/MaterialDosageView.xaml.cs create mode 100644 DosingSystem/ViewModel/MaterialDosageViewModel.cs diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index ad3e9562..ae1f061b 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -162,7 +162,13 @@ namespace BPASmartClient.DosingSystem AssemblyName = "BPASmartClient.DosingSystem", ToggleWindowPath = "View.RecipeControlView" }); - + RecipeManage.Add(new SubMenumodel() + { + SubMenuName = "配方记录查询", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.MaterialDosageView" + }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/DosingSystem/Converter/RunStatusConvert.cs b/DosingSystem/Converter/RunStatusConvert.cs index 18f96712..e3ee1e62 100644 --- a/DosingSystem/Converter/RunStatusConvert.cs +++ b/DosingSystem/Converter/RunStatusConvert.cs @@ -1,5 +1,8 @@ -using System; +using BPASmartClient.Model; +using System; +using System.Collections.ObjectModel; using System.Globalization; +using System.Linq; using System.Windows; using System.Windows.Data; @@ -132,4 +135,37 @@ namespace BPASmartClient.DosingSystem.Converter } } + public class DownWeightConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ObservableCollection temp = value as ObservableCollection; + if (temp!=null) + { + float weight = 0; + if ((int)parameter > 18) + { + temp.ToList().ForEach(a => + { + weight += a.TotalWeight; + }); + } + temp.ToList().ForEach(a => + { + if (a.RawMaterialName == parameter.ToString()) + { + weight += a.TotalWeight; + } + }); + return weight; + } + return 0; + + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } } diff --git a/DosingSystem/ExcuteControl .cs b/DosingSystem/ExcuteControl .cs index 6b92bf0f..8d0bf92c 100644 --- a/DosingSystem/ExcuteControl .cs +++ b/DosingSystem/ExcuteControl .cs @@ -559,6 +559,8 @@ namespace BPASmartClient.DosingSystem } } + + bool allowStart=false; private void MatchRun() { @@ -667,7 +669,7 @@ namespace BPASmartClient.DosingSystem if (recipe != null && recipe.RecipStatus != "制作完成") { - int res = recipe.RawMaterials.ToList().FindIndex(a => a.RecipeStatus <3); + int res = recipe.RawMaterials.ToList().FindIndex(a => a.RecipeStatus !=3); if (res < 0 ) { recipe.RecipStatus = "制作完成"; @@ -751,6 +753,13 @@ namespace BPASmartClient.DosingSystem } + int rep = doDeviceCount.Count(a => a.Value == 1); + + if ( rep== DeviceInquire.GetInstance.devices.Count&&!allowStart) + { + App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"可以开始放入配料桶!"); }); + allowStart = true; + } } Thread.Sleep(10); diff --git a/DosingSystem/Model/DeviceAddress.cs b/DosingSystem/Model/DeviceAddress.cs index 2d8eb12c..d5b477c6 100644 --- a/DosingSystem/Model/DeviceAddress.cs +++ b/DosingSystem/Model/DeviceAddress.cs @@ -28,7 +28,7 @@ namespace BPASmartClient.DosingSystem /// /// 下料重量反馈地址 /// - public static string CutWeightFeedback { get; set; } = "LW54"; + public static string CutWeightFeedback { get; set; } = "LW58"; /// /// 设备编号 diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index 2a243b39..c5953478 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -448,8 +448,8 @@ namespace BPASmartClient.DosingSystem if (wf.IsSuccess) deviceStatus.WeightFeedback = (uint)(wf.Content); ////获取下料重量 - var nwf = this.modbusTcp.Read(DeviceAddress.CutWeightFeedback.ToAdd(), 1, BPA.Helper.DataFormat.CDAB); - if (nwf.IsSuccess) deviceStatus.NowWeightFeedback = nwf.Content; + var nwf = this.modbusTcp.Read(DeviceAddress.CutWeightFeedback.ToAdd(), 2, BPA.Helper.DataFormat.CDAB); + if (nwf.IsSuccess) deviceStatus.CutWeightFeedback = nwf.Content; ////获取设备编号 var dnum = this.modbusTcp.Read(DeviceAddress.DeviceNum.ToAdd(), 1, BPA.Helper.DataFormat.CDAB); @@ -461,6 +461,8 @@ 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; + deviceStatus.InPailAll = SimensSend.GetInstance.SendSimens.Read($"DB1.DBW1000").Content; + deviceStatus.OutPailAll = SimensSend.GetInstance.SendSimens.Read($"DB1.DBW1002").Content; } } diff --git a/DosingSystem/Model/RawMaterialDeviceStatus.cs b/DosingSystem/Model/RawMaterialDeviceStatus.cs index 7ed83e98..9fc86e35 100644 --- a/DosingSystem/Model/RawMaterialDeviceStatus.cs +++ b/DosingSystem/Model/RawMaterialDeviceStatus.cs @@ -118,5 +118,13 @@ namespace BPASmartClient.DosingSystem /// 设置桶号 /// public int RecipePail { get;set; } + /// + /// 进桶总数 + /// + public int InPailAll { get; set; } + /// + /// 出桶总数 + /// + public int OutPailAll { get; set; } } } diff --git a/DosingSystem/Model/par/LocalRecipe.cs b/DosingSystem/Model/par/LocalRecipe.cs index 335e2003..c85d1b39 100644 --- a/DosingSystem/Model/par/LocalRecipe.cs +++ b/DosingSystem/Model/par/LocalRecipe.cs @@ -13,5 +13,11 @@ namespace BPASmartClient.DosingSystem public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + } + public class OldRecipe + { + public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + + } } diff --git a/DosingSystem/View/MaterialDosageView.xaml b/DosingSystem/View/MaterialDosageView.xaml new file mode 100644 index 00000000..3b06e171 --- /dev/null +++ b/DosingSystem/View/MaterialDosageView.xaml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DosingSystem/View/MaterialDosageView.xaml.cs b/DosingSystem/View/MaterialDosageView.xaml.cs new file mode 100644 index 00000000..cbab969e --- /dev/null +++ b/DosingSystem/View/MaterialDosageView.xaml.cs @@ -0,0 +1,44 @@ +using BPA.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.DosingSystem.View +{ + /// + /// MaterialDosageView.xaml 的交互逻辑 + /// + public partial class MaterialDosageView : UserControl + { + public MaterialDosageView() + { + InitializeComponent(); + } + + private void RadioButton_Click(object sender, RoutedEventArgs e) + { + this.View.ItemsSource = ExcuteControl.GetInstance.recipeProcesses; + } + + private void RadioButton_Click_1(object sender, RoutedEventArgs e) + { + this.View.ItemsSource = ExcuteControl.GetInstance.UserTreeCompelete; + } + + private void RadioButton_Click_2(object sender, RoutedEventArgs e) + { + this.View.ItemsSource = Json.Data.Recipes; + } + } +} diff --git a/DosingSystem/ViewModel/MaterialDosageViewModel.cs b/DosingSystem/ViewModel/MaterialDosageViewModel.cs new file mode 100644 index 00000000..bb1fd6df --- /dev/null +++ b/DosingSystem/ViewModel/MaterialDosageViewModel.cs @@ -0,0 +1,34 @@ +using BPA.Helper; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.DosingSystem.ViewModel +{ + public class MaterialDosageViewModel:NotifyBase + { + public MaterialDosageViewModel() + { + + } + /// + /// 当前正在制作的配方 + /// + public ObservableCollection recipeProcesses { get; set; } = ExcuteControl.GetInstance.recipeProcesses; + + /// + /// 等待制作的配方 + /// + public ObservableCollection OldRecipe { get; set; } = ExcuteControl.GetInstance.UserTreeWait; + + /// + /// 已完成的配方 + /// + public ObservableCollection UserTreeCompelete { get; set; } = ExcuteControl.GetInstance.UserTreeCompelete; + } + +} diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index 2dbc70d5..2f601b75 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -1039,7 +1039,7 @@ namespace BPASmartClient.DosingSystem.ViewModel /// /// 等待制作的配方 /// - public static ObservableCollection UserTreeWait { get; set; } = ExcuteControl.GetInstance.UserTreeWait; + public static ObservableCollection UserTreeWait { get; set; } = Json.Data.Recipes; /// /// 已完成的配方