|
@@ -123,7 +123,6 @@ Error_manager StoreProcessTask::back_locate_step()
|
|
|
*/
|
|
|
Error_manager StoreProcessTask::compare_step()
|
|
|
{
|
|
|
-
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
/*
|
|
@@ -131,6 +130,7 @@ Error_manager StoreProcessTask::compare_step()
|
|
|
*/
|
|
|
Error_manager StoreProcessTask::back_compare_step()
|
|
|
{
|
|
|
+
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
|
|
@@ -202,8 +202,11 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
/*
|
|
|
* 检查是否有测量数据
|
|
|
*/
|
|
|
+ m_step_statu=eAlloc_step;
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
if(m_locate_info.has_locate_height()==false||m_locate_info.has_locate_width()==false)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eError);
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
|
|
|
}
|
|
|
/*
|
|
@@ -212,6 +215,7 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eError);
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -233,6 +237,7 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eError);
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -243,12 +248,14 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
{
|
|
|
return Error_manager(ERROR,MINOR_ERROR,"分配车位反馈的车辆信息不匹配");
|
|
|
}
|
|
|
+ updata_step_statu_msg(message::eComplete);
|
|
|
//置步骤状态为测量状态.
|
|
|
m_step_statu=eMeasure_step;
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eError);
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"分配车位反馈结果错误");
|
|
|
}
|
|
|
}
|
|
@@ -359,6 +366,7 @@ void StoreProcessTask::Main()
|
|
|
* 外部已经分配好车位,进入到此流程说明车位已经分配好, 存放在 m_parcspace_alloc_response_msg
|
|
|
*/
|
|
|
Error_manager code;
|
|
|
+
|
|
|
//开始执行停车指令
|
|
|
while(m_cancel_condition.wait_for_millisecond(1)==false)
|
|
|
{
|
|
@@ -366,68 +374,72 @@ void StoreProcessTask::Main()
|
|
|
if (m_step_statu == eStoring_step::eMeasure_step)
|
|
|
{
|
|
|
//开始定位
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code = locate_step();
|
|
|
usleep(1000 * 1000 * (rand() % 5 + 1));
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
|
|
|
LOG_IF(ERROR, code != SUCCESS) << "测量失败:" << code.get_error_description();
|
|
|
- m_step_statu = (code != SUCCESS) ? eStoring_step::eBackMeasure_step : eStoring_step::eCompare_step;
|
|
|
+ m_step_statu = (code != SUCCESS) ? eStoring_step::eBackAlloc_step : eStoring_step::eCompare_step;
|
|
|
}
|
|
|
if(m_step_statu==eStoring_step::eCompare_step)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code=compare_step();
|
|
|
usleep(500*1000);
|
|
|
-
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
LOG_IF(ERROR, code != SUCCESS) << "检验失败:" << code.get_error_description();
|
|
|
- m_step_statu = (code != SUCCESS) ? eStoring_step::eBack_compare_step : eStoring_step::eDispatch_step;
|
|
|
+ m_step_statu = (code != SUCCESS) ? eStoring_step::eBackMeasure_step : eStoring_step::eDispatch_step;
|
|
|
|
|
|
}
|
|
|
//第二步,调度
|
|
|
if (m_step_statu == eStoring_step::eDispatch_step)
|
|
|
{
|
|
|
//开始调度
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code = dispatch_step();
|
|
|
- usleep(1000 * 1000 * (rand() % 13));
|
|
|
-
|
|
|
+ usleep(1000 * 1000 * (rand() % 5));
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
LOG_IF(ERROR, code != SUCCESS) << "调度失败:" << code.get_error_description();
|
|
|
- m_step_statu = (code != SUCCESS) ? eStoring_step::eBackDispatch_step : eStoring_step::eConfirm_step;
|
|
|
+ m_step_statu = (code != SUCCESS) ? eStoring_step::eBack_compare_step : eStoring_step::eConfirm_step;
|
|
|
}
|
|
|
//第三步,占据车位
|
|
|
if (m_step_statu == eStoring_step::eConfirm_step)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code = confirm_space_step();
|
|
|
usleep(1000 * 1000);
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
LOG_IF(ERROR, 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(code!=SUCCESS)
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_step_statu=eStoring_step::eComplete;
|
|
|
- }
|
|
|
+ m_step_statu = (code != SUCCESS) ? eStoring_step::eBackDispatch_step : eStoring_step::eComplete;
|
|
|
}
|
|
|
//第四步,完成,退出循环
|
|
|
if (m_step_statu == eStoring_step::eComplete)
|
|
|
{
|
|
|
//流程结束前,保证至少发送一次流程完成状态
|
|
|
- if(updata_step_statu_msg()==SUCCESS)
|
|
|
- {
|
|
|
- System_communicator::get_instance_pointer()->post_process_statu(m_process_msg);
|
|
|
- }
|
|
|
+ updata_step_statu_msg(message::eComplete);
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
//回退confirm ------------------------------------华丽的分割线------------------------------------------
|
|
|
+
|
|
|
if (m_step_statu == eStoring_step::eBackConfirm_step)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
+ usleep(1000*1000);
|
|
|
+ updata_step_statu_msg(message::eComplete);
|
|
|
m_step_statu=eStoring_step::eBackDispatch_step;
|
|
|
}
|
|
|
if(m_step_statu==eStoring_step::eBackDispatch_step)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code=back_dispatch_step();
|
|
|
+ usleep(1000*1000);
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
//提升错误等级为四级
|
|
@@ -437,11 +449,15 @@ void StoreProcessTask::Main()
|
|
|
{
|
|
|
m_step_statu=eStoring_step::eBack_compare_step;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if(m_step_statu==eStoring_step::eBack_compare_step)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code=back_compare_step();
|
|
|
+ usleep(1000*1000);
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
//提升错误等级为四级
|
|
@@ -455,7 +471,10 @@ void StoreProcessTask::Main()
|
|
|
|
|
|
if(m_step_statu==eStoring_step::eBackMeasure_step)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code=back_locate_step();
|
|
|
+ usleep(1000*1000);
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
//提升错误等级为四级
|
|
@@ -468,7 +487,10 @@ void StoreProcessTask::Main()
|
|
|
}
|
|
|
if(m_step_statu==eStoring_step::eBackAlloc_step)
|
|
|
{
|
|
|
+ updata_step_statu_msg(message::eWorking);
|
|
|
code=back_alloc_space_step();
|
|
|
+ usleep(1000*1000);
|
|
|
+ code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
//提升错误等级为四级
|
|
@@ -477,9 +499,13 @@ void StoreProcessTask::Main()
|
|
|
else
|
|
|
{
|
|
|
m_step_statu=eStoring_step::eBackComplete;
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
+ if(m_step_statu==eStoring_step::eBackComplete)
|
|
|
+ {
|
|
|
+ updata_step_statu_msg(message::eComplete);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -494,14 +520,14 @@ void StoreProcessTask::Main()
|
|
|
if(m_step_statu==eStoring_step::eBackComplete)
|
|
|
{
|
|
|
//异常结束
|
|
|
- usleep(1000*10000);
|
|
|
+ usleep(1000*1000);
|
|
|
LOG(ERROR)<<"异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
|
|
|
<<",xxxxxxxxxxxxxx 终端:"<<m_terminor_id<<" xxxxxxxxxxxxxx";
|
|
|
}
|
|
|
if(m_step_statu==eStoring_step::eComplete)
|
|
|
{
|
|
|
//正常结束
|
|
|
- usleep(1000*1000);
|
|
|
+ usleep(1000*500);
|
|
|
LOG(INFO)<<"停车结束,"<<"车牌号:"<<m_car_info.license()
|
|
|
<<",-------------- 终端:"<<m_terminor_id<<" --------------";
|
|
|
}
|
|
@@ -527,10 +553,8 @@ void StoreProcessTask::publish_step_status()
|
|
|
*/
|
|
|
if(System_communicator::get_instance_pointer())
|
|
|
{
|
|
|
- if(updata_step_statu_msg()==SUCCESS)
|
|
|
- {
|
|
|
- System_communicator::get_instance_pointer()->post_process_statu(m_process_msg);
|
|
|
- }
|
|
|
+ std::lock_guard<std::mutex> lock(m_process_msg_lock);
|
|
|
+ System_communicator::get_instance_pointer()->post_process_statu(m_process_msg);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -538,32 +562,22 @@ void StoreProcessTask::publish_step_status()
|
|
|
/*
|
|
|
* 根据当前流程状态,生成状态消息
|
|
|
*/
|
|
|
-Error_manager StoreProcessTask::updata_step_statu_msg()
|
|
|
+void StoreProcessTask::updata_step_statu_msg(message::Step_statu statu)
|
|
|
{
|
|
|
+ std::lock_guard<std::mutex> lock(m_process_msg_lock);
|
|
|
switch (m_step_statu) {
|
|
|
case eStoring_step::eAlloc_step: {
|
|
|
message::Alloc_space_step_statu alloc_step_statu;
|
|
|
- alloc_step_statu.set_step_statu(message::eWorking);
|
|
|
+ alloc_step_statu.set_step_statu(statu);
|
|
|
m_process_msg.mutable_alloc_space_step()->CopyFrom(alloc_step_statu);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eMeasure_step: {
|
|
|
|
|
|
message::Measure_step_statu measure_step_statu;
|
|
|
- measure_step_statu.set_step_statu(message::eWorking);
|
|
|
+ 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);
|
|
|
- if(m_process_msg.has_alloc_space_step())
|
|
|
- {
|
|
|
- m_process_msg.mutable_alloc_space_step()->set_step_statu(message::eComplete);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- message::Alloc_space_step_statu alloc_step_statu;
|
|
|
- alloc_step_statu.set_step_statu(message::eComplete);
|
|
|
- alloc_step_statu.mutable_car_info()->CopyFrom(m_car_info);
|
|
|
- m_process_msg.mutable_alloc_space_step()->CopyFrom(alloc_step_statu);
|
|
|
- }
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eCompare_step:{
|
|
@@ -571,89 +585,63 @@ Error_manager StoreProcessTask::updata_step_statu_msg()
|
|
|
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(message::eWorking);
|
|
|
+ compare_step.set_step_statu(statu);
|
|
|
m_process_msg.mutable_compare_step()->CopyFrom(compare_step);
|
|
|
- if(m_process_msg.has_measure_step())
|
|
|
- m_process_msg.mutable_measure_step()->set_step_statu(message::eComplete);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eDispatch_step: {
|
|
|
message::Dispatch_store_step_statu dispatch_step_statu;
|
|
|
- dispatch_step_statu.set_step_statu(message::eWorking);
|
|
|
+ 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);
|
|
|
- if(m_process_msg.has_compare_step())
|
|
|
- m_process_msg.mutable_compare_step()->set_step_statu(message::eComplete);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eConfirm_step: {
|
|
|
message::Confirm_space_step_statu confirm_step_statu;
|
|
|
- confirm_step_statu.set_step_statu(message::eWorking);
|
|
|
+ confirm_step_statu.set_step_statu(statu);
|
|
|
confirm_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
|
|
|
m_process_msg.mutable_confirm_space_step()->CopyFrom(confirm_step_statu);
|
|
|
- if(m_process_msg.has_dispatch_step())
|
|
|
- m_process_msg.mutable_dispatch_step()->set_step_statu(message::eComplete);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eComplete: {
|
|
|
- if(m_process_msg.has_confirm_space_step())
|
|
|
- m_process_msg.mutable_confirm_space_step()->set_step_statu(message::eComplete);
|
|
|
m_process_msg.set_completed(true);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eBackConfirm_step: {
|
|
|
message::Back_confirm_space_step_statu back_confirm_step_statu;
|
|
|
- back_confirm_step_statu.set_step_statu(message::eWaiting);
|
|
|
- if (m_process_msg.has_confirm_space_step())
|
|
|
- m_process_msg.mutable_confirm_space_step()->set_step_statu(message::eError);
|
|
|
-
|
|
|
+ back_confirm_step_statu.set_step_statu(statu);
|
|
|
+ m_process_msg.mutable_back_confirm_step()->CopyFrom(back_confirm_step_statu);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eBackDispatch_step: {
|
|
|
message::Back_dispatch_store_step_statu back_dispatch_step_statu;
|
|
|
- back_dispatch_step_statu.set_step_statu(message::eWorking);
|
|
|
+ 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);
|
|
|
- if(m_process_msg.has_back_confirm_step())
|
|
|
- m_process_msg.mutable_back_confirm_step()->set_step_statu(message::eComplete);
|
|
|
- else
|
|
|
- m_process_msg.mutable_dispatch_step()->set_step_statu(message::eError);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eBack_compare_step:{
|
|
|
message::Back_compare_step_statu back_compare_step_statu;
|
|
|
- back_compare_step_statu.set_step_statu(message::eWorking);
|
|
|
+ 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_compare_step()->CopyFrom(back_compare_step_statu);
|
|
|
- if(m_process_msg.has_back_dispatch_step())
|
|
|
- m_process_msg.mutable_back_dispatch_step()->set_step_statu(message::eComplete);
|
|
|
- else
|
|
|
- m_process_msg.mutable_compare_step()->set_step_statu(message::eError);
|
|
|
+ m_process_msg.mutable_back_compare_step()->CopyFrom(back_compare_step_statu);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eBackMeasure_step: {
|
|
|
message::Back_measure_step_statu back_measure_step_statu;
|
|
|
- back_measure_step_statu.set_step_statu(message::eWorking);
|
|
|
+ back_measure_step_statu.set_step_statu(statu);
|
|
|
m_process_msg.mutable_back_measure_step()->CopyFrom(back_measure_step_statu);
|
|
|
- if(m_process_msg.has_back_compare_step())
|
|
|
- m_process_msg.mutable_back_compare_step()->set_step_statu(message::eComplete);
|
|
|
- else
|
|
|
- m_process_msg.mutable_measure_step()->set_step_statu(message::eError);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eBackAlloc_step: {
|
|
|
message::Back_alloc_space_step_statu back_alloc_step_statu;
|
|
|
- back_alloc_step_statu.set_step_statu(message::eWorking);
|
|
|
+ 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);
|
|
|
- if(m_process_msg.has_back_measure_step())
|
|
|
- m_process_msg.mutable_back_measure_step()->set_step_statu(message::eComplete);
|
|
|
- else
|
|
|
- m_process_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
break;
|
|
|
}
|
|
|
case eStoring_step::eBackComplete: {
|
|
@@ -663,8 +651,6 @@ Error_manager StoreProcessTask::updata_step_statu_msg()
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
- return SUCCESS;
|
|
|
}
|
|
|
|
|
|
|