diff --git a/BPASmartClient.CustomResource/Pages/View/PromptView.xaml b/BPASmartClient.CustomResource/Pages/View/PromptView.xaml index f3e888b0..e489ca45 100644 --- a/BPASmartClient.CustomResource/Pages/View/PromptView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/PromptView.xaml @@ -10,6 +10,7 @@ Height="200" AllowsTransparency="True" Background="{x:Null}" + Topmost="True" WindowStartupLocation="CenterScreen" WindowStyle="None" mc:Ignorable="d"> @@ -54,7 +55,7 @@ Name="infoType" Grid.Column="1" VerticalAlignment="Top" - FontSize="16" + FontSize="15" Foreground="DeepSkyBlue" /> diff --git a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml index d2034e8a..635e3b0e 100644 --- a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml +++ b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml @@ -102,27 +102,19 @@ - - - - - - diff --git a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs index 7e508ead..a8e571fb 100644 --- a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs +++ b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs @@ -1,6 +1,7 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -97,6 +98,9 @@ namespace BPASmartClient.Model public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } private float _mUpLimtWeightFeedback; + + + /// /// 原料设备执行状态 /// 1:等待配料 diff --git a/DosingSystem/Model/DeviceCurrentStatus.cs b/DosingSystem/Model/DeviceCurrentStatus.cs index 10ae1a78..d77ddc02 100644 --- a/DosingSystem/Model/DeviceCurrentStatus.cs +++ b/DosingSystem/Model/DeviceCurrentStatus.cs @@ -17,13 +17,26 @@ namespace BPASmartClient.DosingSystem private double _mWeight; /// - /// 是否正在下料 + /// 重量设置 /// - public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } - private bool _mIsLayOff; + public float SetWeight { get { return _mSetWeight; } set { _mSetWeight = value; OnPropertyChanged(); } } + private float _mSetWeight; + + ///// + ///// 下料控制 + ///// + //public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } + //private bool _mIsLayOff; + + /// + /// 下料控制 + /// + public bool BaitingControl { get { return _mBaitingControl; } set { _mBaitingControl = value; OnPropertyChanged(); } } + private bool _mBaitingControl; + /// - /// 设备是否在线 + /// 设备运行状态 /// public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } } private bool _mRunStatus; diff --git a/DosingSystem/View/HardwareStatusView.xaml b/DosingSystem/View/HardwareStatusView.xaml index 2f1b7472..906d052f 100644 --- a/DosingSystem/View/HardwareStatusView.xaml +++ b/DosingSystem/View/HardwareStatusView.xaml @@ -31,6 +31,7 @@ Background="Transparent" BorderThickness="0" ItemsSource="{Binding TopDeviceCurrentStatuses}" + ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> @@ -46,7 +47,7 @@ - + @@ -130,7 +131,7 @@ Text="到位检测" /> - + - + + Text="{Binding SetWeight}" /> @@ -426,7 +429,7 @@ VerticalAlignment="Center" Background="Transparent" FontSize="20" - IsChecked="{Binding IsLayOff}" + IsChecked="{Binding BaitingControl}" Style="{StaticResource SwitchToggleButtonStyle}" /> - + + Text="{Binding SetWeight}" /> diff --git a/DosingSystem/View/NewRecipeView.xaml b/DosingSystem/View/NewRecipeView.xaml index 28b35e4f..8ce11a87 100644 --- a/DosingSystem/View/NewRecipeView.xaml +++ b/DosingSystem/View/NewRecipeView.xaml @@ -223,6 +223,7 @@ IsEditable="False" ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" SelectedIndex="{Binding SelectIndex}" + SelectionChanged="cb_SelectionChanged" Style="{StaticResource ComboBoxStyle}" Text="{Binding RawMaterialName}" /> diff --git a/DosingSystem/View/NewRecipeView.xaml.cs b/DosingSystem/View/NewRecipeView.xaml.cs index f9bc22bd..7c779971 100644 --- a/DosingSystem/View/NewRecipeView.xaml.cs +++ b/DosingSystem/View/NewRecipeView.xaml.cs @@ -28,5 +28,10 @@ namespace BPASmartClient.DosingSystem.View ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView", true); this.Unloaded += (o, s) => { Json.Save(); }; } + + private void cb_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ActionManage.GetInstance.SendAsync("原料选择修改", (sender as ComboBox).SelectedValue); + } } } diff --git a/DosingSystem/ViewModel/HardwareStatusViewModel.cs b/DosingSystem/ViewModel/HardwareStatusViewModel.cs index 1460524f..83b91438 100644 --- a/DosingSystem/ViewModel/HardwareStatusViewModel.cs +++ b/DosingSystem/ViewModel/HardwareStatusViewModel.cs @@ -54,11 +54,53 @@ namespace BPASmartClient.DosingSystem.ViewModel } } } + StatusUpdate(TopDeviceCurrentStatuses); + StatusUpdate(BottomDeviceCurrentStatuses); OnDetection = GlobalDevice.PlcData.OnDetection; UnderDetection = GlobalDevice.PlcData.UnderDetection; ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0; Thread.Sleep(100); }), "输送带料仓状态监控"); + + RecipeControlCommand = new RelayCommand((o) => + { + if (o != null && o is DeviceCurrentStatus currentStatus) + { + var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == currentStatus.DeviceName); + if (res != null) + { + DeviceInquire.GetInstance.GetDevice(res.IpAddress).Start(currentStatus.SetWeight); + } + } + }); + } + + private void StatusUpdate(ObservableCollection devices) + { + if (devices == null) return; + for (int i = 0; i < devices.Count; i++) + { + if (devices.ElementAt(i).BaitingControl) + { + var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName); + if (res != null) + { + var runStatus = DeviceInquire.GetInstance.GetDevice(res.IpAddress).deviceStatus.RunStatus; + if (runStatus == 3) + { + if (TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName) != null) + { + TopDeviceCurrentStatuses.ElementAt(i).BaitingControl = false; + } + else if (BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName) != null) + { + BottomDeviceCurrentStatuses.ElementAt(i).BaitingControl = false; + } + DeviceInquire.GetInstance.GetDevice(res.IpAddress).StatusReset(); + } + } + } + } } public ObservableCollection TopDeviceCurrentStatuses { get; set; } @@ -69,6 +111,8 @@ namespace BPASmartClient.DosingSystem.ViewModel public RelayCommand ConveyerBeltControlCommand { get; set; } + public RelayCommand RecipeControlCommand { get; set; } + /// /// 输送带状态 /// diff --git a/DosingSystem/ViewModel/NewRecipeViewModel.cs b/DosingSystem/ViewModel/NewRecipeViewModel.cs index 40d6e777..9c76f5fb 100644 --- a/DosingSystem/ViewModel/NewRecipeViewModel.cs +++ b/DosingSystem/ViewModel/NewRecipeViewModel.cs @@ -5,8 +5,6 @@ using System.Text; using System.Threading.Tasks; using BPA.Helper; using System.Collections.ObjectModel; - -using BPA.Helper; using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.Model; using BPASmartClient.CustomResource.UserControls.MessageShow; @@ -18,6 +16,16 @@ namespace BPASmartClient.DosingSystem.ViewModel { public NewRecipeViewModel() { + ActionManage.GetInstance.RegisterAsync(new Action((o) => + { + if (!string.IsNullOrEmpty(o?.ToString())) + { + if (RawMaterials.FirstOrDefault(p => p.RawMaterialName == o.ToString()) != null) + { + App.Current.Dispatcher.Invoke(() => { MessageNotify.GetInstance.ShowDialog("单前原料和其它原料重复,请重新选择!", DialogType.Warning); }); + } + } + }), "原料选择修改"); ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is RecipeModel rm) @@ -35,13 +43,20 @@ namespace BPASmartClient.DosingSystem.ViewModel AddCommand = new RelayCommand(() => { + if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count) + { + MessageNotify.GetInstance.ShowDialog("原材料不足!"); + return; + } p: string guid = Guid.NewGuid().ToString(); if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null) { + int index = RawMaterials.Count;//<= 0 ? 0 : RawMaterials.Count - 1; RawMaterials.Add(new RawMaterialModel() { - RawMaterialId = guid + RawMaterialId = guid, + SelectIndex = index }); } else goto p; @@ -58,7 +73,14 @@ namespace BPASmartClient.DosingSystem.ViewModel SaveCommand = new RelayCommand(() => { - if (string.IsNullOrEmpty(RecipeName)) { ErrorInfo = "请输入配方名称"; return; } + if (string.IsNullOrEmpty(RecipeName)) { MessageNotify.GetInstance.ShowDialog("请输入配方名称!", DialogType.Warning); ErrorInfo = "请输入配方名称"; return; } + + var tempRes = RawMaterials.GroupBy(p => p.RawMaterialName); + if (tempRes.Count() != RawMaterials.Count) + { + MessageNotify.GetInstance.ShowDialog("单前原料和其它原料重复,请重新选择!", DialogType.Warning); + return; + } //编辑配方 if (Index >= 0 && Index < Json.Data.Recipes.Count) @@ -67,6 +89,7 @@ namespace BPASmartClient.DosingSystem.ViewModel if (res >= 0 && res != Index) { ErrorInfo = "配方名称已经存在!"; + MessageNotify.GetInstance.ShowDialog("配方名称已经存在!", DialogType.Warning); return; } Json.Data.Recipes.ElementAt(Index).RecipeName = RecipeName; @@ -93,6 +116,7 @@ namespace BPASmartClient.DosingSystem.ViewModel if (Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName) != null) { ErrorInfo = "配方名称已存在!"; + MessageNotify.GetInstance.ShowDialog("配方名称已经存在!", DialogType.Warning); return; } @@ -168,7 +192,6 @@ namespace BPASmartClient.DosingSystem.ViewModel } - private string RecipCode = string.Empty; public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }