|
@@ -15,14 +15,6 @@ StoreProcessTask::StoreProcessTask(unsigned int terminor_id)
|
|
|
:m_publish_statu_thread(nullptr)
|
|
|
{
|
|
|
m_terminor_id=terminor_id;
|
|
|
-
|
|
|
- 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_storing_process_statu_msg.mutable_base_info()->CopyFrom(base_info);
|
|
|
- m_storing_process_statu_msg.set_terminal_id(terminor_id);
|
|
|
- reset_process_statu();
|
|
|
}
|
|
|
|
|
|
StoreProcessTask::~StoreProcessTask()
|
|
@@ -42,12 +34,12 @@ StoreProcessTask::~StoreProcessTask()
|
|
|
|
|
|
Error_manager StoreProcessTask::init_task(message::Locate_information locate_info,message::Car_info car_info)
|
|
|
{
|
|
|
- reset_recv_msg();
|
|
|
+ reset_msg();
|
|
|
|
|
|
m_car_info=car_info;
|
|
|
m_locate_info=locate_info;
|
|
|
|
|
|
- reset_process_statu();
|
|
|
+ m_step_statu=eAlloc_step;
|
|
|
///创建状态发布线程
|
|
|
if(m_publish_statu_thread== nullptr)
|
|
|
{
|
|
@@ -67,18 +59,17 @@ Error_manager StoreProcessTask::locate_step() {
|
|
|
if(code!=SUCCESS)
|
|
|
return code;
|
|
|
|
|
|
- message::Measure_request_msg request;
|
|
|
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
|
|
|
- request.mutable_base_info()->CopyFrom(base_info);
|
|
|
+ m_measure_request_msg.mutable_base_info()->CopyFrom(base_info);
|
|
|
|
|
|
- request.set_command_key(create_key());
|
|
|
- request.set_terminal_id(m_terminor_id);
|
|
|
+ m_measure_request_msg.set_command_key(create_key());
|
|
|
+ m_measure_request_msg.set_terminal_id(m_terminor_id);
|
|
|
|
|
|
- code=Locate_communicator::get_instance_pointer()->locate_request(request,m_measure_response_msg);
|
|
|
+ code=Locate_communicator::get_instance_pointer()->locate_request(m_measure_request_msg,m_measure_response_msg);
|
|
|
if(code!=SUCCESS)
|
|
|
return code;
|
|
|
|
|
@@ -90,6 +81,17 @@ Error_manager StoreProcessTask::locate_step() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * 回退定位
|
|
|
+ */
|
|
|
+Error_manager StoreProcessTask::back_locate_step()
|
|
|
+{
|
|
|
+ m_measure_request_msg=message::Measure_request_msg();
|
|
|
+ m_measure_response_msg=message::Measure_response_msg();
|
|
|
+
|
|
|
+ return SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* 调度
|
|
|
*/
|
|
@@ -113,21 +115,20 @@ Error_manager StoreProcessTask::dispatch_step()
|
|
|
if(code!=SUCCESS)
|
|
|
return code;
|
|
|
|
|
|
- message::Dispatch_request_msg request;
|
|
|
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
|
|
|
- request.mutable_base_info()->CopyFrom(base_info);
|
|
|
+ m_dispatch_request_msg.mutable_base_info()->CopyFrom(base_info);
|
|
|
|
|
|
std::string key=create_key();
|
|
|
- request.set_command_key(key);
|
|
|
- request.set_terminal_id(m_terminor_id);
|
|
|
- request.set_dispatch_motion_direction(message::E_STORE_CAR);
|
|
|
- request.set_parkspace_id(m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id());
|
|
|
+ m_dispatch_request_msg.set_command_key(key);
|
|
|
+ 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_communicator::get_instance_pointer()->dispatch_request(request,m_dispatch_response_msg);
|
|
|
+ code=Dispatch_communicator::get_instance_pointer()->dispatch_request(m_dispatch_request_msg,m_dispatch_response_msg);
|
|
|
if(code!=SUCCESS)
|
|
|
return code;
|
|
|
|
|
@@ -139,35 +140,14 @@ Error_manager StoreProcessTask::dispatch_step()
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * reset 进度信息
|
|
|
+ * 回退调度
|
|
|
*/
|
|
|
-void StoreProcessTask::reset_process_statu()
|
|
|
+Error_manager StoreProcessTask::back_dispatch_step()
|
|
|
{
|
|
|
- message::Alloc_space_step_statu alloc_step;
|
|
|
- alloc_step.set_step_statu(message::eWaiting);
|
|
|
-
|
|
|
- message::Measure_step_statu measure_step;
|
|
|
- measure_step.set_step_statu(message::eWaiting);
|
|
|
-
|
|
|
- message::Dispatch_store_step_statu store_step;
|
|
|
- store_step.set_step_statu(message::eWaiting);
|
|
|
-
|
|
|
- message::Confirm_space_step_statu confirm_step;
|
|
|
- confirm_step.set_step_statu(message::eWaiting);
|
|
|
-
|
|
|
- message::Release_space_step_statu release_step;
|
|
|
- release_step.set_step_statu(message::eWaiting);
|
|
|
-
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->CopyFrom(alloc_step);
|
|
|
- m_storing_process_statu_msg.mutable_measure_step()->CopyFrom(measure_step);
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->CopyFrom(store_step);
|
|
|
- m_storing_process_statu_msg.mutable_confirm_space_step()->CopyFrom(confirm_step);
|
|
|
- m_storing_process_statu_msg.mutable_failed_release_space_step()->CopyFrom(release_step);
|
|
|
- m_storing_process_statu_msg.set_license(m_car_info.license());
|
|
|
- m_storing_process_statu_msg.set_terminal_id(m_terminor_id);
|
|
|
-
|
|
|
-
|
|
|
+ //reset 调度请求数据
|
|
|
+ m_dispatch_request_msg=message::Dispatch_request_msg();
|
|
|
+ m_dispatch_response_msg=message::Dispatch_response_msg();
|
|
|
+ return SUCCESS;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -175,21 +155,12 @@ void StoreProcessTask::reset_process_statu()
|
|
|
*/
|
|
|
Error_manager StoreProcessTask::alloc_space()
|
|
|
{
|
|
|
- //更新车位分配步骤状态
|
|
|
- {
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->mutable_car_info()->CopyFrom(m_car_info);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eWorking);
|
|
|
- }
|
|
|
|
|
|
/*
|
|
|
* 检查是否有测量数据
|
|
|
*/
|
|
|
if(m_locate_info.has_locate_height()==false||m_locate_info.has_locate_width()==false)
|
|
|
{
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_description("停车请求缺少车辆高度和宽度信息");
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
|
|
|
}
|
|
|
/*
|
|
@@ -198,33 +169,26 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_description(code.get_error_description());
|
|
|
return code;
|
|
|
}
|
|
|
|
|
|
//发送分配请求
|
|
|
- message::Parkspace_allocation_request_msg request;
|
|
|
message::Base_info base_info;
|
|
|
base_info.set_msg_type(message::eParkspace_allocation_request_msg);
|
|
|
base_info.set_sender(message::eMain);
|
|
|
base_info.set_receiver(message::eParkspace);
|
|
|
base_info.set_timeout_ms(1000); //超时1s
|
|
|
- request.mutable_base_info()->CopyFrom(base_info);
|
|
|
+ m_alloc_request_msg.mutable_base_info()->CopyFrom(base_info);
|
|
|
|
|
|
- request.mutable_car_info()->CopyFrom(m_car_info);
|
|
|
+ m_alloc_request_msg.mutable_car_info()->CopyFrom(m_car_info);
|
|
|
|
|
|
- request.set_command_key(create_key());
|
|
|
- request.set_terminal_id(m_terminor_id);
|
|
|
+ m_alloc_request_msg.set_command_key(create_key());
|
|
|
+ m_alloc_request_msg.set_terminal_id(m_terminor_id);
|
|
|
|
|
|
- code=Parkspace_communicator::get_instance_pointer()->alloc_request(request,m_parcspace_alloc_response_msg);
|
|
|
+ code=Parkspace_communicator::get_instance_pointer()->alloc_request(m_alloc_request_msg,m_parcspace_alloc_response_msg);
|
|
|
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_description(code.get_error_description());
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -233,18 +197,14 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
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())
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_description("分配车位反馈的车辆信息不匹配");
|
|
|
return Error_manager(ERROR,MINOR_ERROR,"分配车位反馈的车辆信息不匹配");
|
|
|
}
|
|
|
-
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eComplete);
|
|
|
+ //置步骤状态为测量状态.
|
|
|
+ m_step_statu=eMeasure_step;
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_alloc_space_step()->set_description("分配车位反馈结果错误");
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"分配车位反馈结果错误");
|
|
|
}
|
|
|
}
|
|
@@ -296,10 +256,11 @@ Error_manager StoreProcessTask::confirm_space_step()
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"parkspace confirm response error_code error");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/*
|
|
|
- * 车位解锁,当停车失败时需要车位解锁
|
|
|
+ * 回退车位分配
|
|
|
*/
|
|
|
-Error_manager StoreProcessTask::release_space_step()
|
|
|
+Error_manager StoreProcessTask::back_alloc_space_step()
|
|
|
{
|
|
|
/*
|
|
|
* 检查是否曾经分配过车位
|
|
@@ -326,10 +287,8 @@ Error_manager StoreProcessTask::release_space_step()
|
|
|
|
|
|
message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
|
|
|
request.mutable_release_space_info()->CopyFrom(space_info);
|
|
|
-
|
|
|
request.set_command_key(create_key());
|
|
|
|
|
|
-
|
|
|
message::Parkspace_release_response_msg release_response;
|
|
|
code=Parkspace_communicator::get_instance_pointer()->release_request(request,release_response);
|
|
|
if(code!=SUCCESS)
|
|
@@ -341,6 +300,9 @@ Error_manager StoreProcessTask::release_space_step()
|
|
|
<<", 车位楼层:"<<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
|
|
@@ -355,124 +317,105 @@ void StoreProcessTask::Main()
|
|
|
Error_manager code;
|
|
|
//开始执行停车指令
|
|
|
//第一步测量
|
|
|
- switch (0)
|
|
|
+ while(1)
|
|
|
{
|
|
|
//第一步,测量
|
|
|
- case 0:
|
|
|
+ if (m_step_statu == eMeasure_step)
|
|
|
{
|
|
|
- //更新状态信息
|
|
|
- {
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_measure_step()->set_step_statu(message::eWorking);
|
|
|
- }
|
|
|
//开始定位
|
|
|
- code=locate_step();
|
|
|
- usleep(1000*1000*(rand()%5+1));
|
|
|
+ code = locate_step();
|
|
|
+ usleep(1000 * 1000 * (rand() % 5 + 1));
|
|
|
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- if(code!=SUCCESS)
|
|
|
- {
|
|
|
- //更新进度状态
|
|
|
- m_storing_process_statu_msg.mutable_measure_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_measure_step()->set_description(code.get_error_description());
|
|
|
- LOG(ERROR)<<"测量失败:"<<code.get_error_description();
|
|
|
- break;
|
|
|
- }
|
|
|
- //更新状态信息
|
|
|
- m_storing_process_statu_msg.mutable_measure_step()->mutable_locate_info()->CopyFrom(m_measure_response_msg.locate_information());
|
|
|
- m_storing_process_statu_msg.mutable_measure_step()->set_step_statu(message::eComplete);
|
|
|
+ LOG_IF(ERROR, code != SUCCESS) << "测量失败:" << code.get_error_description();
|
|
|
+ m_step_statu = (code != SUCCESS) ? eBackMeasure_step : eDispatch_step;
|
|
|
}
|
|
|
//第二步,调度
|
|
|
- case 1:
|
|
|
+ if (m_step_statu == eDispatch_step)
|
|
|
{
|
|
|
- //更新状态信息
|
|
|
- {
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eWorking);
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->mutable_locate_info()->CopyFrom(
|
|
|
- m_measure_response_msg.locate_information());
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->mutable_space_info()->CopyFrom(
|
|
|
- m_parcspace_alloc_response_msg.allocated_space_info());
|
|
|
- }
|
|
|
//开始调度
|
|
|
- code=dispatch_step();
|
|
|
- usleep(1000*1000*(rand()%3));
|
|
|
+ code = dispatch_step();
|
|
|
+ usleep(1000 * 1000 * (rand() % 3));
|
|
|
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
+ LOG_IF(ERROR, code != SUCCESS) << "调度失败:" << code.get_error_description();
|
|
|
+ m_step_statu = (code != SUCCESS) ? eBackDispatch_step : eConfirm_step;
|
|
|
+ }
|
|
|
+ //第三步,占据车位
|
|
|
+ if (m_step_statu == eConfirm_step)
|
|
|
+ {
|
|
|
+ code = confirm_space_step();
|
|
|
+ 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();
|
|
|
+ m_step_statu = (code != SUCCESS) ? eBackConfirm_step : eComplete;
|
|
|
+ }
|
|
|
+ //第四步,完成,退出循环
|
|
|
+ if (m_step_statu == eComplete)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //回退confirm ------------------------------------华丽的分割线------------------------------------------
|
|
|
+ if (m_step_statu == eBackConfirm_step)
|
|
|
+ {
|
|
|
+ m_step_statu=eBackDispatch_step;
|
|
|
+ }
|
|
|
+ if(m_step_statu==eBackDispatch_step)
|
|
|
+ {
|
|
|
+ code=back_dispatch_step();
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->set_description(code.get_error_description());
|
|
|
- LOG(ERROR)<<"调度失败:"<<code.get_error_description();
|
|
|
- break;
|
|
|
+ //提升错误等级为四级
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_step_statu=eBackMeasure_step;
|
|
|
}
|
|
|
- //更新状态信息
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eComplete);
|
|
|
}
|
|
|
- //第三步,占据车位
|
|
|
- case 2:
|
|
|
+ if(m_step_statu==eBackMeasure_step)
|
|
|
{
|
|
|
- //更新状态信息
|
|
|
+ code=back_locate_step();
|
|
|
+ if(code!=SUCCESS)
|
|
|
{
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_confirm_space_step()->set_step_statu(message::eWorking);
|
|
|
- m_storing_process_statu_msg.mutable_confirm_space_step()->mutable_space_info()->CopyFrom(
|
|
|
- m_parcspace_alloc_response_msg.allocated_space_info());
|
|
|
+ //提升错误等级为四级
|
|
|
}
|
|
|
- //开始工作
|
|
|
- code=confirm_space_step();
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- if(code!=SUCCESS)
|
|
|
+ else
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_confirm_space_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_confirm_space_step()->set_description(code.get_error_description());
|
|
|
- LOG(ERROR)<<",终端号:"<<m_terminor_id<<"停车流程:"<<code.get_error_description()<<
|
|
|
- " 车位id :"<<m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()
|
|
|
- <<",车牌:"<<m_car_info.license();
|
|
|
- break;
|
|
|
+ m_step_statu=eBackAlloc_step;
|
|
|
}
|
|
|
- //更新状态信息
|
|
|
- m_storing_process_statu_msg.mutable_confirm_space_step()->set_step_statu(message::eComplete);
|
|
|
}
|
|
|
- //第四步,打印... 日志 .... 记录.....
|
|
|
- case 3:
|
|
|
+ if(m_step_statu==eBackAlloc_step)
|
|
|
{
|
|
|
- LOG(INFO)<<"停车成功,停车终端:"<<m_terminor_id
|
|
|
- <<", 车位id:"<<m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()
|
|
|
- <<", 车牌号:"<<m_car_info.license()<<"**********************";
|
|
|
-
|
|
|
- return ;
|
|
|
+ code=back_alloc_space_step();
|
|
|
+ if(code!=SUCCESS)
|
|
|
+ {
|
|
|
+ //提升错误等级为四级
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_step_statu=eBackComplete;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * switch 语句break,说明停车故障,需清除车位
|
|
|
+ * 跳出循环后,判断状态,是否正常结束, 循环跳出状态只有可能是 eBackComplete(异常结束),eComplete(正常结束)
|
|
|
*/
|
|
|
-
|
|
|
- //失败,清理车位
|
|
|
- {
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eWorking);
|
|
|
- }
|
|
|
- code=release_space_step();
|
|
|
-
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- if(code!=SUCCESS)
|
|
|
+ if(m_step_statu==eBackComplete)
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eError);
|
|
|
- m_storing_process_statu_msg.mutable_failed_release_space_step()->set_description(code.get_error_description());
|
|
|
- LOG(ERROR)<<"致命故障,停车失败,清理车位故障:"<<code.get_error_description();
|
|
|
-
|
|
|
+ //异常结束
|
|
|
+ usleep(1000*10000);
|
|
|
+ LOG(ERROR)<<"异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
|
|
|
+ <<",xxxxxxxxxxxxxx 终端:"<<m_terminor_id<<" xxxxxxxxxxxxxx";
|
|
|
}
|
|
|
- else
|
|
|
+ if(m_step_statu==eComplete)
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eComplete);
|
|
|
+ //正常结束
|
|
|
+ usleep(1000*2000);
|
|
|
+ LOG(INFO)<<"停车结束,"<<"车牌号:"<<m_car_info.license()
|
|
|
+ <<",-------------- 终端:"<<m_terminor_id<<" --------------";
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * 流程异常,此处应暂停系统,待管理员介入
|
|
|
- */
|
|
|
- usleep(1000*2000);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -495,10 +438,10 @@ void StoreProcessTask::publish_step_status()
|
|
|
*/
|
|
|
if(System_communicator::get_instance_pointer())
|
|
|
{
|
|
|
- if(m_storing_process_statu_msg.has_base_info()==true)
|
|
|
+ message::Storing_process_statu_msg msg;
|
|
|
+ if(create_step_statu_msg(msg)==SUCCESS)
|
|
|
{
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- System_communicator::get_instance_pointer()->post_entrance_statu(m_storing_process_statu_msg);
|
|
|
+ System_communicator::get_instance_pointer()->post_entrance_statu(msg);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -506,11 +449,113 @@ void StoreProcessTask::publish_step_status()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * 根据当前流程状态,生成状态消息
|
|
|
+ */
|
|
|
+Error_manager StoreProcessTask::create_step_statu_msg(message::Storing_process_statu_msg& msg)
|
|
|
+{
|
|
|
+ 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);
|
|
|
+ msg.mutable_base_info()->CopyFrom(base_info);
|
|
|
+ msg.set_terminal_id(m_terminor_id);
|
|
|
+ msg.set_license(m_car_info.license());
|
|
|
+
|
|
|
+ message::Alloc_space_step_statu alloc_step_statu;
|
|
|
+ message::Measure_step_statu measure_step_statu;
|
|
|
+ message::Dispatch_store_step_statu dispatch_step_statu;
|
|
|
+ message::Confirm_space_step_statu confirm_step_statu;
|
|
|
+ message::Release_space_step_statu release_step_statu;
|
|
|
+ alloc_step_statu.set_step_statu(message::eWaiting);
|
|
|
+ measure_step_statu.set_step_statu(message::eWaiting);
|
|
|
+ dispatch_step_statu.set_step_statu(message::eWaiting);
|
|
|
+ confirm_step_statu.set_step_statu(message::eWaiting);
|
|
|
+ release_step_statu.set_step_statu(message::eWaiting);
|
|
|
+
|
|
|
+ switch (m_step_statu) {
|
|
|
+ case eAlloc_step: {
|
|
|
+ alloc_step_statu.set_step_statu(message::eWorking);
|
|
|
+ if(m_step_statu==eAlloc_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eMeasure_step: {
|
|
|
+ alloc_step_statu.mutable_car_info()->CopyFrom(m_car_info);
|
|
|
+ alloc_step_statu.set_step_statu(message::eComplete);
|
|
|
+ measure_step_statu.set_step_statu(message::eWorking);
|
|
|
+ measure_step_statu.mutable_locate_info()->CopyFrom(m_locate_info);
|
|
|
+ if(m_step_statu==eMeasure_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eDispatch_step: {
|
|
|
+ measure_step_statu.set_step_statu(message::eComplete);
|
|
|
+ dispatch_step_statu.set_step_statu(message::eWorking);
|
|
|
+ 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());
|
|
|
+ if(m_step_statu==eDispatch_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eConfirm_step: {
|
|
|
+ dispatch_step_statu.set_step_statu(message::eComplete);
|
|
|
+ confirm_step_statu.set_step_statu(message::eWorking);
|
|
|
+ confirm_step_statu.mutable_space_info()->CopyFrom(
|
|
|
+ m_parcspace_alloc_response_msg.allocated_space_info());
|
|
|
+ if(m_step_statu==eConfirm_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eComplete: {
|
|
|
+ confirm_step_statu.set_step_statu(message::eComplete);
|
|
|
+ if(m_step_statu==eComplete)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eBackConfirm_step: {
|
|
|
+ confirm_step_statu.set_step_statu(message::eError);
|
|
|
+ if(m_step_statu==eBackConfirm_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eBackDispatch_step: {
|
|
|
+ dispatch_step_statu.set_step_statu(message::eError);
|
|
|
+ if(m_step_statu==eBackDispatch_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eBackMeasure_step: {
|
|
|
+ measure_step_statu.set_step_statu(message::eError);
|
|
|
+ if(m_step_statu==eBackMeasure_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eBackAlloc_step: {
|
|
|
+ alloc_step_statu.set_step_statu(message::eError);
|
|
|
+ release_step_statu.set_step_statu(message::eWorking);
|
|
|
+ if(m_step_statu==eBackAlloc_step)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case eBackComplete: {
|
|
|
+ release_step_statu.set_step_statu(message::eComplete);
|
|
|
+ if(m_step_statu==eBackComplete)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ msg.mutable_alloc_space_step()->CopyFrom(alloc_step_statu);
|
|
|
+ msg.mutable_measure_step()->CopyFrom(measure_step_statu);
|
|
|
+ msg.mutable_dispatch_step()->CopyFrom(dispatch_step_statu);
|
|
|
+ msg.mutable_confirm_space_step()->CopyFrom(confirm_step_statu);
|
|
|
+ msg.mutable_failed_release_space_step()->CopyFrom(release_step_statu);
|
|
|
+
|
|
|
+ return SUCCESS;
|
|
|
+}
|
|
|
|
|
|
/*
|
|
|
* 初始化 接收到的消息
|
|
|
*/
|
|
|
-void StoreProcessTask::reset_recv_msg() {
|
|
|
+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_locate_info = message::Locate_information();
|
|
|
m_measure_response_msg = message::Measure_response_msg(); //测量模块的测量数据
|
|
|
m_parcspace_alloc_response_msg = message::Parkspace_allocation_response_msg(); //分配的车位数据
|