From a28b81537c6dc2831698025e20d6c4e98fe99118 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: Tue, 17 May 2022 18:31:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPASmartClient.Business.csproj | 2 +- BPASmartClient.Business/Plugin/OrderProxy.cs | 7 +- .../BPASmartClient.CustomResource.csproj | 2 +- .../Converters/VisibleTypeConverter.cs | 34 +++ .../BPASmartClient.Device.csproj | 2 +- BPASmartClient.Modbus/ModbusTcp.cs | 38 --- .../BPASmartClient.Model.csproj | 2 +- .../订单/OrderStatusChangedEvent.cs | 7 +- BPASmartClient.MorkT/Control_MorkT.cs | 8 +- .../Model/DeviceConfigModel.cs | 102 ++++++-- .../ShopDeviceConfigViewModel.cs | 219 ++++++++++++++++-- BPASmartClient/App.config | 35 ++- BPASmartClient/App.xaml | 1 + .../Control/ShopDeviceConfigView.xaml | 218 +++++++++-------- .../Control/ShopDeviceConfigView.xaml.cs | 64 +++++ BPASmartClient/DeviceInfo.xml | 2 +- .../BPASmartClient.MORKIC.csproj | 2 +- 17 files changed, 531 insertions(+), 214 deletions(-) create mode 100644 BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index da5bfe70..e150ff8b 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.Business/Plugin/OrderProxy.cs b/BPASmartClient.Business/Plugin/OrderProxy.cs index 2f0a2b36..5f8969ef 100644 --- a/BPASmartClient.Business/Plugin/OrderProxy.cs +++ b/BPASmartClient.Business/Plugin/OrderProxy.cs @@ -45,11 +45,11 @@ namespace BPASmartClient.Business if (morkOrderPushes.TryDequeue(out MorkOrderPush mork)) { Thread.Sleep(3000); - new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId }.Publish(); + new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); Thread.Sleep(5000); - new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId }.Publish(); + new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); Thread.Sleep(5000); - new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId }.Publish(); + new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); Thread.Sleep(2000); } } @@ -144,6 +144,7 @@ namespace BPASmartClient.Business #region MQTT 订单状态修改 var clientId = Plugin.GetInstance().GetPlugin().ClientId; var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType); + var q = temp.Serialize(false); Plugin.GetInstance().GetPlugin().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false)); #endregion } diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index f1590991..822d0320 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -200,7 +200,7 @@ - + diff --git a/BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs b/BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs new file mode 100644 index 00000000..1225ef80 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +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 VisibleTypeConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && parameter != null && parameter is string p && value is bool type) + { + if (p != null) + { + if (p == "NetworkPort") + return type ? Visibility.Visible : Visibility.Collapsed; + else if (p == "SerialPort") + return !type ? Visibility.Visible : Visibility.Collapsed; + } + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj index d6e29885..3164a1d8 100644 --- a/BPASmartClient.Device/BPASmartClient.Device.csproj +++ b/BPASmartClient.Device/BPASmartClient.Device.csproj @@ -5,7 +5,7 @@ - + diff --git a/BPASmartClient.Modbus/ModbusTcp.cs b/BPASmartClient.Modbus/ModbusTcp.cs index e9d21e05..3db68648 100644 --- a/BPASmartClient.Modbus/ModbusTcp.cs +++ b/BPASmartClient.Modbus/ModbusTcp.cs @@ -452,44 +452,6 @@ namespace BPASmartClient.Modbus master.WriteSingleRegister(slaveAddress, startAddress, value); } #endregion - - - - - - } - - - public enum ReadType - { - /// - /// 读线圈 - /// - Coils, - /// - /// 读输入线圈 - /// - Inputs, - /// - /// 读保持寄存器 - /// - HoldingRegisters, - /// - /// 读输入寄存器 - /// - InputRegisters, - } - - public enum WriteType - { - /// - /// 写线圈 - /// - Coils, - /// - /// 写保持寄存器 - /// - HoldingRegisters, } public enum CommandType diff --git a/BPASmartClient.Model/BPASmartClient.Model.csproj b/BPASmartClient.Model/BPASmartClient.Model.csproj index b30929ab..f10dc37c 100644 --- a/BPASmartClient.Model/BPASmartClient.Model.csproj +++ b/BPASmartClient.Model/BPASmartClient.Model.csproj @@ -15,7 +15,7 @@ - + diff --git a/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs b/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs index f5c25182..7f9045ce 100644 --- a/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs +++ b/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs @@ -10,7 +10,7 @@ namespace BPASmartClient.Model /// /// 订单状态改变事件 /// - public class OrderStatusChangedEvent:BaseEvent + public class OrderStatusChangedEvent : BaseEvent { /// /// 子订单ID @@ -20,5 +20,10 @@ namespace BPASmartClient.Model /// 状态 /// public ORDER_STATUS Status { get; set; } + + /// + /// 商品名称 + /// + public string GoodName { get; set; } } } diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index cfacd727..dcdacc67 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -15,7 +15,7 @@ namespace BPASmartClient.MorkT { public class Control_MorkT : BaseDevice { - public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKIC; } } + public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } } GLV_MorkT morkT = new GLV_MorkT(); @@ -49,7 +49,7 @@ namespace BPASmartClient.MorkT LebaiRobot.GetInstance.GetRobotModeStatus(); } - + public override void Stop() { @@ -108,7 +108,7 @@ namespace BPASmartClient.MorkT //获取当前物料所属商品类型 currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); } - + //获取主料和容器位置 if (morkT.batchings[res.BatchingLoc].BatchingClass == BATCHING_CLASS.MAIN_MATERIAL) loc_Goods = res.BatchingLoc; @@ -157,7 +157,7 @@ namespace BPASmartClient.MorkT return morkT.batchings[batchingLoc].GoodsType; return GOODS_TYPE.NEITHER; } - + } diff --git a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs index 49e9d013..f6f699f3 100644 --- a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs +++ b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; +using Microsoft.Toolkit.Mvvm.Input; namespace BPASmartClient.ViewModel.Model { @@ -13,6 +14,7 @@ namespace BPASmartClient.ViewModel.Model /// public class DeviceConfigModel : ObservableObject { + /// /// 店铺名称 /// @@ -28,7 +30,7 @@ namespace BPASmartClient.ViewModel.Model /// /// 设备集合 /// - public ObservableCollection deviceModels = new ObservableCollection(); + public ObservableCollection deviceModels { get; set; } = new ObservableCollection(); } /// @@ -48,6 +50,11 @@ namespace BPASmartClient.ViewModel.Model public string DeviceModule { get { return _mDeviceModule; } set { _mDeviceModule = value; OnPropertyChanged(); } } private string _mDeviceModule = string.Empty; + + public string Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } } + private string _mId = string.Empty; + + /// /// 设备ID /// @@ -57,7 +64,7 @@ namespace BPASmartClient.ViewModel.Model /// /// 通讯模块 /// - public ObservableCollection communicationDevcies = new ObservableCollection(); + public ObservableCollection communicationDevcies { get; set; } = new ObservableCollection(); } @@ -72,10 +79,14 @@ namespace BPASmartClient.ViewModel.Model public string CommunicationModule { get { return _mCommunicationModule; } set { _mCommunicationModule = value; OnPropertyChanged(); } } private string _mCommunicationModule = string.Empty; - public string CommunicationName { get { return _mCommunicationName; } set { _mCommunicationName = value; OnPropertyChanged(); } } private string _mCommunicationName = string.Empty; + public string DeviceModelId { get { return _mDeviceModelId; } set { _mDeviceModelId = value; OnPropertyChanged(); } } + private string _mDeviceModelId = string.Empty; + + public CommunicationPar communicationPar { get { return _mcommunicationPar; } set { _mcommunicationPar = value; OnPropertyChanged(); } } + private CommunicationPar _mcommunicationPar = new CommunicationPar(); } @@ -85,44 +96,93 @@ namespace BPASmartClient.ViewModel.Model /// public class CommunicationPar : ObservableObject { - public CommunicationParType communicationType { get { return _mcommunicationType; } set { _mcommunicationType = value; OnPropertyChanged(); } } - private CommunicationParType _mcommunicationType; - - - public string CommunicationValue { get { return _mCommunicationValue; } set { _mCommunicationValue = value; OnPropertyChanged(); } } - private string _mCommunicationValue = string.Empty; + /// + /// 通讯类型,false:串口,true:网口 + /// + public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } } + private bool _mCommunicationType; - } - public enum CommunicationParType - { /// /// IP地址 /// - IPAddress, + public string IPAddress { get { return _mIPAddress; } set { _mIPAddress = value; OnPropertyChanged(); } } + private string _mIPAddress; + + /// + /// IP 端口号 + /// + public int IPPort { get { return _mIPPort; } set { _mIPPort = value; OnPropertyChanged(); } } + private int _mIPPort; + /// - /// 端口号 + /// ip 串口 站号 /// - Port, + public int StationNo { get { return _mStationNo; } set { _mStationNo = value; OnPropertyChanged(); } } + private int _mStationNo; + + /// - /// 串口端口号 + /// 串口单口号 /// - SerialPort, + public string SerialPort { get { return _mSerialPort; } set { _mSerialPort = value; OnPropertyChanged(); } } + private string _mSerialPort; + /// /// 波特率 /// - BaudRate, + public int BaudRate { get { return _mBaudRate; } set { _mBaudRate = value; OnPropertyChanged(); } } + private int _mBaudRate; + /// /// 数据位 /// - DataBits, + public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } } + private int _mDataBits; + /// /// 停止位 /// - StopBits, + public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } } + private string _mStopBits; + /// /// 校验位 /// - Parity, + public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } } + private string _mParity; + } + + //public enum CommunicationParType + //{ + // /// + // /// IP地址 + // /// + // IPAddress, + // /// + // /// 端口号 + // /// + // Port, + // /// + // /// 串口端口号 + // /// + // SerialPort, + // /// + // /// 波特率 + // /// + // BaudRate, + // /// + // /// 数据位 + // /// + // DataBits, + // /// + // /// 停止位 + // /// + // StopBits, + // /// + // /// 校验位 + // /// + // Parity, + //} } diff --git a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs index e7e0de7c..a919b862 100644 --- a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs +++ b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs @@ -8,11 +8,16 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using BPASmartClient.ViewModel.Model; using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Windows; namespace BPASmartClient.ViewModel { public class ShopDeviceConfigViewModel : ObservableObject { + private DeviceConfigModel configModel = new DeviceConfigModel(); + public ShopDeviceConfigViewModel() { ActionManage.GetInstance.Register(new Action((o) => @@ -21,43 +26,213 @@ namespace BPASmartClient.ViewModel { if (par.Length == 2) { - ShopName = par[0]; - ShopId = par[1]; + configModel.ShopName = par[0]; + configModel.ShopId = par[1]; + deviceConfig.Add(configModel); } } }), "ShopPar"); - ObservableCollection deviceModels = new ObservableCollection(); - ObservableCollection communicationModels = new ObservableCollection(); - communicationModels.Add(new CommunicationModel() { CommunicationName = "通讯1", CommunicationModule = "qidong" }); - deviceModels.Add(new DeviceModel() { DeviceName = "设备1", DeviceId = "10", DeviceModule = "aa", communicationDevcies = communicationModels }); - deviceConfig = new DeviceConfigModel() + NewDeviceCommand = new RelayCommand(NewDevice); + RemoveDeviceCommand = new RelayCommand(RemoveDevice); + NewCommunicationCommand = new RelayCommand(NewCommunication); + RemoveCommunicationCommand = new RelayCommand(RemoveCommunication); + } + + private void RemoveCommunication(object? obj) + { + if (obj != null && obj is CommunicationModel com) { - ShopName = "且时且多", - ShopId = "10", - deviceModels = deviceModels - }; + if (com != null) + { + int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.Id == com.DeviceModelId); + if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) + { + var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName == com.CommunicationName); + if (res != null) + { + deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Remove(res); + } + } + } + } + } - NewDeviceCommand = new RelayCommand((o) => + private void NewCommunication(object? obj) + { + if (obj != null && obj is DeviceModel dm) { + if (dm != null) + { + string CommunicationName = string.Empty; + int num = 1; + while (true) + { + int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == dm.DeviceName); + if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) + { + var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName.Contains($"Communication_{num}")); + if (res == null) + { + deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Add(new CommunicationModel() + { + CommunicationName = $"Communication_{num}", + DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id, + communicationPar = new CommunicationPar() { CommunicationType = false } - }); + }); + break; + } + } + else break; + num++; + } + } + } + } + + private void RemoveDevice(object? obj) + { + if (obj != null && deviceConfig.Count == 1) + { + string DeviceName = obj?.ToString(); + var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == DeviceName); + if (res != null) + deviceConfig.ElementAt(0).deviceModels.Remove(res); + } } - public Action NewCommand { get; set; } + private void NewDevice(object? obj) + { + if (obj != null && deviceConfig.Count == 1) + { + string DeviceName = string.Empty; + int num = 1; + while (true) + { + var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == $"Device_{num}"); + if (res == null) + { + deviceConfig.ElementAt(0).deviceModels.Add(new DeviceModel() { DeviceId = "0", DeviceName = $"Device_{num}", Id = Guid.NewGuid().ToString() }); + break; + } + num++; + } + } + } + + + public static event EventHandler StaticPropertyChanged; + private static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") + { + StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName)); + } + + + //public static string DeviceNamePar + //{ + // get { return _mDeviceNamePar; } + // set + // { + // _mDeviceNamePar = value; + // if (deviceConfig.Count == 1) + // { + // int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName); + // if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) + // { + // deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceName = value; + // } + // } + // OnStaticPropertyChanged(); + // } + //} + //private static string _mDeviceNamePar; + + //public static string DeviceIdPar + //{ + // get { return _mDeviceIdPar; } + // set + // { + // _mDeviceIdPar = value; + // if (deviceConfig.Count == 1) + // { + // int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName); + // if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) + // { + // deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceId = value; + // } + // } + // OnStaticPropertyChanged(); + // } + //} + //private static string _mDeviceIdPar; + + public static Visibility DeviceParVisibility { get { return _mDeviceParVisibility; } set { _mDeviceParVisibility = value; OnStaticPropertyChanged(); } } + private static Visibility _mDeviceParVisibility = Visibility.Hidden; + public static Visibility CommunicationVisibility { get { return _mCommunicationVisibility; } set { _mCommunicationVisibility = value; OnStaticPropertyChanged(); } } + private static Visibility _mCommunicationVisibility = Visibility.Hidden; + + + + + //public static string DeviceModelId + //{ + // get { return _mDeviceModelId; } + // set + // { + // _mDeviceModelId = value; + + // } + //} + //private static string _mDeviceModelId; + + + //public static string DeviceName + //{ + // get { return _mDeviceName; } + // set + // { + // _mDeviceName = value; + // if (deviceConfig.Count == 1) + // { + // var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == value); + // if (res != null) + // { + // DeviceIdPar = res.DeviceId; + // DeviceNamePar = res.DeviceName; + // } + // } + // } + //} + //private static string _mDeviceName; + + + //public static string CommunicationName { get; set; } + + + + /// + /// 新建设备 + /// + public RelayCommand NewDeviceCommand { get; set; } - public RelayCommand NewDeviceCommand { get; set; } + /// + /// 删除设备 + /// + public RelayCommand RemoveDeviceCommand { get; set; } - public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } } - private string _mShopName = "店铺名称"; + /// + /// 新建通讯 + /// + public RelayCommand NewCommunicationCommand { get; set; } - public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } } - private string _mShopId; + /// + /// 删除通讯 + /// + public RelayCommand RemoveCommunicationCommand { get; set; } - public ObservableCollection deviceConfig = new ObservableCollection(); + public static ObservableCollection deviceConfig { get; set; } = new ObservableCollection(); - //public DeviceConfigModel deviceConfig { get { return _mdeviceConfig; } set { _mdeviceConfig = value; OnPropertyChanged(); } } - //private DeviceConfigModel _mdeviceConfig; } diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config index 1caea14f..14df6b84 100644 --- a/BPASmartClient/App.config +++ b/BPASmartClient/App.config @@ -3,7 +3,7 @@ - + @@ -12,35 +12,34 @@ - - + + + + + + - - + + + + + + + + --> - + diff --git a/BPASmartClient/App.xaml b/BPASmartClient/App.xaml index a85b3559..ca1097b8 100644 --- a/BPASmartClient/App.xaml +++ b/BPASmartClient/App.xaml @@ -21,6 +21,7 @@ + diff --git a/BPASmartClient/Control/ShopDeviceConfigView.xaml b/BPASmartClient/Control/ShopDeviceConfigView.xaml index c43c33c0..11d18b8a 100644 --- a/BPASmartClient/Control/ShopDeviceConfigView.xaml +++ b/BPASmartClient/Control/ShopDeviceConfigView.xaml @@ -12,15 +12,13 @@ d:DesignWidth="1200" mc:Ignorable="d"> - - - - + + + --> + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - @@ -511,6 +513,20 @@ + + + + + + Text="{Binding deviceConfig[0].ShopName}" /> + Text="{Binding deviceConfig[0].ShopId}" /> - + @@ -584,7 +600,7 @@ Margin="0" HorizontalAlignment="Left" Style="{StaticResource TextBoxStyle}" - Text="255.255.255.255" /> + Text="{Binding SelectedValue.DeviceName, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.DeviceId, ElementName=tv, Mode=TwoWay}" /> - + @@ -623,7 +639,7 @@ Width="170" HorizontalAlignment="Left" Style="{StaticResource TextBoxStyle}" - Text="{Binding Path=Device.IP}" /> + Text="{Binding SelectedValue.communicationPar.IPAddress, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.communicationPar.IPPort, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.communicationPar.StationNo, ElementName=tv, Mode=TwoWay}" /> @@ -657,7 +673,7 @@ + Visibility="{Binding SelectedValue.communicationPar.CommunicationType, ElementName=tv, Mode=TwoWay, Converter={StaticResource VisibleTypeConverter}, ConverterParameter=SerialPort}"> @@ -694,7 +710,7 @@ ItemsSource="{Binding Path=Device.Ports}" SelectedIndex="0" Style="{StaticResource ComboBoxStyle}" - Text="{Binding Path=Device.ComSerialPort}" /> + Text="{Binding SelectedValue.communicationPar.SerialPort, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.communicationPar.BaudRate, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.communicationPar.Parity, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.communicationPar.DataBits, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.communicationPar.StopBits, ElementName=tv, Mode=TwoWay}" /> + Text="{Binding SelectedValue.communicationPar.StationNo, ElementName=tv, Mode=TwoWay}" /> diff --git a/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs b/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs index 2cb92a67..c30ebd46 100644 --- a/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs +++ b/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs @@ -13,6 +13,8 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using BPASmartClient.DialogWindow; +using BPASmartClient.ViewModel; +using BPASmartClient.ViewModel.Model; namespace BPASmartClient.Control { @@ -31,5 +33,67 @@ namespace BPASmartClient.Control NewShopWindow newShopWindow = new NewShopWindow(); newShopWindow.ShowDialog(); } + + private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) + { + + Refresh(); + } + + private void tv_MouseRightButtonDown(object sender, MouseButtonEventArgs e) + { + //if (e.ButtonState == MouseButtonState.Pressed) + //{ + // Refresh(); + //} + } + + private void Refresh() + { + if (this.tv.SelectedValue is DeviceConfigModel deviceConfigModel) + { + //ShopDeviceConfigViewModel.ShopName = deviceConfigModel.ShopName; + } + else if (this.tv.SelectedValue is DeviceModel deviceModel) + { + ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Visible; + ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Hidden; + //ShopDeviceConfigViewModel.DeviceName = deviceModel.DeviceName; + } + else if (this.tv.SelectedValue is CommunicationModel communicationModel) + { + ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Visible; + ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Hidden; + //ShopDeviceConfigViewModel.CommunicationName = communicationModel.CommunicationName; + //ShopDeviceConfigViewModel.DeviceModelId = communicationModel.DeviceModelId; + } + } + + private void tv_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) + { + + } + + private void DeviceInfo(object sender, MouseButtonEventArgs e) + { + var tb = sender as TextBlock; + if (tb != null) + { + //ShopDeviceConfigViewModel.DeviceName = tb.Text.Trim(); + //tb.Background = Brushes.Blue; + } + } + private void CommunicationInfo(object sender, MouseButtonEventArgs e) + { + //var tb = sender as TextBlock; + //if (tb != null) + //{ + // ShopDeviceConfigViewModel.CommunicationName = tb.Text.Trim(); + // ShopDeviceConfigViewModel.DeviceModelId = tb.Tag.ToString(); + // tb.Focus(); + // //tb.Background = Brushes.Blue; + + //} + } } } diff --git a/BPASmartClient/DeviceInfo.xml b/BPASmartClient/DeviceInfo.xml index 48d28f7c..89e636c8 100644 --- a/BPASmartClient/DeviceInfo.xml +++ b/BPASmartClient/DeviceInfo.xml @@ -38,7 +38,7 @@ --> - + diff --git a/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj b/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj index e444219e..0dcf2236 100644 --- a/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj +++ b/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj @@ -5,7 +5,7 @@ - +