Browse Source

完成停车流程,取车出现完成后dump,未解决

zx 4 years ago
parent
commit
5087a8907b

+ 22 - 14
system/PickupProcessTask.cpp

@@ -15,7 +15,7 @@ PickupProcessTask::PickupProcessTask(unsigned int terminal_id)
     m_terminor_id=terminal_id;
 
     message::Base_info base_info;
-    base_info.set_msg_type(message::eStoring_process_statu_msg);
+    base_info.set_msg_type(message::ePicking_process_statu_msg);
     base_info.set_sender(message::eMain);
     base_info.set_receiver(message::eEmpty);
     m_picking_process_statu_msg.mutable_base_info()->CopyFrom(base_info);
@@ -38,15 +38,12 @@ PickupProcessTask::~PickupProcessTask()
 }
 Error_manager PickupProcessTask::init_task(message::Command_info command_info, message::Car_info car_info)
 {
+    reset_recv_msg();
+
     m_command_info=command_info;
     m_car_info=car_info;
 
-    message::Base_info base_info;
-    base_info.set_msg_type(message::ePicking_process_statu_msg);
-    base_info.set_sender(message::eMain);
-    base_info.set_receiver(message::eEmpty);
 
-    m_picking_process_statu_msg.mutable_base_info()->CopyFrom(base_info);
     reset_process_statu();
 
     ///创建状态发布线程
@@ -60,6 +57,12 @@ Error_manager PickupProcessTask::init_task(message::Command_info command_info, m
 
 }
 
+void PickupProcessTask::reset_recv_msg()
+{
+    m_parcspace_search_response_msg=message::Parkspace_search_response_msg();
+    m_dispatch_response_msg=message::Dispatch_response_msg();
+}
+
 /*
      * reset 进度信息
      */
@@ -84,8 +87,6 @@ void PickupProcessTask::reset_process_statu()
     m_picking_process_statu_msg.mutable_waitfor_leave()->CopyFrom(waitfor_leave_step);
     m_picking_process_statu_msg.set_license(m_car_info.license());
 
-
-
 }
 
 
@@ -152,7 +153,10 @@ Error_manager PickupProcessTask::search_space()
 void PickupProcessTask::Main()
 {
     Error_manager code;
+    usleep(1000*1000);
+    LOG(WARNING)<<"取车完成-----------------------------"<<m_car_info.license();
 
+    return ;
     //进入取车流程
     switch (0)
     {
@@ -182,12 +186,7 @@ void PickupProcessTask::Main()
                 break;
             }
             m_picking_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eComplete);
-            LOG(WARNING)<<"取车调度成功,取车终端:"<<m_terminor_id<<"指令id:"<<m_command_info.place()
-                        <<", 车位id:"<<m_parcspace_search_response_msg.car_position().parkspace_id()
-                        <<", 车位楼层:"<<m_parcspace_search_response_msg.car_position().floor()
-                        <<", 车位序号:"<<m_parcspace_search_response_msg.car_position().index()
-                        <<", 车牌号:"<<m_car_info.license()
-                        <<", 库内车牌号:"<<m_parcspace_search_response_msg.car_position().car_info().license();
+
         }
         //第二步,清除车位
         case 1:
@@ -220,6 +219,7 @@ void PickupProcessTask::Main()
                 m_picking_process_statu_msg.mutable_waitfor_leave()->mutable_car_info()->CopyFrom(m_car_info);
             }
             //等待离开
+
             code=wait_for_leave_step();
             std::lock_guard<std::mutex> lock(m_picking_statu_lock);
             if(code!=SUCCESS)
@@ -229,8 +229,16 @@ void PickupProcessTask::Main()
                 break;
             }
             m_picking_process_statu_msg.mutable_waitfor_leave()->set_step_statu(message::eComplete);
+            LOG(WARNING)<<"取车完成-----------------------------"<<m_car_info.license();
+            usleep(1000*1000);
+            return ;
         }
+        default:break;
     }
+    /*
+     *
+     */
+    usleep(1000*1000);
 
 }
 

+ 1 - 0
system/PickupProcessTask.h

