|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using BPASmartClient.FoodStationTest.Model;
- using BPASmartClient.FoodStationTest.View;
- using BPA.Helper;
- using BPA.Helper;
-
- using System.Collections.ObjectModel;
-
- namespace BPASmartClient.FoodStationTest.ViewModel
- {
- public class DeviceListViewModel : NotifyBase
- {
- public DeviceListViewModel()
- {
- ChangeNameCommand = new BPARelayCommand<object>((o) =>
- {
- if (o != null && o is string str)
- {
- ChangeDeviceNameView cdn = new ChangeDeviceNameView();
- ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
- cdn.ShowDialog();
- }
- });
-
- Open = new BPARelayCommand<object>((o) =>
- {
- if (o != null && o is string str)
- {
- DeviceInquire.GetInstance.GetDevice(str).OpenLid();//设置PLC名称
- }
- });
-
- Close = new BPARelayCommand<object>((o) =>
- {
- if (o != null && o is string str)
- {
- DeviceInquire.GetInstance.GetDevice(str).CloseLid();//设置PLC名称
- }
- });
-
- devices = DeviceInquire.GetInstance.devices;
- /*foreach (var device in devices)
- {
- device.Serial = Convert.ToInt32(device.DeviceName.Substring(1, device.DeviceName.Length - 1)) / 10;
- }
- devices = new ObservableCollection<Devices>(devices.OrderBy(item => item.Serial));*/
- }
-
- public BPARelayCommand<object> ChangeNameCommand { get; set; }
- public BPARelayCommand<object> Open { get; set; }
- public BPARelayCommand<object> Close { get; set; }
-
- //public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
- public ObservableCollection<Devices> devices { get; set; }
- }
-
- public class Devices : NotifyBase
- {
- public int Serial { get { return _mSerial; } set { _mSerial = value; OnPropertyChanged(); } }
- private int _mSerial;
-
- public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
- private string _mIpAddress;
-
- public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
- private string _mDeviceName;
-
- }
- }
|