123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- //
- // Created by zx on 2020/8/28.
- //
- #include "message_communicator.h"
- #include "measure_excutor.h"
- #include "exception_solver.h"
- #include "dispatch_excutor.h"
- #include "parkspace_excutor.h"
- #include "command_accepter.h"
- Message_communicator::Message_communicator()
- {
- }
- Message_communicator::~Message_communicator()
- {
- }
- /*
- * 发送消息
- */
- Error_manager Message_communicator::send_msg(Communication_message* p_msg)
- {
- return Communication_socket_base::encapsulate_msg(p_msg);
- }
- //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
- Error_manager Message_communicator::encapsulate_send_data()
- {
- return Error_code::SUCCESS;
- }
- /*
- * 检测消息是否合法
- */
- Error_manager Message_communicator::check_msg(Communication_message* p_msg)
- {
- if ( (p_msg->get_receiver() == Communication_message::Communicator::eMain) &&
- (p_msg->get_message_type() == Communication_message::Message_type::eDispatch_response_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eDispatch_status_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eStore_command_request_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::ePickup_command_request_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_allocation_response_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_search_response_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_release_response_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_confirm_alloc_response_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_allocation_status_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eLocate_response_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eLocate_status_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eProcess_manual_operation_msg
- ||p_msg->get_message_type() == Communication_message::Message_type::eEntrance_manual_operation_msg))
- {
- return Error_code::SUCCESS;
- }
- return Error_code::INVALID_MESSAGE;
- }
- //检查消息是否可以被处理, 需要重载
- Error_manager Message_communicator::check_executer(Communication_message* p_msg)
- {
- return SUCCESS;
- }
- /*
- * 处理接收到的消息
- */
- Error_manager Message_communicator::execute_msg(Communication_message* p_msg)
- {
- /*
- * 接收终端指令, 生成流程
- */
- Error_manager code;
- switch(p_msg->get_message_type())
- {
- //终端消息
- case Communication_message::eStore_command_request_msg:
- {
- Command_accepter::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- case Communication_message::ePickup_command_request_msg:
- {
- Command_accepter::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- ///搬运结果反馈消息
- case Communication_message::eDispatch_response_msg:
- {
- Dispatch_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- case Communication_message::eDispatch_status_msg:
- {
- Dispatch_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- ///// 车位分配模块的消息
- case Communication_message::eParkspace_allocation_response_msg:
- {
- Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- case Communication_message::eParkspace_search_response_msg:
- {
- Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- case Communication_message::eParkspace_release_response_msg:
- {
- Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- case Communication_message::eParkspace_confirm_alloc_response_msg:
- {
- Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- case Communication_message::eParkspace_allocation_status_msg:
- {
- Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- ///测量结果反馈消息
- case Communication_message::eLocate_response_msg:
- {
- Measure_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- //测量系统状态
- case Communication_message::eLocate_status_msg:
- {
- Measure_excutor::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- //异常处理,手动操作
- case Communication_message::eProcess_manual_operation_msg:
- {
- Exception_solver::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- case Communication_message::eEntrance_manual_operation_msg:
- {
- Exception_solver::get_instance_pointer()->consume_msg(p_msg);
- break;
- }
- default:break;
- }
- return SUCCESS;
- }
|