@@ -54,6 +54,7 @@ protected:
     static void publish_thread_func(PickupProcessTask* p_commander);
     void publish_step_status();
 
+    void reset_recv_msg();
 protected:
     message::Command_info                m_command_info;
     unsigned int                m_terminor_id;

+ 11 - 13
system/StoreProcessTask.cpp

@@ -49,6 +49,7 @@ Error_manager StoreProcessTask::init_task(message::Command_info command_info,
     m_car_info=car_info;
     m_locate_info=locate_info;
 
+    reset_process_statu();
     ///创建状态发布线程
     if(m_publish_statu_thread== nullptr)
     {
@@ -56,7 +57,7 @@ Error_manager StoreProcessTask::init_task(message::Command_info command_info,
         m_publish_statu_thread=new std::thread(publish_thread_func,this);
     }
 
-    reset_process_statu();
+
     return SUCCESS;
 
 }
@@ -290,11 +291,11 @@ Error_manager StoreProcessTask::confirm_space_step()
     }
 
     if(confirm_response.error_manager().error_code()==0) {
-        LOG(INFO)<<"停车流程正常,确认占用车位成功,停车终端:"<<m_terminor_id
+        /*LOG(INFO)<<"停车流程正常,确认占用车位成功,停车终端:"<<m_terminor_id
                     <<", 指令id:"<<m_command_info.place()+m_command_info.time()
                     <<", 车位楼层:"<<confirm_response.confirm_alloc_space_info().floor()
                     <<", 车位序号:"<<confirm_response.confirm_alloc_space_info().index()
-                    <<", 车牌号:"<<confirm_response.confirm_alloc_space_info().car_info().license();
+                    <<", 车牌号:"<<confirm_response.confirm_alloc_space_info().car_info().license();*/
         return SUCCESS;
     }
     else
@@ -342,11 +343,11 @@ Error_manager StoreProcessTask::release_space_step()
         return code;
 
     if(release_response.error_manager().error_code()==0) {
-        LOG(WARNING)<<"停车流程异常,释放车位成功,停车终端:"<<m_terminor_id
+        /*LOG(WARNING)<<"停车流程异常,释放车位成功,停车终端:"<<m_terminor_id
                  <<", 指令id:"<<m_command_info.place()+m_command_info.time()
                  <<", 车位楼层:"<<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_parcspace_alloc_response_msg.allocated_space_info().car_info().license();*/
         return SUCCESS;
     }
     else
@@ -373,7 +374,7 @@ void StoreProcessTask::Main()
             }
             //开始定位
             code=locate_step();
-            usleep(1000*1000);
+            usleep(1000*1000*(rand()%5+1));
 
             std::lock_guard<std::mutex> lock(m_storing_statu_lock);
             if(code!=SUCCESS)
@@ -443,14 +444,10 @@ void StoreProcessTask::Main()
         //第四步,打印...  日志 .... 记录.....
         case 3:
         {
-            LOG(INFO)<<"停车成功,停车终端:"<<m_terminor_id<<"指令id:"<<m_command_info.place()
+            LOG(INFO)<<"停车成功,停车终端:"<<m_terminor_id
                      <<", 车位id:"<<m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()
-                     <<", 车位楼层:"<<m_parcspace_alloc_response_msg.allocated_space_info().floor()
-                     <<", 车位序号:"<<m_parcspace_alloc_response_msg.allocated_space_info().index()
-                     <<", 车牌号:"<<m_car_info.license()
-                     <<", 库内车牌号:"<<m_parcspace_alloc_response_msg.allocated_space_info().car_info().license();
+                     <<", 车牌号:"<<m_car_info.license()<<"**********************";
 
-            usleep(1000*3000);
             return ;
         }
     }
@@ -478,10 +475,11 @@ void StoreProcessTask::Main()
     {
         m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eComplete);
     }
-    usleep(1000*1000*10);
+
     /*
     *   流程异常,此处应暂停系统,待管理员介入
     */
