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

JakaMachine.cs 3.1 KiB

1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. 
  2. using BPA.Helper;
  3. using BPASmartClient.JakaRobot;
  4. using BPASmartClient.Model;
  5. using BPASmartClient.Peripheral;
  6. using static BPA.Helper.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. TaskManage.GetInstance.StartLong(new Action(() =>
  16. {
  17. IsConnected = jaKaHelper.IsConnected;
  18. if (!IsConnected)
  19. {
  20. IsWork = false;
  21. }
  22. if (IsConnected)
  23. {
  24. IsWork = true;
  25. if (status != null)
  26. {
  27. SetStatus("Get_JakaRobotProgramStatus", (int)jaKaHelper.GetProgramStatus());
  28. SetStatus("Get_JakaRobotAO1", Convert.ToInt32(jaKaHelper.Get_RobotAO1()));
  29. SetStatus("Get_JakaRobotDI0", jaKaHelper.Get_RobotDI(0));
  30. SetStatus("Get_JakaRobotDI1", jaKaHelper.Get_RobotDI(1));
  31. SetStatus("Get_JakaRobotDI2", jaKaHelper.Get_RobotDI(2));
  32. SetStatus("Get_JakaRobotDI3", jaKaHelper.Get_RobotDI(3));
  33. SetStatus("Get_JakaRobotDI5", jaKaHelper.Get_RobotDI(5));
  34. }
  35. Thread.Sleep(500);
  36. }
  37. Thread.Sleep(1000);
  38. }), $"设备[{DeviceId}]节卡机器人读取线程", true);
  39. EventBus.GetInstance.Subscribe<WriteJaka>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  40. {
  41. if (@event == null) return;
  42. var par = @event as WriteJaka;
  43. switch (par?.TagName)
  44. {
  45. case "Power_On":
  46. jaKaHelper.Power_On();
  47. break;
  48. case "Enable_robot":
  49. jaKaHelper.Enable_robot();
  50. break;
  51. case "Set_RobotAO1":
  52. if (par?.Value is int intvalue) jaKaHelper.Set_RobotAO1(intvalue);
  53. break;
  54. case "JaKaProgramName":
  55. if (par?.Value is string stringvalue) jaKaHelper.JaKaProgramName(stringvalue);
  56. break;
  57. case "JakaDOutput":
  58. if (par?.Value is bool DO_value && par?.DO_Index is int DO_Index) jaKaHelper.Set_RobotDO(DO_Index, DO_value);
  59. break;
  60. default:
  61. break;
  62. }
  63. });
  64. }
  65. //public override void ReadData(string address)
  66. //{
  67. //}
  68. public override void Start()
  69. {
  70. }
  71. public override void Stop()
  72. {
  73. }
  74. public override void WriteData(string address, object value)
  75. {
  76. }
  77. protected override void InitStatus()
  78. {
  79. }
  80. }
  81. }