终端一体化运控平台
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

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