Ver código fonte

修改各个模块通讯command 为唯一key,赋值在command_info.time

zx 4 anos atrás
pai
commit
0c463eeb89

+ 1 - 17
dispatch/dispatch_communicator.cpp

@@ -190,9 +190,8 @@ Error_manager Dispatch_communicator::execute_msg(Communication_message* p_msg)
         {
             message::Dispatch_response_msg response;
             response.ParseFromString(p_msg->get_message_buf());
-            message::Dispatch_request_msg request=create_request_by_response(response);
             ///查询请求表是否存在,并且更新
-            if(m_response_table.find_update(request.command_info().time(),response)==false)
+            if(m_response_table.find_update(response.command_info().time(),response)==false)
             {
                 return Error_manager(ERROR,NEGLIGIBLE_ERROR,"dispatch response without request");
             }
@@ -253,18 +252,3 @@ Error_manager Dispatch_communicator::check_executer(Communication_message* p_msg
 {
     return SUCCESS;
 }
-
-/*
- * 根据接收到的response,生成对应的 request
- */
-message::Dispatch_request_msg Dispatch_communicator::create_request_by_response(message::Dispatch_response_msg& response)
-{
-    message::Dispatch_request_msg request;
-    message::Base_info baseInfo;
-    baseInfo.set_msg_type(message::eDispatch_request_msg);
-    baseInfo.set_sender(response.base_info().receiver());
-    baseInfo.set_receiver(response.base_info().sender());
-    request.mutable_base_info()->CopyFrom(baseInfo);
-    request.mutable_command_info()->CopyFrom(response.command_info());
-    return request;
-}

+ 1 - 4
dispatch/dispatch_communicator.h

@@ -48,10 +48,7 @@ protected:
     //检查消息是否可以被解析, 需要重载
     virtual Error_manager check_executer(Communication_message* p_msg);
 
-    /*
-     * 根据接收到的response,生成对应的 request
-     */
-    message::Dispatch_request_msg create_request_by_response(message::Dispatch_response_msg& msg);
+
 
 private:
     thread_safe_map<std::string,message::Dispatch_response_msg>          m_response_table;

+ 9 - 22
lidar_locate/Locate_communicator.cpp

@@ -21,12 +21,12 @@ Error_manager Locate_communicator::encapsulate_msg(Communication_message* messag
         {
             message::Measure_request_msg request;
             request.ParseFromString(message->get_message_buf());
-            m_response_table[request]=message::Measure_response_msg();
+            m_response_table[request.command_info().time()]=message::Measure_response_msg();
             //发送请求
             code= Communication_socket_base::encapsulate_msg(message);
             if(code!=SUCCESS)
             {
-                m_response_table.erase(request);
+                m_response_table.erase(request.command_info().time());
             }
             break;
         }
@@ -47,7 +47,7 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
     if(request.base_info().sender()!=message::eMain||request.base_info().receiver()!=message::eMeasurer)
         return Error_manager(LOCATER_MSG_REQUEST_INVALID,MINOR_ERROR,"measure request invalid");
 
-    if(m_response_table.find(request)==true)
+    if(m_response_table.find(request.command_info().time())==true)
         return Error_manager(LOCATER_MSG_REQUEST_REPEATED,MAJOR_ERROR," measure reques repeated");
     //设置超时,若没有设置,默认3000
     int timeout=request.base_info().has_timeout_ms()?request.base_info().timeout_ms():3000;
@@ -73,7 +73,7 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
         //查询到记录
         message::Measure_response_msg response;
         ///查询是否存在,并且删除该记录,
-        if(m_response_table.find(request,response))
+        if(m_response_table.find(request.command_info().time(),response))
         {
             //判断是否接收到回应,若回应信息被赋值则证明有回应
             if (response.has_base_info() && response.has_command_info())
@@ -92,7 +92,7 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
                                          "measure response msg info error");
                 }
                 result = response;
-                m_response_table.erase(request);
+                m_response_table.erase(request.command_info().time());
 
                 return SUCCESS;
 
@@ -110,7 +110,7 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
         std::this_thread::yield();
         usleep(1000);
     }while(time<double(timeout));
-    m_response_table.erase(request);
+    m_response_table.erase(request.command_info().time());
     return Error_manager(RESPONSE_TIMEOUT,MINOR_ERROR,"measure request timeout");
 }
 
