Browse Source

修改为全局唯一一个通讯单元,整改类名

zx 4 years ago
parent
commit
b0c85c7787

+ 3 - 27
CMakeLists.txt

@@ -21,21 +21,19 @@ include_directories(
         ./lidar_locate
         ./parkspace
         ./dispatch
-        ./solve_exception
+        ./exception
 )
 link_directories("/usr/local/lib")
 
 message(STATUS ${EXECUTABLE_OUTPUT_PATH})
 
-
-
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/message message_src )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/lidar_locate locate_src )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/robot robot_src )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/laser LASER_SRC )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/plc PLC_SRC )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/locate LOCATE_SRC )
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/solve_exception exception_solve_src )
+aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/exception  exception_src )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/terminor TERMINOR_SRC )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/task TASK_MANAGER_SRC )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/tool TOOL_SRC )
@@ -57,7 +55,7 @@ add_executable(process
         ${SYSTEM_SRC}
         ${PARKSPACE_SRC}
         ${DISPATCH_SRC}
-        ${exception_solve_src}
+        ${exception_src}
         )
 
 target_link_libraries(process
@@ -74,16 +72,11 @@ add_executable(terminal
         ./test/store_terminal.cpp
         ./test/pickup_terminal.cpp
         ./test/Terminal_communication.cpp
-        ./lidar_locate/Locate_communicator.cpp
         ./error_code/error_code.cpp
-        ${locate_src}
-        ${robot_src}
         ${message_src}
         ${TOOL_SRC}
         ${TASK_QUEUE_SRC}
         ${COMMUNICATION_SRC}
-        ${PARKSPACE_SRC}
-        ${DISPATCH_SRC}
         )
 target_link_libraries(terminal
         nnxx
@@ -92,20 +85,3 @@ target_link_libraries(terminal
         /usr/local/lib/libglog.a
         /usr/local/lib/libgflags.a
         )
-
-
-#add_executable(locate_test
-#        ./test/test_locate_sample.cpp
-#        ./lidar_locate/Locate_communicator.cpp
-#        ./error_code/error_code.cpp
-#        ${message_src}
-#        ${TOOL_SRC}
-#        ${COMMUNICATION_SRC}
-#        )
-#target_link_libraries(locate_test
-#        nnxx
-#        nanomsg
-#        ${PROTOBUF_LIBRARIES}
-#        /usr/local/lib/libglog.a
-#        /usr/local/lib/libgflags.a
-#        )

+ 0 - 18
communication/communication_socket_base.h

@@ -130,33 +130,15 @@ protected://member variable
 	std::thread*						mp_analysis_data_thread;    	//解析的线程指针
 	Thread_condition					m_analysis_data_condition;		//解析的条件变量
 
-
 	//发送模块,
 	Thread_safe_list<Communication_message*>		m_send_data_list;				//发送的list容器
 	std::thread*						mp_send_data_thread;    		//发送的线程指针
 	Thread_condition					m_send_data_condition;			//发送的条件变量
 	std::thread*						mp_encapsulate_data_thread;    	//封装的线程指针
 	Thread_condition					m_encapsulate_data_condition;	//封装的条件变量
-	
-
 
 private:
 
 };
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 #endif //__COMMUNICATION_SOCKET_BASE__HH__

+ 16 - 66
dispatch/dispatch_communicator.cpp

@@ -2,12 +2,12 @@
 // Created by zx on 2020/7/21.
 //
 
-#include "dispatch_communicator.h"
+#include "dispatch_excutor.h"
 #include "uniq_key.h"
 
-Dispatch_communicator::~Dispatch_communicator(){}
+Dispatch_excutor::~Dispatch_excutor(){}
 
-Error_manager Dispatch_communicator::dispatch_request(message::Dispatch_request_msg& request,
+Error_manager Dispatch_excutor::dispatch_request(message::Dispatch_request_msg& request,
         message::Dispatch_response_msg& result,Thread_condition& cancel_condition)
 {
 
@@ -34,10 +34,15 @@ Error_manager Dispatch_communicator::dispatch_request(message::Dispatch_request_
     base_msg.set_timeout_ms(timeout);
     message.reset(base_msg,request.SerializeAsString());
 
-    code=encapsulate_msg(&message);
+    //发送请求
+    m_response_table[request.command_key()]=message::Dispatch_response_msg();
+    code= Message_communicator::get_instance_pointer()->send_msg(&message);
     if(code!=SUCCESS)
+    {
+        m_response_table.erase(request.command_key());
         return code;
-    m_response_table[request.command_key()]=message::Dispatch_response_msg();
+    }
+
     //循环查询请求是否被处理
     auto start_time=std::chrono::system_clock::now();
     double time=0;
@@ -66,7 +71,6 @@ Error_manager Dispatch_communicator::dispatch_request(message::Dispatch_request_
                 result = response;
                 m_response_table.erase(request.command_key());
                 return SUCCESS;
-
             }
         }
         else
@@ -93,7 +97,7 @@ Error_manager Dispatch_communicator::dispatch_request(message::Dispatch_request_
 /*
  * 提前取消请求
  */
-Error_manager Dispatch_communicator::cancel_request(message::Dispatch_request_msg& request)
+Error_manager Dispatch_excutor::cancel_request(message::Dispatch_request_msg& request)
 {
     message::Dispatch_response_msg t_response;
     if(m_response_table.find(request.command_key(),t_response))
@@ -104,7 +108,7 @@ Error_manager Dispatch_communicator::cancel_request(message::Dispatch_request_ms
 }
 
 
-Error_manager Dispatch_communicator::check_entrance_statu(int terminal_id)
+Error_manager Dispatch_excutor::check_entrance_statu(int terminal_id)
 {
     if(m_storing_dispatch_statu_msg_map.find(terminal_id)==false || m_storing_dispatch_statu_time_map.find(terminal_id)==false)
         return Error_manager(FAILED,MINOR_ERROR,"停车口调度模块状态未找到");
@@ -129,7 +133,7 @@ Error_manager Dispatch_communicator::check_entrance_statu(int terminal_id)
 
 }
 
-Error_manager Dispatch_communicator::check_export_statu(int terminal_id)
+Error_manager Dispatch_excutor::check_export_statu(int terminal_id)
 {
     if(m_picking_dispatch_statu_msg_map.find(terminal_id)==false || m_picking_dispatch_statu_time_map.find(terminal_id)==false)
         return Error_manager(FAILED,MINOR_ERROR,"停车口调度模块状态未找到");
@@ -153,35 +157,11 @@ Error_manager Dispatch_communicator::check_export_statu(int terminal_id)
     return SUCCESS;
 }
 
-Dispatch_communicator::Dispatch_communicator()
+Dispatch_excutor::Dispatch_excutor()
 {
 }
-Error_manager Dispatch_communicator::encapsulate_msg(Communication_message* message)
-{
-    Error_manager code;
-    //记录请求
-    switch (message->get_message_type())
-    {
-        case Communication_message::eDispatch_request_msg:
-        {
-            message::Dispatch_request_msg request;
-            if(false==request.ParseFromString(message->get_message_buf()))
-            {
-                code=Error_manager(ERROR,CRITICAL_ERROR,"request message parse failed");
-            }
-
-            //发送请求
-            code= Communication_socket_base::encapsulate_msg(message);
 
-            break;
-        }
-        default:
-            code= Error_manager(FAILED,CRITICAL_ERROR," measure发送任务类型不存在");
-            break;
-    }
-    return code;
-}
-Error_manager Dispatch_communicator::execute_msg(Communication_message* p_msg)
+Error_manager Dispatch_excutor::consume_msg(Communication_message* p_msg)
 {
     if(p_msg== nullptr)
         return Error_manager(POINTER_IS_NULL,CRITICAL_ERROR,"dispatch response msg pointer is null");
@@ -233,34 +213,4 @@ Error_manager Dispatch_communicator::execute_msg(Communication_message* p_msg)
     }
     return SUCCESS;
 }
-/*
- * 检测消息是否可被处理
- */
-Error_manager Dispatch_communicator::check_msg(Communication_message* p_msg)
-{
-    //通过 p_msg->get_message_type() 和 p_msg->get_receiver() 判断这条消息是不是给我的.
-    //子类重载时, 增加自己模块的判断逻辑, 以后再写.
-    if ( (p_msg->get_message_type() == Communication_message::Message_type::eDispatch_response_msg
-          ||p_msg->get_message_type() == Communication_message::Message_type::eDispatch_status_msg)
-         && p_msg->get_receiver() == Communication_message::Communicator::eMain )
-    {
-        return Error_code::SUCCESS;
-    }
-    else
-    {
-        //认为接受人
-        return Error_code::INVALID_MESSAGE;
-    }
-}
-/*
- * 心跳发送函数,重载
- */
-Error_manager Dispatch_communicator::encapsulate_send_data()
-{
-    return SUCCESS;
-}
-//检查消息是否可以被解析, 需要重载
-Error_manager Dispatch_communicator::check_executer(Communication_message* p_msg)
-{
-    return SUCCESS;
-}
+

+ 9 - 21
dispatch/dispatch_communicator.h

@@ -4,18 +4,17 @@
 
 #ifndef NNXX_TESTS_DISPATCH_COMMUNICATOR_H
 #define NNXX_TESTS_DISPATCH_COMMUNICATOR_H
-
-#include "communication_socket_base.h"
+#include "message_communicator.h"
 #include "singleton.h"
 #include "dispatch_message.pb.h"
-#include "error_code.h"
 #include "thread_safe_map.h"
 
-class Dispatch_communicator :public Singleton<Dispatch_communicator>, public Communication_socket_base
+
+class Dispatch_excutor :public Singleton<Dispatch_excutor>
 {
-    friend Singleton<Dispatch_communicator>;
+    friend Singleton<Dispatch_excutor>;
 public:
-    virtual ~Dispatch_communicator();
+    virtual ~Dispatch_excutor();
     Error_manager dispatch_request(message::Dispatch_request_msg& request,
             message::Dispatch_response_msg& result,Thread_condition& cancel_condition);
     /*
@@ -32,23 +31,12 @@ public:
     //检查取车出口 调度节点状态
     Error_manager check_export_statu(int terminal_id);
 
-
-protected:
-    Dispatch_communicator();
-    virtual Error_manager encapsulate_msg(Communication_message* message);
-    virtual Error_manager execute_msg(Communication_message* p_msg);
-    /*
-     * 检测消息是否可被处理
-     */
-    virtual Error_manager check_msg(Communication_message* p_msg);
-    /*
-     * 心跳发送函数,重载
-     */
-    virtual Error_manager encapsulate_send_data();
-    //检查消息是否可以被解析, 需要重载
-    virtual Error_manager check_executer(Communication_message* p_msg);
+    //消费本模块的接收消息
+    Error_manager consume_msg(Communication_message* p_msg);
 
 
+protected:
+    Dispatch_excutor();
 
 private:
     thread_safe_map<std::string,message::Dispatch_response_msg>          m_response_table;

+ 5 - 32
solve_exception/exception_solver.cpp

@@ -5,6 +5,7 @@
 #include "exception_solver.h"
 #include "command_manager.h"
 #include "communication_message.h"
+#include <glog/logging.h>
 
 Exception_solver::Exception_solver() {
 
@@ -33,19 +34,7 @@ Error_manager Exception_solver::delete_task_cancel_condition(std::string license
     return Error_manager(ERROR,MINOR_ERROR,"任务取消标志不存在");
 }
 
-Error_manager Exception_solver::encapsulate_msg(Communication_message* message)
-{
-    Error_manager code;
-    //记录请求
-    switch (message->get_message_type())
-    {
-        default:
-            code= Communication_socket_base::encapsulate_msg(message);
-            break;
-    }
-    return code;
-}
-Error_manager Exception_solver::execute_msg(Communication_message* p_msg)
+Error_manager Exception_solver::consume_msg(Communication_message* p_msg)
 {
     if(p_msg== nullptr)
         return Error_manager(POINTER_IS_NULL,CRITICAL_ERROR,"dispatch response msg pointer is null");
@@ -68,6 +57,7 @@ Error_manager Exception_solver::execute_msg(Communication_message* p_msg)
             }
             LOG(INFO)<<"接收到手动消息//////////////////////////  : "<<msg.license();
             m_manual_msg_map[msg.license()]=msg;
+            break;
         }
         case Communication_message::eEntrance_manual_operation_msg:
         {
@@ -91,31 +81,14 @@ Error_manager Exception_solver::execute_msg(Communication_message* p_msg)
                     break;
                 }
             }
+            break;
         }
 
         default:break;
     }
     return SUCCESS;
 }
-/*
- * 检测消息是否可被处理
- */
-Error_manager Exception_solver::check_msg(Communication_message* p_msg)
-{
-    return SUCCESS;
-}
-/*
- * 心跳发送函数,重载
- */
-Error_manager Exception_solver::encapsulate_send_data()
-{
-    return SUCCESS;
-}
-//检查消息是否可以被解析, 需要重载
-Error_manager Exception_solver::check_executer(Communication_message* p_msg)
-{
-    return SUCCESS;
-}
+
 
 /*
      * 等待手动消息

+ 7 - 18
solve_exception/exception_solver.h

@@ -4,16 +4,13 @@
 
 #ifndef NNXX_TESTS_ERROR_HANDLING_H
 #define NNXX_TESTS_ERROR_HANDLING_H
-#include "communication_socket_base.h"
-
-#include "singleton.h"
+#include "message_communicator.h"
 #include "central_control_message.pb.h"
-#include "error_code.h"
 #include "thread_safe_map.h"
 #include "StoreProcessTask.h"
 #include "PickupProcessTask.h"
 
-class Exception_solver :public Singleton<Exception_solver>, public Communication_socket_base
+class Exception_solver :public Singleton<Exception_solver>
 {
     friend Singleton<Exception_solver>;
 public:
@@ -39,21 +36,13 @@ public:
      */
     Error_manager waitfor_manual_operate_msg(Process_task* task,message::Process_manual_operation_msg& msg);
 
-protected:
-    Exception_solver();
-
-    virtual Error_manager encapsulate_msg(Communication_message* message);
-    virtual Error_manager execute_msg(Communication_message* p_msg);
     /*
-     * 检测消息是否可被处理
+     * 消息消费函数
      */
-    virtual Error_manager check_msg(Communication_message* p_msg);
-    /*
-     * 心跳发送函数,重载
-     */
-    virtual Error_manager encapsulate_send_data();
-    //检查消息是否可以被解析, 需要重载
-    virtual Error_manager check_executer(Communication_message* p_msg);
+    Error_manager consume_msg(Communication_message* p_msg);
+
+protected:
+    Exception_solver();
 
 private:
     thread_safe_map<std::string,tq::BaseTask*>                              m_ptask_map;

+ 14 - 66
lidar_locate/Locate_communicator.cpp

@@ -2,43 +2,15 @@
 // Created by zx on 2020/6/18.
 //
 
-#include "Locate_communicator.h"
-
-Locate_communicator::Locate_communicator()
+#include "measure_excutor.h"
+Measure_excutor::Measure_excutor()
 {
 }
-Locate_communicator::~Locate_communicator()
+Measure_excutor::~Measure_excutor()
 {
 }
 
-Error_manager Locate_communicator::encapsulate_msg(Communication_message* message)
-{
-    Error_manager code;
-    //记录请求
-    switch (message->get_message_type())
-    {
-        case Communication_message::eLocate_request_msg:
-        {
-            message::Measure_request_msg request;
-            request.ParseFromString(message->get_message_buf());
-            m_response_table[request.command_key()]=message::Measure_response_msg();
-            //发送请求
-            code= Communication_socket_base::encapsulate_msg(message);
-            if(code!=SUCCESS)
-            {
-                m_response_table.erase(request.command_key());
-            }
-            break;
-        }
-        default:
-            code= Error_manager(FAILED,CRITICAL_ERROR," measure发送任务类型不存在");
-            break;
-    }
-    return code;
-
-}
-
-Error_manager Locate_communicator::locate_request(message::Measure_request_msg& request,
+Error_manager Measure_excutor::locate_request(message::Measure_request_msg& request,
         message::Measure_response_msg& result,Thread_condition& cancel_condition)
 {
     /*
@@ -52,8 +24,8 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
         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;
-    //向测量节点发送测量请求,并记录请求
 
+    //向测量节点发送测量请求,并记录请求
     Error_manager code;
     Communication_message message;
 
@@ -64,9 +36,14 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
     base_msg.set_timeout_ms(timeout);
     message.reset(base_msg,request.SerializeAsString());
 
-    code=encapsulate_msg(&message);
+    m_response_table[request.command_key()]=message::Measure_response_msg();
+    //发送请求
+    code= Message_communicator::get_instance_pointer()->send_msg(&message);
     if(code!=SUCCESS)
+    {
+        m_response_table.erase(request.command_key());
         return code;
+    }
     //循环查询请求是否被处理
     auto start_time=std::chrono::system_clock::now();
     double time=0;
@@ -94,9 +71,7 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
                 }
                 result = response;
                 m_response_table.erase(request.command_key());
-
                 return SUCCESS;
-
             }
         }
         else
@@ -119,13 +94,7 @@ Error_manager Locate_communicator::locate_request(message::Measure_request_msg&
     return Error_manager(TASK_CANCEL,MINOR_ERROR,"measure request timeout");
 }
 
-//检查消息是否可以被解析, 需要子类重载
-Error_manager Locate_communicator::check_executer(Communication_message* p_msg)
-{
-    return SUCCESS;
-}
-
-Error_manager Locate_communicator::check_statu(int terminal_id)
+Error_manager Measure_excutor::check_statu(int terminal_id)
 {
     if(m_measure_statu_msg_map.find(terminal_id)==false || m_statu_recv_time_map.find(terminal_id)==false)
         return Error_manager(FAILED,MINOR_ERROR,"测量节点状态不存在");
@@ -152,29 +121,8 @@ Error_manager Locate_communicator::check_statu(int terminal_id)
     return SUCCESS;
 }
 
-//检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
-Error_manager Locate_communicator::check_msg(Communication_message*  p_msg)
-{
-    //通过 p_msg->get_message_type() 和 p_msg->get_receiver() 判断这条消息是不是给我的.
-    //子类重载时, 增加自己模块的判断逻辑, 以后再写.
-    if ( (p_msg->get_message_type() == Communication_message::Message_type::eLocate_response_msg
-        ||p_msg->get_message_type() == Communication_message::Message_type::eLocate_status_msg)
-         && p_msg->get_receiver() == Communication_message::Communicator::eMain )
-    {
-        return Error_code::SUCCESS;
-    }
-    else
-    {
-        //认为接受人
-        return Error_code::INVALID_MESSAGE;
-    }
-}
-
-Error_manager Locate_communicator::encapsulate_send_data(){
-    return SUCCESS;
-}
 
-Error_manager Locate_communicator::execute_msg(Communication_message* p_msg)
+Error_manager Measure_excutor::consume_msg(Communication_message* p_msg)
 {
     if(p_msg== nullptr)
         return Error_manager(POINTER_IS_NULL,CRITICAL_ERROR,"measure response msg pointer is null");
@@ -211,7 +159,7 @@ Error_manager Locate_communicator::execute_msg(Communication_message* p_msg)
 
 }
 
-Error_manager Locate_communicator::cancel_request(message::Measure_request_msg& request)
+Error_manager Measure_excutor::cancel_request(message::Measure_request_msg& request)
 {
     if(m_response_table.find(request.command_key())==true)
         m_response_table.erase(request.command_key());

+ 7 - 22
lidar_locate/Locate_communicator.h

@@ -7,25 +7,23 @@
 
 
 #include <mutex>
-#include "communication_socket_base.h"
-#include "singleton.h"
-
+#include "message_communicator.h"
 #include "measure_message.pb.h"
-#include "error_code.h"
-
 #include "thread_safe_map.h"
+
 /*
  * 注册消息的比较函数,用于重载==与<符号,使其可以用作map中的key
  */
 
 
-class Locate_communicator: public Singleton<Locate_communicator>, public Communication_socket_base
+class Measure_excutor: public Singleton<Measure_excutor>
 {
-    friend Singleton<Locate_communicator>;
+    friend Singleton<Measure_excutor>;
 public:
-    virtual ~Locate_communicator();
+    virtual ~Measure_excutor();
     Error_manager locate_request(message::Measure_request_msg& request,
             message::Measure_response_msg& result,Thread_condition& cancel_condition);
+    Error_manager consume_msg(Communication_message* p_msg);
     /*
      * 提前取消请求
      */
@@ -33,20 +31,7 @@ public:
     Error_manager check_statu(int terminal_id);
 
 protected:
-    Locate_communicator();
-    virtual Error_manager encapsulate_msg(Communication_message* message);
-    virtual Error_manager execute_msg(Communication_message* p_msg);
-    /*
-     * 检测消息是否可被处理
-     */
-    virtual Error_manager check_msg(Communication_message* p_msg);
-    /*
-     * 心跳发送函数,重载
-     */
-    virtual Error_manager encapsulate_send_data();
-    //检查消息是否可以被解析, 需要重载
-    virtual Error_manager check_executer(Communication_message* p_msg);
-
+    Measure_excutor();
 
 protected:
 

+ 25 - 49
main.cpp

@@ -5,15 +5,16 @@
 #include <iostream>
 #include <glog/logging.h>
 
-#include "system_communicator.h"
-#include "Locate_communicator.h"
+#include "command_accepter.h"
+#include "measure_excutor.h"
 #include "command_manager.h"
 #include "exception_solver.h"
 #include "proto_tool.h"
 #include "pathcreator.h"
 
-#include <Parkspace_communicator.h>
-#include <dispatch_communicator.h>
+#include <parkspace_excutor.h>
+#include <dispatch_excutor.h>
+#include "message_communicator.h"
 //using google::protobuf::io::FileInputStream;
 //using google::protobuf::io::FileOutputStream;
 using google::protobuf::io::ZeroCopyInputStream;
@@ -35,7 +36,6 @@ int main(int argc,char* argv[])
 	    LOG(ERROR)<<code.to_string();
 	    return 0;
     }
-
 	getchar();
 
 	return 0;
@@ -43,59 +43,44 @@ int main(int argc,char* argv[])
 
 Error_manager init_communicators()
 {
+    Error_manager code;
     setting::System_setting system_setting;
     if(! proto_tool::read_proto_param("./setting/system_setting.prototxt",system_setting) )
     {
         return Error_manager(COMMUNICATION_READ_PROTOBUF_ERROR,MINOR_ERROR,
                              "Communication_socket_base read_proto_param  failed");
     }
-    ///初始化故障处理通讯对象
-    if(Exception_solver::get_instance_pointer()== nullptr)
+
+    /*
+     * 初始化通讯模块
+     */
+    if(Message_communicator::get_instance_pointer()== nullptr)
         return FAILED;
     char bind_string[64]={0};
-    sprintf(bind_string,"tcp://%s:%d",system_setting.bind_ip().c_str(),system_setting.exception_handle_port());
-    Exception_solver::get_instance_pointer()->communication_bind(bind_string);
-    Exception_solver::get_instance_pointer()->communication_run();
+    sprintf(bind_string,"tcp://%s:%d",system_setting.bind_ip().c_str(),system_setting.bind_port());
+    Message_communicator::get_instance_pointer()->communication_bind(bind_string);
+
+    ///初始化故障处理对象
+    if(Exception_solver::get_instance_pointer()== nullptr)
+        return FAILED;
 
     ///初始化与终端通讯的对象
-    if(System_communicator::get_instance_pointer()== nullptr)
+    if(Command_accepter::get_instance_pointer()== nullptr)
         return FAILED;
-    memset(bind_string,0,64);
-    sprintf(bind_string,"tcp://%s:%d",system_setting.bind_ip().c_str(),system_setting.terminor_port());
-    System_communicator::get_instance_pointer()->communication_bind(bind_string);
 
-    Error_manager code;
     /*
-     * 初始化各个通讯模块,
+     * 初始化各个模块,
      */
-
-    if(Locate_communicator::get_instance_pointer()== nullptr)
+    if(Measure_excutor::get_instance_pointer()== nullptr)
         return FAILED;
-    sprintf(bind_string,"tcp://%s:%d",system_setting.bind_ip().c_str(),system_setting.measurer_port());
-    code=Locate_communicator::get_instance_pointer()->communication_bind(bind_string);
-    if(code!=SUCCESS)
-    {
-        return code;
-    }
-    Locate_communicator::get_instance_pointer()->communication_run();
 
-    //初始化车位分配通讯模块
-    if(Parkspace_communicator::get_instance_pointer()== nullptr)
+    if(Dispatch_excutor::get_instance_pointer()== nullptr)
+        return FAILED;
+    //初始化车位分配模块
+    if(Parkspace_excutor::get_instance_pointer()== nullptr)
         return FAILED;
-    sprintf(bind_string,"tcp://%s:%d",system_setting.bind_ip().c_str(),system_setting.park_space_port());
-    code=Parkspace_communicator::get_instance_pointer()->communication_bind(bind_string);
-    if(code!=SUCCESS)
-    {
-        return code;
-    }
-    Parkspace_communicator::get_instance_pointer()->communication_run();
 
-    /*
-     * 初始化调度模块
-     */
-    sprintf(bind_string,"tcp://%s:%d",system_setting.bind_ip().c_str(),system_setting.dispatcher_port());
-    Dispatch_communicator::get_instance_pointer()->communication_bind(bind_string);
-    Dispatch_communicator::get_instance_pointer()->communication_run();
+    Message_communicator::get_instance_pointer()->communication_run();
 
     /*
      * 初始化指令执行模块
@@ -104,15 +89,6 @@ Error_manager init_communicators()
         return Error_manager(FAILED,CRITICAL_ERROR,"创建指令执行模块失败");
     code=Command_manager::get_instance_pointer()->init(system_setting);
 
-
-    if(code!=SUCCESS)
-    {
-        return code;
-    }
-    usleep(1000*1000);
-    //运行接收指令通讯块,开始接收指令
-    System_communicator::get_instance_pointer()->communication_run();
-
     LOG(INFO)<<"系统初始化完成 --------------------------------------------- !!!";
     return SUCCESS;
 }

+ 38 - 123
parkspace/Parkspace_communicator.cpp

@@ -2,14 +2,13 @@
 // Created by zx on 2020/7/9.
 //
 
-#include "Parkspace_communicator.h"
+#include "parkspace_excutor.h"
 
-
-Parkspace_communicator::~Parkspace_communicator(){}
+Parkspace_excutor::~Parkspace_excutor(){}
 /*
  * 请求分配车位
  */
-Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocation_request_msg& request,
+Error_manager Parkspace_excutor::alloc_request(message::Parkspace_allocation_request_msg& request,
         message::Parkspace_allocation_response_msg& result,Thread_condition& cancel_condition)
 {
     /*
@@ -21,7 +20,7 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
     if(m_alloc_table.find(request.command_key())==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;
+    int timeout=request.base_info().has_timeout_ms()?request.base_info().timeout_ms():10000;
     //向测量节点发送测量请求,并记录请求
 
     Error_manager code;
@@ -34,9 +33,15 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
     base_msg.set_timeout_ms(timeout);
     message.reset(base_msg,request.SerializeAsString());
 
-    code=encapsulate_msg(&message);
+    m_alloc_table[request.command_key()]=message::Parkspace_allocation_response_msg();
+    //发送请求
+    code= Message_communicator::get_instance_pointer()->send_msg(&message);
     if(code!=SUCCESS)
+    {
+        m_alloc_table.erase(request.command_key());
         return code;
+    }
+
     //循环查询请求是否被处理
     auto start_time=std::chrono::system_clock::now();
     double time=0;
@@ -83,7 +88,7 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
             m_alloc_table.erase(request.command_key());
             return Error_manager(RESPONSE_TIMEOUT,MINOR_ERROR,"parkspace alloc request timeout");
         }
-    }while(cancel_condition.wait_for_ex(std::chrono::milliseconds(1))==false);
+    }while(cancel_condition.wait_for_ex(std::chrono::milliseconds(50))==false);
     //超时,删除记录,返回错误
     m_alloc_table.erase(request.command_key());
     return Error_manager(TASK_CANCEL,MINOR_ERROR,"parkspace alloc request timeout");
@@ -93,7 +98,7 @@ Error_manager Parkspace_communicator::alloc_request(message::Parkspace_allocatio
 /*
  * 查询车辆所在位置请求
  */
-Error_manager Parkspace_communicator::search_request(message::Parkspace_search_request_msg& request,
+Error_manager Parkspace_excutor::search_request(message::Parkspace_search_request_msg& request,
         message::Parkspace_search_response_msg& result,Thread_condition& cancel_condition)
 {
     /*
@@ -118,9 +123,14 @@ Error_manager Parkspace_communicator::search_request(message::Parkspace_search_r
     base_msg.set_timeout_ms(timeout);
     message.reset(base_msg,request.SerializeAsString());
 
-    code=encapsulate_msg(&message);
+    m_search_table[request.command_key()]=message::Parkspace_search_response_msg();
+    //发送请求
+    code= Message_communicator::get_instance_pointer()->send_msg(&message);
     if(code!=SUCCESS)
+    {
+        m_search_table.erase(request.command_key());
         return code;
+    }
     //循环查询请求是否被处理
     auto start_time=std::chrono::system_clock::now();
     double time=0;
@@ -180,7 +190,7 @@ Error_manager Parkspace_communicator::search_request(message::Parkspace_search_r
 /*
  * 释放车位请求(停车失败或者取车完成时调用)
  */
-Error_manager Parkspace_communicator::release_request(message::Parkspace_release_request_msg& request,
+Error_manager Parkspace_excutor::release_request(message::Parkspace_release_request_msg& request,
         message::Parkspace_release_response_msg& result,Thread_condition& cancel_condition)
 {
     /*
@@ -192,7 +202,7 @@ Error_manager Parkspace_communicator::release_request(message::Parkspace_release
     if(m_release_table.find(request.command_key())==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;
+    int timeout=request.base_info().has_timeout_ms()?request.base_info().timeout_ms():3000;
     //向测量节点发送测量请求,并记录请求
 
     Error_manager code;
@@ -205,9 +215,14 @@ Error_manager Parkspace_communicator::release_request(message::Parkspace_release
     base_msg.set_timeout_ms(timeout);
     message.reset(base_msg,request.SerializeAsString());
 
-    code=encapsulate_msg(&message);
+    m_release_table[request.command_key()]=message::Parkspace_release_response_msg();
+    //发送请求
+    code= Message_communicator::get_instance_pointer()->send_msg(&message);
     if(code!=SUCCESS)
+    {
+        m_release_table.erase(request.command_key());
         return code;
+    }
     //循环查询请求是否被处理
     auto start_time=std::chrono::system_clock::now();
     double time=0;
@@ -263,7 +278,7 @@ Error_manager Parkspace_communicator::release_request(message::Parkspace_release
 /*
      * 确认占用车位消息
      */
-Error_manager Parkspace_communicator::confirm_request(message::Parkspace_confirm_alloc_request_msg& request,
+Error_manager Parkspace_excutor::confirm_request(message::Parkspace_confirm_alloc_request_msg& request,
         message::Parkspace_confirm_alloc_response_msg& result,Thread_condition& cancel_condition)
 {
     /*
@@ -285,9 +300,14 @@ Error_manager Parkspace_communicator::confirm_request(message::Parkspace_confirm
     Communication_message message;
     message.reset(request.base_info(),request.SerializeAsString());
 
-    code=encapsulate_msg(&message);
+    m_confirm_table[request.command_key()]=message::Parkspace_confirm_alloc_response_msg();
+    //发送请求
+    code= Message_communicator::get_instance_pointer()->send_msg(&message);
     if(code!=SUCCESS)
+    {
+        m_confirm_table.erase(request.command_key());
         return code;
+    }
     //循环查询请求是否被处理
     auto start_time=std::chrono::system_clock::now();
     double time=0;
@@ -341,13 +361,13 @@ Error_manager Parkspace_communicator::confirm_request(message::Parkspace_confirm
     return Error_manager(TASK_CANCEL,MINOR_ERROR,"parkspace confirm request canceled");
 }
 
-Error_manager Parkspace_communicator::check_statu()
+Error_manager Parkspace_excutor::check_statu()
 {
     //return SUCCESS;
     std::chrono::system_clock::time_point time_now=std::chrono::system_clock::now();
     auto durantion=time_now-m_parkspace_statu_time;
     if(m_parkspace_status_msg.has_base_info()== false
-       || durantion>std::chrono::seconds(2))
+       || durantion>std::chrono::seconds(5))
     {
         return Error_manager(ERROR,MINOR_ERROR,"车位管理节点通讯断开");
     }
@@ -357,76 +377,9 @@ Error_manager Parkspace_communicator::check_statu()
 
 
 
-Parkspace_communicator::Parkspace_communicator(){}
+Parkspace_excutor::Parkspace_excutor(){}
 
-Error_manager Parkspace_communicator::encapsulate_msg(Communication_message* message)
-{
-    Error_manager code;
-    switch (message->get_message_type())
-    {
-        case Communication_message::eParkspace_allocation_request_msg:
-        {
-            message::Parkspace_allocation_request_msg request;
-            request.ParseFromString(message->get_message_buf());
-            //记录数据
-            m_alloc_table[request.command_key()]=message::Parkspace_allocation_response_msg();
-            //发送请求
-            code= Communication_socket_base::encapsulate_msg(message);
-            if(code!=SUCCESS)
-            {
-                m_alloc_table.erase(request.command_key());
-            }
-            break;
-        }
-        case Communication_message::eParkspace_search_request_msg:
-        {
-            message::Parkspace_search_request_msg request;
-            request.ParseFromString(message->get_message_buf());
-            //记录数据
-            m_search_table[request.command_key()]=message::Parkspace_search_response_msg();
-            //发送请求
-            code= Communication_socket_base::encapsulate_msg(message);
-            if(code!=SUCCESS)
-            {
-                m_search_table.erase(request.command_key());
-            }
-            break;
-        }
-        case Communication_message::eParkspace_release_request_msg:
-        {
-            message::Parkspace_release_request_msg request;
-            request.ParseFromString(message->get_message_buf());
-            //记录数据
-            m_release_table[request.command_key()]=message::Parkspace_release_response_msg();
-            //发送请求
-            code= Communication_socket_base::encapsulate_msg(message);
-            if(code!=SUCCESS)
-            {
-                m_release_table.erase(request.command_key());
-            }
-            break;
-        }
-        case Communication_message::eParkspace_confirm_alloc_request_msg:
-        {
-            message::Parkspace_confirm_alloc_request_msg request;
-            request.ParseFromString(message->get_message_buf());
-            //记录数据
-            m_confirm_table[request.command_key()]=message::Parkspace_confirm_alloc_response_msg();
-            //发送请求
-            code= Communication_socket_base::encapsulate_msg(message);
-            if(code!=SUCCESS)
-            {
-                m_confirm_table.erase(request.command_key());
-            }
-            break;
-        }
-        default:
-            code= Error_manager(PARKSPACE_REQUEST_MSG_TYPE_ERROR,NEGLIGIBLE_ERROR,"不存在该类型消息的发送处理!!!");
-    }
-    return code;
-
-}
-Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
+Error_manager Parkspace_excutor::consume_msg(Communication_message* p_msg)
 {
     if(p_msg== nullptr)
         return Error_manager(POINTER_IS_NULL,CRITICAL_ERROR,"parkspace response msg pointer is null");
@@ -440,7 +393,6 @@ Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
         {
             message::Parkspace_allocation_response_msg response;
             response.ParseFromString(p_msg->get_message_buf());
-
             ///查询请求表是否存在,并且更新
             if(m_alloc_table.find_update(response.command_key(),response)==false)
             {
@@ -486,7 +438,6 @@ Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
             }
             break;
         }
-            ///测量系统状态
         case Communication_message::eParkspace_allocation_status_msg:
         {
             if(m_parkspace_status_msg.ParseFromString(p_msg->get_message_buf())==false)
@@ -500,39 +451,3 @@ Error_manager Parkspace_communicator::execute_msg(Communication_message* p_msg)
     return SUCCESS;
 
 }
-/*
- * 检测消息类型是否可被处理
- */
-Error_manager Parkspace_communicator::check_msg(Communication_message* p_msg)
-{
-    //通过 p_msg->get_message_type() 和 p_msg->get_receiver() 判断这条消息是不是给我的.
-    //子类重载时, 增加自己模块的判断逻辑, 以后再写.
-    if ( (p_msg->get_message_type() == Communication_message::Message_type::eParkspace_allocation_response_msg
-        ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_search_response_msg
-        ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_release_response_msg
-        ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_allocation_status_msg
-        ||p_msg->get_message_type()==Communication_message::eParkspace_confirm_alloc_response_msg)
-         && p_msg->get_receiver() == Communication_message::Communicator::eMain
-         && p_msg->get_sender() == Communication_message::Communicator::eTable)
-    {
-        return Error_code::SUCCESS;
-    }
-    else
-    {
-        //认为接受人
-        return Error_code::INVALID_MESSAGE;
-    }
-    return SUCCESS;
-}
-/*
- * 心跳发送函数,重载
- */
-Error_manager Parkspace_communicator::encapsulate_send_data()
-{
-    return SUCCESS;
-}
-//检查消息是否可以被解析, 需要重载
-Error_manager Parkspace_communicator::check_executer(Communication_message* p_msg)
-{
-    return SUCCESS;
-}

+ 7 - 20
parkspace/Parkspace_communicator.h

@@ -5,17 +5,17 @@
 #ifndef NNXX_TESTS_PARKSPACE_COMMUNICATOR_H
 #define NNXX_TESTS_PARKSPACE_COMMUNICATOR_H
 
+#include "message_communicator.h"
 #include <parkspace_allocation_message.pb.h>
-#include "communication_socket_base.h"
-#include "singleton.h"
 #include "thread_safe_map.h"
+#include "communication_message.h"
 
 
-class Parkspace_communicator :public Singleton<Parkspace_communicator>, public Communication_socket_base
+class Parkspace_excutor :public Singleton<Parkspace_excutor>
 {
-    friend Singleton<Parkspace_communicator>;
+    friend Singleton<Parkspace_excutor>;
 public:
-    virtual ~Parkspace_communicator();
+    virtual ~Parkspace_excutor();
     /*
      * 请求分配车位
      */
@@ -40,24 +40,11 @@ public:
     Error_manager confirm_request(message::Parkspace_confirm_alloc_request_msg& request,
             message::Parkspace_confirm_alloc_response_msg& response,Thread_condition& cancel_condition);
 
+    Error_manager consume_msg(Communication_message* p_msg);
     Error_manager check_statu();
 
 protected:
-    Parkspace_communicator();
-    virtual Error_manager encapsulate_msg(Communication_message* message);
-    virtual Error_manager execute_msg(Communication_message* p_msg);
-    /*
-     * 检测消息是否可被处理
-     */
-    virtual Error_manager check_msg(Communication_message* p_msg);
-    /*
-     * 心跳发送函数,重载
-     */
-    virtual Error_manager encapsulate_send_data();
-    //检查消息是否可以被解析, 需要重载
-    virtual Error_manager check_executer(Communication_message* p_msg);
-
-
+    Parkspace_excutor();
 
 protected:
     thread_safe_map<std::string,message::Parkspace_allocation_response_msg>         m_alloc_table;

+ 57 - 21
system/PickupProcessTask.cpp

@@ -2,12 +2,12 @@
 // Created by zx on 2020/7/7.
 //
 
-#include <Parkspace_communicator.h>
+#include <parkspace_excutor.h>
 #include <dispatch_message.pb.h>
 #include "PickupProcessTask.h"
 #include "process_message.pb.h"
 #include "command_manager.h"
-#include "system_communicator.h"
+#include "command_accepter.h"
 #include "exception_solver.h"
 #include "uniq_key.h"
 
@@ -56,13 +56,31 @@ void PickupProcessTask::reset_recv_msg()
     m_search_response_msg=message::Parkspace_search_response_msg();
     m_dispatch_request_msg=message::Dispatch_request_msg();
     m_dispatch_response_msg=message::Dispatch_response_msg();
+    m_command_response_msg=message::Pickup_command_response_msg();
 }
 
 /*
  * 查询车位
  */
-Error_manager PickupProcessTask::search_space()
+Error_manager PickupProcessTask::search_space_step()
 {
+
+    message::Base_info base_info_response;
+    base_info_response.set_msg_type(message::ePickup_command_response_msg);
+    base_info_response.set_sender(message::eMain);
+    base_info_response.set_receiver(message::eTerminor);
+    m_command_response_msg.mutable_base_info()->CopyFrom(base_info_response);
+    m_command_response_msg.set_terminal_id(m_terminor_id);
+
+    if(Command_manager::get_instance_pointer()->is_paused()==true)
+    {
+        return Error_manager(PAUSE, MINOR_ERROR, "系统已急停");
+    }
+    //
+    if(Command_manager::get_instance_pointer()->export_statu(m_terminor_id)!=Command_manager::Enable) {
+        return Error_manager(ERROR, MINOR_ERROR, "出口已禁止使用 Disable");
+    }
+
     /*
      * 检验汽车信息是否正常
      */
@@ -75,24 +93,24 @@ Error_manager PickupProcessTask::search_space()
     /*
      * 检查车位管理模块是否正常
      */
-    Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
+    Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
     if(code!=SUCCESS)
     {
         return code;
     }
 
-    message::Base_info base_info;
-    base_info.set_msg_type(message::eParkspace_search_request_msg);
-    base_info.set_sender(message::eMain);
-    base_info.set_receiver(message::eParkspace);
-    base_info.set_timeout_ms(1000);
+    message::Base_info base_info_request;
+    base_info_request.set_msg_type(message::eParkspace_search_request_msg);
+    base_info_request.set_sender(message::eMain);
+    base_info_request.set_receiver(message::eParkspace);
+    base_info_request.set_timeout_ms(2000);
 
     message::Parkspace_search_request_msg request;
     request.set_command_key(create_key());
-    request.mutable_base_info()->CopyFrom(base_info);
+    request.mutable_base_info()->CopyFrom(base_info_request);
     request.mutable_car_info()->CopyFrom(m_car_info);
 
-    code = Parkspace_communicator::get_instance_pointer()->search_request(request,
+    code = Parkspace_excutor::get_instance_pointer()->search_request(request,
             m_search_response_msg,m_cancel_condition);
     return code;
 }
@@ -144,9 +162,26 @@ void PickupProcessTask::Main()
 {
     Error_manager code;
     //进入取车流程
-    m_current_step_type = message::eDispatch_step;
     while(is_canceled()==false)
     {
+        //第一步查询
+        if(m_current_step_type==message::eSearch_step)
+        {
+            code=search_space_step();
+            message::Error_manager error_msg;
+            error_msg.set_error_code(code.get_error_code());
+            error_msg.set_error_description(code.get_error_description());
+            m_command_response_msg.mutable_code()->CopyFrom(error_msg);
+            Communication_message msg;
+            msg.reset(m_command_response_msg.base_info(),m_command_response_msg.SerializeAsString());
+            Message_communicator::get_instance_pointer()->send_msg(&msg);
+            LOG_IF(ERROR, code != SUCCESS) << "查询失败,取车终端:"<<m_terminor_id
+                                           <<", 车牌号:"<<m_car_info.license();
+            LOG(WARNING)<<"查询成功:"<<m_terminor_id
+                                 <<", 车牌号:"<<m_car_info.license();
+            m_current_step_type = (code != SUCCESS) ?  message::eBackComplete :  message::eDispatch_step;
+        }
+
         if(m_current_step_type== message::eDispatch_step)
         {
             code=dispatch_step();
@@ -156,7 +191,8 @@ void PickupProcessTask::Main()
                                            <<", 车位楼层:"<<m_search_response_msg.car_position().floor()
                                            <<", 车位序号:"<<m_search_response_msg.car_position().index()
                                            <<", 车牌号:"<<m_car_info.license()
-                                           <<", 库内车牌号:"<<m_search_response_msg.car_position().car_info().license();
+                                           <<", 库内车牌号:"<<m_search_response_msg.car_position().car_info().license()
+                                           <<code.get_error_description();
             m_current_step_type = (code != SUCCESS) ?  message::eBackDispatch_step :  message::eWait_step;
         }
         if(m_current_step_type== message::eWait_step)
@@ -184,7 +220,7 @@ void PickupProcessTask::Main()
         if(m_current_step_type==message::eComplete) {
             //至少发送一次流程完成状态
             updata_step_statu_msg();
-            System_communicator::get_instance_pointer()->post_process_statu(m_process_msg);
+            Command_accepter::get_instance_pointer()->post_process_statu(m_process_msg);
             break;
         }
         if(m_current_step_type== message::eBackWait_step)
@@ -265,7 +301,7 @@ Error_manager PickupProcessTask::dispatch_step()
     }
 
     //2,判断调度节点状态
-    Error_manager code=Dispatch_communicator::get_instance_pointer()->check_export_statu(m_terminor_id);
+    Error_manager code=Dispatch_excutor::get_instance_pointer()->check_export_statu(m_terminor_id);
     if(code!=SUCCESS)
         return code;
 
@@ -286,7 +322,7 @@ Error_manager PickupProcessTask::dispatch_step()
 
 
     message::Dispatch_response_msg response;
-    code=Dispatch_communicator::get_instance_pointer()->dispatch_request(request,response,m_cancel_condition);
+    code=Dispatch_excutor::get_instance_pointer()->dispatch_request(request,response,m_cancel_condition);
     if(code!=SUCCESS)
         return code;
 
@@ -338,7 +374,7 @@ Error_manager PickupProcessTask::release_space_step()
     /*
      * 检查车位管理模块是否正常
      */
-    Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
+    Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
     if(code!=SUCCESS)
         return code;
 
@@ -347,7 +383,7 @@ Error_manager PickupProcessTask::release_space_step()
     base_info.set_msg_type(message::eParkspace_release_request_msg);
     base_info.set_sender(message::eMain);
     base_info.set_receiver(message::eParkspace);
-    base_info.set_timeout_ms(1000); //测量超时1s
+    base_info.set_timeout_ms(5000); //测量超时1s
     request.mutable_base_info()->CopyFrom(base_info);
 
     message::Parkspace_info space_info=m_search_response_msg.car_position();
@@ -357,7 +393,7 @@ Error_manager PickupProcessTask::release_space_step()
 
 
     message::Parkspace_release_response_msg release_response;
-    code=Parkspace_communicator::get_instance_pointer()->release_request(request,release_response,m_cancel_condition);
+    code=Parkspace_excutor::get_instance_pointer()->release_request(request,release_response,m_cancel_condition);
     if(code!=SUCCESS)
         return code;
 
@@ -373,9 +409,9 @@ void PickupProcessTask::publish_step_status() {
     /*
      * 通过communicator 发布状态
      */
-    if (System_communicator::get_instance_pointer()) {
+    if (Command_accepter::get_instance_pointer()) {
         updata_step_statu_msg();
-        System_communicator::get_instance_pointer()->post_process_statu(m_process_msg);
+        Command_accepter::get_instance_pointer()->post_process_statu(m_process_msg);
     }
 }
 

+ 8 - 4
system/PickupProcessTask.h

@@ -8,7 +8,8 @@
 #include "process_message.pb.h"
 #include "error_code.h"
 #include "process_task.h"
-#include "dispatch_communicator.h"
+#include "dispatch_excutor.h"
+#include "terminal_message.pb.h"
 
 class PickupProcessTask :public Process_task{
 
@@ -24,16 +25,18 @@ public:
      */
     virtual Error_manager next_step();
 
+
+protected:
+    virtual void Main();
+
     /*
      * 查询车位
      */
-    Error_manager search_space();
+    Error_manager search_space_step();
     /*
      * 回退查询车位
      */
     Error_manager back_search_space_step();
-protected:
-    virtual void Main();
 
     /*
      * 执行取车动作请求,并等待执行完成
@@ -78,6 +81,7 @@ private:
     message::Parkspace_search_request_msg                   m_search_request_msg;
     message::Parkspace_search_response_msg                  m_search_response_msg;
     //取车调度反馈信息
+    message::Pickup_command_response_msg                    m_command_response_msg;
     message::Dispatch_request_msg                           m_dispatch_request_msg;
     message::Dispatch_response_msg                          m_dispatch_response_msg;
 

+ 62 - 33
system/StoreProcessTask.cpp

@@ -2,13 +2,13 @@
 // Created by zx on 2020/7/7.
 //
 
-#include <Parkspace_communicator.h>
+#include <parkspace_excutor.h>
 #include <dispatch_message.pb.h>
-#include "dispatch_communicator.h"
+#include "dispatch_excutor.h"
 #include "StoreProcessTask.h"
 #include "process_message.pb.h"
 #include "command_manager.h"
-#include "system_communicator.h"
+#include "command_accepter.h"
 #include "exception_solver.h"
 #include "uniq_key.h"
 
@@ -59,7 +59,7 @@ Error_manager StoreProcessTask::init_task(message::Locate_information locate_inf
 Error_manager StoreProcessTask::locate_step() {
     Error_manager code;
     //检查测量模块状态
-    code=Locate_communicator::get_instance_pointer()->check_statu(m_terminor_id);
+    code=Measure_excutor::get_instance_pointer()->check_statu(m_terminor_id);
     if(code!=SUCCESS)
         return code;
 
@@ -73,7 +73,7 @@ Error_manager StoreProcessTask::locate_step() {
     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(m_measure_request_msg,
+    code=Measure_excutor::get_instance_pointer()->locate_request(m_measure_request_msg,
             m_measure_response_msg,m_cancel_condition);
     if(code!=SUCCESS)
         return code;
@@ -139,7 +139,7 @@ Error_manager StoreProcessTask::dispatch_step()
     }
 
     //2,判断调度节点状态
-    code=Dispatch_communicator::get_instance_pointer()->check_entrance_statu(m_terminor_id);
+    code=Dispatch_excutor::get_instance_pointer()->check_entrance_statu(m_terminor_id);
     if(code!=SUCCESS)
         return code;
 
@@ -156,7 +156,7 @@ Error_manager StoreProcessTask::dispatch_step()
     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(m_dispatch_request_msg,
+    code=Dispatch_excutor::get_instance_pointer()->dispatch_request(m_dispatch_request_msg,
             m_dispatch_response_msg,m_cancel_condition);
     if(code!=SUCCESS)
         return code;
@@ -188,48 +188,59 @@ Error_manager StoreProcessTask::back_dispatch_step()
 /*
      * 分配车位
      */
-Error_manager StoreProcessTask::alloc_space()
+Error_manager StoreProcessTask::alloc_space_step()
 {
 
+    message::Base_info base_info_response;
+    base_info_response.set_msg_type(message::eStore_command_response_msg);
+    base_info_response.set_sender(message::eMain);
+    base_info_response.set_receiver(message::eTerminor);
+    m_command_response_msg.mutable_base_info()->CopyFrom(base_info_response);
+    m_command_response_msg.set_terminal_id(m_terminor_id);
+
+    if(Command_manager::get_instance_pointer()->is_paused()==true)
+    {
+        return Error_manager(PAUSE, MINOR_ERROR, "系统已急停");
+    }
+    //
+    if(Command_manager::get_instance_pointer()->entrance_statu(m_terminor_id)!=Command_manager::Enable) {
+        return Error_manager(ERROR, MINOR_ERROR, "入口已禁止使用 Disable");
+    }
+
     /*
      * 检查是否有测量数据
      */
-    m_current_step_type=message::eAlloc_step;
-    updata_step_statu(message::eWorking);
     if(m_locate_info.has_locate_height()==false||m_locate_info.has_locate_width()==false)
     {
-        updata_step_statu(message::eError);
         return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
     }
     /*
      * 检查车位管理模块是否正常
      */
-    Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
+    Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
     if(code!=SUCCESS)
     {
-        updata_step_statu(message::eError);
         return code;
     }
 
     //发送分配请求
-    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
-    m_alloc_request_msg.mutable_base_info()->CopyFrom(base_info);
+    message::Base_info base_info_request;
+    base_info_request.set_msg_type(message::eParkspace_allocation_request_msg);
+    base_info_request.set_sender(message::eMain);
+    base_info_request.set_receiver(message::eParkspace);
+    base_info_request.set_timeout_ms(5000); //超时1s
+    m_alloc_request_msg.mutable_base_info()->CopyFrom(base_info_request);
 
     m_alloc_request_msg.mutable_car_info()->CopyFrom(m_car_info);
 
     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(m_alloc_request_msg,
+    code=Parkspace_excutor::get_instance_pointer()->alloc_request(m_alloc_request_msg,
             m_parcspace_alloc_response_msg,m_cancel_condition);
 
     if(code!=SUCCESS)
     {
-        updata_step_statu(message::eError);
         return code;
     }
 
@@ -240,13 +251,10 @@ Error_manager StoreProcessTask::alloc_space()
         {
             return Error_manager(ERROR,MINOR_ERROR,"分配车位反馈的车辆信息不匹配");
         }
-        updata_step_statu(message::eFinished);
-        //置步骤状态为测量状态.
         return SUCCESS;
     }
     else
     {
-        updata_step_statu(message::eError);
         Error_code  t_code=(Error_code)m_parcspace_alloc_response_msg.error_manager().error_code();
         Error_level t_level=(Error_level)m_parcspace_alloc_response_msg.error_manager().error_level();
         return Error_manager(t_code,t_level,"分配车位反馈结果错误");
@@ -261,7 +269,7 @@ Error_manager StoreProcessTask::confirm_space_step()
     /*
      * 检查车位管理模块是否正常
      */
-    Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
+    Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
     if(code!=SUCCESS)
         return code;
 
@@ -270,7 +278,7 @@ Error_manager StoreProcessTask::confirm_space_step()
     base_info.set_msg_type(message::eParkspace_confirm_alloc_request_msg);
     base_info.set_sender(message::eMain);
     base_info.set_receiver(message::eParkspace);
-    base_info.set_timeout_ms(1000); //测量超时1s
+    base_info.set_timeout_ms(5000); //测量超时1s
     request.mutable_base_info()->CopyFrom(base_info);
 
     message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
@@ -278,7 +286,7 @@ Error_manager StoreProcessTask::confirm_space_step()
     request.set_command_key(create_key());
 
     message::Parkspace_confirm_alloc_response_msg confirm_response;
-    code=Parkspace_communicator::get_instance_pointer()->confirm_request(request,confirm_response,m_cancel_condition);
+    code=Parkspace_excutor::get_instance_pointer()->confirm_request(request,confirm_response,m_cancel_condition);
     if(code!=SUCCESS)
         return code;
 
@@ -324,7 +332,7 @@ Error_manager StoreProcessTask::back_alloc_space_step()
     /*
      * 检查车位管理模块是否正常
      */
-    Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
+    Error_manager code=Parkspace_excutor::get_instance_pointer()->check_statu();
     if(code!=SUCCESS)
         return Error_manager(code.get_error_code(),CRITICAL_ERROR,code.get_error_description());
 
@@ -333,7 +341,7 @@ Error_manager StoreProcessTask::back_alloc_space_step()
     base_info.set_msg_type(message::eParkspace_release_request_msg);
     base_info.set_sender(message::eMain);
     base_info.set_receiver(message::eParkspace);
-    base_info.set_timeout_ms(1000); //测量超时1s
+    base_info.set_timeout_ms(5000); //测量超时1s
     request.mutable_base_info()->CopyFrom(base_info);
 
     message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
@@ -341,7 +349,7 @@ Error_manager StoreProcessTask::back_alloc_space_step()
     request.set_command_key(create_key());
 
     message::Parkspace_release_response_msg release_response;
-    code=Parkspace_communicator::get_instance_pointer()->release_request(request,release_response,m_cancel_condition);
+    code=Parkspace_excutor::get_instance_pointer()->release_request(request,release_response,m_cancel_condition);
     if(code!=SUCCESS)
         return Error_manager(code.get_error_code(),CRITICAL_ERROR,code.get_error_description());
 
@@ -421,7 +429,25 @@ void StoreProcessTask::Main()
     //开始执行停车指令
     while(is_canceled()==false)
     {
-        //第一步,测量
+        //第一步分配车位
+        if(m_current_step_type == message::eAlloc_step)
+        {
+            updata_step_statu(message::eWorking);
+            code=alloc_space_step();
+            //发送反馈
+            message::Error_manager error_msg;
+            error_msg.set_error_code(code.get_error_code());
+            error_msg.set_error_description(code.get_error_description());
+            m_command_response_msg.mutable_code()->CopyFrom(error_msg);
+            Communication_message msg;
+            msg.reset(m_command_response_msg.base_info(),m_command_response_msg.SerializeAsString());
+            Message_communicator::get_instance_pointer()->send_msg(&msg);
+
+            code!=SUCCESS?updata_step_statu(message::eError):updata_step_statu(message::eFinished);
+            LOG_IF(ERROR, code != SUCCESS) << "分配失败:" <<m_car_info.license()<< code.get_error_description();
+        }
+
+        //第二步,测量
         if (m_current_step_type ==  message::eMeasure_step)
         {
             //开始定位
@@ -579,9 +605,9 @@ void StoreProcessTask::publish_step_status() {
     /*
      * 通过communicator 发布状态
      */
-    if (System_communicator::get_instance_pointer()) {
+    if (Command_accepter::get_instance_pointer()) {
         std::lock_guard<std::mutex> lock(m_process_msg_lock);
-        System_communicator::get_instance_pointer()->post_process_statu(m_process_msg);
+        Command_accepter::get_instance_pointer()->post_process_statu(m_process_msg);
     }
 }
 
@@ -685,11 +711,14 @@ void StoreProcessTask::updata_step_statu(message::Step_statu statu)
      */
 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_command_response_msg=message::Store_command_response_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(); //分配的车位数据

+ 14 - 12
system/StoreProcessTask.h

@@ -6,9 +6,10 @@
 #define NNXX_TESTS_STOREPROCESS_H
 
 #include <parkspace_allocation_message.pb.h>
-#include "dispatch_communicator.h"
+#include <terminal_message.pb.h>
+#include "dispatch_excutor.h"
 #include "process_task.h"
-#include "Locate_communicator.h"
+#include "measure_excutor.h"
 #include "process_message.pb.h"
 
 class StoreProcessTask :public Process_task{
@@ -18,16 +19,6 @@ public:
     virtual  ~StoreProcessTask();
     Error_manager init_task(message::Locate_information locate_info);
 
-    /*
-     * 分配车位
-     */
-    Error_manager alloc_space();
-
-    /*
-     * 回退分配车位
-     */
-    Error_manager back_alloc_space_step();
-
     /*
      * 获取任务类型
      */
@@ -42,6 +33,16 @@ public:
 protected:
     virtual void Main();
 
+    /*
+     * 分配车位
+     */
+    Error_manager alloc_space_step();
+
+    /*
+     * 回退分配车位
+     */
+    Error_manager back_alloc_space_step();
+
     /*
      * 定位
      */
@@ -98,6 +99,7 @@ protected:
     message::Parkspace_confirm_alloc_request_msg    m_confirm_request_msg;
 
     //停车请求发送过来的测量数据,终端位置的测量数据
+    message::Store_command_response_msg             m_command_response_msg;         //发送给终端的停车反馈
     message::Measure_response_msg                   m_measure_response_msg;         //测量模块的测量数据
     message::Parkspace_allocation_response_msg      m_parcspace_alloc_response_msg; //分配的车位数据
     message::Dispatch_response_msg                  m_dispatch_response_msg;        //调度模块的反馈数据

+ 12 - 54
system/system_communicator.cpp

@@ -2,75 +2,44 @@
 // Created by huli on 2020/6/28.
 //
 
-#include "system_communicator.h"
+#include "command_accepter.h"
 #include "command_manager.h"
-
-System_communicator::System_communicator()
-{
-}
-
-System_communicator::~System_communicator()
+Command_accepter::Command_accepter()
 {
-
 }
 
-//定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
-Error_manager System_communicator::encapsulate_send_data()
+Command_accepter::~Command_accepter()
 {
 
-	return Error_code::SUCCESS;
 }
 
 //发送停车流程进度
-Error_manager System_communicator::post_process_statu(message::Storing_process_statu_msg& msg)
+Error_manager Command_accepter::post_process_statu(message::Storing_process_statu_msg& msg)
 {
     Communication_message message;
     message.reset(msg.base_info(),msg.SerializeAsString());
-    return encapsulate_msg(&message);
+    return Message_communicator::get_instance_pointer()->send_msg(&message);
 }
 //发送取车流程进度
-Error_manager System_communicator::post_process_statu(message::Picking_process_statu_msg& msg)
+Error_manager Command_accepter::post_process_statu(message::Picking_process_statu_msg& msg)
 {
     Communication_message message;
     message.reset(msg.base_info(),msg.SerializeAsString());
-    return encapsulate_msg(&message);
+    return Message_communicator::get_instance_pointer()->send_msg(&message);
 }
 
 //发送中控状态消息
-Error_manager System_communicator::post_central_statu(message::Central_controller_statu_msg& msg)
+Error_manager Command_accepter::post_central_statu(message::Central_controller_statu_msg& msg)
 {
     Communication_message message;
     message.reset(msg.base_info(),msg.SerializeAsString());
-    return encapsulate_msg(&message);
-}
-
-/*
- * 发送消息函数
- */
-Error_manager System_communicator::encapsulate_msg(Communication_message* message)
-{
-    return Communication_socket_base::encapsulate_msg(message);
-}
-
-/*
- * 检测消息是否合法
- */
-Error_manager System_communicator::check_msg(Communication_message* p_msg)
-{
-
-    return SUCCESS;
-}
-
-//检查消息是否可以被处理, 需要重载
-Error_manager System_communicator::check_executer(Communication_message* p_msg)
-{
-    return SUCCESS;
+    return Message_communicator::get_instance_pointer()->send_msg(&message);
 }
 
 /*
  * 处理接收到的消息
  */
-Error_manager System_communicator::execute_msg(Communication_message* p_msg)
+Error_manager Command_accepter::consume_msg(Communication_message* p_msg)
 {
     /*
      * 接收终端指令, 生成流程
@@ -90,15 +59,9 @@ Error_manager System_communicator::execute_msg(Communication_message* p_msg)
                     //严重错误
                     return Error_manager(INVALID_MESSAGE,MAJOR_ERROR,"停车请求消息解析失败");
                 }
-                message::Store_command_response_msg response;
 
-                code=Command_manager::get_instance_pointer()->execute_store_command(request,response);
+                code=Command_manager::get_instance_pointer()->execute_store_command(request);
                 LOG_IF(ERROR,code!=SUCCESS)<<code.get_error_description();
-                Communication_message send_response;
-                send_response.reset(response.base_info(),response.SerializeAsString());
-                //发送反馈
-                encapsulate_msg(&send_response);
-
             }
             break;
         }
@@ -114,13 +77,8 @@ Error_manager System_communicator::execute_msg(Communication_message* p_msg)
                 }
                 message::Pickup_command_response_msg response;
                 //调用请求回调,无需判断返回值,错误信息保存在response中
-                code=Command_manager::get_instance_pointer()->execute_pickup_command(request,response);
+                code=Command_manager::get_instance_pointer()->execute_pickup_command(request);
                 LOG_IF(ERROR,code!=SUCCESS)<<code.get_error_description();
-                Communication_message send_response;
-                send_response.reset(response.base_info(),response.SerializeAsString());
-                //发送反馈
-                encapsulate_msg(&send_response);
-
             }
             break;
         }

+ 45 - 0
system/command_accepter.h

@@ -0,0 +1,45 @@
+//
+// Created by huli on 2020/6/28.
+//
+
+#ifndef NNXX_TESTS_SYSTEM_COMMUNICATION_H
+#define NNXX_TESTS_SYSTEM_COMMUNICATION_H
+
+#include "message_communicator.h"
+#include <process_message.pb.h>
+#include <central_control_message.pb.h>
+#include "terminal_message.pb.h"
+
+/*typedef Error_manager (*StoreCommandCallback)(message::Store_command_request_msg& msg,message::Store_command_response_msg& response);
+typedef Error_manager (*PickupCommandCallback)(message::Pickup_command_request_msg& msg,message::Pickup_command_response_msg& response);*/
+
+class Command_accepter:public Singleton<Command_accepter>
+{
+// 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
+   friend class Singleton<Command_accepter>;
+private:
+    // 父类的构造函数必须保护,子类的构造函数必须私有。
+    Command_accepter();
+public:
+    //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
+    Command_accepter(const Command_accepter& other) = delete;
+    Command_accepter& operator =(const Command_accepter& other) = delete;
+
+    /*
+     * 发送中控状态消息, 出入口状态消息
+     */
+    Error_manager post_process_statu(message::Storing_process_statu_msg& msg);
+    Error_manager post_process_statu(message::Picking_process_statu_msg& msg);
+    Error_manager post_central_statu(message::Central_controller_statu_msg& msg);
+
+    /*
+     * 消费消息
+     */
+    Error_manager consume_msg(Communication_message* p_msg);
+
+    ~Command_accepter();
+
+};
+
+
+#endif //NNXX_TESTS_SYSTEM_COMMUNICATION_H

+ 84 - 120
system/command_manager.cpp

@@ -4,11 +4,11 @@
 
 #include <sstream>
 #include <iomanip>
-#include <Parkspace_communicator.h>
+#include <parkspace_excutor.h>
 #include "command_manager.h"
 #include "StoreProcessTask.h"
 #include "PickupProcessTask.h"
-#include "system_communicator.h"
+#include "command_accepter.h"
 
 Command_manager::Command_manager()
     :m_thread_queue_process(nullptr)
@@ -75,7 +75,7 @@ Error_manager Command_manager::init(setting::System_setting system_setting) {
     do
     {
         if (parkspace_code != SUCCESS) {
-            parkspace_code = Parkspace_communicator::get_instance_pointer()->check_statu();
+            parkspace_code = Parkspace_excutor::get_instance_pointer()->check_statu();
             LOG_IF(INFO, parkspace_code == SUCCESS) << "车位管理模块初始化完成!!!";
         }
         if(parkspace_code==SUCCESS)
@@ -100,11 +100,11 @@ Error_manager Command_manager::init(setting::System_setting system_setting) {
         Error_manager locate_code=ERROR,dispatch_code=ERROR;
         do {
             if (locate_code != SUCCESS) {
-                locate_code = Locate_communicator::get_instance_pointer()->check_statu(i);
+                locate_code = Measure_excutor::get_instance_pointer()->check_statu(i);
                 LOG_IF(INFO, locate_code == SUCCESS) << "停车入口:"<<i<<" 测量模块初始化完成!!!";
             }
             if (dispatch_code != SUCCESS) {
-                dispatch_code = Dispatch_communicator::get_instance_pointer()->check_entrance_statu(i);
+                dispatch_code = Dispatch_excutor::get_instance_pointer()->check_entrance_statu(i);
                 LOG_IF(INFO, dispatch_code == SUCCESS) << "停车入口:"<<i<<" 调度模块初始化完成!!!";
             }
 
@@ -127,7 +127,7 @@ Error_manager Command_manager::init(setting::System_setting system_setting) {
         Error_manager dispatch_code=ERROR;
         do {
             if (dispatch_code != SUCCESS) {
-                dispatch_code = Dispatch_communicator::get_instance_pointer()->check_export_statu(i);
+                dispatch_code = Dispatch_excutor::get_instance_pointer()->check_export_statu(i);
                 LOG_IF(INFO, dispatch_code == SUCCESS) << "取车出口:" << i << " 调度模块初始化完成!!!";
             }
 
@@ -161,129 +161,78 @@ Error_manager Command_manager::init(setting::System_setting system_setting) {
  * 执行停车请求
  */
 
-Error_manager Command_manager::execute_store_command(message::Store_command_request_msg& request,message::Store_command_response_msg& response)
+Error_manager Command_manager::execute_store_command(message::Store_command_request_msg& request)
 {
-    message::Base_info base_info;
-    base_info.set_msg_type(message::eStore_command_response_msg);
-    base_info.set_sender(message::eMain);
-    base_info.set_receiver(message::eTerminor);
-    response.mutable_base_info()->CopyFrom(base_info);
-    response.set_terminal_id(request.terminal_id());
-
     message::Error_manager error_msg;
-    error_msg.set_error_code(0);
-
-    if (m_thread_queue_process == nullptr) {
-        error_msg.set_error_code(ERROR);
-        error_msg.set_error_description("bug,线程池未初始化");
-        response.mutable_code()->CopyFrom(error_msg);
-        return Error_manager(ERROR, MINOR_ERROR, "线程池未初始化,bug");
-    }
-
-    if(m_system_paused==true)
-    {
-        error_msg.set_error_code(PAUSE);
-        error_msg.set_error_description("急停");
-        response.mutable_code()->CopyFrom(error_msg);
-        return Error_manager(PAUSE, MINOR_ERROR, "系统已急停");
-    }
 
-    //判断入口是否开放
-    if(request.terminal_id()<0 || request.terminal_id()>=m_system_setting.entrance_num())
-    {
-        error_msg.set_error_code(ERROR);
-        error_msg.set_error_description("terminal_id 参数设置错误");
-        response.mutable_code()->CopyFrom(error_msg);
-        return Error_manager(ERROR, MINOR_ERROR, "terminal id 设置错误");
-    }
-    if(m_input_entrance_statu[request.terminal_id()]!=Enable) {
-        error_msg.set_error_code(ERROR);
-        error_msg.set_error_description("入口已关闭 Disable");
-        response.mutable_code()->CopyFrom(error_msg);
-        return Error_manager(ERROR, MINOR_ERROR, "入口已禁止使用 Disable");
-    }
+    message::Store_command_response_msg response;
+    message::Base_info base_info_response;
+    base_info_response.set_msg_type(message::eStore_command_response_msg);
+    base_info_response.set_sender(message::eMain);
+    base_info_response.set_receiver(message::eTerminor);
+    response.mutable_base_info()->CopyFrom(base_info_response);
+    response.set_terminal_id(request.terminal_id());
 
+    Error_manager code;
     if (request.base_info().msg_type() == message::eStore_command_request_msg
         && request.base_info().receiver() == message::eMain
-        && request.base_info().sender() == message::eTerminor)
-    {
-        if (request.has_locate_information() && request.has_base_info())
-        {
+        && request.base_info().sender() == message::eTerminor) {
+        if (request.has_locate_information() && request.has_base_info()) {
             message::Locate_information locate_info = request.locate_information();
-            if (locate_info.has_locate_correct())
-            {
-                if (locate_info.locate_correct() == true)
-                {
+            if (locate_info.has_locate_correct()) {
+                if (locate_info.locate_correct() == true) {
                     if (locate_info.has_locate_width() && locate_info.has_locate_height()
                         && locate_info.has_locate_x() && locate_info.has_locate_y()
-                        && locate_info.has_locate_angle() && locate_info.has_locate_wheel_base())
-                    {
+                        && locate_info.has_locate_angle() && locate_info.has_locate_wheel_base()) {
+
                         /*
                          * 检查消息完毕,开始处理
                          */
 
-                        response.set_terminal_id(request.terminal_id());
-
-                        /*
-                        * 检查各个节点是否正常
-                        */
-                        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());
-                            error_msg.set_error_description(parkspace_code.get_error_description());
-                            response.mutable_code()->CopyFrom(error_msg);
-                            return parkspace_code;
-                        }
-                        Error_manager locate_code= Locate_communicator::get_instance_pointer()->check_statu(request.terminal_id());
-                        if(locate_code!=SUCCESS)
-                        {
-                            error_msg.set_error_code(locate_code.get_error_code());
-                            error_msg.set_error_description(locate_code.get_error_description());
-                            response.mutable_code()->CopyFrom(error_msg);
-                            return locate_code;
-                        }
-                        Error_manager dispatch_code= Dispatch_communicator::get_instance_pointer()->check_entrance_statu(request.terminal_id());
-                        if(dispatch_code!=SUCCESS)
-                        {
-                            error_msg.set_error_code(dispatch_code.get_error_code());
-                            error_msg.set_error_description(dispatch_code.get_error_description());
-                            response.mutable_code()->CopyFrom(error_msg);
-                            return dispatch_code;
-                        }
-
-                        LOG(INFO) << "收到停车,车牌:"<< request.car_info().license() <<
-                                  ",终端:" << request.terminal_id()<<"............................";
-                        Process_task *ptask = new StoreProcessTask(request.terminal_id(),request.car_info());
+                        LOG(INFO) << "收到停车,车牌:" << request.car_info().license() <<
+                                  ",终端:" << request.terminal_id() << "............................";
+                        Process_task *ptask = new StoreProcessTask(request.terminal_id(), request.car_info());
                         StoreProcessTask *pStore_task = (StoreProcessTask *) ptask;
                         //初始化流程
-                        pStore_task->init_task(locate_info);
-
-                        //获取车位
-                        Error_manager code = pStore_task->alloc_space();
-                        if (code == SUCCESS) {
-                            pStore_task->next_step();
-                            m_thread_queue_process->AddTask(pStore_task);
+                        code = pStore_task->init_task(locate_info);
+                        if (code != SUCCESS) {
+                            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);
-                            return SUCCESS;
+                            LOG(ERROR) << "创建停车流程失败(车位分配失败),终端:" << request.terminal_id() <<
+                                       "车牌:" << request.car_info().license() << "  " << code.to_string();
 
+                            Communication_message msg;
+                            msg.reset(response.base_info(), response.SerializeAsString());
+                            Message_communicator::get_instance_pointer()->send_msg(&msg);
+                            return code;
                         }
-                        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);
-                        LOG(ERROR) << "创建停车流程失败(车位分配失败),终端:" << request.terminal_id() <<
-                                   "车牌:" << request.car_info().license() << "  " << code.to_string();
-                        return code;
+                        m_thread_queue_process->AddTask(pStore_task);
+                        return SUCCESS;
 
                     }
                 }
             }
 
         }
+        error_msg.set_error_code(FAILED);
+        error_msg.set_error_description("创建停车流程失败...指令缺少必要信息...");
+        response.mutable_code()->CopyFrom(error_msg);
+
+        Communication_message msg;
+        msg.reset(response.base_info(), response.SerializeAsString());
+        Message_communicator::get_instance_pointer()->send_msg(&msg);
+
         return Error_manager(FAILED, MINOR_ERROR, "创建停车流程失败...指令缺少必要信息...");
     } else {
+        error_msg.set_error_code(INVALID_MESSAGE);
+        error_msg.set_error_description("停车请求基本信息错误");
+        response.mutable_code()->CopyFrom(error_msg);
+
+        Communication_message msg;
+        msg.reset(response.base_info(),response.SerializeAsString());
+        Message_communicator::get_instance_pointer()->send_msg(&msg);
         return Error_manager(INVALID_MESSAGE, MAJOR_ERROR, "停车请求基本信息错误");
     }
 }
@@ -292,19 +241,18 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
 /*
  * 执行取车请求
  */
-Error_manager Command_manager::execute_pickup_command(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response)
+Error_manager Command_manager::execute_pickup_command(message::Pickup_command_request_msg& request)
 {
+    message::Error_manager error_msg;
+    message::Pickup_command_response_msg response;
 
-    message::Base_info base_info;
-    base_info.set_msg_type(message::ePickup_command_response_msg);
-    base_info.set_sender(message::eMain);
-    base_info.set_receiver(message::eTerminor);
-    response.mutable_base_info()->CopyFrom(base_info);
+    message::Base_info base_info_response;
+    base_info_response.set_msg_type(message::ePickup_command_response_msg);
+    base_info_response.set_sender(message::eMain);
+    base_info_response.set_receiver(message::eTerminor);
+    response.mutable_base_info()->CopyFrom(base_info_response);
     response.set_terminal_id(request.terminal_id());
 
-    message::Error_manager error_msg;
-    error_msg.set_error_code(0);
-
     if (m_thread_queue_process == nullptr) {
         error_msg.set_error_code(ERROR);
         error_msg.set_error_description("bug,线程池未初始化");
@@ -347,7 +295,7 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
         /*
         * 检查各个节点是否正常
         */
-        Error_manager parkspace_code= Parkspace_communicator::get_instance_pointer()->check_statu();
+        Error_manager parkspace_code= Parkspace_excutor::get_instance_pointer()->check_statu();
         if(parkspace_code!=SUCCESS)
         {
             error_msg.set_error_code(parkspace_code.get_error_code());
@@ -356,7 +304,7 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
             return parkspace_code;
         }
 
-        Error_manager dispatch_code= Dispatch_communicator::get_instance_pointer()->check_export_statu(request.terminal_id());
+        Error_manager dispatch_code= Dispatch_excutor::get_instance_pointer()->check_export_statu(request.terminal_id());
         if(dispatch_code!=SUCCESS)
         {
             error_msg.set_error_code(dispatch_code.get_error_code());
@@ -372,14 +320,10 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
         PickupProcessTask* pPick_task=(PickupProcessTask*)ptask;
         //初始化流程
         code=pPick_task->init_task();
-        /////查询车位
-        code=pPick_task->search_space();
 
         if(code==SUCCESS)
         {
-            pPick_task->next_step();
             m_thread_queue_process->AddTask(pPick_task);
-            response.mutable_code()->CopyFrom(error_msg);
             return SUCCESS;
         }
         usleep(1000*1000);
@@ -389,10 +333,19 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
         LOG(ERROR)<<"创建取车流程失败(车位查询失败),终端:"<<request.terminal_id()<<
                   "车牌:"<<request.car_info().license()<<"  "<<code.to_string();
         delete pPick_task;
+        Communication_message msg;
+        msg.reset(response.base_info(),response.SerializeAsString());
+        Message_communicator::get_instance_pointer()->send_msg(&msg);
         return code;
     }
     else
     {
+        error_msg.set_error_code(INVALID_MESSAGE);
+        error_msg.set_error_description("停车请求信息错误");
+        response.mutable_code()->CopyFrom(error_msg);
+        Communication_message msg;
+        msg.reset(response.base_info(),response.SerializeAsString());
+        Message_communicator::get_instance_pointer()->send_msg(&msg);
         return Error_manager(INVALID_MESSAGE,MAJOR_ERROR,"停车请求信息错误");
     }
 }
@@ -408,6 +361,18 @@ Error_manager Command_manager::enable_entrance(int terminal_id,Entrance_statu st
     return SUCCESS;
 }
 
+Command_manager::Entrance_statu Command_manager::entrance_statu(int terminal_id)
+{
+    if(terminal_id<0 || terminal_id>=m_system_setting.entrance_num())
+        return Disable;
+    return m_input_entrance_statu[terminal_id];
+}
+Command_manager::Entrance_statu Command_manager::export_statu(int terminal_id)
+{
+    if(terminal_id<0 || terminal_id>=m_system_setting.export_num())
+        return Disable;
+    return m_output_entrance_statu[terminal_id];
+}
 /*
  * 控制出口 开放或者关闭
  */
@@ -455,7 +420,6 @@ void Command_manager::publish_statu()
             entrance_statu=message::Entrance_statu (m_input_entrance_statu[i]);
             msg.add_export_statu_vector(entrance_statu);
         }
-
-        System_communicator::get_instance_pointer()->post_central_statu(msg);
+        Command_accepter::get_instance_pointer()->post_central_statu(msg);
     }
 }

+ 12 - 2
system/command_manager.h

@@ -40,17 +40,22 @@ public:
     /*
      * 执行停车请求
      */
-    Error_manager execute_store_command(message::Store_command_request_msg& request,message::Store_command_response_msg& response);
+    Error_manager execute_store_command(message::Store_command_request_msg& request);
 
     /*
      * 执行取车请求
      */
-    Error_manager execute_pickup_command(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response);
+    Error_manager execute_pickup_command(message::Pickup_command_request_msg& request);
 
     /*
      * 控制入口 开放或者关闭
      */
     Error_manager enable_entrance(int terminal_id,Entrance_statu statu);
+    /*
+     * 获取出入口状态
+     */
+    Entrance_statu entrance_statu(int terminal_id);
+    Entrance_statu export_statu(int terminal_id);
 
     /*
      * 控制出口 开放或者关闭
@@ -62,6 +67,11 @@ public:
      */
     void pause_system();
 
+    /*
+     * 系统是否急停
+     */
+    bool is_paused(){return m_system_paused;}
+
 private:
     Command_manager();
 

+ 151 - 0
system/message_communicator.cpp

@@ -0,0 +1,151 @@
+//
+// Created by zx on 2020/8/28.
+//
+
+#include "message_communicator.h"
+#include "measure_excutor.h"
+#include "exception_solver.h"
+#include "dispatch_excutor.h"
+#include "parkspace_excutor.h"
+#include "command_accepter.h"
+
+Message_communicator::Message_communicator()
+{
+}
+
+Message_communicator::~Message_communicator()
+{
+}
+/*
+     * 发送消息
+     */
+Error_manager Message_communicator::send_msg(Communication_message* p_msg)
+{
+    return Communication_socket_base::encapsulate_msg(p_msg);
+}
+
+//定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
+Error_manager Message_communicator::encapsulate_send_data()
+{
+    return Error_code::SUCCESS;
+}
+
+/*
+ * 检测消息是否合法
+ */
+Error_manager Message_communicator::check_msg(Communication_message* p_msg)
+{
+    if ( (p_msg->get_receiver() == Communication_message::Communicator::eMain) &&
+         (p_msg->get_message_type() == Communication_message::Message_type::eDispatch_response_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eDispatch_status_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eStore_command_request_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::ePickup_command_request_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_allocation_response_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_search_response_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_release_response_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_confirm_alloc_response_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eParkspace_allocation_status_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eLocate_response_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eLocate_status_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eProcess_manual_operation_msg
+          ||p_msg->get_message_type() == Communication_message::Message_type::eEntrance_manual_operation_msg))
+    {
+        return Error_code::SUCCESS;
+    }
+    return Error_code::INVALID_MESSAGE;
+}
+
+//检查消息是否可以被处理, 需要重载
+Error_manager Message_communicator::check_executer(Communication_message* p_msg)
+{
+    return SUCCESS;
+}
+
+/*
+ * 处理接收到的消息
+ */
+Error_manager Message_communicator::execute_msg(Communication_message* p_msg)
+{
+    /*
+     * 接收终端指令, 生成流程
+     */
+    Error_manager code;
+
+    switch(p_msg->get_message_type())
+    {
+        //终端消息
+        case Communication_message::eStore_command_request_msg:
+        {
+            Command_accepter::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        case Communication_message::ePickup_command_request_msg:
+        {
+            Command_accepter::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+
+            ///搬运结果反馈消息
+        case Communication_message::eDispatch_response_msg:
+        {
+            Dispatch_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        case Communication_message::eDispatch_status_msg:
+        {
+            Dispatch_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        /////  车位分配模块的消息
+        case Communication_message::eParkspace_allocation_response_msg:
+        {
+            Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        case Communication_message::eParkspace_search_response_msg:
+        {
+            Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        case Communication_message::eParkspace_release_response_msg:
+        {
+            Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        case Communication_message::eParkspace_confirm_alloc_response_msg:
+        {
+            Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        case Communication_message::eParkspace_allocation_status_msg:
+        {
+            Parkspace_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+            ///测量结果反馈消息
+        case Communication_message::eLocate_response_msg:
+        {
+            Measure_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+            //测量系统状态
+        case Communication_message::eLocate_status_msg:
+        {
+            Measure_excutor::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+            //异常处理,手动操作
+        case Communication_message::eProcess_manual_operation_msg:
+        {
+            Exception_solver::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        case Communication_message::eEntrance_manual_operation_msg:
+        {
+            Exception_solver::get_instance_pointer()->consume_msg(p_msg);
+            break;
+        }
+        default:break;
+    }
+    return SUCCESS;
+}

+ 45 - 0
system/message_communicator.h

@@ -0,0 +1,45 @@
+//
+// Created by zx on 2020/8/28.
+//
+
+#ifndef NNXX_TESTS_MESSAGE_COMMUNICATOR_H
+#define NNXX_TESTS_MESSAGE_COMMUNICATOR_H
+
+#include "singleton.h"
+#include "communication_socket_base.h"
+#include "error_code.h"
+
+class Message_communicator :public Singleton<Message_communicator>, public Communication_socket_base
+{
+    friend class Singleton<Message_communicator>;
+public:
+    //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
+    Message_communicator(const Message_communicator& other) = delete;
+    Message_communicator& operator =(const Message_communicator& other) = delete;
+
+    /*
+     * 发送消息
+     */
+    Error_manager send_msg(Communication_message* p_msg);
+
+    ~Message_communicator();
+
+protected:
+    // 父类的构造函数必须保护,子类的构造函数必须私有。
+    Message_communicator();
+
+    virtual Error_manager execute_msg(Communication_message* p_msg);
+    /*
+     * 检测消息是否可被处理
+     */
+    virtual Error_manager check_msg(Communication_message* p_msg);
+    /*
+     * 心跳发送函数,重载
+     */
+    virtual Error_manager encapsulate_send_data();
+    //检查消息是否可以被解析, 需要重载
+    virtual Error_manager check_executer(Communication_message* p_msg);
+};
+
+
+#endif //NNXX_TESTS_MESSAGE_COMMUNICATOR_H

+ 0 - 58
system/system_communicator.h

@@ -1,58 +0,0 @@
-//
-// Created by huli on 2020/6/28.
-//
-
-#ifndef NNXX_TESTS_SYSTEM_COMMUNICATION_H
-#define NNXX_TESTS_SYSTEM_COMMUNICATION_H
-
-#include <process_message.pb.h>
-#include <central_control_message.pb.h>
-#include "../tool/singleton.h"
-#include "../communication/communication_socket_base.h"
-#include "terminal_message.pb.h"
-
-/*typedef Error_manager (*StoreCommandCallback)(message::Store_command_request_msg& msg,message::Store_command_response_msg& response);
-typedef Error_manager (*PickupCommandCallback)(message::Pickup_command_request_msg& msg,message::Pickup_command_response_msg& response);*/
-
-class System_communicator:public Singleton<System_communicator>, public Communication_socket_base
-{
-// 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
-   friend class Singleton<System_communicator>;
-private:
- // 父类的构造函数必须保护,子类的构造函数必须私有。
- System_communicator();
-public:
-    //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
-    System_communicator(const System_communicator& other) = delete;
-    System_communicator& operator =(const System_communicator& other) = delete;
-
-    /*
-     * 发送中控状态消息, 出入口状态消息
-     */
-    Error_manager post_process_statu(message::Storing_process_statu_msg& msg);
-    Error_manager post_process_statu(message::Picking_process_statu_msg& msg);
-    Error_manager post_central_statu(message::Central_controller_statu_msg& msg);
-    ~System_communicator();
-
-protected:
-    //重载函数
-    virtual Error_manager encapsulate_msg(Communication_message* message);
-    virtual Error_manager execute_msg(Communication_message* p_msg);
-    /*
-     * 检测消息是否可被处理
-     */
-    virtual Error_manager check_msg(Communication_message* p_msg);
-    /*
-     * 心跳发送函数,重载
-     */
-    virtual Error_manager encapsulate_send_data();
-    //检查消息是否可以被解析, 需要重载
-    virtual Error_manager check_executer(Communication_message* p_msg);
-
-private:
-    /*StoreCommandCallback                mp_store_command_callback;              //收到停车请求回调函数
-    PickupCommandCallback               mp_pickup_command_callback;             //收到取车指令后的回调函数*/
-};
-
-
-#endif //NNXX_TESTS_SYSTEM_COMMUNICATION_H

+ 45 - 210
system/system_setting.pb.cc

@@ -57,24 +57,16 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   ~0u,  // no _oneof_case_
   ~0u,  // no _weak_field_map_
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, bind_ip_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, terminor_port_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, park_space_port_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, measurer_port_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, dispatcher_port_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, exception_handle_port_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, bind_port_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, entrance_num_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::setting::System_setting, export_num_),
   0,
-  4,
-  5,
-  6,
-  7,
   3,
   1,
   2,
 };
 static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-  { 0, 13, sizeof(::setting::System_setting)},
+  { 0, 9, sizeof(::setting::System_setting)},
 };
 
 static ::google::protobuf::Message const * const file_default_instances[] = {
@@ -103,16 +95,13 @@ void protobuf_RegisterTypes(const ::std::string&) {
 void AddDescriptorsImpl() {
   InitDefaults();
   static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-      "\n\024system_setting.proto\022\007setting\"\355\001\n\016Syst"
-      "em_setting\022\017\n\007bind_ip\030\001 \002(\t\022\034\n\rterminor_"
-      "port\030\002 \001(\005:\00530000\022\036\n\017park_space_port\030\003 \001"
-      "(\005:\00530001\022\034\n\rmeasurer_port\030\004 \001(\005:\00530002\022"
-      "\036\n\017dispatcher_port\030\005 \001(\005:\00530003\022$\n\025excep"
-      "tion_handle_port\030\006 \001(\005:\00530004\022\024\n\014entranc"
-      "e_num\030\007 \002(\005\022\022\n\nexport_num\030\010 \002(\005"
+      "\n\024system_setting.proto\022\007setting\"e\n\016Syste"
+      "m_setting\022\017\n\007bind_ip\030\001 \002(\t\022\030\n\tbind_port\030"
+      "\002 \001(\005:\00530000\022\024\n\014entrance_num\030\003 \002(\005\022\022\n\nex"
+      "port_num\030\004 \002(\005"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 271);
+      descriptor, 134);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "system_setting.proto", &protobuf_RegisterTypes);
 }
@@ -136,11 +125,7 @@ void System_setting::InitAsDefaultInstance() {
 }
 #if !defined(_MSC_VER) || _MSC_VER >= 1900
 const int System_setting::kBindIpFieldNumber;
-const int System_setting::kTerminorPortFieldNumber;
-const int System_setting::kParkSpacePortFieldNumber;
-const int System_setting::kMeasurerPortFieldNumber;
-const int System_setting::kDispatcherPortFieldNumber;
-const int System_setting::kExceptionHandlePortFieldNumber;
+const int System_setting::kBindPortFieldNumber;
 const int System_setting::kEntranceNumFieldNumber;
 const int System_setting::kExportNumFieldNumber;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
@@ -164,8 +149,8 @@ System_setting::System_setting(const System_setting& from)
     bind_ip_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.bind_ip_);
   }
   ::memcpy(&entrance_num_, &from.entrance_num_,
-    static_cast<size_t>(reinterpret_cast<char*>(&dispatcher_port_) -
-    reinterpret_cast<char*>(&entrance_num_)) + sizeof(dispatcher_port_));
+    static_cast<size_t>(reinterpret_cast<char*>(&bind_port_) -
+    reinterpret_cast<char*>(&entrance_num_)) + sizeof(bind_port_));
   // @@protoc_insertion_point(copy_constructor:setting.System_setting)
 }
 
@@ -175,11 +160,7 @@ void System_setting::SharedCtor() {
   ::memset(&entrance_num_, 0, static_cast<size_t>(
       reinterpret_cast<char*>(&export_num_) -
       reinterpret_cast<char*>(&entrance_num_)) + sizeof(export_num_));
-  exception_handle_port_ = 30004;
-  terminor_port_ = 30000;
-  park_space_port_ = 30001;
-  measurer_port_ = 30002;
-  dispatcher_port_ = 30003;
+  bind_port_ = 30000;
 }
 
 System_setting::~System_setting() {
@@ -225,15 +206,11 @@ void System_setting::Clear() {
     GOOGLE_DCHECK(!bind_ip_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
     (*bind_ip_.UnsafeRawStringPointer())->clear();
   }
-  if (cached_has_bits & 254u) {
+  if (cached_has_bits & 14u) {
     ::memset(&entrance_num_, 0, static_cast<size_t>(
         reinterpret_cast<char*>(&export_num_) -
         reinterpret_cast<char*>(&entrance_num_)) + sizeof(export_num_));
-    exception_handle_port_ = 30004;
-    terminor_port_ = 30000;
-    park_space_port_ = 30001;
-    measurer_port_ = 30002;
-    dispatcher_port_ = 30003;
+    bind_port_ = 30000;
   }
   _has_bits_.Clear();
   _internal_metadata_.Clear();
@@ -265,80 +242,24 @@ bool System_setting::MergePartialFromCodedStream(
         break;
       }
 
-      // optional int32 terminor_port = 2 [default = 30000];
+      // optional int32 bind_port = 2 [default = 30000];
       case 2: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
             static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
-          set_has_terminor_port();
+          set_has_bind_port();
           DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                    ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &terminor_port_)));
+                 input, &bind_port_)));
         } else {
           goto handle_unusual;
         }
         break;
       }
 
-      // optional int32 park_space_port = 3 [default = 30001];
+      // required int32 entrance_num = 3;
       case 3: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
             static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) {
-          set_has_park_space_port();
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &park_space_port_)));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // optional int32 measurer_port = 4 [default = 30002];
-      case 4: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {
-          set_has_measurer_port();
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &measurer_port_)));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // optional int32 dispatcher_port = 5 [default = 30003];
-      case 5: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) {
-          set_has_dispatcher_port();
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &dispatcher_port_)));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // optional int32 exception_handle_port = 6 [default = 30004];
-      case 6: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) {
-          set_has_exception_handle_port();
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &exception_handle_port_)));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // required int32 entrance_num = 7;
-      case 7: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(56u /* 56 & 0xFF */)) {
           set_has_entrance_num();
           DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                    ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -349,10 +270,10 @@ bool System_setting::MergePartialFromCodedStream(
         break;
       }
 
-      // required int32 export_num = 8;
-      case 8: {
+      // required int32 export_num = 4;
+      case 4: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(64u /* 64 & 0xFF */)) {
+            static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {
           set_has_export_num();
           DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                    ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -400,39 +321,19 @@ void System_setting::SerializeWithCachedSizes(
       1, this->bind_ip(), output);
   }
 
-  // optional int32 terminor_port = 2 [default = 30000];
-  if (cached_has_bits & 0x00000010u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->terminor_port(), output);
-  }
-
-  // optional int32 park_space_port = 3 [default = 30001];
-  if (cached_has_bits & 0x00000020u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->park_space_port(), output);
-  }
-
-  // optional int32 measurer_port = 4 [default = 30002];
-  if (cached_has_bits & 0x00000040u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->measurer_port(), output);
-  }
-
-  // optional int32 dispatcher_port = 5 [default = 30003];
-  if (cached_has_bits & 0x00000080u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->dispatcher_port(), output);
-  }
-
-  // optional int32 exception_handle_port = 6 [default = 30004];
+  // optional int32 bind_port = 2 [default = 30000];
   if (cached_has_bits & 0x00000008u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->exception_handle_port(), output);
+    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->bind_port(), output);
   }
 
-  // required int32 entrance_num = 7;
+  // required int32 entrance_num = 3;
   if (cached_has_bits & 0x00000002u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->entrance_num(), output);
+    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->entrance_num(), output);
   }
 
-  // required int32 export_num = 8;
+  // required int32 export_num = 4;
   if (cached_has_bits & 0x00000004u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(8, this->export_num(), output);
+    ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->export_num(), output);
   }
 
   if (_internal_metadata_.have_unknown_fields()) {
@@ -461,39 +362,19 @@ void System_setting::SerializeWithCachedSizes(
         1, this->bind_ip(), target);
   }
 
-  // optional int32 terminor_port = 2 [default = 30000];
-  if (cached_has_bits & 0x00000010u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->terminor_port(), target);
-  }
-
-  // optional int32 park_space_port = 3 [default = 30001];
-  if (cached_has_bits & 0x00000020u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->park_space_port(), target);
-  }
-
-  // optional int32 measurer_port = 4 [default = 30002];
-  if (cached_has_bits & 0x00000040u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->measurer_port(), target);
-  }
-
-  // optional int32 dispatcher_port = 5 [default = 30003];
-  if (cached_has_bits & 0x00000080u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->dispatcher_port(), target);
-  }
-
-  // optional int32 exception_handle_port = 6 [default = 30004];
+  // optional int32 bind_port = 2 [default = 30000];
   if (cached_has_bits & 0x00000008u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(6, this->exception_handle_port(), target);
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->bind_port(), target);
   }
 
-  // required int32 entrance_num = 7;
+  // required int32 entrance_num = 3;
   if (cached_has_bits & 0x00000002u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->entrance_num(), target);
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->entrance_num(), target);
   }
 
