From 7ca625c0f39df3e68583f96df5647ffdf447a9bf 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: Mon, 24 Oct 2022 17:15:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E5=8A=A8=E6=8E=A7=E5=88=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Converters/CountIsVisiableConvert.cs | 33 ++++ .../UserControls/ConveyBelt2.xaml | 4 +- DosingSystem/App.xaml | 1 + DosingSystem/App.xaml.cs | 14 +- .../BPASmartClient.DosingSystem.csproj | 3 +- DosingSystem/Model/CylinderStatusModel.cs | 4 +- DosingSystem/Model/DeviceCurrentStatus.cs | 4 +- DosingSystem/Model/DeviceInquire.cs | 4 +- DosingSystem/Model/OutletInfoModel.cs | 4 +- DosingSystem/Model/RecipeModel.cs | 4 +- DosingSystem/Model/RecipeProcess.cs | 4 +- DosingSystem/Model/StockStatusModel.cs | 4 +- DosingSystem/Model/ViewModelBase.cs | 6 +- DosingSystem/Model/par/BasePar.cs | 52 ++++++ DosingSystem/Model/par/DevicePar.cs | 29 +--- DosingSystem/Model/par/DeviceParModel.cs | 4 +- DosingSystem/Service/SiemensDevice.cs | 23 ++- DosingSystem/View/CommParSetView.xaml | 149 +++++++++++++++++- DosingSystem/View/CommParSetView.xaml.cs | 4 +- DosingSystem/View/ManualControlView.xaml | 13 +- DosingSystem/View/ManualControlView.xaml.cs | 3 + .../ViewModel/ChangeDeviceNameViewModel.cs | 2 - DosingSystem/ViewModel/CommparSetViewModel.cs | 16 +- DosingSystem/ViewModel/DeviceListViewModel.cs | 6 +- .../ViewModel/DeviceMaterialParViewModel.cs | 4 +- .../ViewModel/HardwareStatusViewModel.cs | 6 +- .../ViewModel/ManualControlViewModel.cs | 57 +++++-- .../ViewModel/NewMaterialViewModel.cs | 4 +- DosingSystem/ViewModel/NewOutletViewModel.cs | 14 +- DosingSystem/ViewModel/NewRecipeViewModel.cs | 4 +- .../ViewModel/OutletManagementViewModel.cs | 4 +- .../ViewModel/RecipeControlViewModel.cs | 6 +- .../ViewModel/RecipeSettingsViewModel.cs | 6 +- .../ViewModel/StockControViewModel.cs | 6 +- 34 files changed, 374 insertions(+), 127 deletions(-) create mode 100644 BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs create mode 100644 DosingSystem/Model/par/BasePar.cs diff --git a/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs b/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs new file mode 100644 index 00000000..9d3ba102 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace BPASmartClient.CustomResource.Converters +{ + public class CountIsVisiableConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + var count = value?.GetType()?.GetProperty("Count")?.GetValue(value); + if (count != null && count is int tempCount) + { + if (tempCount > 0) return Visibility.Visible; + } + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml index 1b336e6d..79e65167 100644 --- a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml +++ b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml @@ -12,10 +12,10 @@ + Margin="5" + Background="Transparent"> + diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index bbb1143a..cebb3189 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -128,13 +128,13 @@ namespace BPASmartClient.DosingSystem AssemblyName = "BPASmartClient.DosingSystem", ToggleWindowPath = "View.ManualControlView" }); - ManualControl.Add(new SubMenumodel() - { - SubMenuName = "料仓控制", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.StockControlView" - }); + //ManualControl.Add(new SubMenumodel() + //{ + // SubMenuName = "料仓控制", + // SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + // AssemblyName = "BPASmartClient.DosingSystem", + // ToggleWindowPath = "View.StockControlView" + //}); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/DosingSystem/BPASmartClient.DosingSystem.csproj b/DosingSystem/BPASmartClient.DosingSystem.csproj index 0807292b..df8df978 100644 --- a/DosingSystem/BPASmartClient.DosingSystem.csproj +++ b/DosingSystem/BPASmartClient.DosingSystem.csproj @@ -16,9 +16,8 @@ - + - diff --git a/DosingSystem/Model/CylinderStatusModel.cs b/DosingSystem/Model/CylinderStatusModel.cs index 8e94d96b..933851a4 100644 --- a/DosingSystem/Model/CylinderStatusModel.cs +++ b/DosingSystem/Model/CylinderStatusModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class CylinderStatusModel : ObservableObject + public class CylinderStatusModel : NotifyBase { /// /// 气缸原点信号 diff --git a/DosingSystem/Model/DeviceCurrentStatus.cs b/DosingSystem/Model/DeviceCurrentStatus.cs index 37ec350b..f7473b11 100644 --- a/DosingSystem/Model/DeviceCurrentStatus.cs +++ b/DosingSystem/Model/DeviceCurrentStatus.cs @@ -4,11 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DeviceCurrentStatus : ObservableObject + public class DeviceCurrentStatus : NotifyBase { /// /// 当前料仓重量反馈 diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index b7218bf7..120b1252 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -111,8 +111,8 @@ namespace BPASmartClient.DosingSystem public void Init() { - if (!string.IsNullOrEmpty(Json.Data.Address)) IPSegment = Json.Data.Address; - else Json.Data.Address = IPSegment; + if (!string.IsNullOrEmpty(Json.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json.Data.BaseParModel.NetworkSegAddress; + else Json.Data.BaseParModel.NetworkSegAddress = IPSegment; TestData(); IpAddressLines(); DeviceDataInit(); diff --git a/DosingSystem/Model/OutletInfoModel.cs b/DosingSystem/Model/OutletInfoModel.cs index 046e52dd..470115dc 100644 --- a/DosingSystem/Model/OutletInfoModel.cs +++ b/DosingSystem/Model/OutletInfoModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; using System.Collections.ObjectModel; namespace BPASmartClient.DosingSystem @@ -11,7 +11,7 @@ namespace BPASmartClient.DosingSystem /// /// 出料口信息 /// - public class OutletInfoModel : ObservableObject + public class OutletInfoModel : NotifyBase { /// /// 出料口名称 diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs index df6e89b2..cbdb4c7b 100644 --- a/DosingSystem/Model/RecipeModel.cs +++ b/DosingSystem/Model/RecipeModel.cs @@ -6,14 +6,14 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using BPASmartClient.Model; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { /// /// 配方模块 /// - public class RecipeModel : ObservableObject + public class RecipeModel : NotifyBase { [Newtonsoft.Json.JsonIgnore] public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } diff --git a/DosingSystem/Model/RecipeProcess.cs b/DosingSystem/Model/RecipeProcess.cs index 9de11200..d9f5c708 100644 --- a/DosingSystem/Model/RecipeProcess.cs +++ b/DosingSystem/Model/RecipeProcess.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class RecipeProcess : ObservableObject + public class RecipeProcess : NotifyBase { public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } private string _mRawMaterialName; diff --git a/DosingSystem/Model/StockStatusModel.cs b/DosingSystem/Model/StockStatusModel.cs index 531882fe..072da4e7 100644 --- a/DosingSystem/Model/StockStatusModel.cs +++ b/DosingSystem/Model/StockStatusModel.cs @@ -1,4 +1,4 @@ -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; using System; using System.Collections.Generic; using System.Linq; @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace BPASmartClient.DosingSystem { - public class StockStatusModel : ObservableObject + public class StockStatusModel : NotifyBase { /// /// 料仓物料重量 diff --git a/DosingSystem/Model/ViewModelBase.cs b/DosingSystem/Model/ViewModelBase.cs index ae5f8e17..b28647bc 100644 --- a/DosingSystem/Model/ViewModelBase.cs +++ b/DosingSystem/Model/ViewModelBase.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; -using Microsoft.Toolkit.Mvvm.Input; +using BPA.Helper; + using System.Collections.ObjectModel; namespace BPASmartClient.DosingSystem { - public class ViewModelBase : ObservableObject + public class ViewModelBase : NotifyBase { public int Index { get; set; } = -1; public RelayCommand AddCommand { get; set; }//添加 diff --git a/DosingSystem/Model/par/BasePar.cs b/DosingSystem/Model/par/BasePar.cs new file mode 100644 index 00000000..f527f9a5 --- /dev/null +++ b/DosingSystem/Model/par/BasePar.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BPA.Helper; + +namespace BPASmartClient.DosingSystem +{ + /// + /// 基础参数 + /// + public class BasePar : NotifyBase + { + /// + /// 设备扫描网段 + /// + public string NetworkSegAddress { get { return _mNetworkSegAddress; } set { _mNetworkSegAddress = value; OnPropertyChanged(); } } + private string _mNetworkSegAddress = "192.168.0."; + + /// + /// 输送带设备 PLC IP 地址 + /// + public string DeviceAddress { get { return _mDeviceAddress; } set { _mDeviceAddress = value; OnPropertyChanged(); } } + private string _mDeviceAddress = "192.168.0.1"; + + /// + /// 输送带数量 + /// + public int ConveyerBeltCount { get { return _mConveyerBeltCount; } set { _mConveyerBeltCount = value; OnPropertyChanged(); } } + private int _mConveyerBeltCount = 0; + + /// + /// 升降气缸数量 + /// + public int LiftCylinderCount { get { return _mLiftCylinderCount; } set { _mLiftCylinderCount = value; OnPropertyChanged(); } } + private int _mLiftCylinderCount = 0; + + /// + /// 阻挡气缸数量 + /// + public int BlockCylinderCount { get { return _mBlockCylinderCount; } set { _mBlockCylinderCount = value; OnPropertyChanged(); } } + private int _mBlockCylinderCount = 0; + + /// + /// 托盘气缸数量 + /// + public int PalletCylinderCount { get { return _mPalletCylinderCount; } set { _mPalletCylinderCount = value; OnPropertyChanged(); } } + private int _mPalletCylinderCount = 0; + + } +} diff --git a/DosingSystem/Model/par/DevicePar.cs b/DosingSystem/Model/par/DevicePar.cs index 61e7bf74..899ec930 100644 --- a/DosingSystem/Model/par/DevicePar.cs +++ b/DosingSystem/Model/par/DevicePar.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DevicePar + public class DevicePar : NotifyBase { /// /// 配料设备参数 @@ -17,30 +17,9 @@ namespace BPASmartClient.DosingSystem public ObservableCollection OutletInfoModels { get; set; } = new ObservableCollection(); - /// - /// 设备扫描网段 - /// - public string Address { get; set; } = string.Empty; - /// - /// 设备端口号 - /// - public int Port { get; set; } = 502; - - /// - /// 升降气缸数量 - /// - public int LiftCylinderCount { get; set; } - - /// - /// 阻挡气缸数量 - /// - public int BlockCylinderCount { get; set; } - - /// - /// 托盘气缸数量 - /// - public int PalletCylinderCount { get; set; } + public BasePar BaseParModel { get { return _mBaseParModel; } set { _mBaseParModel = value; OnPropertyChanged(); } } + private BasePar _mBaseParModel = new BasePar(); } } diff --git a/DosingSystem/Model/par/DeviceParModel.cs b/DosingSystem/Model/par/DeviceParModel.cs index c9dfe67f..d7a0d5f3 100644 --- a/DosingSystem/Model/par/DeviceParModel.cs +++ b/DosingSystem/Model/par/DeviceParModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DeviceParModel : ObservableObject + public class DeviceParModel : NotifyBase { /// /// 原料名称 diff --git a/DosingSystem/Service/SiemensDevice.cs b/DosingSystem/Service/SiemensDevice.cs index dd53f713..d3dbf086 100644 --- a/DosingSystem/Service/SiemensDevice.cs +++ b/DosingSystem/Service/SiemensDevice.cs @@ -36,12 +36,33 @@ namespace BPASmartClient.DosingSystem ThreadManage.GetInstance().StartLong(new Action(() => { - GlobalDevice.PlcData = MySiemens.ReadClass(3); + GlobalDevice.PlcData = MySiemens.ReadClass(3);//获取PLC到上位机的数据 Thread.Sleep(50); }), "读取输送线设备数据", true); } + public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0) + { + if (num > 0) + { + string Add = string.Empty; + var FirstAdd = num / 8; + var EndAdd = (num % 8); + if (EndAdd == 0) + { + FirstAdd--; + EndAdd = 7; + } + else EndAdd--; + Add = $"{Prefix}{FirstAdd + StartAdd}.{EndAdd}"; + return Add; + } + return default; + + + } + } diff --git a/DosingSystem/View/CommParSetView.xaml b/DosingSystem/View/CommParSetView.xaml index f6b2a380..bb57c734 100644 --- a/DosingSystem/View/CommParSetView.xaml +++ b/DosingSystem/View/CommParSetView.xaml @@ -22,24 +22,157 @@ - - - - + + + +