终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

83 行
2.4 KiB

  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. }
  27. Thread.Sleep(500);
  28. }
  29. Thread.Sleep(1000);
  30. }), $"设备[{DeviceId}]节卡机器人读取线程", true);
  31. EventBus.EventBus.GetInstance().Subscribe<WriteJaka>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  32. {
  33. if (@event == null) return;
  34. var par = @event as WriteJaka;
  35. switch (par?.TagName)
  36. {
  37. case "Power_On":
  38. jaKaHelper.Power_On();
  39. break;
  40. case "Enable_robot":
  41. jaKaHelper.Enable_robot();
  42. break;
  43. case "Set_RobotAO1":
  44. if (par?.Value is int intvalue) jaKaHelper.Set_RobotAO1(intvalue);
  45. break;
  46. case "JaKaProgramName":
  47. if (par?.Value is string stringvalue) jaKaHelper.JaKaProgramName(stringvalue);
  48. break;
  49. default:
  50. break;
  51. }
  52. });
  53. }
  54. //public override void ReadData(string address)
  55. //{
  56. //}
  57. public override void Start()
  58. {
  59. }
  60. public override void Stop()
  61. {
  62. }
  63. public override void WriteData(string address, object value)
  64. {
  65. }
  66. protected override void InitStatus()
  67. {
  68. }
  69. }
  70. }