@@ -183,9 +183,8 @@ Error_manager Locate_communicator::execute_msg(Communication_message* p_msg)
         {
             message::Measure_response_msg response;
             response.ParseFromString(p_msg->get_message_buf());
-            message::Measure_request_msg request=create_request_by_response(response);
             ///查询请求表是否存在,并且更新
-            if(m_response_table.find_update(request,response)==false)
+            if(m_response_table.find_update(response.command_info().time(),response)==false)
             {
                 return Error_manager(LOCATER_MSG_RESPONSE_HAS_NO_REQUEST,NEGLIGIBLE_ERROR,"measure response without request");
             }
@@ -209,21 +208,9 @@ Error_manager Locate_communicator::execute_msg(Communication_message* p_msg)
 
 Error_manager Locate_communicator::cancel_request(message::Measure_request_msg& request)
 {
-    if(m_response_table.find(request)==true)
-        m_response_table.erase(request);
+    if(m_response_table.find(request.command_info().time())==true)
+        m_response_table.erase(request.command_info().time());
     return SUCCESS;
 }
 
-message::Measure_request_msg Locate_communicator::create_request_by_response(message::Measure_response_msg& response)
-{
-    message::Measure_request_msg request;
-    message::Base_info baseInfo;
-    baseInfo.set_msg_type(message::eLocate_request_msg);
-    baseInfo.set_sender(response.base_info().receiver());
-    baseInfo.set_receiver(response.base_info().sender());
-    request.mutable_base_info()->CopyFrom(baseInfo);
-    request.mutable_command_info()->CopyFrom(response.command_info());
-    request.set_terminal_id(response.terminal_id());
-    return request;
-}
 

+ 1 - 6
lidar_locate/Locate_communicator.h

@@ -51,15 +51,10 @@ protected:
     //检查消息是否可以被解析, 需要重载
     virtual Error_manager check_executer(Communication_message* p_msg);
 
-    /*
-     * 根据接收到的response,生成对应的 request
-     */
-    message::Measure_request_msg create_request_by_response(message::Measure_response_msg& msg);
 
 protected:
 
-    thread_safe_map<message::Measure_request_msg,message::Measure_response_msg>          m_response_table;
-
+    thread_safe_map<std::string,message::Measure_response_msg>                                  m_response_table;
 
     thread_safe_map<int ,message::Measure_status_msg >                                          m_measure_statu_msg_map;
     thread_safe_map<int ,std::chrono::system_clock::time_point>		                            m_statu_recv_time_map;

+ 29 - 89
parkspace/Parkspace_communicator.cpp

@@ -17,7 +17,7 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
     if(request.base_info().sender()!=message::eMain||request.base_info().receiver()!=message::eParkspace)
         return Error_manager(PARKSPACE_ALLOC_REQUEST_INVALID,MINOR_ERROR,"车位分配请求信息错误!!!");
 
-    if(m_alloc_table.find(request)==true)
+    if(m_alloc_table.find(request.command_info().time())==true)
         return Error_manager(PARKSPACE_ALLOC_REQUEST_REPEATED,MINOR_ERROR,"车位分配请求已经存在,重复!!!");
     //设置超时,若没有设置,默认1000
     int timeout=request.base_info().has_timeout_ms()?request.base_info().timeout_ms():1000;
@@ -43,7 +43,7 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
         //查询到记录
         message::Parkspace_allocation_response_msg response;
         ///查询是否存在,并且删除该记录,
-        if(m_alloc_table.find(request,response))
+        if(m_alloc_table.find(request.command_info().time(),response))
         {
             //判断是否接收到回应,若回应信息被赋值则证明有回应
             if (response.has_base_info() && response.has_command_info())
@@ -62,7 +62,7 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
                                          "parkspace alloc response msg info error");
                 }
                 result = response;
-                m_alloc_table.erase(request);
+                m_alloc_table.erase(request.command_info().time());
 
                 return SUCCESS;
 
@@ -81,7 +81,7 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
         usleep(1000);
     }while(time<double(timeout));
     //超时,删除记录,返回错误
-    m_alloc_table.erase(request);
+    m_alloc_table.erase(request.command_info().time());
     return Error_manager(RESPONSE_TIMEOUT,MINOR_ERROR,"parkspace alloc request timeout");
 
 }
