终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

135 linhas
7.5 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 BPASmartClient.JXJFoodSmallStation.Model;
  9. using BPASmartClient.Helper;
  10. using Microsoft.Toolkit.Mvvm.Input;
  11. using BPASmartClient.CustomResource.UserControls.MessageShow;
  12. using BPASmartClient.CustomResource.UserControls;
  13. using System.Diagnostics;
  14. using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
  15. using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
  16. using System.Threading;
  17. using System.ComponentModel;
  18. using System.Runtime.CompilerServices;
  19. using BPASmartClient.CustomResource.Pages.Model;
  20. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  21. {
  22. public class RobotViewModel : ObservableObject
  23. {
  24. public RobotViewModel()
  25. {
  26. ThreadManage.GetInstance().StartLong(() =>
  27. {
  28. IsRunProgramNum = GVL_SmallStation.GetInstance.RobotProgramNum;
  29. RobotIsAutoMode = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(2);
  30. RobotIsAutoRun = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(3);
  31. RobotIsStop = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(4);
  32. RobotIsRun = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(5);
  33. RobotIsAlarm = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(6);
  34. RobotIsHomed = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(7);
  35. //RobotGetEmptyBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(8);
  36. //RobotPutEmptyBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(9);
  37. //RobotGetFullBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(10);
  38. //RobotPutFullBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(11);
  39. Thread.Sleep(10);
  40. },"机器人状态",true);
  41. SystemStart = new RelayCommand(() => {
  42. ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX0.1");
  43. MessageNotify.GetInstance.ShowUserLog($"手动控制,机器人启动");
  44. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"机器人启动,操作完成!");
  45. });
  46. SystemStop = new RelayCommand(() => {
  47. ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX0.2");
  48. MessageNotify.GetInstance.ShowUserLog($"手动控制,机器人停止");
  49. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"机器人停止,操作完成!");
  50. });
  51. EStopReset = new RelayCommand(() => {
  52. ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX0.3");
  53. MessageNotify.GetInstance.ShowUserLog($"手动控制,机器人急停复位");
  54. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"机器人急停复位,操作完成!");
  55. });
  56. //TestRobotRun = new RelayCommand(() => {
  57. // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.4");
  58. //});
  59. //AutoMode = new RelayCommand(() => {
  60. // ActionManage.GetInstance.Send("RobotSendFalseCommand", "DB4.DBX100.3");
  61. //});
  62. //TestMode = new RelayCommand(() => {
  63. // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.3");
  64. //});
  65. //RobotGetEmptyBarrel = new RelayCommand(() => {
  66. // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.7");
  67. //});
  68. //RobotPutEmptyBarrel = new RelayCommand(() => {
  69. // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.0");
  70. //});
  71. //RobotGetFullBarrel = new RelayCommand(() => {
  72. // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.1");
  73. //});
  74. //RobotPutFullBarrel = new RelayCommand(() => {
  75. // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.2");
  76. //});
  77. //SetProgramNumCommand = new RelayCommand(() =>{
  78. // ActionManage.GetInstance.Send("RobotSetProgramNum", SetProgramNum);
  79. //});
  80. }
  81. public RelayCommand SystemStart { get; set; }
  82. public RelayCommand SystemStop { get; set; }
  83. public RelayCommand EStopReset { get; set; }
  84. public RelayCommand TestRobotRun { get; set; }
  85. public RelayCommand AutoMode { get; set; }
  86. public RelayCommand TestMode { get; set; }
  87. public RelayCommand RobotGetEmptyBarrel { get; set; }
  88. public RelayCommand RobotPutEmptyBarrel { get; set; }
  89. public RelayCommand RobotGetFullBarrel { get; set; }
  90. public RelayCommand RobotPutFullBarrel { get; set; }
  91. public RelayCommand SetProgramNumCommand { get; set; }
  92. public static short IsRunProgramNum { get { return _runProgramNum; } set { _runProgramNum = value; OnStaticPropertyChanged(); } }
  93. private static short _runProgramNum;
  94. public short SetProgramNum { get { return _SetProgramNum; } set { _SetProgramNum = value; OnPropertyChanged(); } }
  95. private short _SetProgramNum;
  96. public static bool RobotIsAutoMode { get { return _RobotIsAutoMode; } set { _RobotIsAutoMode = value; OnStaticPropertyChanged(); } }
  97. private static bool _RobotIsAutoMode;
  98. public static bool RobotIsAutoRun { get { return _RobotIsAutoRun; } set { _RobotIsAutoRun = value; OnStaticPropertyChanged(); } }
  99. private static bool _RobotIsAutoRun;
  100. public static bool RobotIsStop { get { return _RobotIsStop; } set { _RobotIsStop = value; OnStaticPropertyChanged(); } }
  101. private static bool _RobotIsStop;
  102. public static bool RobotIsRun { get { return _RobotIsRun; } set { _RobotIsRun = value; OnStaticPropertyChanged(); } }
  103. private static bool _RobotIsRun;
  104. public static bool RobotIsAlarm { get { return _RobotIsAlarm; } set { _RobotIsAlarm = value; OnStaticPropertyChanged(); } }
  105. private static bool _RobotIsAlarm;
  106. public static bool RobotIsHomed { get { return _RobotIsHomed; } set { _RobotIsHomed = value; OnStaticPropertyChanged(); } }
  107. private static bool _RobotIsHomed;
  108. public bool RobotGetEmptyBarrelComplete { get { return _RobotGetEmptyBarrelComplete; } set { _RobotGetEmptyBarrelComplete = value; OnPropertyChanged(); } }
  109. private bool _RobotGetEmptyBarrelComplete;
  110. public bool RobotPutEmptyBarrelComplete { get { return _RobotPutEmptyBarrelComplete; } set { _RobotPutEmptyBarrelComplete = value; OnPropertyChanged(); } }
  111. private bool _RobotPutEmptyBarrelComplete;
  112. public bool RobotGetFullBarrelComplete { get { return _RobotGetFullBarrelComplete; } set { _RobotGetFullBarrelComplete = value; OnPropertyChanged(); } }
  113. private bool _RobotGetFullBarrelComplete;
  114. public bool RobotPutFullBarrelComplete { get { return _RobotPutFullBarrelComplete; } set { _RobotPutFullBarrelComplete = value; OnPropertyChanged(); } }
  115. private bool _RobotPutFullBarrelComplete;
  116. public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
  117. public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
  118. {
  119. StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
  120. }
  121. }
  122. }