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

73 lines
2.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using Lebai.SDK;
  8. using Lebai.SDK.Dtos;
  9. using Robotc;
  10. using BPASmartClient.Message;
  11. using BPASmartClient.Helper;
  12. using TaskStatus = Lebai.SDK.Dtos.TaskStatus;
  13. using BPASmartClient.Peripheral;
  14. using BPASmartClient.EventBus;
  15. using static BPASmartClient.EventBus.EventBus;
  16. using BPASmartClient.Model;
  17. using BPASmartClient.LebaiRobot;
  18. namespace BPASmartClient.Lebai
  19. {
  20. public class LebaiRobot: BasePeripheral
  21. {
  22. /// <summary>
  23. /// IP地址
  24. /// </summary>
  25. public string IpAddress { get; set; } = "192.168.0.1";
  26. /// <summary>
  27. /// 抓手上传感器输入位索引
  28. /// </summary>
  29. public int HandSensor { get; set; }
  30. /// <summary>
  31. /// 输出信号量索引
  32. /// </summary>
  33. public int OutputSingalValue { get; set; }
  34. protected override void InitStatus()
  35. {
  36. status["Connected"] = false;
  37. status["HandSensor"] = 0;
  38. status["OutputSingalValue"] = 0;
  39. }
  40. public override void Start()
  41. {
  42. LebaiHelper.GetInstance().Connect(IpAddress);
  43. ThreadManage.GetInstance().StartLong(() => { LebaiHelper.GetInstance().Reconnect(IpAddress); Thread.Sleep(5000); }, "机器人重连检测");
  44. ThreadManage.GetInstance().StartLong(() =>
  45. {
  46. status["Connected"] = LebaiHelper.GetInstance().IsConnected;
  47. if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
  48. },"获取乐白机器人数据");
  49. }
  50. public override void Stop()
  51. {
  52. }
  53. public override void Init()
  54. {
  55. EventBus.EventBus.GetInstance().Subscribe<Demo_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack )
  56. {
  57. });
  58. InitStatus();
  59. Start();
  60. }
  61. }
  62. }