+    usleep(1000*2000);
 }
 
 /*

+ 14 - 16
system/command_manager.cpp

@@ -41,14 +41,14 @@ Error_manager Command_manager::init(setting::System_setting system_setting) {
     //创建线程池
     if (m_thread_queue_process == nullptr) {
         m_thread_queue_process = tq::TQFactory::CreateDefaultQueue();
-        m_thread_queue_process->Start(12);
+        m_thread_queue_process->Start(48);
     }
 
 
     /*
      * 此处添加等待各个通讯模块正常代码
      */
-    /*std::chrono::system_clock::time_point t_start=std::chrono::system_clock::now();
+    std::chrono::system_clock::time_point t_start=std::chrono::system_clock::now();
     std::chrono::system_clock::time_point t_end=std::chrono::system_clock::now();
 
     Error_manager parkspace_code=ERROR;
@@ -126,12 +126,11 @@ Error_manager Command_manager::init(setting::System_setting system_setting) {
     }
 
     return SUCCESS;
-}
 
+}
 /*
  * 执行停车请求
  */
-}
 
 Error_manager Command_manager::execute_store_command(message::Store_command_request_msg& request,message::Store_command_response_msg& response)
 {
@@ -169,7 +168,7 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
                         /*
                         * 检查各个节点是否正常
                         */
-                        /*Error_manager parkspace_code= Parkspace_communicator::get_instance_pointer()->check_statu();
+                        Error_manager parkspace_code= Parkspace_communicator::get_instance_pointer()->check_statu();
                         if(parkspace_code!=SUCCESS)
                         {
                             error_msg.set_error_code(parkspace_code.get_error_code());
@@ -192,7 +191,7 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
                             error_msg.set_error_description(dispatch_code.get_error_description());
                             response.mutable_code()->CopyFrom(error_msg);
                             return dispatch_code;
-                        }*/
+                        }
 
                         //一切正常,接受指令
                         message::Command_info command_info;
@@ -208,9 +207,9 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
                         command_info.set_place(place);
                         command_info.set_event(message::eStoring);
 
-                        LOG(INFO) << "收到停车指令:" << command_info.place() + "-" + command_info.time() << ", 车牌:"
+                        LOG(INFO) << "收到停车:" << command_info.place() + "-" + command_info.time() << ", 车牌:"
                                   << request.car_info().license() <<
-                                  ",终端:" << request.terminal_id();
+                                  ",终端:" << request.terminal_id()<<"............................";
                         tq::BaseTask *ptask = new StoreProcessTask(request.terminal_id());
                         StoreProcessTask *pStore_task = (StoreProcessTask *) ptask;
                         //初始化流程
@@ -224,8 +223,8 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
                             return SUCCESS;
 
                         }
-                        usleep(1000 * 5000);
-                        //delete pStore_task;
+                        usleep(1000 * 1000);
+                        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);
@@ -298,20 +297,17 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
         message::Command_info command_info;
         //获取当前时间
         auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
-        std::stringstream ss;
-        ss << std::put_time(std::localtime(&t), "%Y-%m-%d:%H-%M-%S-%ms");
-        std::string str_time = ss.str();
-        command_info.set_time(str_time);
 
         char place[255]={0};
-        sprintf(place ,"027-01-%02d",request.terminal_id());
+        sprintf(place, "027-01-%02d:%s", request.terminal_id(), request.car_info().license().c_str());
         command_info.set_place(place);
         command_info.set_event(message::ePicking);
 
+        LOG(WARNING)<<"收到取车-----------------------------"<<request.car_info().license();
         tq::BaseTask* ptask=new PickupProcessTask(request.terminal_id());
         PickupProcessTask* pPick_task=(PickupProcessTask*)ptask;
         //初始化流程
-        pPick_task->init_task(command_info, request.car_info());
+        code=pPick_task->init_task(command_info, request.car_info());
         /////查询车位
         code=pPick_task->search_space();
 
@@ -321,11 +317,13 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
             response.mutable_code()->CopyFrom(error_msg);
             return SUCCESS;
         }
+        usleep(1000*1000);
         error_msg.set_error_code(code.get_error_code());
         error_msg.set_error_description(code.to_string());
         response.mutable_code()->CopyFrom(error_msg);
         LOG(ERROR)<<"创建取车流程失败(车位查询失败),终端:"<<request.terminal_id()<<
                   "车牌:"<<request.car_info().license()<<"  "<<code.to_string();
