system_communication.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // Created by huli on 2020/6/28.
  3. //
  4. #include "system_communication.h"
  5. //#include "../laser/laser_manager.h"
  6. //#include "../locate/locate_manager.h"
  7. #include "../system/system_executor.h"
  8. System_communication::System_communication()
  9. {
  10. }
  11. System_communication::~System_communication()
  12. {
  13. }
  14. //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
  15. Error_manager System_communication::check_msg(Communication_message* p_msg)
  16. {
  17. return System_executor::get_instance_references().check_msg(p_msg);
  18. }
  19. //检查执行者的状态, 判断能否处理这条消息, 需要子类重载
  20. Error_manager System_communication::check_executer(Communication_message* p_msg)
  21. {
  22. //检查对应模块的状态, 判断是否可以处理这条消息
  23. //同时也要判断是否超时, 超时返回 COMMUNICATION_ANALYSIS_TIME_OUT
  24. //如果处理器正在忙别的, 那么返回 COMMUNICATION_EXCUTER_IS_BUSY
  25. // std::cout << "Communication_socket_base::check_msg p_buf = " << p_msg->get_message_buf() << std::endl;
  26. // std::cout << "Communication_socket_base::check_msg size = " << p_msg->get_message_buf().size() << std::endl;
  27. Error_manager t_error;
  28. if ( p_msg->is_over_time() )
  29. {
  30. std::cout << "COMMUNICATION_ANALYSIS_TIME_OUT , " << std::endl;
  31. //超时:接收方不做处理,发送方会进行超时处理
  32. return Error_code::COMMUNICATION_ANALYSIS_TIME_OUT;
  33. }
  34. else
  35. {
  36. return System_executor::get_instance_references().check_executer(p_msg);
  37. }
  38. return Error_code::SUCCESS;
  39. }
  40. //处理消息, 需要子类重载
  41. Error_manager System_communication::execute_msg(Communication_message* p_msg)
  42. {
  43. return System_executor::get_instance_references().execute_msg(p_msg);
  44. }
  45. //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
  46. Error_manager System_communication::encapsulate_send_data()
  47. {
  48. Error_manager t_error;
  49. // return System_executor::get_instance_references().encapsulate_send_status();
  50. return System_executor::get_instance_references().encapsulate_send_dispatch_manager_status();
  51. return Error_code::SUCCESS;
  52. }