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

155 line
4.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.ObjectModel;
  8. using Microsoft.Toolkit.Mvvm.Input;
  9. using BPASmartClient.Helper;
  10. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  11. {
  12. public class ManualControlViewModel : ObservableObject
  13. {
  14. public ManualControlViewModel()
  15. {
  16. for (int i = 0; i < 15; i++)
  17. {
  18. cylinderModels.Add(new CylinderModel()
  19. {
  20. Name = $"升降气缸 {i + 1}",
  21. LeftTog = false,
  22. RightTog = false,
  23. });
  24. BlockCylinders.Add(new CylinderModel()
  25. {
  26. Name = $"阻挡气缸 {i + 1}",
  27. LeftTog = false,
  28. RightTog = false,
  29. });
  30. }
  31. for (int i = 1; i < 3; i++)
  32. {
  33. PalletCylinders.Add(new CylinderModel()
  34. {
  35. Name = $"托盘气缸1_{(i + 1)%2 +1}",
  36. LeftTog = false,
  37. RightTog = false,
  38. });
  39. }
  40. for (int i = 1; i < 3; i++)
  41. {
  42. PalletCylinders.Add(new CylinderModel()
  43. {
  44. Name = $"托盘气缸2_{(i + 1) % 2 + 1}",
  45. LeftTog = false,
  46. RightTog = false,
  47. });
  48. }
  49. PalletCylinders.Add(new CylinderModel()
  50. {
  51. Name = $"进料桶顶升气缸",
  52. LeftTog = false,
  53. RightTog = false,
  54. });
  55. for (int i = 0; i < 3; i++)
  56. {
  57. PalletCylinders.Add(new CylinderModel()
  58. {
  59. Name = $"出料桶顶升气缸{i+1}",
  60. LeftTog = false,
  61. RightTog = false,
  62. });
  63. }
  64. Open = new RelayCommand<object>((o) =>
  65. {
  66. ActionManage.GetInstance.Send("ManualOpen", o);
  67. });
  68. Close = new RelayCommand<object>((o) =>
  69. {
  70. ActionManage.GetInstance.Send("ManualClose", o);
  71. });
  72. SystemStartCommand = new RelayCommand(() =>
  73. {
  74. ActionManage.GetInstance.Send("SystemStart");
  75. });
  76. SystemStopCommand = new RelayCommand(() =>
  77. {
  78. ActionManage.GetInstance.Send("SystemStop");
  79. });
  80. SystemPauseCommand = new RelayCommand(() =>
  81. {
  82. ActionManage.GetInstance.Send("SystemPause");
  83. });
  84. SystemResetCommand = new RelayCommand(() =>
  85. {
  86. ActionManage.GetInstance.Send("SystemReset");
  87. });
  88. DebugMode = new RelayCommand(() =>
  89. {
  90. ActionManage.GetInstance.Send("SystemDebugMode");
  91. });
  92. AutoMode = new RelayCommand(() =>
  93. {
  94. ActionManage.GetInstance.Send("SystemAutoMode");
  95. });
  96. }
  97. /// <summary>
  98. /// 升降气缸
  99. /// </summary>
  100. public ObservableCollection<CylinderModel> cylinderModels { get; set; } = new ObservableCollection<CylinderModel>();
  101. /// <summary>
  102. /// 阻挡气缸
  103. /// </summary>
  104. public ObservableCollection<CylinderModel> BlockCylinders { get; set; } = new ObservableCollection<CylinderModel>();
  105. /// <summary>
  106. /// 托盘气缸
  107. /// </summary>
  108. public ObservableCollection<CylinderModel> PalletCylinders { get; set; } = new ObservableCollection<CylinderModel>();
  109. public RelayCommand<object> Open { get; set; }
  110. public RelayCommand<object> Close { get; set; }
  111. public RelayCommand SystemStartCommand { get; set; }
  112. public RelayCommand SystemStopCommand { get; set; }
  113. public RelayCommand SystemPauseCommand { get; set; }
  114. public RelayCommand SystemResetCommand { get; set; }
  115. public RelayCommand AutoMode { get; set; }
  116. public RelayCommand DebugMode { get; set; }
  117. }
  118. public class CylinderModel : ObservableObject
  119. {
  120. public bool LeftTog { get { return _mLeftTog; } set { _mLeftTog = value; OnPropertyChanged(); } }
  121. private bool _mLeftTog;
  122. public bool RightTog { get { return _mRightTog; } set { _mRightTog = value; OnPropertyChanged(); } }
  123. private bool _mRightTog;
  124. public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } }
  125. private string _mName;
  126. }
  127. }