123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704 |
- //
- // Created by zx on 2020/7/7.
- //
- #include <parkspace_excutor.h>
- #include <dispatch_message.pb.h>
- #include "dispatch_excutor.h"
- #include "StoreProcessTask.h"
- #include "process_message.pb.h"
- #include "command_manager.h"
- #include "command_accepter.h"
- #include "exception_solver.h"
- #include "uniq_key.h"
- StoreProcessTask::StoreProcessTask(unsigned int terminor_id,message::Car_info car_info)
- :Process_task(terminor_id,car_info)
- {
- }
- StoreProcessTask::~StoreProcessTask()
- {
- Exception_solver::get_instance_pointer()->delete_task_cancel_condition(m_car_info.license());
- }
- Error_manager StoreProcessTask::init_task(message::Locate_information locate_info)
- {
- reset_msg();
- m_locate_info=locate_info;
- //添加当前流程的任务取消标志位到异常处理模块
- m_cancel_condition.reset(false, false, false);
- Error_manager code=Exception_solver::get_instance_pointer()->add_task_cancel_condition(m_car_info.license(),this);
- if(code!=SUCCESS)
- return code;
- //初始化进度状态消息基本信息
- message::Base_info base_info;
- base_info.set_msg_type(message::eStoring_process_statu_msg);
- base_info.set_sender(message::eMain);
- base_info.set_receiver(message::eEmpty);
- m_process_msg.mutable_base_info()->CopyFrom(base_info);
- m_process_msg.set_terminal_id(m_terminor_id);
- m_process_msg.set_license(m_car_info.license());
- m_current_step_type=message::eAlloc_step;
- ///创建状态发布线程
- if(m_publish_statu_thread== nullptr)
- {
- m_publish_exit_condition.reset(false, false, false);
- m_publish_statu_thread=new std::thread(publish_thread_func,this);
- }
- return SUCCESS;
- }
- Error_manager StoreProcessTask::locate_step() {
- Error_manager code;
- //检查测量模块状态
- code=Measure_excutor::get_instance_pointer()->check_statu(m_terminor_id);
- if(code!=SUCCESS)
- return code;
- message::Base_info base_info;
- base_info.set_msg_type(message::eLocate_request_msg);
- base_info.set_sender(message::eMain);
- base_info.set_receiver(message::eMeasurer);
- base_info.set_timeout_ms(20000); //测量超时5s
- m_measure_request_msg.mutable_base_info()->CopyFrom(base_info);
- m_measure_request_msg.set_terminal_id(m_terminor_id);
- code=Measure_excutor::get_instance_pointer()->locate_request(m_measure_request_msg,
- m_measure_response_msg,m_cancel_condition);
- if(code!=SUCCESS)
- return code;
- if(m_measure_response_msg.error_manager().error_code()==0) {
- return SUCCESS;
- }
- else {
- Error_code t_code=(Error_code)m_measure_response_msg.error_manager().error_code();
- Error_level t_level=(Error_level)m_measure_response_msg.error_manager().error_level();
- return Error_manager(t_code, t_level, m_measure_response_msg.error_manager().error_description().c_str());
- }
- }
- /*
- * 回退定位
- */
- Error_manager StoreProcessTask::back_locate_step()
- {
- m_measure_request_msg=message::Measure_request_msg();
- m_measure_response_msg=message::Measure_response_msg();
- return SUCCESS;
- }
- /*
- * 检验结果
- */
- Error_manager StoreProcessTask::compare_step()
- {
- return SUCCESS;
- }
- /*
- * 回退检验
- */
- Error_manager StoreProcessTask::back_compare_step()
- {
- return SUCCESS;
- }
- /*
- * 调度
- */
- Error_manager StoreProcessTask::dispatch_step()
- {
- Error_manager code;
- /*
- * 判断调度所需的数据是否都正常
- */
- //1,测量信息是否存在
- if(m_measure_response_msg.has_base_info()== false
- ||m_measure_response_msg.has_locate_information()==false
- ||m_parcspace_alloc_response_msg.has_base_info()== false
- ||m_parcspace_alloc_response_msg.has_allocated_space_info()==false)
- {
- return Error_manager(ERROR,MAJOR_ERROR,"调度所需的前置数据(测量,车位)不存在");
- }
- //2,判断调度节点状态
- code=Dispatch_excutor::get_instance_pointer()->check_entrance_statu(m_terminor_id);
- if(code!=SUCCESS)
- return code;
- message::Base_info base_info;
- base_info.set_msg_type(message::eDispatch_request_msg);
- base_info.set_sender(message::eMain);
- base_info.set_receiver(message::eDispatch);
- base_info.set_timeout_ms(1000*15); //超时15s
- m_dispatch_request_msg.mutable_base_info()->CopyFrom(base_info);
- m_dispatch_request_msg.set_terminal_id(m_terminor_id);
- m_dispatch_request_msg.set_dispatch_motion_direction(message::E_STORE_CAR);
- m_dispatch_request_msg.set_parkspace_id(m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id());
- code=Dispatch_excutor::get_instance_pointer()->dispatch_request(m_dispatch_request_msg,
- m_dispatch_response_msg,m_cancel_condition);
- if(code!=SUCCESS)
- return code;
- if(m_dispatch_response_msg.error_manager().error_code()==0) {
- return SUCCESS;
- }
- else
- {
- Error_code t_code=(Error_code)m_dispatch_response_msg.error_manager().error_code();
- Error_level t_level=(Error_level)m_dispatch_response_msg.error_manager().error_level();
- return Error_manager(t_code,t_level,"dispatch response error_code error");
- }
- }
- /*
- * 回退调度
- */
- Error_manager StoreProcessTask::back_dispatch_step()
- {
- //reset 调度请求数据
- m_dispatch_request_msg=message::Dispatch_request_msg();
- m_dispatch_response_msg=message::Dispatch_response_msg();
- return SUCCESS;
- }
- /*
- * 分配车位
- */
- Error_manager StoreProcessTask::alloc_space_step()
- {
- message::Base_info base_info_response;
- base_info_response.set_msg_type(message::eStore_command_response_msg);
- base_info_response.set_sender(message::eMain);
- base_info_response.set_receiver(message::eTerminor);
- m_command_response_msg.mutable_base_info()->CopyFrom(base_info_response);
- m_command_response_msg.set_terminal_id(m_terminor_id);
- if(Command_manager::get_instance_pointer()->is_paused()==true)
- {
- return Error_manager(PAUSE, MINOR_ERROR, "系统已急停");
- }
- //
- message::Entrance_statu statu=Command_manager::get_instance_pointer()->entrance_statu(m_terminor_id);
- if(statu.has_paused()==false) {
- return Error_manager(ERROR, MINOR_ERROR, "入口已禁止使用 Disable");
- }
- if(statu.paused()==true)
- {
- return Error_manager(ERROR, MINOR_ERROR, "入口已禁止使用 Disable");
- }
- /*
- * 检查是否有测量数据
- */
- if(m_locate_info.has_locate_height()==false||m_locate_info.has_locate_width()==false)
- {
- return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
- }
- /*
- * 检查车位管理模块是否正常
- */
- Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
- if(code!=SUCCESS)
- {
- return code;
- }
- //发送分配请求
- message::Base_info base_info_request;
- base_info_request.set_msg_type(message::eParkspace_allocation_request_msg);
- base_info_request.set_sender(message::eMain);
- base_info_request.set_receiver(message::eParkspace);
- base_info_request.set_timeout_ms(5000); //超时1s
- m_alloc_request_msg.mutable_base_info()->CopyFrom(base_info_request);
- m_alloc_request_msg.mutable_car_info()->CopyFrom(m_car_info);
- m_alloc_request_msg.set_terminal_id(m_terminor_id);
- code=Parkspace_excutor::get_instance_pointer()->alloc_request(m_alloc_request_msg,
- m_parcspace_alloc_response_msg,m_cancel_condition);
- if(code!=SUCCESS)
- {
- return code;
- }
- if(m_parcspace_alloc_response_msg.error_manager().error_code()==0)
- {
- message::Car_info alloc_car_info=m_parcspace_alloc_response_msg.allocated_space_info().car_info();
- if(alloc_car_info.license()!=m_car_info.license())
- {
- return Error_manager(ERROR,MINOR_ERROR,"分配车位反馈的车辆信息不匹配");
- }
- return SUCCESS;
- }
- else
- {
- Error_code t_code=(Error_code)m_parcspace_alloc_response_msg.error_manager().error_code();
- Error_level t_level=(Error_level)m_parcspace_alloc_response_msg.error_manager().error_level();
- return Error_manager(t_code,t_level,"分配车位反馈结果错误");
- }
- }
- /*
- * 车位占用确认
- */
- Error_manager StoreProcessTask::confirm_space_step()
- {
- /*
- * 检查车位管理模块是否正常
- */
- Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
- if(code!=SUCCESS)
- return code;
- message::Parkspace_confirm_alloc_request_msg request;
- message::Base_info base_info;
- base_info.set_msg_type(message::eParkspace_confirm_alloc_request_msg);
- base_info.set_sender(message::eMain);
- base_info.set_receiver(message::eParkspace);
- base_info.set_timeout_ms(5000); //测量超时1s
- request.mutable_base_info()->CopyFrom(base_info);
- message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
- request.mutable_confirm_space_info()->CopyFrom(space_info);
- request.set_command_key(create_key());
- message::Parkspace_confirm_alloc_response_msg confirm_response;
- code=Parkspace_excutor::get_instance_pointer()->confirm_request(request,confirm_response,m_cancel_condition);
- if(code!=SUCCESS)
- return code;
- if(m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()!=
- confirm_response.confirm_alloc_space_info().parkspace_id())
- {
- return Error_manager(ERROR,MINOR_ERROR,"占用车位与分配车位不一致");
- }
- if(confirm_response.error_manager().error_code()==0) {
- /*LOG(INFO)<<"停车流程正常,确认占用车位成功,停车终端:"<<m_terminor_id
- <<", 指令id:"<<m_command_info.place()+m_command_info.time()
- <<", 车位楼层:"<<confirm_response.confirm_alloc_space_info().floor()
- <<", 车位序号:"<<confirm_response.confirm_alloc_space_info().index()
- <<", 车牌号:"<<confirm_response.confirm_alloc_space_info().car_info().license();*/
- return SUCCESS;
- }
- else
- {
- Error_code t_code=(Error_code)confirm_response.error_manager().error_code();
- Error_level t_level=(Error_level)confirm_response.error_manager().error_level();
- return Error_manager(t_code,t_level,"parkspace confirm response error_code error");
- }
- }
- /*
- * 回退车位分配
- */
- Error_manager StoreProcessTask::back_alloc_space_step()
- {
- /*
- * 检查是否曾经分配过车位
- */
- if(m_parcspace_alloc_response_msg.has_allocated_space_info()==false)
- {
- return Error_manager(FAILED,MAJOR_ERROR," parkspace release request without space info");
- }
- /*
- * 检查车位管理模块是否正常
- */
- Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
- if(code!=SUCCESS)
- return Error_manager(code.get_error_code(),MAJOR_ERROR,code.get_error_description());
- message::Parkspace_release_request_msg request;
- message::Base_info base_info;
- base_info.set_msg_type(message::eParkspace_release_request_msg);
- base_info.set_sender(message::eMain);
- base_info.set_receiver(message::eParkspace);
- base_info.set_timeout_ms(5000); //测量超时1s
- request.mutable_base_info()->CopyFrom(base_info);
- message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
- request.mutable_release_space_info()->CopyFrom(space_info);
- message::Parkspace_release_response_msg release_response;
- code=Parkspace_excutor::get_instance_pointer()->release_request(request,release_response,m_cancel_condition);
- if(code!=SUCCESS)
- return Error_manager(code.get_error_code(),MAJOR_ERROR,code.get_error_description());
- if(release_response.error_manager().error_code()==0) {
- /*LOG(WARNING)<<"停车流程异常,释放车位成功,停车终端:"<<m_terminor_id
- <<", 指令id:"<<m_command_info.place()+m_command_info.time()
- <<", 车位楼层:"<<m_parcspace_alloc_response_msg.allocated_space_info().floor()
- <<", 车位序号:"<<m_parcspace_alloc_response_msg.allocated_space_info().index()
- <<", 车牌号:"<<m_parcspace_alloc_response_msg.allocated_space_info().car_info().license();*/
- m_alloc_request_msg=message::Parkspace_allocation_request_msg();
- m_parcspace_alloc_response_msg=message::Parkspace_allocation_response_msg();
- return SUCCESS;
- }
- else
- {
- Error_code t_code=(Error_code)release_response.error_manager().error_code();
- Error_level t_level=(Error_level)release_response.error_manager().error_level();
- return Error_manager(t_code,MAJOR_ERROR,"back alloc response error_code error");
- }
- }
- /*
- * 控制流程到下一步
- */
- Error_manager StoreProcessTask::next_step()
- {
- if(m_current_step_statu==message::eWaiting || m_current_step_statu== message::eWorking)
- return Error_manager(ERROR,MINOR_ERROR,"当前步骤还未开始或者正在执行中,禁止改变步骤类型");
- switch (m_current_step_type)
- {
- case message::eAlloc_step:
- m_current_step_type=(m_current_step_statu==message::eFinished)?message::eMeasure_step:message::eBackComplete;
- break;
- case message::eMeasure_step:
- m_current_step_type=(m_current_step_statu==message::eFinished)?message::eCompare_step:message::eBackAlloc_step;
- break;
- case message::eCompare_step:
- m_current_step_type=(m_current_step_statu==message::eFinished)?message::eDispatch_step:message::eBackMeasure_step;
- break;
- case message::eDispatch_step:
- m_current_step_type=(m_current_step_statu==message::eFinished)?message::eConfirm_step:message::eBack_compare_step;
- break;
- case message::eConfirm_step:
- m_current_step_type=(m_current_step_statu==message::eFinished)?message::eComplete:message::eBackDispatch_step;
- break;
- case message::eComplete:
- break;
- case message::eBackDispatch_step:
- m_current_step_type=message::eBack_compare_step;
- break;
- case message::eBack_compare_step:
- m_current_step_type=message::eBackMeasure_step;
- break;
- case message::eBackMeasure_step:
- m_current_step_type=message::eBackAlloc_step;
- break;
- case message::eBackAlloc_step:
- m_current_step_type=message::eBackComplete;
- break;
- case message::eBackComplete:
- break;
- }
- return SUCCESS;
- }
- /*
- * 流程函数
- */
- void StoreProcessTask::Main()
- {
- /*
- * 外部已经分配好车位,进入到此流程说明车位已经分配好, 存放在 m_parcspace_alloc_response_msg
- */
- Error_manager code;
- //开始执行停车指令
- while(is_canceled()==false)
- {
- //分配车位
- if(m_current_step_type == message::eAlloc_step)
- {
- updata_step_statu(message::eWorking);
- code=alloc_space_step();
- //发送反馈
- message::Error_manager error_msg;
- error_msg.set_error_code(code.get_error_code());
- error_msg.set_error_description(code.get_error_description());
- m_command_response_msg.mutable_code()->CopyFrom(error_msg);
- Communication_message msg;
- msg.reset(m_command_response_msg.base_info(),m_command_response_msg.SerializeAsString());
- Message_communicator::get_instance_pointer()->send_msg(&msg);
- LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 分配失败:" <<m_car_info.license()<< code.get_error_description();
- }
- //测量
- if (m_current_step_type == message::eMeasure_step)
- {
- //开始定位
- updata_step_statu(message::eWorking);
- code = locate_step();
- usleep(1000 * 500 );
- LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 测量失败:" <<m_car_info.license()<< code.get_error_description();
- }
- if(m_current_step_type== message::eCompare_step)
- {
- updata_step_statu(message::eWorking);
- code=compare_step();
- usleep(500*1000);
- LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 检验失败:"<<m_car_info.license() << code.get_error_description();
- }
- //调度
- if (m_current_step_type == message::eDispatch_step)
- {
- //开始调度
- updata_step_statu(message::eWorking);
- code = dispatch_step();
- usleep(1000 * 500 );
- LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 调度失败:"<<m_car_info.license() << code.get_error_description();
- }
- //占据车位
- if (m_current_step_type == message::eConfirm_step)
- {
- updata_step_statu(message::eWorking);
- code = confirm_space_step();
- usleep(1000 * 200);
- LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 占据车位失败,终端号:" << m_terminor_id << "停车流程:" << code.get_error_description() <<
- " 车位id :"
- << m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()
- << ",车牌:" << m_car_info.license()<<code.to_string();
- }
- //完成,退出循环
- if (m_current_step_type == message::eComplete)
- {
- //流程结束前,保证至少发送一次流程完成状态
- updata_step_statu(message::eFinished);
- break;
- }
- //回退confirm ------------------------------------华丽的分割线------------------------------------------
- if (m_current_step_type == message::eBackConfirm_step)
- {
- updata_step_statu(message::eWorking);
- usleep(1000*200);
- updata_step_statu(message::eFinished);
- }
- if(m_current_step_type== message::eBackDispatch_step)
- {
- updata_step_statu(message::eWorking);
- code=back_dispatch_step();
- usleep(1000*500);
- LOG_IF(WARNING,code!=SUCCESS)<<" ------ 停 ------- 回退调度失败 ------进入异常处理, 车牌号:"
- <<m_car_info.license();
- }
- if(m_current_step_type== message::eBack_compare_step)
- {
- updata_step_statu(message::eWorking);
- code=back_compare_step();
- usleep(1000*200);
- LOG_IF(WARNING,code!=SUCCESS)<<" ------ 停 ------- 回退对比失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
- LOG(WARNING)<<" 手动处理 结果对比, 继续 ..........车牌:"<<m_car_info.license();
- }
- if(m_current_step_type== message::eBackMeasure_step)
- {
- updata_step_statu(message::eWorking);
- code=back_locate_step();
- usleep(1000*200);
- LOG_IF(WARNING,code!=SUCCESS)
- <<" ------ 停 ------- 回退测量失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
- }
- if(m_current_step_type== message::eBackAlloc_step)
- {
- updata_step_statu(message::eWorking);
- code=back_alloc_space_step();
- LOG_IF(WARNING,code!=SUCCESS)
- <<" ------ 停 ------- 回退分配车位失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
- }
- if(m_current_step_type== message::eBackComplete)
- {
- break;
- }
- //异常处理
- if(code!=SUCCESS)
- {
- //处理异常
- code=Exception_solver::get_instance_pointer()->solve_exception(code, this);
- //根据处理结果更新步骤状态
- }
- else
- {
- //本次步骤正常,切换步骤类型,进入下一步,否则不修改步骤类型,再次执行本次步骤
- updata_step_statu(message::eFinished);
- next_step();
- }
- }
- /*
- * 跳出循环后,判断状态,是否正常结束, 循环跳出状态只有可能是 eBackComplete(异常结束),eComplete(正常结束),任务取消状态
- */
- updata_step_statu(message::eFinished);
- publish_step_status();
- if(m_cancel_condition.wait_for_millisecond(1)==true) {
- LOG(ERROR) << "------ 停 ------- 停车任务被强制取消,车牌号:" << m_car_info.license()
- << ", 终端号:" << m_terminor_id;
- usleep(1000*200);
- return ;
- }
- if(m_current_step_type== message::eBackComplete)
- {
- //异常结束
- usleep(1000*200);
- LOG(WARNING)<<"------ 停 ------- 异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
- <<",xxxxxxxxxxxxxx 终端:"<<m_terminor_id<<" xxxxxxxxxxxxxx";
- }
- if(m_current_step_type== message::eComplete)
- {
- //正常结束
- usleep(1000*200);
- LOG(INFO)<<"------ 停 ------- 停车结束,"<<"车牌号:"<<m_car_info.license()
- <<",-------------- 终端:"<<m_terminor_id<<" --------------";
- }
- }
- void StoreProcessTask::publish_step_status() {
- /*
- * 通过communicator 发布状态
- */
- if (Command_accepter::get_instance_pointer()) {
- std::lock_guard<std::mutex> lock(m_process_msg_lock);
- Command_accepter::get_instance_pointer()->post_process_statu(m_process_msg);
- }
- }
- /*
- * 根据当前流程状态,并修改状态消息
- */
- void StoreProcessTask::updata_step_statu(message::Step_statu statu)
- {
- m_current_step_statu=statu;
- std::lock_guard<std::mutex> lock(m_process_msg_lock);
- switch (m_current_step_type) {
- case message::eAlloc_step: {
- message::Alloc_space_step_statu alloc_step_statu;
- alloc_step_statu.set_step_statu(statu);
- m_process_msg.mutable_alloc_space_step()->CopyFrom(alloc_step_statu);
- break;
- }
- case message::eMeasure_step: {
- message::Measure_step_statu measure_step_statu;
- measure_step_statu.set_step_statu(statu);
- measure_step_statu.mutable_locate_info()->CopyFrom(m_locate_info);
- m_process_msg.mutable_measure_step()->CopyFrom(measure_step_statu);
- break;
- }
- case message::eCompare_step:{
- message::Compare_step_statu compare_step;
- compare_step.mutable_locate_info_wj()->CopyFrom(m_locate_info);
- compare_step.mutable_locate_info_dj()->CopyFrom(m_measure_response_msg.locate_information());
- compare_step.mutable_locate_info_result()->CopyFrom(m_compare_location_data);
- compare_step.set_step_statu(statu);
- m_process_msg.mutable_compare_step()->CopyFrom(compare_step);
- break;
- }
- case message::eDispatch_step: {
- message::Dispatch_store_step_statu dispatch_step_statu;
- dispatch_step_statu.set_step_statu(statu);
- dispatch_step_statu.mutable_locate_info()->CopyFrom(m_locate_info);
- dispatch_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
- m_process_msg.mutable_dispatch_step()->CopyFrom(dispatch_step_statu);
- break;
- }
- case message::eConfirm_step: {
- message::Confirm_space_step_statu confirm_step_type;
- confirm_step_type.set_step_statu(statu);
- confirm_step_type.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
- m_process_msg.mutable_confirm_space_step()->CopyFrom(confirm_step_type);
- break;
- }
- case message::eComplete: {
- m_process_msg.set_completed(true);
- break;
- }
- case message::eBackConfirm_step: {
- message::Back_confirm_space_step_statu back_confirm_step_type;
- back_confirm_step_type.set_step_statu(statu);
- m_process_msg.mutable_back_confirm_step()->CopyFrom(back_confirm_step_type);
- break;
- }
- case message::eBackDispatch_step: {
- message::Back_dispatch_store_step_statu back_dispatch_step_statu;
- back_dispatch_step_statu.set_step_statu(statu);
- back_dispatch_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
- back_dispatch_step_statu.mutable_locate_info()->CopyFrom(m_compare_location_data);
- m_process_msg.mutable_back_dispatch_step()->CopyFrom(back_dispatch_step_statu);
- break;
- }
- case message::eBack_compare_step:{
- message::Back_compare_step_statu back_compare_step_statu;
- back_compare_step_statu.set_step_statu(statu);
- back_compare_step_statu.mutable_locate_info_wj()->CopyFrom(m_locate_info);
- back_compare_step_statu.mutable_locate_info_dj()->CopyFrom(m_measure_response_msg.locate_information());
- back_compare_step_statu.mutable_locate_info_result()->CopyFrom(m_compare_location_data);
- m_process_msg.mutable_back_compare_step()->CopyFrom(back_compare_step_statu);
- break;
- }
- case message::eBackMeasure_step: {
- message::Back_measure_step_statu back_measure_step_statu;
- back_measure_step_statu.set_step_statu(statu);
- m_process_msg.mutable_back_measure_step()->CopyFrom(back_measure_step_statu);
- break;
- }
- case message::eBackAlloc_step: {
- message::Back_alloc_space_step_statu back_alloc_step_statu;
- back_alloc_step_statu.set_step_statu(statu);
- back_alloc_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
- m_process_msg.mutable_back_alloc_space_step()->CopyFrom(back_alloc_step_statu);
- break;
- }
- case message::eBackComplete: {
- m_process_msg.set_back_completed(true);
- break;
- }
- default:
- break;
- }
- }
- /*
- * 初始化 接收到的消息
- */
- void StoreProcessTask::reset_msg() {
- m_alloc_request_msg = message::Parkspace_allocation_request_msg();
- m_measure_request_msg = message::Measure_request_msg();
- m_dispatch_request_msg = message::Dispatch_request_msg();
- m_confirm_request_msg = message::Parkspace_confirm_alloc_request_msg();
- m_command_response_msg=message::Store_command_response_msg();
- m_locate_info = message::Locate_information();
- m_measure_response_msg = message::Measure_response_msg(); //测量模块的测量数据
- m_parcspace_alloc_response_msg = message::Parkspace_allocation_response_msg(); //分配的车位数据
- m_dispatch_response_msg = message::Dispatch_response_msg(); //调度模块的反馈数据
- }
|