@@ -98,7 +98,7 @@ Error_manager Parkspace_communicator::search_request(message::Parkspace_search_r
     if(request.base_info().sender()!=message::eMain||request.base_info().receiver()!=message::eParkspace)
         return Error_manager(PARKSPACE_SEARCH_REQUEST_INVALID,MINOR_ERROR,"parkspace search request invalid");
 
-    if(m_search_table.find(request)==true)
+    if(m_search_table.find(request.command_info().time())==true)
         return Error_manager(PARKSPACE_SEARCH_REQUEST_REPEATED,MAJOR_ERROR," parkspace search request repeated");
     //设置超时,若没有设置,默认1000
     int timeout=request.base_info().has_timeout_ms()?request.base_info().timeout_ms():1000;
@@ -124,7 +124,7 @@ Error_manager Parkspace_communicator::search_request(message::Parkspace_search_r
         //查询到记录
         message::Parkspace_search_response_msg response;
         ///查询是否存在,并且删除该记录,
-        if(m_search_table.find(request,response))
+        if(m_search_table.find(request.command_info().time(),response))
         {
             //判断是否接收到回应,若回应信息被赋值则证明有回应
             if (response.has_base_info() && response.has_command_info())
@@ -143,7 +143,7 @@ Error_manager Parkspace_communicator::search_request(message::Parkspace_search_r
                                          "parkspace search response msg info error");
                 }
                 result = response;
-                m_search_table.erase(request);
+                m_search_table.erase(request.command_info().time());
                 if(response.has_error_manager())
                 {
                     if(response.error_manager().error_code()==0)
@@ -166,7 +166,7 @@ Error_manager Parkspace_communicator::search_request(message::Parkspace_search_r
         usleep(1000);
     }while(time<double(timeout));
     //超时,删除记录,返回错误
-    m_search_table.erase(request);
+    m_search_table.erase(request.command_info().time());
     return Error_manager(RESPONSE_TIMEOUT,MINOR_ERROR,"parkspace search request timeout");
 }
 
@@ -182,7 +182,7 @@ Error_manager Parkspace_communicator::release_request(message::Parkspace_release
     if(request.base_info().sender()!=message::eMain||request.base_info().receiver()!=message::eParkspace)
         return Error_manager(PARKSPACE_RELEASE_REQUEST_INVALID,MINOR_ERROR,"parkspace release request invalid");
 
-    if(m_release_table.find(request)==true)
+    if(m_release_table.find(request.command_info().time())==true)
         return Error_manager(PARKSPACE_RELEASE_REQUEST_REPEATED,MAJOR_ERROR," parkspace release request repeated");
     //设置超时,若没有设置,默认1000
     int timeout=request.base_info().has_timeout_ms()?request.base_info().timeout_ms():1000;
@@ -208,7 +208,7 @@ Error_manager Parkspace_communicator::release_request(message::Parkspace_release
         //查询到记录
         message::Parkspace_release_response_msg response;
         ///查询是否存在,并且删除该记录,
-        if(m_release_table.find(request,response))
+        if(m_release_table.find(request.command_info().time(),response))
         {
             //判断是否接收到回应,若回应信息被赋值则证明有回应
             if (response.has_base_info() && response.has_command_info())
@@ -227,7 +227,7 @@ Error_manager Parkspace_communicator::release_request(message::Parkspace_release
                                          "parkspace release response msg info error");
                 }
                 result = response;
-                m_release_table.erase(request);
+                m_release_table.erase(request.command_info().time());
 
                 return SUCCESS;
 
@@ -246,7 +246,7 @@ Error_manager Parkspace_communicator::release_request(message::Parkspace_release
         usleep(1000);
     }while(time<double(timeout));
     //超时,删除记录,返回错误
-    m_release_table.erase(request);
+    m_release_table.erase(request.command_info().time());
     return Error_manager(RESPONSE_TIMEOUT,MINOR_ERROR,"parkspace release request timeout");
 }
 
@@ -263,7 +263,7 @@ Error_manager Parkspace_communicator::confirm_request(message::Parkspace_confirm
         return Error_manager(FAILED,MINOR_ERROR,"parkspace confirm request invalid");
 
 
-    if(m_confirm_table.find(request)==true)
+    if(m_confirm_table.find(request.command_info().time())==true)
     {
         return Error_manager(FAILED,MAJOR_ERROR," parkspace confirm request repeated");
     }
@@ -285,7 +285,7 @@ Error_manager Parkspace_communicator::confirm_request(message::Parkspace_confirm
         //查询到记录
         message::Parkspace_confirm_alloc_response_msg response;
         ///查询是否存在,并且删除该记录,
-        if(m_confirm_table.find(request,response))
+        if(m_confirm_table.find(request.command_info().time(),response))
         {
             //判断是否接收到回应,若回应信息被赋值则证明有回应
             if (response.has_base_info() && response.has_command_info())
@@ -304,7 +304,7 @@ Error_manager Parkspace_communicator::confirm_request(message::Parkspace_confirm
                                          "parkspace confirm response msg info error");
                 }
                 result = response;
-                m_confirm_table.erase(request);
+                m_confirm_table.erase(request.command_info().time());
 
                 return SUCCESS;
 
@@ -323,7 +323,7 @@ Error_manager Parkspace_communicator::confirm_request(message::Parkspace_confirm
         usleep(1000);
     }while(time<double(timeout));
     //超时,删除记录,返回错误
-    m_confirm_table.erase(request);
+    m_confirm_table.erase(request.command_info().time());
     return Error_manager(RESPONSE_TIMEOUT,MINOR_ERROR,"parkspace confirm request timeout");
 }
 
@@ -355,12 +355,12 @@ Error_manager Parkspace_communicator::encapsulate_msg(Communication_message* mes
             message::Parkspace_allocation_request_msg request;
             request.ParseFromString(message->get_message_buf());
             //记录数据
-            m_alloc_table[request]=message::Parkspace_allocation_response_msg();
+            m_alloc_table[request.command_info().time()]=message::Parkspace_allocation_response_msg();
             //发送请求
             code= Communication_socket_base::encapsulate_msg(message);
             if(code!=SUCCESS)
             {
-                m_alloc_table.erase(request);
+                m_alloc_table.erase(request.command_info().time());
             }
             break;
         }
@@ -369,12 +369,12 @@ Error_manager Parkspace_communicator::encapsulate_msg(Communication_message* mes
             message::Parkspace_search_request_msg request;
             request.ParseFromString(message->get_message_buf());
             //记录数据
-            m_search_table[request]=message::Parkspace_search_response_msg();
+            m_search_table[request.command_info().time()]=message::Parkspace_search_response_msg();
             //发送请求
             code= Communication_socket_base::encapsulate_msg(message);
             if(code!=SUCCESS)
             {
-                m_search_table.erase(request);
+                m_search_table.erase(request.command_info().time());
             }
             break;
         }
@@ -383,12 +383,12 @@ Error_manager Parkspace_communicator::encapsulate_msg(Communication_message* mes
             message::Parkspace_release_request_msg request;
             request.ParseFromString(message->get_message_buf());
             //记录数据
-            m_release_table[request]=message::Parkspace_release_response_msg();
+            m_release_table[request.command_info().time()]=message::Parkspace_release_response_msg();
             //发送请求
             code= Communication_socket_base::encapsulate_msg(message);
             if(code!=SUCCESS)
             {
-                m_release_table.erase(request);
+                m_release_table.erase(request.command_info().time());
             }
             break;
         }
@@ -398,12 +398,12 @@ Error_manager Parkspace_communicator::encapsulate_msg(Communication_message* mes
             request.ParseFromString(message->get_message_buf());
             //记录数据
             LOG(INFO)<<" Add  request :  "<<request.command_info().DebugString();
-            m_confirm_table[request]=message::Parkspace_confirm_alloc_response_msg();
+            m_confirm_table[request.command_info().time()]=message::Parkspace_confirm_alloc_response_msg();
             //发送请求
             code= Communication_socket_base::encapsulate_msg(message);
             if(code!=SUCCESS)
             {
-                m_confirm_table.erase(request);
+                m_confirm_table.erase(request.command_info().time());
             }
             break;
         }
@@ -427,9 +427,9 @@ Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
         {
             message::Parkspace_allocation_response_msg response;
             response.ParseFromString(p_msg->get_message_buf());
-            message::Parkspace_allocation_request_msg request=create_request_by_response(response);
+
             ///查询请求表是否存在,并且更新
-            if(m_alloc_table.find_update(request,response)==false)
+            if(m_alloc_table.find_update(response.command_info().time(),response)==false)
             {
                 return Error_manager(PARKSPACE_ALLOCMSG_RESPONSE_HAS_NO_REQUEST,NEGLIGIBLE_ERROR,"parkspace alloc response without request");
             }
@@ -443,9 +443,8 @@ Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
             {
                 return Error_manager(ERROR,CRITICAL_ERROR,"parkspace search response 解析失败");
             }
-            message::Parkspace_search_request_msg request=create_request_by_response(response);
             ///查询请求表是否存在,并且更新
-            if(m_search_table.find_update(request,response)==false)
+            if(m_search_table.find_update(response.command_info().time(),response)==false)
             {
                 return Error_manager(PARKSPACE_SEARCHMSG_RESPONSE_HAS_NO_REQUEST,NEGLIGIBLE_ERROR,"parkspace search response without request");
             }
@@ -455,9 +454,8 @@ Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
         {
             message::Parkspace_release_response_msg response;
             response.ParseFromString(p_msg->get_message_buf());
-            message::Parkspace_release_request_msg request=create_request_by_response(response);
             ///查询请求表是否存在,并且更新
-            if(m_release_table.find_update(request,response)==false)
+            if(m_release_table.find_update(response.command_info().time(),response)==false)
             {
                 return Error_manager(PARKSPACE_RELEASEMSG_RESPONSE_HAS_NO_REQUEST,NEGLIGIBLE_ERROR,"parkspace release response without request");
             }
@@ -468,9 +466,8 @@ Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
         {
             message::Parkspace_confirm_alloc_response_msg response;
             response.ParseFromString(p_msg->get_message_buf());
-            message::Parkspace_confirm_alloc_request_msg request=create_request_by_response(response);
             ///查询请求表是否存在,并且更新
-            if(m_confirm_table.find_update(request,response)==true)
+            if(m_confirm_table.find_update(response.command_info().time(),response)==true)
             {
                 return SUCCESS;
             }
@@ -526,60 +523,3 @@ Error_manager Parkspace_communicator::check_executer(Communication_message* p_ms
 {
     return SUCCESS;
 }
-
-/*
- * 根据接收到的response,生成对应的 request
- */
-message::Parkspace_allocation_request_msg
-Parkspace_communicator::create_request_by_response(message::Parkspace_allocation_response_msg& response)
-{
-    message::Parkspace_allocation_request_msg request;
-    message::Base_info baseInfo;
-    baseInfo.set_msg_type(message::eParkspace_allocation_request_msg);
-    baseInfo.set_sender(response.base_info().receiver());
-    baseInfo.set_receiver(response.base_info().sender());
-    request.mutable_base_info()->CopyFrom(baseInfo);
-    request.mutable_command_info()->CopyFrom(response.command_info());
-    return request;
-}
-
-message::Parkspace_search_request_msg
-Parkspace_communicator::create_request_by_response(message::Parkspace_search_response_msg& response)
-{
-    message::Parkspace_search_request_msg request;
-    message::Base_info baseInfo;
-    baseInfo.set_msg_type(message::eParkspace_search_request_msg);
-    baseInfo.set_sender(response.base_info().receiver());
-    baseInfo.set_receiver(response.base_info().sender());
-    request.mutable_base_info()->CopyFrom(baseInfo);
-    request.mutable_command_info()->CopyFrom(response.command_info());
-
-
-    return request;
-}
-
-message::Parkspace_release_request_msg
-Parkspace_communicator::create_request_by_response(message::Parkspace_release_response_msg& response)
-{
-    message::Parkspace_release_request_msg request;
-    message::Base_info baseInfo;
-    baseInfo.set_msg_type(message::eParkspace_release_request_msg);
-    baseInfo.set_sender(response.base_info().sender());
-    baseInfo.set_receiver(response.base_info().receiver());
-    request.mutable_base_info()->CopyFrom(baseInfo);
-    request.mutable_command_info()->CopyFrom(response.command_info());
-    return request;
-}
-
-message::Parkspace_confirm_alloc_request_msg
-Parkspace_communicator::create_request_by_response(message::Parkspace_confirm_alloc_response_msg& response)
-{
-    message::Parkspace_confirm_alloc_request_msg request;
-    message::Base_info baseInfo;
-    baseInfo.set_msg_type(message::eParkspace_confirm_alloc_request_msg);
-    baseInfo.set_sender(response.base_info().sender());
-    baseInfo.set_receiver(response.base_info().receiver());
-    request.mutable_base_info()->CopyFrom(baseInfo);
-    request.mutable_command_info()->CopyFrom(response.command_info());
-    return request;
-}

+ 4 - 12
parkspace/Parkspace_communicator.h

@@ -63,21 +63,13 @@ protected:
     //检查消息是否可以被解析, 需要重载
     virtual Error_manager check_executer(Communication_message* p_msg);
 
-    /*
-     * 根据接收到的response,生成对应的 request
-     */
-    message::Parkspace_allocation_request_msg create_request_by_response(message::Parkspace_allocation_response_msg& msg);
-    message::Parkspace_search_request_msg create_request_by_response(message::Parkspace_search_response_msg& msg);
-    message::Parkspace_release_request_msg create_request_by_response(message::Parkspace_release_response_msg& msg);
-    message::Parkspace_confirm_alloc_request_msg create_request_by_response(message::Parkspace_confirm_alloc_response_msg& msg);
-
 
 
 protected:
-    thread_safe_map<message::Parkspace_allocation_request_msg,message::Parkspace_allocation_response_msg>       m_alloc_table;
-    thread_safe_map<message::Parkspace_search_request_msg,message::Parkspace_search_response_msg>               m_search_table;
-    thread_safe_map<message::Parkspace_release_request_msg,message::Parkspace_release_response_msg>             m_release_table;
-    thread_safe_map<message::Parkspace_confirm_alloc_request_msg,message::Parkspace_confirm_alloc_response_msg>     m_confirm_table;
+    thread_safe_map<std::string,message::Parkspace_allocation_response_msg>         m_alloc_table;
+    thread_safe_map<std::string,message::Parkspace_search_response_msg>              m_search_table;
+    thread_safe_map<std::string,message::Parkspace_release_response_msg>             m_release_table;
+    thread_safe_map<std::string,message::Parkspace_confirm_alloc_response_msg>      m_confirm_table;
 
     message::Parkspace_allocation_status_msg                                                                    m_parkspace_status_msg;
     std::chrono::system_clock::time_point                                                                       m_parkspace_statu_time;

+ 4 - 0
system/PickupProcessTask.cpp

@@ -8,6 +8,7 @@
 #include "process_message.pb.h"
 #include "command_manager.h"
 #include "system_communicator.h"
+#include "uniq_key.h"
 
 PickupProcessTask::PickupProcessTask(unsigned int terminal_id)
 {
@@ -121,6 +122,7 @@ Error_manager PickupProcessTask::search_space()
 
     message::Parkspace_search_request_msg request;
     request.mutable_command_info()->CopyFrom(m_command_info);
+    request.mutable_command_info()->set_time(create_key());
     request.mutable_base_info()->CopyFrom(base_info);
     request.mutable_car_info()->CopyFrom(m_car_info);
 
@@ -253,6 +255,7 @@ Error_manager PickupProcessTask::pickup_step()
     request.set_parkspace_id(space_info.parkspace_id());
     request.set_terminal_id(m_terminor_id);
     request.mutable_command_info()->CopyFrom(m_command_info);
+    request.mutable_command_info()->set_time(create_key());
 
 
     message::Dispatch_response_msg response;
@@ -307,6 +310,7 @@ Error_manager PickupProcessTask::release_space_step()
     request.mutable_release_space_info()->CopyFrom(space_info);
 
     request.mutable_command_info()->CopyFrom(m_command_info);
+    request.mutable_command_info()->set_time(create_key());
 
 
     message::Parkspace_release_response_msg release_response;

+ 34 - 26
system/StoreProcessTask.cpp

@@ -20,6 +20,7 @@ StoreProcessTask::StoreProcessTask(unsigned int terminor_id)
 
 StoreProcessTask::~StoreProcessTask()
 {
+    Command_manager::get_instance_pointer()->erase_statu(m_storing_process_statu);
 }
 
 Error_manager StoreProcessTask::init_task(message::Command_info command_info,
@@ -31,14 +32,10 @@ Error_manager StoreProcessTask::init_task(message::Command_info command_info,
     m_car_info=car_info;
     m_locate_info=locate_info;
 
-    if(is_ready()) {
-        reset_process_statu();
-        return SUCCESS;
-    }
-    else
-    {
-        return Error_manager(ERROR,MINOR_ERROR,"终端未准备!!!");
-    }
+
+    reset_process_statu();
+    return SUCCESS;
+
 }
 
 Error_manager StoreProcessTask::locate_step() {
@@ -57,6 +54,7 @@ Error_manager StoreProcessTask::locate_step() {
     request.mutable_base_info()->CopyFrom(base_info);
 
     request.mutable_command_info()->CopyFrom(m_command_info);
+    request.mutable_command_info()->set_time(create_key());
     request.set_terminal_id(m_terminor_id);
 
     code=Locate_communicator::get_instance_pointer()->locate_request(request,m_measure_response_msg);
@@ -147,26 +145,11 @@ void StoreProcessTask::reset_process_statu()
     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());
+    m_storing_process_statu.set_terminal_id(m_terminor_id);
 
-}
 
-/*
-     * 检查当前任务是否处于空闲准备状态
-     */
-bool StoreProcessTask::is_ready()
-{
-    std::lock_guard<std::mutex> lock(m_storing_statu_lock);
-    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;
+    Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
+
 }
 
 /*
@@ -179,6 +162,7 @@ Error_manager StoreProcessTask::alloc_space()
         std::lock_guard<std::mutex> lock(m_storing_statu_lock);
         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);
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
     }
 
     /*
@@ -189,6 +173,7 @@ Error_manager StoreProcessTask::alloc_space()
         std::lock_guard<std::mutex> lock(m_storing_statu_lock);
         m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
         m_storing_process_statu.mutable_alloc_space_step()->set_description("停车请求缺少车辆高度和宽度信息");
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
     }
     /*
@@ -200,6 +185,7 @@ Error_manager StoreProcessTask::alloc_space()
         std::lock_guard<std::mutex> lock(m_storing_statu_lock);
         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());
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         return code;
     }
 
@@ -215,6 +201,7 @@ Error_manager StoreProcessTask::alloc_space()
     request.mutable_car_info()->CopyFrom(m_car_info);
 
     request.mutable_command_info()->CopyFrom(m_command_info);
+    request.mutable_command_info()->set_time(create_key());
     request.set_terminal_id(m_terminor_id);
 
     code=Parkspace_communicator::get_instance_pointer()->alloc_request(request,m_parcspace_alloc_response_msg);
@@ -224,6 +211,7 @@ Error_manager StoreProcessTask::alloc_space()
     {
         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());
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         return code;
     }
 
@@ -234,16 +222,19 @@ Error_manager StoreProcessTask::alloc_space()
         {
             m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
             m_storing_process_statu.mutable_alloc_space_step()->set_description("分配车位反馈的车辆信息不匹配");
+            Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
             return Error_manager(ERROR,MINOR_ERROR,"分配车位反馈的车辆信息不匹配");
         }
 
         m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eComplete);
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         return SUCCESS;
     }
     else
     {
         m_storing_process_statu.mutable_alloc_space_step()->set_step_statu(message::eError);
         m_storing_process_statu.mutable_alloc_space_step()->set_description("分配车位反馈结果错误");
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         return Error_manager(FAILED,MINOR_ERROR,"分配车位反馈结果错误");
     }
 }
@@ -271,6 +262,7 @@ Error_manager StoreProcessTask::confirm_space_step()
     message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
     request.mutable_confirm_space_info()->CopyFrom(space_info);
     request.mutable_command_info()->CopyFrom(m_command_info);
+    request.mutable_command_info()->set_time(create_key());
 
     message::Parkspace_confirm_alloc_response_msg confirm_response;
     code=Parkspace_communicator::get_instance_pointer()->confirm_request(request,confirm_response);
@@ -327,6 +319,7 @@ Error_manager StoreProcessTask::release_space_step()
     request.mutable_release_space_info()->CopyFrom(space_info);
 
     request.mutable_command_info()->CopyFrom(m_command_info);
+    request.mutable_command_info()->set_time(create_key());
 
 
     message::Parkspace_release_response_msg release_response;
@@ -363,6 +356,7 @@ void StoreProcessTask::Main()
             {
                 std::lock_guard<std::mutex> lock(m_storing_statu_lock);
                 m_storing_process_statu.mutable_measure_step()->set_step_statu(message::eWorking);
+                Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
             }
             //开始定位
             code=locate_step();
@@ -374,12 +368,14 @@ void StoreProcessTask::Main()
                 //更新进度状态
                 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());
+                Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
                 LOG(ERROR)<<"测量失败:"<<code.get_error_description();
                 break;
             }
             //更新状态信息
             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);
+            Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         }
         //第二步,调度
         case 1:
@@ -392,6 +388,7 @@ void StoreProcessTask::Main()
                         m_measure_response_msg.locate_information());
                 m_storing_process_statu.mutable_dispatch_step()->mutable_space_info()->CopyFrom(
                         m_parcspace_alloc_response_msg.allocated_space_info());
+                Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
             }
             //开始调度
             code=dispatch_step();
@@ -402,11 +399,13 @@ void StoreProcessTask::Main()
             {
                 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());
+                Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
                 LOG(ERROR)<<"调度失败:"<<code.get_error_description();
                 break;
             }
             //更新状态信息
             m_storing_process_statu.mutable_dispatch_step()->set_step_statu(message::eComplete);
+            Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         }
         //第三步,占据车位
         case 2:
@@ -417,6 +416,7 @@ void StoreProcessTask::Main()
                 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());
+                Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
             }
             //开始工作
             code=confirm_space_step();
@@ -425,6 +425,7 @@ void StoreProcessTask::Main()
             {
                 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());
+                Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
                 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();
@@ -432,6 +433,7 @@ void StoreProcessTask::Main()
             }
             //更新状态信息
             m_storing_process_statu.mutable_confirm_space_step()->set_step_statu(message::eComplete);
+            Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         }
         //第四步,打印...  日志 .... 记录.....
         case 3:
@@ -442,6 +444,8 @@ void StoreProcessTask::Main()
                      <<", 车位序号:"<<m_parcspace_alloc_response_msg.allocated_space_info().index()
                      <<", 车牌号:"<<m_car_info.license()
                      <<", 库内车牌号:"<<m_parcspace_alloc_response_msg.allocated_space_info().car_info().license();
+
+            usleep(1000*3000);
             return ;
         }
     }
@@ -454,6 +458,7 @@ void StoreProcessTask::Main()
     {
         std::lock_guard<std::mutex> lock(m_storing_statu_lock);
         m_storing_process_statu.mutable_failed_release_space_step()->set_step_statu(message::eWorking);
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
     }
     code=release_space_step();
 
@@ -462,13 +467,16 @@ void StoreProcessTask::Main()
     {
         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());
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
         LOG(ERROR)<<"致命故障,停车失败,清理车位故障:"<<code.get_error_description();
 
     }
     else
     {
         m_storing_process_statu.mutable_failed_release_space_step()->set_step_statu(message::eComplete);
+        Command_manager::get_instance_pointer()->updata_statu(m_storing_process_statu);
     }
+    usleep(1000*1000*10);
     /*
     *   流程异常,此处应暂停系统,待管理员介入
     */

+ 0 - 5
system/StoreProcessTask.h

@@ -18,11 +18,6 @@ public:
     Error_manager init_task(message::Command_info command_info,
             message::Locate_information locate_info,message::Car_info car_info);
 
-    /*
-     * 检查当前任务是否处于空闲准备状态
-     */
-    bool is_ready();
-
     /*
      * 分配车位
      */

+ 2 - 0
system/command_manager.cpp

@@ -252,6 +252,8 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
                             return SUCCESS;
 
                         }
+                        usleep(1000*5000);
+                        delete pStore_task;
                         error_msg.set_error_code(code.get_error_code());
                         error_msg.set_error_description(code.to_string());
                         response.mutable_code()->CopyFrom(error_msg);

+ 1 - 36
test/terminal_client.cpp

@@ -112,43 +112,8 @@ int main() {
 
     while (c!='q') {
 
-        /*int k=rand()%4;
 
-        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::eTerminor);
-        msg.mutable_base_info()->CopyFrom(base_info);
-
-        message::Alloc_space_step_statu alloc_step;
-        alloc_step.set_step_statu(message::Step_statu(k));
-
-        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);
-
-        msg.mutable_alloc_space_step()->CopyFrom(alloc_step);
-        msg.mutable_measure_step()->CopyFrom(measure_step);
-        msg.mutable_dispatch_step()->CopyFrom(store_step);
-        msg.mutable_confirm_space_step()->CopyFrom(confirm_step);
-        msg.mutable_failed_release_space_step()->CopyFrom(release_step);
-
-        System_communicator::get_instance_pointer()->post_entrance_statu(msg);
-        usleep(1000*1000);*/
-
-
-
-
-        int license_id = rand() % 90000 + 20000;
+        int license_id = rand() % 90000 + 0000;
         char C=rand()%10+'A';
         char license[255] = {0};
         sprintf(license, "鄂%c%d",C, license_id);

+ 1 - 1
tool/TaskQueue/ThreadTaskQueue.cpp

@@ -257,7 +257,7 @@ namespace tq{
             _recyclerMutex.unlock();
         }
         //禁止析构
-        //delete task;
+        delete task;
 
     }