|
@@ -44,7 +44,7 @@ Error_manager StoreProcessTask::init_task(message::Locate_information locate_inf
|
|
|
m_process_msg.set_terminal_id(m_terminor_id);
|
|
|
m_process_msg.set_license(m_car_info.license());
|
|
|
|
|
|
- m_step_type=eAlloc_step;
|
|
|
+ m_current_step_type=message::eAlloc_step;
|
|
|
///创建状态发布线程
|
|
|
if(m_publish_statu_thread== nullptr)
|
|
|
{
|
|
@@ -194,11 +194,11 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
/*
|
|
|
* 检查是否有测量数据
|
|
|
*/
|
|
|
- m_step_type=eAlloc_step;
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ m_current_step_type=message::eAlloc_step;
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
if(m_locate_info.has_locate_height()==false||m_locate_info.has_locate_width()==false)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eError);
|
|
|
+ updata_step_statu(message::eError);
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
|
|
|
}
|
|
|
/*
|
|
@@ -207,7 +207,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);
|
|
|
+ updata_step_statu(message::eError);
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -229,7 +229,7 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eError);
|
|
|
+ updata_step_statu(message::eError);
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -240,14 +240,13 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
{
|
|
|
return Error_manager(ERROR,MINOR_ERROR,"分配车位反馈的车辆信息不匹配");
|
|
|
}
|
|
|
- updata_step_statu_msg(message::eFinished);
|
|
|
+ updata_step_statu(message::eFinished);
|
|
|
//置步骤状态为测量状态.
|
|
|
- m_step_type=eMeasure_step;
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eError);
|
|
|
+ updata_step_statu(message::eError);
|
|
|
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,"分配车位反馈结果错误");
|
|
@@ -365,6 +364,53 @@ Error_manager StoreProcessTask::back_alloc_space_step()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * 控制流程到下一步
|
|
|
+ */
|
|
|
+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()
|
|
|
{
|
|
|
/*
|
|
@@ -373,172 +419,156 @@ void StoreProcessTask::Main()
|
|
|
Error_manager code;
|
|
|
|
|
|
//开始执行停车指令
|
|
|
- while(m_cancel_condition.wait_for_millisecond(1)==false)
|
|
|
+ while(is_canceled()==false)
|
|
|
{
|
|
|
//第一步,测量
|
|
|
- if (m_step_type == eMeasure_step)
|
|
|
+ if (m_current_step_type == message::eMeasure_step)
|
|
|
{
|
|
|
//开始定位
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code = locate_step();
|
|
|
- usleep(1000 * 1000 * (rand() % 5 + 1));
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
+ usleep(1000 * 1000 );
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
|
|
|
LOG_IF(ERROR, code != SUCCESS) << "测量失败:" <<m_car_info.license()<< code.get_error_description();
|
|
|
- m_step_type = (code != SUCCESS) ? eBackAlloc_step : eCompare_step;
|
|
|
}
|
|
|
- if(m_step_type== eCompare_step)
|
|
|
+ if(m_current_step_type== message::eCompare_step)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code=compare_step();
|
|
|
usleep(500*1000);
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
- LOG_IF(ERROR, code != SUCCESS) << "检验失败:"<<m_car_info.license() << code.get_error_description();
|
|
|
- m_step_type = (code != SUCCESS) ? eBackMeasure_step : eDispatch_step;
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
|
|
|
+ LOG_IF(ERROR, code != SUCCESS) << "检验失败:"<<m_car_info.license() << code.get_error_description();
|
|
|
}
|
|
|
//第二步,调度
|
|
|
- if (m_step_type == eDispatch_step)
|
|
|
+ if (m_current_step_type == message::eDispatch_step)
|
|
|
{
|
|
|
//开始调度
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code = dispatch_step();
|
|
|
- usleep(1000 * 1000 * (rand() % 5));
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
+ usleep(1000 * 2000 );
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
LOG_IF(ERROR, code != SUCCESS) << "调度失败:"<<m_car_info.license() << code.get_error_description();
|
|
|
- m_step_type = (code != SUCCESS) ? eBack_compare_step : eConfirm_step;
|
|
|
}
|
|
|
//第三步,占据车位
|
|
|
- if (m_step_type == eConfirm_step)
|
|
|
+ if (m_current_step_type == message::eConfirm_step)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code = confirm_space_step();
|
|
|
usleep(1000 * 1000);
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
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();
|
|
|
- m_step_type = (code != SUCCESS) ? eBackDispatch_step : eComplete;
|
|
|
}
|
|
|
//第四步,完成,退出循环
|
|
|
- if (m_step_type == eComplete)
|
|
|
+ if (m_current_step_type == message::eComplete)
|
|
|
{
|
|
|
//流程结束前,保证至少发送一次流程完成状态
|
|
|
- updata_step_statu_msg(message::eFinished);
|
|
|
+ updata_step_statu(message::eFinished);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//回退confirm ------------------------------------华丽的分割线------------------------------------------
|
|
|
|
|
|
- if (m_step_type == eBackConfirm_step)
|
|
|
+ if (m_current_step_type == message::eBackConfirm_step)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
usleep(1000*1000);
|
|
|
- updata_step_statu_msg(message::eFinished);
|
|
|
- m_step_type= eBackDispatch_step;
|
|
|
+ updata_step_statu(message::eFinished);
|
|
|
+
|
|
|
}
|
|
|
- if(m_step_type== eBackDispatch_step)
|
|
|
+ if(m_current_step_type== message::eBackDispatch_step)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code=back_dispatch_step();
|
|
|
usleep(1000*1000);
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
if(code.get_error_level()>=MAJOR_ERROR)
|
|
|
{
|
|
|
//提升错误等级为四级
|
|
|
LOG(ERROR)<<" 回退调度失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
Exception_solver::get_instance_pointer()->solve_exception(code,this);
|
|
|
+ continue;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- m_step_type= eBack_compare_step;
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- if(m_step_type== eBack_compare_step)
|
|
|
+ if(m_current_step_type== message::eBack_compare_step)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code=back_compare_step();
|
|
|
usleep(1000*1000);
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
if(code.get_error_level()>=MAJOR_ERROR)
|
|
|
{
|
|
|
LOG(ERROR)<<" 回退对比失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
Exception_solver::get_instance_pointer()->solve_exception(code,this);
|
|
|
LOG(WARNING)<<" 手动处理 结果对比, 继续 ..........车牌:"<<m_car_info.license();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_step_type= eBackMeasure_step;
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(m_step_type== eBackMeasure_step)
|
|
|
+ if(m_current_step_type== message::eBackMeasure_step)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code=back_locate_step();
|
|
|
usleep(1000*1000);
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
if(code.get_error_level()>=MAJOR_ERROR)
|
|
|
{
|
|
|
//提升错误等级为四级
|
|
|
LOG(ERROR)<<" 回退测量失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
Exception_solver::get_instance_pointer()->solve_exception(code,this);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_step_type= eBackAlloc_step;
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
- if(m_step_type== eBackAlloc_step)
|
|
|
+ if(m_current_step_type== message::eBackAlloc_step)
|
|
|
{
|
|
|
- updata_step_statu_msg(message::eWorking);
|
|
|
+ updata_step_statu(message::eWorking);
|
|
|
code=back_alloc_space_step();
|
|
|
usleep(1000*1000);
|
|
|
- code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eFinished);
|
|
|
+ code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
|
|
|
if(code.get_error_level()>=MAJOR_ERROR)
|
|
|
{
|
|
|
//提升错误等级为四级
|
|
|
LOG(ERROR)<<" 回退分配车位失败 ------进入异常处理, 车牌号:"<<m_car_info.license();
|
|
|
Exception_solver::get_instance_pointer()->solve_exception(code,this);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_step_type= eBackComplete;
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
- if(m_step_type== eBackComplete)
|
|
|
+ if(m_current_step_type== message::eBackComplete)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
+ next_step();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 跳出循环后,判断状态,是否正常结束, 循环跳出状态只有可能是 eBackComplete(异常结束),eComplete(正常结束),任务取消状态
|
|
|
*/
|
|
|
- updata_step_statu_msg(message::eFinished);
|
|
|
+ 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*500);
|
|
|
+ usleep(1000*200);
|
|
|
return ;
|
|
|
}
|
|
|
|
|
|
- if(m_step_type== eBackComplete)
|
|
|
+ if(m_current_step_type== message::eBackComplete)
|
|
|
{
|
|
|
//异常结束
|
|
|
- usleep(1000*1000);
|
|
|
+ usleep(1000*200);
|
|
|
LOG(ERROR)<<"异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
|
|
|
<<",xxxxxxxxxxxxxx 终端:"<<m_terminor_id<<" xxxxxxxxxxxxxx";
|
|
|
}
|
|
|
- if(m_step_type== eComplete)
|
|
|
+ if(m_current_step_type== message::eComplete)
|
|
|
{
|
|
|
//正常结束
|
|
|
- usleep(1000*500);
|
|
|
+ usleep(1000*200);
|
|
|
LOG(INFO)<<"停车结束,"<<"车牌号:"<<m_car_info.license()
|
|
|
<<",-------------- 终端:"<<m_terminor_id<<" --------------";
|
|
|
}
|
|
@@ -556,26 +586,27 @@ void StoreProcessTask::publish_step_status() {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * 根据当前流程状态,生成状态消息
|
|
|
+ * 根据当前流程状态,并修改状态消息
|
|
|
*/
|
|
|
-void StoreProcessTask::updata_step_statu_msg(message::Step_statu statu)
|
|
|
+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_step_type) {
|
|
|
- case eAlloc_step: {
|
|
|
+ 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 eMeasure_step: {
|
|
|
+ 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 eCompare_step:{
|
|
|
+ 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());
|
|
@@ -584,7 +615,7 @@ void StoreProcessTask::updata_step_statu_msg(message::Step_statu statu)
|
|
|
m_process_msg.mutable_compare_step()->CopyFrom(compare_step);
|
|
|
break;
|
|
|
}
|
|
|
- case eDispatch_step: {
|
|
|
+ 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);
|
|
@@ -592,24 +623,24 @@ void StoreProcessTask::updata_step_statu_msg(message::Step_statu statu)
|
|
|
m_process_msg.mutable_dispatch_step()->CopyFrom(dispatch_step_statu);
|
|
|
break;
|
|
|
}
|
|
|
- case eConfirm_step: {
|
|
|
+ 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 eComplete: {
|
|
|
+ case message::eComplete: {
|
|
|
m_process_msg.set_completed(true);
|
|
|
break;
|
|
|
}
|
|
|
- case eBackConfirm_step: {
|
|
|
+ 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 eBackDispatch_step: {
|
|
|
+ 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());
|
|
@@ -617,7 +648,7 @@ void StoreProcessTask::updata_step_statu_msg(message::Step_statu statu)
|
|
|
m_process_msg.mutable_back_dispatch_step()->CopyFrom(back_dispatch_step_statu);
|
|
|
break;
|
|
|
}
|
|
|
- case eBack_compare_step:{
|
|
|
+ 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);
|
|
@@ -626,20 +657,20 @@ void StoreProcessTask::updata_step_statu_msg(message::Step_statu statu)
|
|
|
m_process_msg.mutable_back_compare_step()->CopyFrom(back_compare_step_statu);
|
|
|
break;
|
|
|
}
|
|
|
- case eBackMeasure_step: {
|
|
|
+ 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 eBackAlloc_step: {
|
|
|
+ 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 eBackComplete: {
|
|
|
+ case message::eBackComplete: {
|
|
|
m_process_msg.set_back_completed(true);
|
|
|
break;
|
|
|
}
|