-  // required int32 export_num = 8;
+  // required int32 export_num = 4;
   if (cached_has_bits & 0x00000004u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(8, this->export_num(), target);
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->export_num(), target);
   }
 
   if (_internal_metadata_.have_unknown_fields()) {
@@ -516,14 +397,14 @@ size_t System_setting::RequiredFieldsByteSizeFallback() const {
   }
 
   if (has_entrance_num()) {
-    // required int32 entrance_num = 7;
+    // required int32 entrance_num = 3;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::Int32Size(
         this->entrance_num());
   }
 
   if (has_export_num()) {
-    // required int32 export_num = 8;
+    // required int32 export_num = 4;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::Int32Size(
         this->export_num());
@@ -546,12 +427,12 @@ size_t System_setting::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormatLite::StringSize(
         this->bind_ip());
 
-    // required int32 entrance_num = 7;
+    // required int32 entrance_num = 3;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::Int32Size(
         this->entrance_num());
 
-    // required int32 export_num = 8;
+    // required int32 export_num = 4;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::Int32Size(
         this->export_num());
@@ -559,43 +440,13 @@ size_t System_setting::ByteSizeLong() const {
   } else {
     total_size += RequiredFieldsByteSizeFallback();
   }
-  if (_has_bits_[0 / 32] & 248u) {
-    // optional int32 exception_handle_port = 6 [default = 30004];
-    if (has_exception_handle_port()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->exception_handle_port());
-    }
-
-    // optional int32 terminor_port = 2 [default = 30000];
-    if (has_terminor_port()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->terminor_port());
-    }
-
-    // optional int32 park_space_port = 3 [default = 30001];
-    if (has_park_space_port()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->park_space_port());
-    }
-
-    // optional int32 measurer_port = 4 [default = 30002];
-    if (has_measurer_port()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->measurer_port());
-    }
-
-    // optional int32 dispatcher_port = 5 [default = 30003];
-    if (has_dispatcher_port()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->dispatcher_port());
-    }
-
+  // optional int32 bind_port = 2 [default = 30000];
+  if (has_bind_port()) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int32Size(
+        this->bind_port());
   }
