dispatch_ground_lidar.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // Created by huli on 2021/9/25.
  3. //
  4. #include "dispatch_ground_lidar.h"
  5. Dispatch_ground_lidar::Dispatch_ground_lidar()
  6. {
  7. m_dispatch_ground_lidar_status = DISPATCH_GROUND_LIDAR_UNKNOW;
  8. m_plc_id = 0;
  9. m_ground_lidar_id = 0;
  10. }
  11. Dispatch_ground_lidar::~Dispatch_ground_lidar()
  12. {
  13. dispatch_plc_uninit();
  14. }
  15. //调度地面雷达 初始化
  16. Error_manager Dispatch_ground_lidar::dispatch_plc_init(int plc_id, int ground_lidar_id)
  17. {
  18. m_plc_id = plc_id;
  19. m_ground_lidar_id = ground_lidar_id;
  20. return Error_code::SUCCESS;
  21. }
  22. //调度地面雷达 反初始化
  23. Error_manager Dispatch_ground_lidar::dispatch_plc_uninit()
  24. {
  25. return Error_code::SUCCESS;
  26. }
  27. //调度地面雷达 执行状态消息
  28. Error_manager Dispatch_ground_lidar::execute_for_ground_status_msg(message::Ground_status_msg &ground_status_msg)
  29. {
  30. //将nnxx的protobuf 转化为 snap7的DB块, 把店面雷达数据转发给plc
  31. int t_inlet_id = ground_status_msg.terminal_id() %2;
  32. std::unique_lock<std::mutex> t_lock(Dispatch_communication::get_instance_references().m_data_lock);
  33. Dispatch_communication::Ground_lidar_response_from_manager_to_plc_for_data * p_response_data = & Dispatch_communication::get_instance_references().m_ground_lidar_response_from_manager_to_plc_for_data[t_inlet_id];
  34. Dispatch_communication::Ground_lidar_response_from_manager_to_plc_for_key * p_response_key = & Dispatch_communication::get_instance_references().m_ground_lidar_response_from_manager_to_plc_for_key[t_inlet_id];
  35. Dispatch_communication::Ground_lidar_request_from_plc_to_manager * p_request = & Dispatch_communication::get_instance_references().m_ground_lidar_request_from_plc_to_manager[t_inlet_id];
  36. if ( p_request->m_request_communication_mode == 0 )
  37. {
  38. p_response_key->m_response_heartbeat++;
  39. p_response_key->m_response_communication_mode = p_request->m_request_communication_mode;
  40. p_response_key->m_response_refresh_command = p_request->m_request_refresh_command;
  41. p_response_data->m_response_car_center_x = ground_status_msg.locate_information_realtime().locate_x();
  42. p_response_data->m_response_car_center_y = ground_status_msg.locate_information_realtime().locate_y();
  43. p_response_data->m_response_car_angle = ground_status_msg.locate_information_realtime().locate_angle();
  44. p_response_data->m_response_car_front_theta = ground_status_msg.locate_information_realtime().locate_front_theta();
  45. p_response_data->m_response_car_length = ground_status_msg.locate_information_realtime().locate_length();
  46. p_response_data->m_response_car_width = ground_status_msg.locate_information_realtime().locate_width();
  47. p_response_data->m_response_car_height = ground_status_msg.locate_information_realtime().locate_height();
  48. p_response_data->m_response_car_wheel_base = ground_status_msg.locate_information_realtime().locate_wheel_base();
  49. p_response_data->m_response_car_wheel_width = ground_status_msg.locate_information_realtime().locate_wheel_width();
  50. p_response_data->m_response_locate_correct = ground_status_msg.locate_information_realtime().locate_correct();
  51. }
  52. else if ( p_response_key->m_response_refresh_command == p_request->m_request_refresh_command )
  53. {
  54. p_response_key->m_response_heartbeat++;
  55. p_response_key->m_response_communication_mode = p_request->m_request_communication_mode;
  56. p_response_key->m_response_refresh_command = p_request->m_request_refresh_command;
  57. }
  58. else
  59. {
  60. p_response_key->m_response_heartbeat++;
  61. p_response_key->m_response_communication_mode = p_request->m_request_communication_mode;
  62. p_response_key->m_response_refresh_command = p_request->m_request_refresh_command;
  63. p_response_data->m_response_car_center_x = ground_status_msg.locate_information_realtime().locate_x();
  64. p_response_data->m_response_car_center_y = ground_status_msg.locate_information_realtime().locate_y();
  65. p_response_data->m_response_car_angle = ground_status_msg.locate_information_realtime().locate_angle();
  66. p_response_data->m_response_car_front_theta = ground_status_msg.locate_information_realtime().locate_front_theta();
  67. p_response_data->m_response_car_length = ground_status_msg.locate_information_realtime().locate_length();
  68. p_response_data->m_response_car_width = ground_status_msg.locate_information_realtime().locate_width();
  69. p_response_data->m_response_car_height = ground_status_msg.locate_information_realtime().locate_height();
  70. p_response_data->m_response_car_wheel_base = ground_status_msg.locate_information_realtime().locate_wheel_base();
  71. p_response_data->m_response_car_wheel_width = ground_status_msg.locate_information_realtime().locate_wheel_width();
  72. p_response_data->m_response_locate_correct = ground_status_msg.locate_information_realtime().locate_correct();
  73. }
  74. }
  75. Dispatch_ground_lidar::Dispatch_ground_lidar_status Dispatch_ground_lidar::get_dispatch_ground_lidar_status()
  76. {
  77. return m_dispatch_ground_lidar_status;
  78. }