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

76 line
2.6 KiB

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