1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- //
- // Created by huli on 2020/6/28.
- //
- #include "command_accepter.h"
- #include "command_manager.h"
- Command_accepter::Command_accepter()
- {
- }
- Command_accepter::~Command_accepter()
- {
- }
- //发送停车流程进度
- Error_manager Command_accepter::post_process_statu(message::Storing_process_statu_msg& msg)
- {
- Communication_message message;
- message.reset(msg.base_info(),msg.SerializeAsString());
- return Message_communicator::get_instance_pointer()->send_msg(&message);
- }
- //发送取车流程进度
- Error_manager Command_accepter::post_process_statu(message::Picking_process_statu_msg& msg)
- {
- Communication_message message;
- message.reset(msg.base_info(),msg.SerializeAsString());
- return Message_communicator::get_instance_pointer()->send_msg(&message);
- }
- //发送中控状态消息
- Error_manager Command_accepter::post_central_statu(message::Central_controller_statu_msg& msg)
- {
- Communication_message message;
- message.reset(msg.base_info(),msg.SerializeAsString());
- return Message_communicator::get_instance_pointer()->send_msg(&message);
- }
- /*
- * 处理接收到的消息
- */
- Error_manager Command_accepter::consume_msg(Communication_message* p_msg)
- {
- /*
- * 接收终端指令, 生成流程
- */
- Error_manager code;
- switch(p_msg->get_message_type())
- {
- case Communication_message::eStore_command_request_msg:
- {
- if(Command_manager::get_instance_pointer()!= nullptr)
- {
- message::Store_command_request_msg request;
- if(request.ParseFromString(p_msg->get_message_buf())==false)
- {
- //严重错误
- return Error_manager(INVALID_MESSAGE,MAJOR_ERROR,"停车请求消息解析失败");
- }
- code=Command_manager::get_instance_pointer()->execute_store_command(request);
- LOG_IF(ERROR,code!=SUCCESS)<<code.get_error_description();
- }
- break;
- }
- case Communication_message::ePickup_command_request_msg:
- {
- if(Command_manager::get_instance_pointer()!= nullptr)
- {
- message::Pickup_command_request_msg request;
- if(request.ParseFromString(p_msg->get_message_buf())==false)
- {
- //严重错误
- return Error_manager(INVALID_MESSAGE,MAJOR_ERROR,"取车请求消息解析失败");
- }
- message::Pickup_command_response_msg response;
- //调用请求回调,无需判断返回值,错误信息保存在response中
- code=Command_manager::get_instance_pointer()->execute_pickup_command(request);
- LOG_IF(ERROR,code!=SUCCESS)<<code.get_error_description();
- }
- break;
- }
- default:break;
- }
- return SUCCESS;
- }
|