+        delete pPick_task;
         return code;
     }
     else

+ 80 - 20
test/Terminal_communication.cpp

@@ -6,7 +6,15 @@
 #include "process_message.pb.h"
 #include <condition_variable>
 
-Terminal_communication::Terminal_communication(){}
+Terminal_communication::Terminal_communication()
+    :m_update_msg_map_thread(nullptr)
+{
+    if(m_update_msg_map_thread== nullptr)
+    {
+        m_publish_exit_condition.reset(false, false, false);
+        m_update_msg_map_thread=new std::thread(thread_update_map_function,this);
+    }
+}
 Terminal_communication::~Terminal_communication(){}
 
 //重载函数
@@ -93,7 +101,14 @@ Error_manager Terminal_communication::execute_msg(Communication_message* p_msg)
         message::Base_info base_info=msg.base_info();
         if(base_info.sender()==message::eMain)
         {
-            m_storing_statu_map[msg.terminal_id()]=msg;
+            if(m_storing_statu_map.find(msg.license())==false)
+            {
+                m_storing_license_queue.push(msg.license());
+            }
+            m_storing_statu_map[msg.license()]=msg;
+            std::chrono::system_clock::time_point time_point=std::chrono::system_clock::now();
+            m_storing_statu_time_point_map[msg.license()]=time_point;
+
 
         }
     }
@@ -108,7 +123,13 @@ Error_manager Terminal_communication::execute_msg(Communication_message* p_msg)
         message::Base_info base_info=msg.base_info();
         if(base_info.sender()==message::eMain)
         {
-            m_picking_statu_map[msg.terminal_id()]=msg;
+            if(m_picking_statu_map.find(msg.license())==false)
+            {
+                m_picking_license_queue.push(msg.license());
+            }
+            m_picking_statu_map[msg.license()]=msg;
+            std::chrono::system_clock::time_point time_point=std::chrono::system_clock::now();
+            m_picking_statu_time_point_map[msg.license()]=time_point;
         }
     }
 
@@ -136,17 +157,6 @@ Error_manager Terminal_communication::check_executer(Communication_message* p_ms
     return SUCCESS;
 }
 
-/*
-    * 设置终端id
-    */
-Error_manager Terminal_communication::set_terminal_id(int id)
-{
-    if(id<0 || id>5)
-        return Error_manager(ERROR,CRITICAL_ERROR,"终端设置id不在范围");
-    m_terminal_id=id;
-    return SUCCESS;
-}
-
 
 /*
     * 发送停车指令请求
@@ -163,7 +173,7 @@ Error_manager Terminal_communication::store_request(message::Store_command_reque
     Error_manager code;
     Communication_message message;
     message.reset(request.base_info(),request.SerializeAsString());
-    int timeout=1000*5;
+    int timeout=1000*3;
 
     code=encapsulate_msg(&message);
     if(code!=SUCCESS)
@@ -221,7 +231,7 @@ Error_manager Terminal_communication::pickup_request(message::Pickup_command_req
     Error_manager code;
     Communication_message message;
     message.reset(request.base_info(),request.SerializeAsString());
-    int timeout=1000;
+    int timeout=1000*3;
 
     code=encapsulate_msg(&message);
     if(code!=SUCCESS)
@@ -272,9 +282,9 @@ Error_manager Terminal_communication::pickup_request(message::Pickup_command_req
 /*
      * 获取停车流程状态
      */
