123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- //
- // Created by zx on 2020/8/20.
- //
- #include "exception_solver.h"
- #include "command_manager.h"
- Exception_solver::Exception_solver() {
- }
- Exception_solver::~Exception_solver() {
- }
- Error_manager Exception_solver::add_task_cancel_condition(std::string license,tq::BaseTask* task)
- {
- if(m_ptask_map.find(license)==true || task== nullptr)
- {
- return Error_manager(ERROR,MINOR_ERROR,"任务标识已存在,或者标识地址为null");
- }
- m_ptask_map[license]=task;
- return SUCCESS;
- }
- Error_manager Exception_solver::delete_task_cancel_condition(std::string license)
- {
- if(m_ptask_map.find(license)==true)
- {
- m_ptask_map.erase(license);
- return SUCCESS;
- }
- return Error_manager(ERROR,MINOR_ERROR,"任务取消标志不存在");
- }
- Error_manager Exception_solver::encapsulate_msg(Communication_message* message)
- {
- Error_manager code;
- //记录请求
- switch (message->get_message_type())
- {
- default:
- code= Communication_socket_base::encapsulate_msg(message);
- break;
- }
- return code;
- }
- Error_manager Exception_solver::execute_msg(Communication_message* p_msg)
- {
- if(p_msg== nullptr)
- return Error_manager(POINTER_IS_NULL,CRITICAL_ERROR,"dispatch response msg pointer is null");
- //测量response消息
- switch (p_msg->get_message_type())
- {
- default:break;
- }
- return SUCCESS;
- }
- /*
- * 检测消息是否可被处理
- */
- Error_manager Exception_solver::check_msg(Communication_message* p_msg)
- {
- //通过 p_msg->get_message_type() 和 p_msg->get_receiver() 判断这条消息是不是给我的.
- //子类重载时, 增加自己模块的判断逻辑, 以后再写.
- /*if ( (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_receiver() == Communication_message::Communicator::eMain )
- {
- return Error_code::SUCCESS;
- }
- else
- {
- //认为接受人
- return Error_code::INVALID_MESSAGE;
- }*/
- }
- /*
- * 心跳发送函数,重载
- */
- Error_manager Exception_solver::encapsulate_send_data()
- {
- return SUCCESS;
- }
- //检查消息是否可以被解析, 需要重载
- Error_manager Exception_solver::check_executer(Communication_message* p_msg)
- {
- return SUCCESS;
- }
- /*
- * 处理故障
- */
- Error_manager Exception_solver::solve_exception(Error_manager code,tq::BaseTask* task)
- {
- if(code.get_error_level()==CRITICAL_ERROR)
- {
- //系统急停
- Command_manager::get_instance_pointer()->pause_system();
- return SUCCESS;
- }
- if(code.get_error_level()==MAJOR_ERROR)
- {
- task->Cancel();
- //关闭出入口
- if(task->GetCategory()==message::eStoring) {
- StoreProcessTask* pstoring=(StoreProcessTask*)task;
- Command_manager::get_instance_pointer()->enable_entrance(pstoring->terminal_id(),false);
- }
- if(task->GetCategory()==message::ePicking) {
- PickupProcessTask* pPicking=(PickupProcessTask*)task;
- Command_manager::get_instance_pointer()->enable_export(pPicking->terminal_id(),false);
- }
- return SUCCESS;
- }
- switch(code.get_error_code())
- {
- case ERROR:
- {
- break;
- }
- }
- }
|