终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
2.4 KiB

  1. using BPASmartClient.FoodStationTest.Model;
  2. using BPASmartClient.FoodStationTest.View;
  3. using BPA.Helper;
  4. using BPA.Helper;
  5. using System.Collections.ObjectModel;
  6. namespace BPASmartClient.FoodStationTest.ViewModel
  7. {
  8. public class DeviceListViewModel : NotifyBase
  9. {
  10. public DeviceListViewModel()
  11. {
  12. ChangeNameCommand = new BPARelayCommand<object>((o) =>
  13. {
  14. if (o != null && o is string str)
  15. {
  16. ChangeDeviceNameView cdn = new ChangeDeviceNameView();
  17. ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
  18. cdn.ShowDialog();
  19. }
  20. });
  21. Open = new BPARelayCommand<object>((o) =>
  22. {
  23. if (o != null && o is string str)
  24. {
  25. DeviceInquire.GetInstance.GetDevice(str).OpenLid();//设置PLC名称
  26. }
  27. });
  28. Close = new BPARelayCommand<object>((o) =>
  29. {
  30. if (o != null && o is string str)
  31. {
  32. DeviceInquire.GetInstance.GetDevice(str).CloseLid();//设置PLC名称
  33. }
  34. });
  35. devices = DeviceInquire.GetInstance.devices;
  36. /*foreach (var device in devices)
  37. {
  38. device.Serial = Convert.ToInt32(device.DeviceName.Substring(1, device.DeviceName.Length - 1)) / 10;
  39. }
  40. devices = new ObservableCollection<Devices>(devices.OrderBy(item => item.Serial));*/
  41. }
  42. public BPARelayCommand<object> ChangeNameCommand { get; set; }
  43. public BPARelayCommand<object> Open { get; set; }
  44. public BPARelayCommand<object> Close { get; set; }
  45. //public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
  46. public ObservableCollection<Devices> devices { get; set; }
  47. }
  48. public class Devices : NotifyBase
  49. {
  50. public int Serial { get { return _mSerial; } set { _mSerial = value; OnPropertyChanged(); } }
  51. private int _mSerial;
  52. public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
  53. private string _mIpAddress;
  54. public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
  55. private string _mDeviceName;
  56. }
  57. }