+
   int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
   GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
   _cached_size_ = cached_size;
@@ -626,7 +477,7 @@ void System_setting::MergeFrom(const System_setting& from) {
   (void) cached_has_bits;
 
   cached_has_bits = from._has_bits_[0];
-  if (cached_has_bits & 255u) {
+  if (cached_has_bits & 15u) {
     if (cached_has_bits & 0x00000001u) {
       set_has_bind_ip();
       bind_ip_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.bind_ip_);
@@ -638,19 +489,7 @@ void System_setting::MergeFrom(const System_setting& from) {
       export_num_ = from.export_num_;
     }
     if (cached_has_bits & 0x00000008u) {
-      exception_handle_port_ = from.exception_handle_port_;
-    }
-    if (cached_has_bits & 0x00000010u) {
-      terminor_port_ = from.terminor_port_;
-    }
-    if (cached_has_bits & 0x00000020u) {
-      park_space_port_ = from.park_space_port_;
-    }
-    if (cached_has_bits & 0x00000040u) {
-      measurer_port_ = from.measurer_port_;
-    }
-    if (cached_has_bits & 0x00000080u) {
-      dispatcher_port_ = from.dispatcher_port_;
+      bind_port_ = from.bind_port_;
     }
     _has_bits_[0] |= cached_has_bits;
   }
@@ -684,11 +523,7 @@ void System_setting::InternalSwap(System_setting* other) {
   bind_ip_.Swap(&other->bind_ip_);
   swap(entrance_num_, other->entrance_num_);
   swap(export_num_, other->export_num_);
-  swap(exception_handle_port_, other->exception_handle_port_);
-  swap(terminor_port_, other->terminor_port_);
-  swap(park_space_port_, other->park_space_port_);
-  swap(measurer_port_, other->measurer_port_);
-  swap(dispatcher_port_, other->dispatcher_port_);
+  swap(bind_port_, other->bind_port_);
   swap(_has_bits_[0], other->_has_bits_[0]);
   _internal_metadata_.Swap(&other->_internal_metadata_);
   swap(_cached_size_, other->_cached_size_);

+ 29 - 165
system/system_setting.pb.h

@@ -161,69 +161,33 @@ class System_setting : public ::google::protobuf::Message /* @@protoc_insertion_
   ::std::string* release_bind_ip();
   void set_allocated_bind_ip(::std::string* bind_ip);
 
-  // required int32 entrance_num = 7;
+  // required int32 entrance_num = 3;
   bool has_entrance_num() const;
   void clear_entrance_num();
-  static const int kEntranceNumFieldNumber = 7;
+  static const int kEntranceNumFieldNumber = 3;
   ::google::protobuf::int32 entrance_num() const;
   void set_entrance_num(::google::protobuf::int32 value);
 
-  // required int32 export_num = 8;
+  // required int32 export_num = 4;
   bool has_export_num() const;
   void clear_export_num();
-  static const int kExportNumFieldNumber = 8;
+  static const int kExportNumFieldNumber = 4;
   ::google::protobuf::int32 export_num() const;
   void set_export_num(::google::protobuf::int32 value);
 
-  // optional int32 exception_handle_port = 6 [default = 30004];
-  bool has_exception_handle_port() const;
-  void clear_exception_handle_port();
-  static const int kExceptionHandlePortFieldNumber = 6;
-  ::google::protobuf::int32 exception_handle_port() const;
-  void set_exception_handle_port(::google::protobuf::int32 value);
-
-  // optional int32 terminor_port = 2 [default = 30000];
-  bool has_terminor_port() const;
-  void clear_terminor_port();
-  static const int kTerminorPortFieldNumber = 2;
-  ::google::protobuf::int32 terminor_port() const;
-  void set_terminor_port(::google::protobuf::int32 value);
-
-  // optional int32 park_space_port = 3 [default = 30001];
-  bool has_park_space_port() const;
-  void clear_park_space_port();
-  static const int kParkSpacePortFieldNumber = 3;
-  ::google::protobuf::int32 park_space_port() const;
-  void set_park_space_port(::google::protobuf::int32 value);
-
-  // optional int32 measurer_port = 4 [default = 30002];
-  bool has_measurer_port() const;
-  void clear_measurer_port();
-  static const int kMeasurerPortFieldNumber = 4;
-  ::google::protobuf::int32 measurer_port() const;
-  void set_measurer_port(::google::protobuf::int32 value);
-
-  // optional int32 dispatcher_port = 5 [default = 30003];
-  bool has_dispatcher_port() const;
-  void clear_dispatcher_port();
-  static const int kDispatcherPortFieldNumber = 5;
-  ::google::protobuf::int32 dispatcher_port() const;
-  void set_dispatcher_port(::google::protobuf::int32 value);
+  // optional int32 bind_port = 2 [default = 30000];
+  bool has_bind_port() const;
+  void clear_bind_port();
+  static const int kBindPortFieldNumber = 2;
+  ::google::protobuf::int32 bind_port() const;
+  void set_bind_port(::google::protobuf::int32 value);
 
   // @@protoc_insertion_point(class_scope:setting.System_setting)
  private:
   void set_has_bind_ip();
   void clear_has_bind_ip();
-  void set_has_terminor_port();
-  void clear_has_terminor_port();
-  void set_has_park_space_port();
-  void clear_has_park_space_port();
-  void set_has_measurer_port();
-  void clear_has_measurer_port();
-  void set_has_dispatcher_port();
-  void clear_has_dispatcher_port();
-  void set_has_exception_handle_port();
-  void clear_has_exception_handle_port();
+  void set_has_bind_port();
+  void clear_has_bind_port();
   void set_has_entrance_num();
   void clear_has_entrance_num();
   void set_has_export_num();
@@ -238,11 +202,7 @@ class System_setting : public ::google::protobuf::Message /* @@protoc_insertion_
   ::google::protobuf::internal::ArenaStringPtr bind_ip_;
   ::google::protobuf::int32 entrance_num_;
   ::google::protobuf::int32 export_num_;
-  ::google::protobuf::int32 exception_handle_port_;
-  ::google::protobuf::int32 terminor_port_;
-  ::google::protobuf::int32 park_space_port_;
-  ::google::protobuf::int32 measurer_port_;
-  ::google::protobuf::int32 dispatcher_port_;
+  ::google::protobuf::int32 bind_port_;
   friend struct ::protobuf_system_5fsetting_2eproto::TableStruct;
   friend void ::protobuf_system_5fsetting_2eproto::InitDefaultsSystem_settingImpl();
 };
@@ -320,127 +280,31 @@ inline void System_setting::set_allocated_bind_ip(::std::string* bind_ip) {
   // @@protoc_insertion_point(field_set_allocated:setting.System_setting.bind_ip)
 }
 
-// optional int32 terminor_port = 2 [default = 30000];
-inline bool System_setting::has_terminor_port() const {
-  return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void System_setting::set_has_terminor_port() {
-  _has_bits_[0] |= 0x00000010u;
-}
-inline void System_setting::clear_has_terminor_port() {
-  _has_bits_[0] &= ~0x00000010u;
-}
-inline void System_setting::clear_terminor_port() {
-  terminor_port_ = 30000;
-  clear_has_terminor_port();
-}
-inline ::google::protobuf::int32 System_setting::terminor_port() const {
-  // @@protoc_insertion_point(field_get:setting.System_setting.terminor_port)
-  return terminor_port_;
-}
-inline void System_setting::set_terminor_port(::google::protobuf::int32 value) {
-  set_has_terminor_port();
-  terminor_port_ = value;
-  // @@protoc_insertion_point(field_set:setting.System_setting.terminor_port)
-}
-
-// optional int32 park_space_port = 3 [default = 30001];
-inline bool System_setting::has_park_space_port() const {
-  return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void System_setting::set_has_park_space_port() {
-  _has_bits_[0] |= 0x00000020u;
-}
-inline void System_setting::clear_has_park_space_port() {
-  _has_bits_[0] &= ~0x00000020u;
-}
-inline void System_setting::clear_park_space_port() {
-  park_space_port_ = 30001;
-  clear_has_park_space_port();
-}
-inline ::google::protobuf::int32 System_setting::park_space_port() const {
-  // @@protoc_insertion_point(field_get:setting.System_setting.park_space_port)
-  return park_space_port_;
-}
-inline void System_setting::set_park_space_port(::google::protobuf::int32 value) {
-  set_has_park_space_port();
-  park_space_port_ = value;
-  // @@protoc_insertion_point(field_set:setting.System_setting.park_space_port)
-}
-
-// optional int32 measurer_port = 4 [default = 30002];
-inline bool System_setting::has_measurer_port() const {
-  return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void System_setting::set_has_measurer_port() {
-  _has_bits_[0] |= 0x00000040u;
-}
-inline void System_setting::clear_has_measurer_port() {
-  _has_bits_[0] &= ~0x00000040u;
-}
-inline void System_setting::clear_measurer_port() {
-  measurer_port_ = 30002;
-  clear_has_measurer_port();
-}
-inline ::google::protobuf::int32 System_setting::measurer_port() const {
-  // @@protoc_insertion_point(field_get:setting.System_setting.measurer_port)
-  return measurer_port_;
-}
-inline void System_setting::set_measurer_port(::google::protobuf::int32 value) {
-  set_has_measurer_port();
-  measurer_port_ = value;
-  // @@protoc_insertion_point(field_set:setting.System_setting.measurer_port)
-}
-
-// optional int32 dispatcher_port = 5 [default = 30003];
-inline bool System_setting::has_dispatcher_port() const {
-  return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void System_setting::set_has_dispatcher_port() {
-  _has_bits_[0] |= 0x00000080u;
-}
-inline void System_setting::clear_has_dispatcher_port() {
-  _has_bits_[0] &= ~0x00000080u;
-}
-inline void System_setting::clear_dispatcher_port() {
-  dispatcher_port_ = 30003;
-  clear_has_dispatcher_port();
-}
-inline ::google::protobuf::int32 System_setting::dispatcher_port() const {
-  // @@protoc_insertion_point(field_get:setting.System_setting.dispatcher_port)
-  return dispatcher_port_;
-}
-inline void System_setting::set_dispatcher_port(::google::protobuf::int32 value) {
-  set_has_dispatcher_port();
-  dispatcher_port_ = value;
-  // @@protoc_insertion_point(field_set:setting.System_setting.dispatcher_port)
-}
-
-// optional int32 exception_handle_port = 6 [default = 30004];
-inline bool System_setting::has_exception_handle_port() const {
+// optional int32 bind_port = 2 [default = 30000];
+inline bool System_setting::has_bind_port() const {
   return (_has_bits_[0] & 0x00000008u) != 0;
 }
-inline void System_setting::set_has_exception_handle_port() {
+inline void System_setting::set_has_bind_port() {
   _has_bits_[0] |= 0x00000008u;
 }
-inline void System_setting::clear_has_exception_handle_port() {
+inline void System_setting::clear_has_bind_port() {
   _has_bits_[0] &= ~0x00000008u;
 }
-inline void System_setting::clear_exception_handle_port() {
-  exception_handle_port_ = 30004;
-  clear_has_exception_handle_port();
+inline void System_setting::clear_bind_port() {
+  bind_port_ = 30000;
+  clear_has_bind_port();
 }
-inline ::google::protobuf::int32 System_setting::exception_handle_port() const {
-  // @@protoc_insertion_point(field_get:setting.System_setting.exception_handle_port)
-  return exception_handle_port_;
+inline ::google::protobuf::int32 System_setting::bind_port() const {
+  // @@protoc_insertion_point(field_get:setting.System_setting.bind_port)
+  return bind_port_;
 }
-inline void System_setting::set_exception_handle_port(::google::protobuf::int32 value) {
-  set_has_exception_handle_port();
-  exception_handle_port_ = value;
-  // @@protoc_insertion_point(field_set:setting.System_setting.exception_handle_port)
+inline void System_setting::set_bind_port(::google::protobuf::int32 value) {
+  set_has_bind_port();
+  bind_port_ = value;
+  // @@protoc_insertion_point(field_set:setting.System_setting.bind_port)
 }
 
-// required int32 entrance_num = 7;
+// required int32 entrance_num = 3;
 inline bool System_setting::has_entrance_num() const {
   return (_has_bits_[0] & 0x00000002u) != 0;
 }
@@ -464,7 +328,7 @@ inline void System_setting::set_entrance_num(::google::protobuf::int32 value) {
   // @@protoc_insertion_point(field_set:setting.System_setting.entrance_num)
 }
 
-// required int32 export_num = 8;
+// required int32 export_num = 4;
 inline bool System_setting::has_export_num() const {
   return (_has_bits_[0] & 0x00000004u) != 0;
 }

+ 3 - 7
system/system_setting.proto

@@ -4,12 +4,8 @@ package setting;
 message System_setting
 {
     required string         bind_ip=1;
-    optional int32          terminor_port=2 [default=30000];
-    optional int32          park_space_port=3 [default=30001];
-    optional int32          measurer_port=4 [default=30002];
-    optional int32          dispatcher_port=5 [default=30003];
-    optional int32          exception_handle_port=6 [default=30004];
+    optional int32          bind_port=2 [default=30000];
 
-    required int32          entrance_num=7;
-    required int32          export_num=8;
+    required int32          entrance_num=3;
+    required int32          export_num=4;
 }

+ 1 - 1
test/Terminal_communication.cpp

@@ -182,7 +182,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*3;
+    int timeout=1000*5;
 
     code=encapsulate_msg(&message);
     if(code!=SUCCESS)

+ 0 - 1
test/terminal_client.cpp

@@ -20,7 +20,6 @@
 #include "pickup_terminal.h"
 #include "pathcreator.h"
 #include "process_message.pb.h"
-#include "system_communicator.h"
 
 GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
 {