|
@@ -9,34 +9,17 @@
|
|
|
#include "process_message.pb.h"
|
|
|
#include "command_manager.h"
|
|
|
#include "system_communicator.h"
|
|
|
+#include "uniq_key.h"
|
|
|
|
|
|
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()
|
|
|
{
|
|
|
- //退出线程
|
|
|
- m_publish_exit_condition.set_pass_ever(true);
|
|
|
- if(m_publish_statu_thread!= nullptr)
|
|
|
- {
|
|
|
- if(m_publish_statu_thread->joinable())
|
|
|
- {
|
|
|
- m_publish_statu_thread->join();
|
|
|
- }
|
|
|
- delete m_publish_statu_thread;
|
|
|
- m_publish_statu_thread=nullptr;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
Error_manager StoreProcessTask::init_task(message::Command_info command_info,
|
|
@@ -48,13 +31,6 @@ Error_manager StoreProcessTask::init_task(message::Command_info command_info,
|
|
|
m_car_info=car_info;
|
|
|
m_locate_info=locate_info;
|
|
|
|
|
|
- ///创建状态发布线程
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
if(is_ready()) {
|
|
|
reset_process_statu();
|
|
|
return SUCCESS;
|
|
@@ -127,6 +103,8 @@ Error_manager StoreProcessTask::dispatch_step()
|
|
|
request.mutable_base_info()->CopyFrom(base_info);
|
|
|
|
|
|
request.mutable_command_info()->CopyFrom(m_command_info);
|
|
|
+ std::string key=create_key();
|
|
|
+ request.mutable_command_info()->set_time(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());
|
|
@@ -163,11 +141,12 @@ void StoreProcessTask::reset_process_statu()
|
|
|
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.mutable_alloc_space_step()->CopyFrom(alloc_step);
|
|
|
+ m_storing_process_statu.mutable_measure_step()->CopyFrom(measure_step);
|
|
|
+ m_storing_process_statu.mutable_dispatch_step()->CopyFrom(store_step);
|
|
|
+ m_storing_process_statu.mutable_confirm_space_step()->CopyFrom(confirm_step);
|
|
|
+ m_storing_process_statu.mutable_failed_release_space_step()->CopyFrom(release_step);
|
|
|
+ m_storing_process_statu.set_license(m_car_info.license());
|
|
|
|
|
|
}
|
|
|
|
|
@@ -177,16 +156,16 @@ void StoreProcessTask::reset_process_statu()
|
|
|
bool StoreProcessTask::is_ready()
|
|
|
{
|
|
|
std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- bool cond_alloc_space = m_storing_process_statu_msg.alloc_space_step().step_statu()==message::eWaiting
|
|
|
- ||m_storing_process_statu_msg.alloc_space_step().step_statu()==message::eComplete;
|
|
|
- bool cond_measure = m_storing_process_statu_msg.measure_step().step_statu()==message::eWaiting
|
|
|
- ||m_storing_process_statu_msg.measure_step().step_statu()==message::eComplete;
|
|
|
- bool cond_dispatch = m_storing_process_statu_msg.dispatch_step().step_statu()==message::eWaiting
|
|
|
- ||m_storing_process_statu_msg.dispatch_step().step_statu()==message::eComplete;
|
|
|
- bool cond_confirm_space = m_storing_process_statu_msg.confirm_space_step().step_statu()==message::eWaiting
|
|
|
- ||m_storing_process_statu_msg.confirm_space_step().step_statu()==message::eComplete;
|
|
|
- bool cond_release_space = m_storing_process_statu_msg.failed_release_space_step().step_statu()==message::eWaiting
|
|
|
- ||m_storing_process_statu_msg.failed_release_space_step().step_statu()==message::eComplete;
|
|
|
+ bool cond_alloc_space = m_storing_process_statu.alloc_space_step().step_statu()==message::eWaiting
|
|
|
+ ||m_storing_process_statu.alloc_space_step().step_statu()==message::eComplete;
|
|
|
+ bool cond_measure = m_storing_process_statu.measure_step().step_statu()==message::eWaiting
|
|
|
+ ||m_storing_process_statu.measure_step().step_statu()==message::eComplete;
|
|
|
+ bool cond_dispatch = m_storing_process_statu.dispatch_step().step_statu()==message::eWaiting
|
|
|
+ ||m_storing_process_statu.dispatch_step().step_statu()==message::eComplete;
|
|
|
+ bool cond_confirm_space = m_storing_process_statu.confirm_space_step().step_statu()==message::eWaiting
|
|
|
+ ||m_storing_process_statu.confirm_space_step().step_statu()==message::eComplete;
|
|
|
+ bool cond_release_space = m_storing_process_statu.failed_release_space_step().step_statu()==message::eWaiting
|
|
|
+ ||m_storing_process_statu.failed_release_space_step().step_statu()==message::eComplete;
|
|
|
return cond_alloc_space && cond_measure && cond_dispatch && cond_confirm_space && cond_release_space;
|
|
|
}
|
|
|
|
|
@@ -198,8 +177,8 @@ 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);
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->mutable_car_info()->CopyFrom(m_car_info);
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eWorking);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -208,8 +187,8 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
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("停车请求缺少车辆高度和宽度信息");
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_description("停车请求缺少车辆高度和宽度信息");
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
|
|
|
}
|
|
|
/*
|
|
@@ -219,8 +198,8 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
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());
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_description(code.get_error_description());
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -243,8 +222,8 @@ Error_manager StoreProcessTask::alloc_space()
|
|
|
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());
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_description(code.get_error_description());
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -253,18 +232,18 @@ 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("分配车位反馈的车辆信息不匹配");
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.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_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eComplete);
|
|
|
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("分配车位反馈结果错误");
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.mutable_alloc_space_step()->set_description("分配车位反馈结果错误");
|
|
|
return Error_manager(FAILED,MINOR_ERROR,"分配车位反馈结果错误");
|
|
|
}
|
|
|
}
|
|
@@ -383,7 +362,7 @@ void StoreProcessTask::Main()
|
|
|
//更新状态信息
|
|
|
{
|
|
|
std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- m_storing_process_statu_msg.mutable_measure_step()->set_step_statu(message::eWorking);
|
|
|
+ m_storing_process_statu.mutable_measure_step()->set_step_statu(message::eWorking);
|
|
|
}
|
|
|
//开始定位
|
|
|
code=locate_step();
|
|
@@ -393,14 +372,14 @@ void StoreProcessTask::Main()
|
|
|
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());
|
|
|
+ m_storing_process_statu.mutable_measure_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.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);
|
|
|
+ m_storing_process_statu.mutable_measure_step()->mutable_locate_info()->CopyFrom(m_measure_response_msg.locate_information());
|
|
|
+ m_storing_process_statu.mutable_measure_step()->set_step_statu(message::eComplete);
|
|
|
}
|
|
|
//第二步,调度
|
|
|
case 1:
|
|
@@ -408,10 +387,10 @@ void StoreProcessTask::Main()
|
|
|
//更新状态信息
|
|
|
{
|
|
|
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_storing_process_statu.mutable_dispatch_step()->set_step_statu(message::eWorking);
|
|
|
+ m_storing_process_statu.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_storing_process_statu.mutable_dispatch_step()->mutable_space_info()->CopyFrom(
|
|
|
m_parcspace_alloc_response_msg.allocated_space_info());
|
|
|
}
|
|
|
//开始调度
|
|
@@ -421,13 +400,13 @@ void StoreProcessTask::Main()
|
|
|
std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
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());
|
|
|
+ m_storing_process_statu.mutable_dispatch_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.mutable_dispatch_step()->set_description(code.get_error_description());
|
|
|
LOG(ERROR)<<"调度失败:"<<code.get_error_description();
|
|
|
break;
|
|
|
}
|
|
|
//更新状态信息
|
|
|
- m_storing_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eComplete);
|
|
|
+ m_storing_process_statu.mutable_dispatch_step()->set_step_statu(message::eComplete);
|
|
|
}
|
|
|
//第三步,占据车位
|
|
|
case 2:
|
|
@@ -435,8 +414,8 @@ void StoreProcessTask::Main()
|
|
|
//更新状态信息
|
|
|
{
|
|
|
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_storing_process_statu.mutable_confirm_space_step()->set_step_statu(message::eWorking);
|
|
|
+ m_storing_process_statu.mutable_confirm_space_step()->mutable_space_info()->CopyFrom(
|
|
|
m_parcspace_alloc_response_msg.allocated_space_info());
|
|
|
}
|
|
|
//开始工作
|
|
@@ -444,15 +423,15 @@ void StoreProcessTask::Main()
|
|
|
std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
- 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());
|
|
|
+ m_storing_process_statu.mutable_confirm_space_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.mutable_confirm_space_step()->set_description(code.get_error_description());
|
|
|
LOG(ERROR)<<"指令:"<<m_command_info.place()<<",终端号:"<<m_terminor_id<<"停车流程:"<<code.get_error_description()<<
|
|
|
" 车位id :"<<m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()
|
|
|
<<",车牌:"<<m_car_info.license();
|
|
|
break;
|
|
|
}
|
|
|
//更新状态信息
|
|
|
- m_storing_process_statu_msg.mutable_confirm_space_step()->set_step_statu(message::eComplete);
|
|
|
+ m_storing_process_statu.mutable_confirm_space_step()->set_step_statu(message::eComplete);
|
|
|
}
|
|
|
//第四步,打印... 日志 .... 记录.....
|
|
|
case 3:
|
|
@@ -474,59 +453,27 @@ void StoreProcessTask::Main()
|
|
|
//失败,清理车位
|
|
|
{
|
|
|
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);
|
|
|
+ m_storing_process_statu.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)
|
|
|
{
|
|
|
- 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());
|
|
|
+ m_storing_process_statu.mutable_failed_release_space_step()->set_step_statu(message::eError);
|
|
|
+ m_storing_process_statu.mutable_failed_release_space_step()->set_description(code.get_error_description());
|
|
|
LOG(ERROR)<<"致命故障,停车失败,清理车位故障:"<<code.get_error_description();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eComplete);
|
|
|
+ m_storing_process_statu.mutable_failed_release_space_step()->set_step_statu(message::eComplete);
|
|
|
}
|
|
|
/*
|
|
|
* 流程异常,此处应暂停系统,待管理员介入
|
|
|
*/
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- * 发布状态线程
|
|
|
- */
|
|
|
-void StoreProcessTask::publish_thread_func(StoreProcessTask* ptask)
|
|
|
-{
|
|
|
- if(ptask)
|
|
|
- {
|
|
|
- ptask->publish_step_status();
|
|
|
- }
|
|
|
-}
|
|
|
-void StoreProcessTask::publish_step_status()
|
|
|
-{
|
|
|
- //未收到退出信号
|
|
|
- while(false==m_publish_exit_condition.wait_for_ex(std::chrono::milliseconds(50)))
|
|
|
- {
|
|
|
- /*
|
|
|
- * 通过communicator 发布状态
|
|
|
- */
|
|
|
- if(System_communicator::get_instance_pointer())
|
|
|
- {
|
|
|
- if(m_storing_process_statu_msg.has_base_info()==true)
|
|
|
- {
|
|
|
- std::lock_guard<std::mutex> lock(m_storing_statu_lock);
|
|
|
- System_communicator::get_instance_pointer()->post_entrance_statu(m_storing_process_statu_msg);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/*
|
|
|
* 初始化 接收到的消息
|
|
|
*/
|