终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JakaMachine.cs 2.9 KiB

2 년 전
2 년 전
2 년 전
2 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using BPASmartClient.EventBus;
  2. using BPASmartClient.Helper;
  3. using BPASmartClient.JakaRobot;
  4. using BPASmartClient.Model;
  5. using BPASmartClient.Peripheral;
  6. using static BPASmartClient.EventBus.EventBus;
  7. namespace BPASmartClient.JAKA
  8. {
  9. public class JakaMachine : BasePeripheral
  10. {
  11. JaKaHelper jaKaHelper = new JaKaHelper();
  12. public override void Init()
  13. {
  14. jaKaHelper.Connect(communicationPar.IPAddress);
  15. ThreadManage.GetInstance().StartLong(new Action(() =>
  16. {
  17. IsConnected = jaKaHelper.IsConnected;
  18. if (!IsConnected) IsWork = false;
  19. while (IsConnected)
  20. {
  21. IsWork = true;
  22. if (status != null)
  23. {
  24. SetStatus("GetProgramStatus", (int)jaKaHelper.GetProgramStatus());
  25. SetStatus("Get_RobotAO1", jaKaHelper.Get_RobotAO1());
  26. SetStatus("Get_RobotDI0", jaKaHelper.Get_RobotDI(0));
  27. SetStatus("Get_RobotDI1", jaKaHelper.Get_RobotDI(1));
  28. SetStatus("Get_RobotDI2", jaKaHelper.Get_RobotDI(2));
  29. SetStatus("Get_RobotDI3", jaKaHelper.Get_RobotDI(3));
  30. }
  31. Thread.Sleep(500);
  32. }
  33. Thread.Sleep(1000);
  34. }), $"设备[{DeviceId}]节卡机器人读取线程", true);
  35. EventBus.EventBus.GetInstance().Subscribe<WriteJaka>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  36. {
  37. if (@event == null) return;
  38. var par = @event as WriteJaka;
  39. switch (par?.TagName)
  40. {
  41. case "Power_On":
  42. jaKaHelper.Power_On();
  43. break;
  44. case "Enable_robot":
  45. jaKaHelper.Enable_robot();
  46. break;
  47. case "Set_RobotAO1":
  48. if (par?.Value is int intvalue) jaKaHelper.Set_RobotAO1(intvalue);
  49. break;
  50. case "JaKaProgramName":
  51. if (par?.Value is string stringvalue) jaKaHelper.JaKaProgramName(stringvalue);
  52. break;
  53. case "JakaDOutput":
  54. if (par?.Value is bool DO_value && par?.DO_Index is int DO_Index) jaKaHelper.Set_RobotDO(DO_Index, DO_value);
  55. break;
  56. default:
  57. break;
  58. }
  59. });
  60. }
  61. //public override void ReadData(string address)
  62. //{
  63. //}
  64. public override void Start()
  65. {
  66. }
  67. public override void Stop()
  68. {
  69. }
  70. public override void WriteData(string address, object value)
  71. {
  72. }
  73. protected override void InitStatus()
  74. {
  75. }
  76. }
  77. }