|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPA.Helper;
- using System.Collections.Concurrent;
- using System.Collections.ObjectModel;
- using System.Windows;
- using BPA.Helper;
-
- using BPASmartClient.JXJFoodSmallStation.View;
- using BPASmartClient.JXJFoodSmallStation.Model;
-
- namespace BPASmartClient.JXJFoodSmallStation.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;
-
- }
- }
|