终端一体化运控平台
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.5 KiB

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