can_bus.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include "../common/comm.h"
  3. #include "../common/notifier.h"
  4. #include "../common/iobuffer.h"
  5. #include "../common/sensor_socket.h"
  6. // typedef struct {
  7. // int16_t fire_status; //启动/熄火
  8. // int16_t remote_forward; //远程控制前进
  9. // int16_t remote_backward; //远程控制后退
  10. // int16_t Brake; //刹车
  11. // int16_t Park; //驻车
  12. // int16_t Outrigger_status; //支腿
  13. // int16_t Turn_angle; //转弯角度
  14. // int16_t Left_turn; //左旋 左手柄 左信号
  15. // int16_t Right_turn; //右旋 左手柄 右信号
  16. // int16_t Raised; //小臂抬起 左手柄 向后
  17. // int16_t Decrease; //小臂下降 左手柄 向前
  18. // int16_t Stretch; //大臂伸起 右手柄 向后
  19. // int16_t Bulls_decline ; //大臂下降 右手柄 向前
  20. // int16_t Material ; //吸盘吸料
  21. // int16_t Discharge; //吸盘放料
  22. // int16_t zhua; //抓斗抓料
  23. // int16_t fang; //抓斗放料
  24. // int16_t Shell_rotation_left; //贝壳斗旋转 逆时针
  25. // int16_t Shell_rotation_right; //贝壳斗旋转 顺时针
  26. // int16_t Cabin; //驾驶室升
  27. // int16_t Cab; //驾驶室降
  28. // int16_t Working_signal; //作业灯开/关 ?
  29. // int16_t Turn_left_signal; //左转向 开/关
  30. // int16_t Turn_right_signal; //右转向 开/关
  31. // int16_t Warning_Light; //警示灯 开/关 ?
  32. // int16_t Trumpet; //喇叭
  33. // int16_t Security_lock; //安全锁 开/关 ?
  34. // int16_t Urget_stop; //急停
  35. // int16_t Vehicle_id ; //车辆id
  36. // } vehicle_status_t;
  37. class CMessageQueue;
  38. class CCanBusSensor
  39. {
  40. public:
  41. CCanBusSensor(CMessageQueue *q);
  42. void Notify(struct can_frame *date);
  43. void SetCanBusSensor(SensorCanBus<CCanBusSensor>* can);
  44. void Start();
  45. void Stop();
  46. void OnMessage(cannet_frame* frames, int32_t count = 4);
  47. void Emergency();
  48. private:
  49. void Run();
  50. void CanSendProc();
  51. void SendStatusToMSG();
  52. private:
  53. CMessageQueue* _message;
  54. SensorCanBus<CCanBusSensor> * _canbus;
  55. bool _run;
  56. std::thread _can_thread;
  57. std::mutex _last_can_lock;
  58. // struct can_frame Sendframe[4];
  59. struct can_frame Sendframe[5];
  60. bool _front_view = true;
  61. int16_t Direction;//方向
  62. int16_t Hand_Throttle;//手油门
  63. int16_t Foot_Throttle;//脚油门
  64. int16_t Brake;//刹车
  65. int64_t count;
  66. FeedData _data;
  67. int model;//0本地,1远程
  68. vehicle_status can_status;
  69. };