can_bus.h 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. class CMessageQueue;
  7. class CCanBusSensor
  8. {
  9. public:
  10. CCanBusSensor(CMessageQueue *q);
  11. void Notify(struct can_frame *date);
  12. void SetCanBusSensor(SensorCanBus<CCanBusSensor>* can);
  13. void Start();
  14. void Stop();
  15. void OnMessage(cannet_frame* frames, int32_t count = 4);
  16. void Emergency();
  17. private:
  18. void Run();
  19. void CanSendProc();
  20. void SendStatusToMSG();
  21. private:
  22. CMessageQueue* _message;
  23. SensorCanBus<CCanBusSensor> * _canbus;
  24. bool _run;
  25. std::thread _can_thread;
  26. std::mutex _last_can_lock;
  27. struct can_frame Sendframe[4];
  28. bool _front_view = true;
  29. int16_t Direction;//方向
  30. int16_t Hand_Throttle;//手油门
  31. int16_t Foot_Throttle;//脚油门
  32. int16_t Brake;//刹车
  33. int64_t count;
  34. FeedData _data;
  35. int model;//0本地,1远程
  36. };