|
@@ -2,6 +2,7 @@
|
|
|
// Created by zx on 2020/7/7.
|
|
|
//
|
|
|
|
|
|
+#include <glog/logging.h>
|
|
|
#include <parkspace_excutor.h>
|
|
|
#include <dispatch_message.pb.h>
|
|
|
#include "dispatch_excutor.h"
|
|
@@ -15,6 +16,7 @@
|
|
|
StoreProcessTask::StoreProcessTask(unsigned int terminor_id,message::Car_info car_info)
|
|
|
:Process_task(terminor_id,car_info)
|
|
|
{
|
|
|
+ m_process_log.set_process_type(message::eStoring);
|
|
|
}
|
|
|
|
|
|
StoreProcessTask::~StoreProcessTask()
|
|
@@ -23,6 +25,11 @@ StoreProcessTask::~StoreProcessTask()
|
|
|
|
|
|
Error_manager StoreProcessTask::init_task(message::Locate_information locate_info)
|
|
|
{
|
|
|
+
|
|
|
+ char log[255]={0};
|
|
|
+ sprintf(log,"来自终端 %d 的停车指令:\n %s",m_terminor_id,locate_info.DebugString().c_str());
|
|
|
+ ALOG(INFO)<<log;
|
|
|
+
|
|
|
reset_msg();
|
|
|
m_locate_info=locate_info;
|
|
|
|
|
@@ -65,6 +72,11 @@ Error_manager StoreProcessTask::locate_step() {
|
|
|
|
|
|
code=Measure_excutor::get_instance_pointer()->locate_request(m_measure_request_msg,
|
|
|
m_measure_response_msg,m_cancel_condition);
|
|
|
+ message::Measure_data measure_data;
|
|
|
+ measure_data.mutable_request()->CopyFrom(m_measure_request_msg);
|
|
|
+ measure_data.mutable_response()->CopyFrom(m_measure_response_msg);
|
|
|
+ ALOG(INFO)<<measure_data;
|
|
|
+
|
|
|
if(code!=SUCCESS)
|
|
|
return code;
|
|
|
|
|
@@ -86,6 +98,7 @@ Error_manager StoreProcessTask::back_locate_step()
|
|
|
{
|
|
|
m_measure_request_msg=message::Measure_request_msg();
|
|
|
m_measure_response_msg=message::Measure_response_msg();
|
|
|
+ ALOG(INFO)<<"回退测量";
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
|
|
@@ -101,6 +114,7 @@ Error_manager StoreProcessTask::compare_step()
|
|
|
*/
|
|
|
Error_manager StoreProcessTask::back_compare_step()
|
|
|
{
|
|
|
+ ALOG(INFO)<<" 回退compare";
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
|
|
@@ -140,6 +154,12 @@ Error_manager StoreProcessTask::dispatch_step()
|
|
|
|
|
|
code=Dispatch_excutor::get_instance_pointer()->dispatch_request(m_dispatch_request_msg,
|
|
|
m_dispatch_response_msg,m_cancel_condition);
|
|
|
+ //记录
|
|
|
+ message::Dispatch_data dispatch_data;
|
|
|
+ dispatch_data.mutable_request()->CopyFrom(m_dispatch_request_msg);
|
|
|
+ dispatch_data.mutable_response()->CopyFrom(m_dispatch_response_msg);
|
|
|
+ ALOG(INFO)<<dispatch_data;
|
|
|
+
|
|
|
if(code!=SUCCESS)
|
|
|
return code;
|
|
|
|
|
@@ -163,6 +183,8 @@ Error_manager StoreProcessTask::back_dispatch_step()
|
|
|
m_dispatch_request_msg=message::Dispatch_request_msg();
|
|
|
m_dispatch_response_msg=message::Dispatch_response_msg();
|
|
|
|
|
|
+ ALOG(INFO)<<" 回退调度 ";
|
|
|
+
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
|
|
@@ -203,6 +225,7 @@ Error_manager StoreProcessTask::alloc_space_step()
|
|
|
* 检查车位管理模块是否正常
|
|
|
*/
|
|
|
Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
|
|
|
+
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
return code;
|
|
@@ -223,6 +246,12 @@ Error_manager StoreProcessTask::alloc_space_step()
|
|
|
code=Parkspace_excutor::get_instance_pointer()->alloc_request(m_alloc_request_msg,
|
|
|
m_parcspace_alloc_response_msg,m_cancel_condition);
|
|
|
|
|
|
+ //记录日志
|
|
|
+ message::Parkspace_data parkspace_data;
|
|
|
+ parkspace_data.mutable_alloc_request()->CopyFrom(m_alloc_request_msg);
|
|
|
+ parkspace_data.mutable_alloc_response()->CopyFrom(m_parcspace_alloc_response_msg);
|
|
|
+ ALOG(INFO)<<parkspace_data;
|
|
|
+
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
return code;
|
|
@@ -272,6 +301,12 @@ Error_manager StoreProcessTask::confirm_space_step()
|
|
|
|
|
|
message::Parkspace_confirm_alloc_response_msg confirm_response;
|
|
|
code=Parkspace_excutor::get_instance_pointer()->confirm_request(request,confirm_response,m_cancel_condition);
|
|
|
+ //记录日志
|
|
|
+ message::Parkspace_data confirm_data;
|
|
|
+ confirm_data.mutable_confirm_request()->CopyFrom(request);
|
|
|
+ confirm_data.mutable_confirm_response()->CopyFrom(confirm_response);
|
|
|
+ ALOG(INFO)<<confirm_data;
|
|
|
+
|
|
|
if(code!=SUCCESS)
|
|
|
return code;
|
|
|
|
|
@@ -331,6 +366,14 @@ Error_manager StoreProcessTask::back_alloc_space_step()
|
|
|
|
|
|
message::Parkspace_release_response_msg release_response;
|
|
|
code=Parkspace_excutor::get_instance_pointer()->release_request(request,release_response,m_cancel_condition);
|
|
|
+
|
|
|
+ //记录
|
|
|
+ message::Parkspace_data release_data;
|
|
|
+ release_data.mutable_release_request()->CopyFrom(request);
|
|
|
+ release_data.mutable_release_response()->CopyFrom(release_response);
|
|
|
+ release_data.set_description("回退分配步骤,释放车位");
|
|
|
+ ALOG(INFO)<<release_data;
|
|
|
+
|
|
|
if(code!=SUCCESS)
|
|
|
return Error_manager(code.get_error_code(),MAJOR_ERROR,code.get_error_description());
|
|
|
|
|
@@ -394,6 +437,7 @@ Error_manager StoreProcessTask::next_step()
|
|
|
case message::eBackComplete:
|
|
|
break;
|
|
|
}
|
|
|
+ ALOG(INFO)<<"进入下一步:"<<message::Step_type_Name(m_current_step_type);
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
|
|
@@ -413,8 +457,12 @@ void StoreProcessTask::Main()
|
|
|
//分配车位
|
|
|
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());
|
|
@@ -423,6 +471,7 @@ void StoreProcessTask::Main()
|
|
|
Communication_message msg;
|
|
|
msg.reset(m_command_response_msg.base_info(),m_command_response_msg.SerializeAsString());
|
|
|
Message_communicator::get_instance_pointer()->send_msg(&msg);
|
|
|
+ ALOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 分配失败:" <<m_car_info.license()<< code.get_error_description();
|
|
|
LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 分配失败:" <<m_car_info.license()<< code.get_error_description();
|
|
|
}
|
|
|
|
|
@@ -433,6 +482,7 @@ void StoreProcessTask::Main()
|
|
|
updata_step_statu(message::eWorking);
|
|
|
code = locate_step();
|
|
|
usleep(1000 * 500 );
|
|
|
+ ALOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 测量失败:" <<m_car_info.license()<< code.get_error_description();
|
|
|
LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 测量失败:" <<m_car_info.license()<< code.get_error_description();
|
|
|
}
|
|
|
if(m_current_step_type== message::eCompare_step)
|
|
@@ -440,6 +490,7 @@ void StoreProcessTask::Main()
|
|
|
updata_step_statu(message::eWorking);
|
|
|
code=compare_step();
|
|
|
usleep(500*1000);
|
|
|
+ ALOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 检验失败:"<<m_car_info.license() << code.get_error_description();
|
|
|
LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 检验失败:"<<m_car_info.license() << code.get_error_description();
|
|
|
}
|
|
|
//调度
|
|
@@ -449,6 +500,7 @@ void StoreProcessTask::Main()
|
|
|
updata_step_statu(message::eWorking);
|
|
|
code = dispatch_step();
|
|
|
usleep(1000 * 500 );
|
|
|
+ ALOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 调度失败:"<<m_car_info.license() << code.get_error_description();
|
|
|
LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 调度失败:"<<m_car_info.license() << code.get_error_description();
|
|
|
}
|
|
|
//占据车位
|
|
@@ -457,10 +509,14 @@ void StoreProcessTask::Main()
|
|
|
updata_step_statu(message::eWorking);
|
|
|
code = confirm_space_step();
|
|
|
usleep(1000 * 200);
|
|
|
- LOG_IF(WARNING, code != SUCCESS) << "------ 停 ------- 占据车位失败,终端号:" << m_terminor_id << "停车流程:" << code.get_error_description() <<
|
|
|
+ ALOG_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();
|
|
|
+ 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)
|
|
@@ -484,8 +540,10 @@ void StoreProcessTask::Main()
|
|
|
updata_step_statu(message::eWorking);
|
|
|
code=back_dispatch_step();
|
|
|
usleep(1000*500);
|
|
|
- LOG_IF(WARNING,code!=SUCCESS)<<" ------ 停 ------- 回退调度失败 ------进入异常处理, 车牌号:"
|
|
|
+ ALOG_IF(WARNING,code!=SUCCESS)<<" ------ 停 ------- 回退调度失败 ------进入异常处理, 车牌号:"
|
|
|
<<m_car_info.license();
|
|
|
+ LOG_IF(WARNING,code!=SUCCESS)<<" ------ 停 ------- 回退调度失败 ------进入异常处理, 车牌号:"
|
|
|
+ <<m_car_info.license();
|
|
|
}
|
|
|
|
|
|
if(m_current_step_type== message::eBack_compare_step)
|
|
@@ -493,11 +551,8 @@ void StoreProcessTask::Main()
|
|
|
updata_step_statu(message::eWorking);
|
|
|
code=back_compare_step();
|
|
|
usleep(1000*200);
|
|
|
-
|
|
|
+ ALOG_IF(WARNING,code!=SUCCESS)<<" ------ 停 ------- 回退对比失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
LOG_IF(WARNING,code!=SUCCESS)<<" ------ 停 ------- 回退对比失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
-
|
|
|
- LOG(WARNING)<<" 手动处理 结果对比, 继续 ..........车牌:"<<m_car_info.license();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if(m_current_step_type== message::eBackMeasure_step)
|
|
@@ -506,8 +561,10 @@ void StoreProcessTask::Main()
|
|
|
code=back_locate_step();
|
|
|
usleep(1000*200);
|
|
|
|
|
|
- LOG_IF(WARNING,code!=SUCCESS)
|
|
|
+ ALOG_IF(WARNING,code!=SUCCESS)
|
|
|
<<" ------ 停 ------- 回退测量失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
+ LOG_IF(WARNING,code!=SUCCESS)
|
|
|
+ <<" ------ 停 ------- 回退测量失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
|
|
|
}
|
|
|
if(m_current_step_type== message::eBackAlloc_step)
|
|
@@ -515,8 +572,10 @@ void StoreProcessTask::Main()
|
|
|
updata_step_statu(message::eWorking);
|
|
|
code=back_alloc_space_step();
|
|
|
|
|
|
- LOG_IF(WARNING,code!=SUCCESS)
|
|
|
+ ALOG_IF(WARNING,code!=SUCCESS)
|
|
|
<<" ------ 停 ------- 回退分配车位失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
+ LOG_IF(WARNING,code!=SUCCESS)
|
|
|
+ <<" ------ 停 ------- 回退分配车位失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
|
|
|
}
|
|
|
if(m_current_step_type== message::eBackComplete)
|
|
@@ -549,8 +608,10 @@ void StoreProcessTask::Main()
|
|
|
publish_step_status();
|
|
|
|
|
|
if(m_cancel_condition.wait_for_millisecond(1)==true) {
|
|
|
- LOG(ERROR) << "------ 停 ------- 停车任务被强制取消,车牌号:" << m_car_info.license()
|
|
|
+ ALOG(ERROR) << "------ 停 ------- 停车任务被强制取消,车牌号:" << m_car_info.license()
|
|
|
<< ", 终端号:" << m_terminor_id;
|
|
|
+ LOG(ERROR) << "------ 停 ------- 停车任务被强制取消,车牌号:" << m_car_info.license()
|
|
|
+ << ", 终端号:" << m_terminor_id;
|
|
|
usleep(1000*200);
|
|
|
return ;
|
|
|
}
|
|
@@ -559,16 +620,23 @@ void StoreProcessTask::Main()
|
|
|
{
|
|
|
//异常结束
|
|
|
usleep(1000*200);
|
|
|
- LOG(WARNING)<<"------ 停 ------- 异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
|
|
|
+ ALOG(WARNING)<<"------ 停 ------- 异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
|
|
|
<<",xxxxxxxxxxxxxx 终端:"<<m_terminor_id<<" xxxxxxxxxxxxxx";
|
|
|
+ LOG(WARNING)<<"------ 停 ------- 异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
|
|
|
+ <<",xxxxxxxxxxxxxx 终端:"<<m_terminor_id<<" xxxxxxxxxxxxxx";
|
|
|
}
|
|
|
if(m_current_step_type== message::eComplete)
|
|
|
{
|
|
|
//正常结束
|
|
|
usleep(1000*200);
|
|
|
+ ALOG(INFO)<<"------ 停 ------- 停车结束,"<<"车牌号:"<<m_car_info.license()
|
|
|
+ <<",-------------- 终端:"<<m_terminor_id<<" --------------";
|
|
|
LOG(INFO)<<"------ 停 ------- 停车结束,"<<"车牌号:"<<m_car_info.license()
|
|
|
<<",-------------- 终端:"<<m_terminor_id<<" --------------";
|
|
|
}
|
|
|
+
|
|
|
+ return Process_task::Main();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -587,6 +655,11 @@ void StoreProcessTask::publish_step_status() {
|
|
|
*/
|
|
|
void StoreProcessTask::updata_step_statu(message::Step_statu statu)
|
|
|
{
|
|
|
+ if(m_current_step_statu!=statu)
|
|
|
+ {
|
|
|
+ ALOG(INFO) << "切换当前步骤状态:" << message::Step_statu_Name(m_current_step_statu)
|
|
|
+ << " -->" << message::Step_statu_Name(statu);
|
|
|
+ }
|
|
|
m_current_step_statu=statu;
|
|
|
std::lock_guard<std::mutex> lock(m_process_msg_lock);
|
|
|
switch (m_current_step_type) {
|