123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //
- // Created by huli on 2020/6/28.
- //
- #include "system_communication.h"
- //#include "../laser/laser_manager.h"
- //#include "../locate/locate_manager.h"
- #include "../system/system_executor.h"
- System_communication::System_communication()
- {
- }
- System_communication::~System_communication()
- {
- }
- //初始化 通信 模块。如下三选一
- Error_manager System_communication::communication_init()
- {
- return Rabbitmq_base::rabbitmq_init();
- }
- //初始化 通信 模块。如下三选一
- Error_manager System_communication::communication_init(int dispatch_id)
- {
- // return Rabbitmq_base::rabbitmq_init();
- switch ( dispatch_id )
- {
- case 0:
- {
- return Rabbitmq_base::rabbitmq_init_from_protobuf(RABBITMQ_PARAMETER_PATH_A);
- break;
- }
- case 1:
- {
- return Rabbitmq_base::rabbitmq_init_from_protobuf(RABBITMQ_PARAMETER_PATH_B);
- break;
- }
- case 2:
- {
- return Rabbitmq_base::rabbitmq_init_from_protobuf(RABBITMQ_PARAMETER_PATH_C);
- break;
- }
- default:
- {
- return Error_manager(Error_code::COMMUNICATION_READ_PROTOBUF_ERROR, Error_level::MINOR_ERROR,
- " System_communication::communication_init dispatch_id error ");
- break;
- }
- }
- return Error_code::SUCCESS;
- }
- //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
- Error_manager System_communication::check_msg(Rabbitmq_message* p_msg)
- {
- return System_executor::get_instance_references().check_msg(p_msg);
- }
- //检查执行者的状态, 判断能否处理这条消息, 需要子类重载
- Error_manager System_communication::check_executer(Rabbitmq_message* p_msg)
- {
- return System_executor::get_instance_references().check_executer(p_msg);
- /*
- //检查对应模块的状态, 判断是否可以处理这条消息
- //同时也要判断是否超时, 超时返回 COMMUNICATION_ANALYSIS_TIME_OUT
- //如果处理器正在忙别的, 那么返回 COMMUNICATION_EXCUTER_IS_BUSY
- // std::cout << "Communication_socket_base::check_msg p_buf = " << p_msg->get_message_buf() << std::endl;
- // std::cout << "Communication_socket_base::check_msg size = " << p_msg->get_message_buf().size() << std::endl;
- Error_manager t_error;
- if ( p_msg->is_over_time() )
- {
- std::cout << "COMMUNICATION_ANALYSIS_TIME_OUT , " << std::endl;
- //超时:接收方不做处理,发送方会进行超时处理
- return Error_code::COMMUNICATION_ANALYSIS_TIME_OUT;
- }
- else
- {
- return System_executor::get_instance_references().check_executer(p_msg);
- }
- return Error_code::SUCCESS;
- */
- }
- //处理消息, 需要子类重载
- Error_manager System_communication::execute_msg(Rabbitmq_message* p_msg)
- {
- return System_executor::get_instance_references().execute_msg(p_msg);
- }
- //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
- Error_manager System_communication::auto_encapsulate_status()
- {
- Error_manager t_error;
- return System_executor::get_instance_references().encapsulate_send_dispatch_manager_status();
- return Error_code::SUCCESS;
- }
|