From 650e6fb409828976f6d43a5955264ed52b0cec2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Thu, 10 Nov 2022 15:16:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=B3=E9=AD=94=E6=96=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Converters/RecipeStatusConvert.cs | 31 +++++++++++++++++++ .../柔性味魔方/RawMaterialModel.cs | 2 +- .../BPASmartClient.MorkS.csproj | 1 + BPASmartClient.MorkS/DataServer.cs | 1 + DosingSystem/App.xaml | 1 + DosingSystem/App.xaml.cs | 6 +++- DosingSystem/Model/DeviceInquire.cs | 4 +-- DosingSystem/Model/RecipeModel.cs | 5 +++ .../View/ChangeDeviceNameView.xaml.cs | 8 ++--- DosingSystem/View/RecipeControlView.xaml | 4 +-- .../ViewModel/ChangeDeviceNameViewModel.cs | 9 ------ .../ViewModel/RecipeControlViewModel.cs | 15 ++++----- 12 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs diff --git a/BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs b/BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs new file mode 100644 index 00000000..b42f5579 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace BPASmartClient.CustomResource.Converters +{ + public class RecipeStatusConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + if (value.ToString() == "等待制作") + return Brushes.Yellow; + else if (value.ToString() == "制作完成") + return Brushes.Green; + } + return default; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs index a8e571fb..76d6eb0e 100644 --- a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs +++ b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs @@ -114,7 +114,7 @@ namespace BPASmartClient.Model set { _mRecipeStatus = value; - if (value == 1) Status = Status.等待配料; + if (value == 1 && Status != Status.配料完成) Status = Status.等待配料; else if (value == 2) Status = Status.正在配料; else if (value == 3) Status = Status.配料完成; OnPropertyChanged(); diff --git a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj index 6ea9cbb7..f94d003f 100644 --- a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj +++ b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj @@ -9,6 +9,7 @@ + diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index 6d49c57d..8d6019e3 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using BPA.Helper; using BPASmartClient.MQTT; +using BPA.Message; namespace BPASmartClient.MorkS { diff --git a/DosingSystem/App.xaml b/DosingSystem/App.xaml index a10b130a..f6eabe3e 100644 --- a/DosingSystem/App.xaml +++ b/DosingSystem/App.xaml @@ -28,6 +28,7 @@ + diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index b2e2bb6e..3b9a58cf 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -28,8 +28,12 @@ namespace BPASmartClient.DosingSystem BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut(); MenuInit(); DataInit(); - DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 + ThreadManage.GetInstance().Start(new Action(() => + { + DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 + }), "设备初始化"); MainView mv = new MainView(); + mv.TitleName = "味魔方管理系统软件[简称:味魔方] 1.0.1"; LoginView lv = new LoginView(); var res = lv.ShowDialog(); if (res != null && res == true) diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index e07a2d81..8d1787b0 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -307,7 +307,7 @@ namespace BPASmartClient.DosingSystem modbusTcp.ShowEx = new Action((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); this.DeviceName = DeviceName; AlarmHelper.Init(); - + if (modbusTcp.Connected) { ThreadManage.GetInstance().StartLong(new Action(() => @@ -364,7 +364,7 @@ namespace BPASmartClient.DosingSystem modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); - modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100); + modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成"); } } diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs index cbdb4c7b..d3ac46ea 100644 --- a/DosingSystem/Model/RecipeModel.cs +++ b/DosingSystem/Model/RecipeModel.cs @@ -40,6 +40,11 @@ namespace BPASmartClient.DosingSystem [Newtonsoft.Json.JsonIgnore] public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); + [Newtonsoft.Json.JsonIgnore] + public string RecipStatus { get { return _mRecipStatus; } set { _mRecipStatus = value; OnPropertyChanged(); } } + private string _mRecipStatus; + + /// /// 原料集合 /// diff --git a/DosingSystem/View/ChangeDeviceNameView.xaml.cs b/DosingSystem/View/ChangeDeviceNameView.xaml.cs index d8ecd4ac..4b349bd3 100644 --- a/DosingSystem/View/ChangeDeviceNameView.xaml.cs +++ b/DosingSystem/View/ChangeDeviceNameView.xaml.cs @@ -1,5 +1,4 @@ -using BPASmartClient.Helper; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,6 +11,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using BPA.Helper; namespace BPASmartClient.DosingSystem.View { @@ -23,8 +23,8 @@ namespace BPASmartClient.DosingSystem.View public ChangeDeviceNameView() { InitializeComponent(); - ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); - ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose"); + //ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); + ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose", true); this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; } } diff --git a/DosingSystem/View/RecipeControlView.xaml b/DosingSystem/View/RecipeControlView.xaml index a05ea430..752864c0 100644 --- a/DosingSystem/View/RecipeControlView.xaml +++ b/DosingSystem/View/RecipeControlView.xaml @@ -880,8 +880,8 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" - Foreground="Yellow" - Text="等待执行" /> + Foreground="{Binding RecipStatus,Converter={StaticResource RecipeStatusConvert}}" + Text="{Binding RecipStatus}" /> p.RecipeName == deviceName); - UserTreeWait.Add(new RecipeModel { SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); + UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); } NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); @@ -107,7 +107,7 @@ namespace BPASmartClient.DosingSystem.ViewModel if (tempDevice != null) { /*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ - if (tempDevice.DeviceNum > 0) + if (tempDevice.DeviceNum > 0) { int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); @@ -116,9 +116,9 @@ namespace BPASmartClient.DosingSystem.ViewModel MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{item.ToBinString()}"); } } - if (tInfo.ElementAt(i).ElementAt(m).Loc >0) + if (tInfo.ElementAt(i).ElementAt(m).Loc > 0) { - if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) + if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) { BarrelNum.Add(tInfo.ElementAt(i).ElementAt(m).Loc); } @@ -232,6 +232,7 @@ namespace BPASmartClient.DosingSystem.ViewModel RecipeName = recipeComple.RecipeName, SerialNum = UserTreeCompelete.Count + 1, RecipCode = recipeComple.RecipCode, + RecipStatus = "制作完成" }); }); App.Current.Dispatcher.Invoke(new Action(() => @@ -283,14 +284,14 @@ namespace BPASmartClient.DosingSystem.ViewModel MessageNotify.GetInstance.ShowRunLog("错误"); return; } - else + else { switch (cnt) { case 1: int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 1); int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 2); - if (a1 >= 0) + if (a1 >= 0) { Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); } @@ -461,7 +462,7 @@ namespace BPASmartClient.DosingSystem.ViewModel } } } - else + else { if (Location2 >= 0) {