dispatch_ground_lidar.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // Created by huli on 2021/9/25.
  3. //
  4. #ifndef NNXX_TESTS_DISPATCH_GROUND_LIDAR_H
  5. #define NNXX_TESTS_DISPATCH_GROUND_LIDAR_H
  6. #include "../error_code/error_code.h"
  7. #include <glog/logging.h>
  8. #include <thread>
  9. #include <mutex>
  10. #include "../tool/thread_condition.h"
  11. #include "../tool/common_data.h"
  12. #include "../tool/time_tool.h"
  13. #include "../task/task_base.h"
  14. //#include "../message/dispatch_message.pb.h"
  15. //#include "../message/measure_message.pb.h"
  16. #include "../message/message.pb.h"
  17. #include "../dispatch/dispatch_communication.h"
  18. //调度地面雷达
  19. class Dispatch_ground_lidar
  20. {
  21. public:
  22. //调度plc状态
  23. enum Dispatch_ground_lidar_status
  24. {
  25. DISPATCH_GROUND_LIDAR_UNKNOW = 0, //未知
  26. DISPATCH_GROUND_LIDAR_READY = 1, //准备,待机
  27. DISPATCH_GROUND_LIDAR_FAULT = 10, //故障
  28. DISPATCH_GROUND_LIDAR_DISCONNECT = 11, //断连
  29. };
  30. public:
  31. Dispatch_ground_lidar();
  32. Dispatch_ground_lidar(const Dispatch_ground_lidar& other)= default;
  33. Dispatch_ground_lidar& operator =(const Dispatch_ground_lidar& other)= default;
  34. ~Dispatch_ground_lidar();
  35. public://API functions
  36. //调度地面雷达 初始化
  37. Error_manager dispatch_ground_lidar_init(int plc_id, int ground_lidar_id);
  38. //调度地面雷达 反初始化
  39. Error_manager dispatch_ground_lidar_uninit();
  40. //调度地面雷达 执行状态消息
  41. // Error_manager execute_for_ground_status_msg(message::Ground_status_msg &ground_status_msg);
  42. //调度地面雷达 执行状态消息
  43. Error_manager execute_for_ground_status_msg_new(measure_info &t_measure_info);
  44. public://get or set member variable
  45. Dispatch_ground_lidar_status get_dispatch_ground_lidar_status();
  46. protected://member functions
  47. //执行外界任务的执行函数
  48. void execute_thread_fun();
  49. //检查感测消息
  50. Error_manager check_measure_info(measure_info &t_measure_info);
  51. protected://member variable
  52. std::atomic<Dispatch_ground_lidar_status> m_dispatch_ground_lidar_status;//调度地面雷达的状态
  53. int m_plc_id; //设备id, 索引, 就是楚天车库的单元号.
  54. int m_ground_lidar_id; //地面雷达的id
  55. std::mutex m_lock; //锁
  56. //任务执行线程
  57. std::thread* mp_execute_thread; //执行的线程指针,内存由本类管理
  58. Thread_condition m_execute_condition; //执行的条件变量
  59. //数据缓存
  60. // message::Ground_status_msg m_ground_status_msg; //旧版雷达数据
  61. measure_info m_measure_info; //新版雷达数据
  62. std::chrono::system_clock::time_point m_ground_status_msg_updata_time; //状态更新时间点
  63. std::atomic<bool> m_ground_status_msg_updata_flag;
  64. private:
  65. };
  66. #endif //NNXX_TESTS_DISPATCH_GROUND_LIDAR_H