-Error_manager Terminal_communication::get_storing_statu(int terminal_id,message::Storing_process_statu_msg& msg)
+Error_manager Terminal_communication::get_storing_statu(std::string car_license,message::Storing_process_statu_msg& msg)
 {
-    if(m_storing_statu_map.find(terminal_id,msg)) {
+    if(m_storing_statu_map.find(car_license,msg)) {
         return SUCCESS;
     }
     return FAILED;
@@ -283,9 +293,59 @@ Error_manager Terminal_communication::get_storing_statu(int terminal_id,message:
 /*
  * 获取取车流程状态
  */
-Error_manager Terminal_communication::get_picking_statu(int terminal_id,message::Picking_process_statu_msg& msg)
+Error_manager Terminal_communication::get_picking_statu(std::string car_license,message::Picking_process_statu_msg& msg)
 {
-    if(m_picking_statu_map.find(terminal_id,msg))
+    if(m_picking_statu_map.find(car_license,msg))
         return SUCCESS;
     return FAILED;
+}
+
+void Terminal_communication::update_map()
+{
+    while(false==m_publish_exit_condition.wait_for_ex(std::chrono::milliseconds(200)))
+    {
+        std::string license;
+        if (m_storing_license_queue.try_pop(license))
+        {
+            std::chrono::system_clock::time_point t1 = std::chrono::system_clock::now();
+            std::chrono::system_clock::time_point start = m_storing_statu_time_point_map[license];
+            auto duration = std::chrono::duration_cast<std::chrono::microseconds>(t1 - start);
+            double time = 1000.0 * double(duration.count()) * std::chrono::microseconds::period::num /
+                          std::chrono::microseconds::period::den;
+
+            if (time > 3000) {
+                m_storing_statu_time_point_map.erase(license);
+                m_storing_statu_map.erase(license);
+
+            }
+            else
+            {
+                m_storing_license_queue.push(license);
+            }
+        }
+
+        if (m_picking_license_queue.try_pop(license))
+        {
+            std::chrono::system_clock::time_point t1 = std::chrono::system_clock::now();
+            std::chrono::system_clock::time_point start = m_picking_statu_time_point_map[license];
+            auto duration = std::chrono::duration_cast<std::chrono::microseconds>(t1 - start);
+            double time = 1000.0 * double(duration.count()) * std::chrono::microseconds::period::num /
+                          std::chrono::microseconds::period::den;
+
+            if (time > 3000) {
+                m_picking_statu_time_point_map.erase(license);
+                m_picking_statu_map.erase(license);
+
+            }
+            else
+            {
+                m_picking_license_queue.push(license);
+            }
+        }
+
+    }
+}
+
+void Terminal_communication::thread_update_map_function(Terminal_communication *terminal) {
+    terminal->update_map();
 }

+ 14 - 7
test/Terminal_communication.h

@@ -4,7 +4,7 @@
 
 #ifndef NNXX_TESTS_TERMINAL_COMMUNICATION_H
 #define NNXX_TESTS_TERMINAL_COMMUNICATION_H
-
+#include "thread_safe_queue.h"
 #include <process_message.pb.h>
 #include "../tool/singleton.h"
 #include "../communication/communication_socket_base.h"
@@ -42,12 +42,12 @@ public:
     /*
      * 获取停车流程状态
      */
-    Error_manager get_storing_statu(int terminal_id,message::Storing_process_statu_msg& msg);
+    Error_manager get_storing_statu(std::string terminal_id,message::Storing_process_statu_msg& msg);
 
     /*
      * 获取取车流程状态
      */
-    Error_manager get_picking_statu(int terminal_id,message::Picking_process_statu_msg& msg);
+    Error_manager get_picking_statu(std::string terminal_id,message::Picking_process_statu_msg& msg);
 
 protected:
     //重载函数
@@ -64,15 +64,22 @@ protected:
     //检查消息是否可以被解析, 需要重载
     virtual Error_manager check_executer(Communication_message* p_msg);
 
+    static void thread_update_map_function(Terminal_communication* terminal);
+    void update_map();
+
 private:
     message::Store_command_response_msg             m_store_response_msg;
     message::Pickup_command_response_msg            m_pickup_response_msg;
-    int                                             m_terminal_id;
-
-    thread_safe_map<int ,message::Storing_process_statu_msg>        m_storing_statu_map;
-    thread_safe_map<int ,message::Picking_process_statu_msg>        m_picking_statu_map;
 
+    thread_safe_map<std::string ,message::Storing_process_statu_msg>        m_storing_statu_map;
+    thread_safe_map<std::string ,std::chrono::system_clock::time_point>     m_storing_statu_time_point_map;
+    Thread_safe_queue<std::string>                                                m_storing_license_queue;
+    thread_safe_map<std::string ,message::Picking_process_statu_msg>        m_picking_statu_map;
+    thread_safe_map<std::string ,std::chrono::system_clock::time_point>     m_picking_statu_time_point_map;
+    Thread_safe_queue<std::string>                                                m_picking_license_queue;
 
+    std::thread*                    m_update_msg_map_thread;
+    Thread_condition				m_publish_exit_condition;
 
 };
 

+ 11 - 11
test/pickup_terminal.cpp

@@ -55,22 +55,22 @@ Error_manager pickup_terminal::pickup(message::Car_info& car_info)
     }
     //等待停车完成
 
+    bool last_signal=false;
     while(m_exit_cond.wait_for_millisecond(200)==false)
     {
         message::Picking_process_statu_msg msg;
-        code = Terminal_communication::get_instance_pointer()->get_picking_statu(m_terminal_id, msg);
+        code = Terminal_communication::get_instance_pointer()->get_picking_statu(car_info.license(), msg);
         if (code != SUCCESS) {
-            continue;
+           if(last_signal==true)
+           {
+               return SUCCESS;
+           }
         }
-        message::Step_statu check_space_statu=msg.check_space_step().step_statu();
-        message::Step_statu dispatch_space_statu=msg.dispatch_step().step_statu();
-        message::Step_statu release_space_statu=msg.release_space_step().step_statu();
-        if(check_space_statu==message::eComplete
-           && dispatch_space_statu==message::eComplete
-           && release_space_statu ==message::eComplete)
+        else
         {
-            return SUCCESS;
+            last_signal=true;
         }
+
     }
     return FAILED;
 }
@@ -78,7 +78,7 @@ Error_manager pickup_terminal::pickup(message::Car_info& car_info)
 
 void pickup_terminal::pickup_thread(pickup_terminal* picker)
 {
-    while(picker->m_exit_cond.wait_for_millisecond(100)==false)
+    while(picker->m_exit_cond.wait_for_millisecond(200)==false)
     {
         message::Car_info car_info;
         if(picker->m_thread_safe_queue== nullptr)
@@ -87,7 +87,7 @@ void pickup_terminal::pickup_thread(pickup_terminal* picker)
         {
             /*LOG(WARNING)<<"取车终端:"<<picker->m_terminal_id<<",车辆:"<<car_info.license().c_str()
                         <<",开始取车,剩余out:"<<picker->m_thread_safe_queue->size();*/
-            picker->pickup(car_info);
+            Error_manager code=picker->pickup(car_info);
 
         }
     }

+ 22 - 20
test/store_terminal.cpp

@@ -34,7 +34,6 @@ Error_manager store_terminal::init(threadsafe_queue<message::Car_info>* input,
 
 Error_manager store_terminal::storing(message::Car_info& car_info)
 {
-    usleep(1000*1000);
     message::Store_command_request_msg request;
     message::Base_info base_info;
     base_info.set_msg_type(message::eStore_command_request_msg);
@@ -65,27 +64,27 @@ Error_manager store_terminal::storing(message::Car_info& car_info)
     }
     //等待停车完成
 
+    bool last_signal=false;
     while(m_exit_cond.wait_for_millisecond(50)==false) {
+
         message::Storing_process_statu_msg msg;
-        code = Terminal_communication::get_instance_pointer()->get_storing_statu(m_terminal_id, msg);
+        code = Terminal_communication::get_instance_pointer()->get_storing_statu(car_info.license(), msg);
         if (code != SUCCESS) {
-            continue;
+            if(last_signal==true)
+            {
+                if (m_thread_safe_output_queue)
+                    m_thread_safe_output_queue->push(car_info);
+                return SUCCESS;
+            }
         }
-
-        message::Step_statu alloc_space_statu=msg.alloc_space_step().step_statu();
-        message::Step_statu measure_space_statu=msg.measure_step().step_statu();
-        message::Step_statu dispatch_space_statu=msg.dispatch_step().step_statu();
-        message::Step_statu confirm_space_statu=msg.confirm_space_step().step_statu();
-        if(alloc_space_statu==message::eComplete
-            && measure_space_statu==message::eComplete
-            && dispatch_space_statu==message::eComplete
-            && confirm_space_statu ==message::eComplete)
+        else
         {
-            if (m_thread_safe_output_queue)
-                m_thread_safe_output_queue->push(car_info);
-            return SUCCESS;
+            last_signal=true;
         }
 
+
+
+
     }
     return FAILED;
 }
@@ -93,7 +92,7 @@ Error_manager store_terminal::storing(message::Car_info& car_info)
 
 void store_terminal::storing_thread(store_terminal* pStore)
 {
-    while(pStore->m_exit_cond.wait_for_millisecond(50)==false)
+    while(pStore->m_exit_cond.wait_for_millisecond(200)==false)
     {
         message::Car_info car_info;
         if(pStore->m_thread_safe_queue== nullptr)
@@ -101,11 +100,14 @@ void store_terminal::storing_thread(store_terminal* pStore)
 
         if(pStore->m_thread_safe_queue->try_pop(car_info)==true)
         {
-            LOG(INFO)<<"停车终端:"<<pStore->m_terminal_id<<",车辆:"<<car_info.license().c_str()<<",停车开始,剩余in:"
+            LOG(INFO)<<"车辆:"<<car_info.license().c_str()<<",停车开始---"<<pStore->m_terminal_id<<"---,剩余in:"
                   <<pStore->m_thread_safe_queue->size();
-            pStore->storing(car_info);
-            LOG(INFO)<<"停车终端:"<<pStore->m_terminal_id<<",车辆:"<<car_info.license().c_str()<<",停车完成,剩余in:"
-                     <<pStore->m_thread_safe_queue->size();
+            Error_manager code=pStore->storing(car_info);
+
+            LOG_IF(INFO,code==SUCCESS)<<"车辆:"<<car_info.license().c_str()<<",停车结束---"<<pStore->m_terminal_id<<"----------,剩余in:"
+                                      <<pStore->m_thread_safe_queue->size();
+            LOG_IF(ERROR,code!=SUCCESS)<<"车辆:"<<car_info.license().c_str()<<",停车结束---"<<pStore->m_terminal_id<<"---------,剩余in:"
+                                       <<pStore->m_thread_safe_queue->size();
 
         }
     }

+ 1 - 0
test/store_terminal.h

@@ -24,6 +24,7 @@ public:
 
 protected:
     static void storing_thread(store_terminal* pStore);
+
     std::thread*                m_pthread;
     int                         m_terminal_id;
 

+ 7 - 12
test/terminal_client.cpp

@@ -81,14 +81,14 @@ void init_glog()
 
 int main() {
     init_glog();
-    Terminal_communication::get_instance_pointer()->communication_connect("tcp://192.168.245.112:30000");
+    Terminal_communication::get_instance_pointer()->communication_connect("tcp://192.168.2.183:30000");
     Terminal_communication::get_instance_pointer()->communication_run();
     usleep(2000*1000);
     threadsafe_queue<message::Car_info> input_queue;
     threadsafe_queue<message::Car_info> output_queue;
 
     const int n_input=6;
-    const int n_output=1;
+    const int n_output=6;
     std::vector<store_terminal*> input_terminals;
     std::vector<pickup_terminal*> output_terminals;
     for(int i=0;i<n_input;++i)
@@ -109,33 +109,28 @@ int main() {
     bool run = true;
     Error_manager code;
     char c=0;
-
+    int license_id = 11100;
     while (c!='q') {
 
 
-        int license_id = rand() % 50000 + 10000;
+
         char C=rand()%10+'A';
         char license[255] = {0};
-        sprintf(license, "鄂%c%d",C, license_id);
+        sprintf(license, "鄂%c%d",C, license_id++);
         message::Car_info car_info;
         car_info.set_license(license);
         car_info.set_car_height(1.5);
         car_info.set_car_width(1.7);
         input_queue.push(car_info);
-       // std::cout<<" input : "<<++n<<std::endl;
 
         n++;
 
         int in_count=input_queue.size();
         int out_count=output_queue.size();
 
-        if(n%6==0) {
-            printf("  input  q to quite    n=%d\n",n);
-            c=getchar();
-        }
-        else {
+       {
 
-            usleep(1000+1);
+            usleep(1000*1000*in_count);
             std::this_thread::yield();
         }
     }