Prechádzať zdrojové kódy

message, tool, config alignment

yct 3 rokov pred
rodič
commit
5b3a66db2f
38 zmenil súbory, kde vykonal 3099 pridanie a 339 odobranie
  1. 32 25
      communication/communication_message.h
  2. 67 227
      error_code/error_code.cpp
  3. 251 81
      error_code/error_code.h
  4. 11 0
      message/UnNormalized_module_message.proto
  5. 56 0
      message/central_control_message.proto
  6. 209 0
      message/dispatch_control.proto
  7. 316 0
      message/dispatch_message.proto
  8. 59 0
      message/log_process.proto
  9. 3 2
      message/measure_message.proto
  10. 4 4
      message/message_base.proto
  11. 28 0
      message/notify_message.proto
  12. 169 0
      message/parkspace_allocation_message.proto
  13. 156 0
      message/process_message.proto
  14. 189 0
      message/singlechip_msg.proto
  15. 39 0
      message/terminal_message.proto
  16. 33 0
      tool/TaskQueue/BaseTask.cpp
  17. 29 0
      tool/TaskQueue/BaseTask.h
  18. 23 0
      tool/TaskQueue/TQFactory.cpp
  19. 24 0
      tool/TaskQueue/TQFactory.h
  20. 58 0
      tool/TaskQueue/TQInterface.h
  21. 89 0
      tool/TaskQueue/TaskPool.h
  22. 288 0
      tool/TaskQueue/ThreadTaskQueue.cpp
  23. 89 0
      tool/TaskQueue/ThreadTaskQueue.h
  24. 35 0
      tool/TaskQueue/threadpp/impl/pthread_lock.h
  25. 73 0
      tool/TaskQueue/threadpp/impl/pthread_lock.hpp
  26. 45 0
      tool/TaskQueue/threadpp/impl/pthread_thread.h
  27. 110 0
      tool/TaskQueue/threadpp/impl/pthread_thread.hpp
  28. 33 0
      tool/TaskQueue/threadpp/impl/std_lock.h
  29. 52 0
      tool/TaskQueue/threadpp/impl/std_lock.hpp
  30. 40 0
      tool/TaskQueue/threadpp/impl/std_thread.h
  31. 64 0
      tool/TaskQueue/threadpp/impl/std_thread.hpp
  32. 37 0
      tool/TaskQueue/threadpp/impl/win_lock.h
  33. 80 0
      tool/TaskQueue/threadpp/impl/win_lock.hpp
  34. 53 0
      tool/TaskQueue/threadpp/impl/win_thread.h
  35. 81 0
      tool/TaskQueue/threadpp/impl/win_thread.hpp
  36. 101 0
      tool/TaskQueue/threadpp/recursive_lock.h
  37. 40 0
      tool/TaskQueue/threadpp/threadpp.h
  38. 33 0
      tool/TaskQueue/threadpp/threadpp_assert.h

+ 32 - 25
communication/communication_message.h

@@ -33,29 +33,31 @@ public:
 		eLocate_sift_request_msg = 0x14,            //预测算法请求消息
 		eLocate_sift_response_msg = 0x15,           //预测算法反馈消息
 
-		eDispatch_status_msg=0x21,                //调度模块硬件状态消息
-		eDispatch_request_msg=0x22,              //请求调度消息
-		eDispatch_response_msg=0x23,             //调度结果反馈消息
-
-		eParkspace_allocation_status_msg=0x31,  //车位分配模块状态消息,包括车位信息
-		eParkspace_allocation_request_msg=0x32, //请求分配车位消息
-		eParkspace_allocation_response_msg=0x33,//分配车位结果反馈消息
-		eParkspace_search_request_msg = 0x34,		//查询车位请求消息
-		eParkspace_search_response_msg = 0x35,		//查询车位反馈消息
-		eParkspace_release_request_msg = 0x36,		//释放车位请求消息
-		eParkspace_release_response_msg = 0x37,		//释放车位反馈消息
-		eParkspace_force_update_request_msg = 0x38,	//手动修改车位消息
-		eParkspace_force_update_response_msg = 0x39,//手动修改车位反馈消息
-		eParkspace_confirm_alloc_request_msg = 0x3A,//确认分配车位请求消息
-		eParkspace_confirm_alloc_response_msg = 0x3B,//确认分配车位反馈消息
-        eParkspace_refresh_request_msg=0x3C,        //请求更新车位数据
-        eParkspace_allocation_data_response_msg=0x3D,
-
-		eStore_command_request_msg=0x41,        //终端停车请求消息
-		eStore_command_response_msg=0x42,       //停车请求反馈消息
-		ePickup_command_request_msg=0x43,       //取车请求消息
-		ePickup_command_response_msg=0x44,       //取车请求反馈消息
-
+		eDispatch_status_msg=0x21,                	//调度模块硬件状态消息
+		eDispatch_request_msg=0x22,              	//请求调度消息
+		eDispatch_response_msg=0x23,             	//调度结果反馈消息
+
+		eParkspace_allocation_status_msg=0x31,  		//车位分配模块状态消息,包括车位信息
+		eParkspace_allocation_request_msg=0x32, 		//请求分配车位消息
+		eParkspace_allocation_response_msg=0x33,		//分配车位结果反馈消息
+		eParkspace_search_request_msg = 0x34,			//查询车位请求消息
+		eParkspace_search_response_msg = 0x35,			//查询车位反馈消息
+		eParkspace_release_request_msg = 0x36,			//释放车位请求消息
+		eParkspace_release_response_msg = 0x37,			//释放车位反馈消息
+		eParkspace_force_update_request_msg = 0x38,		//手动修改车位消息
+		eParkspace_force_update_response_msg = 0x39,	//手动修改车位反馈消息
+		eParkspace_confirm_alloc_request_msg = 0x3A,	//确认分配车位请求消息
+		eParkspace_confirm_alloc_response_msg = 0x3B,	//确认分配车位反馈消息
+        eParkspace_refresh_request_msg=0x3C,        	//请求更新车位数据
+        eParkspace_allocation_data_response_msg=0x3D,	//车位数据反馈消息
+		eParkspace_manual_search_request_msg = 0x3E,	//手动查询车位请求消息
+		eParkspace_manual_search_response_msg = 0x3F,	//手动查询车位反馈消息
+
+		eStore_command_request_msg=0x41,        	//终端停车请求消息
+		eStore_command_response_msg=0x42,       	//停车请求反馈消息
+		ePickup_command_request_msg=0x43,       	//取车请求消息
+		ePickup_command_response_msg=0x44,       	//取车请求反馈消息
+		eTerminal_status_msg = 0x50,	 			//终端状态消息
 
 
 		eStoring_process_statu_msg=0x90,        //停车指令进度条消息
@@ -64,10 +66,14 @@ public:
 
 		eCentral_controller_statu_msg=0xa0,     //中控系统状态消息
 
-
 		eEntrance_manual_operation_msg=0xb0,            //针对出入口状态操作的手动消息
 		eProcess_manual_operation_msg=0xb1,             //针对流程的手动消息
 
+		eNotify_request_msg=0xc0,               //取车等候区通知请求
+		eNotify_response_msg=0xc1,              //等候区反馈
+		eNotify_status_msg=0xc2,                //等候区通知节点状态
+		eUnNormalized_module_statu_msg = 0xd0, //非标节点状态
+
 		eDispatch_plan_request_msg          = 0xe0,     //调度总规划的请求(用于启动整个调度算法)(调度管理->调度算法)
 		eDispatch_plan_response_msg         = 0xe1,     //调度总规划的答复(调度算法->调度管理)
 		eDispatch_control_request_msg       = 0xe2,     //调度控制的任务请求(调度算法->调度管理)
@@ -101,7 +107,8 @@ public:
 		eDispatch_mamager=0x0400,
 		//调度机构
 		eDispatch_control=0x0401,
-		//...
+		//取车等候区通知节点
+		eNotify=0x0501,
 
 		//地面测量单元
 		eGround_measurer=0x0f00,

+ 67 - 227
error_code/error_code.cpp

@@ -15,45 +15,38 @@ Error_manager::Error_manager()
 {
     m_error_code = SUCCESS;
     m_error_level = NORMAL;
-    pm_error_description = 0;
-    m_description_length = 0;
-    return ;
 }
 //拷贝构造
 Error_manager::Error_manager(const Error_manager & error_manager)
 {
     this->m_error_code = error_manager.m_error_code;
     this->m_error_level = error_manager.m_error_level;
-    pm_error_description = NULL;
-    m_description_length = 0;
-    reallocate_memory_and_copy_string(error_manager.pm_error_description, error_manager.m_description_length);
+	this->m_error_description=error_manager.m_error_description;
     return ;
 }
 //赋值构造
 Error_manager::Error_manager(Error_code error_code, Error_level error_level,
-    const char* p_error_description, int description_length)
+    const char* p_error_description)
 {
     m_error_code = error_code;
     m_error_level = error_level;
-    pm_error_description = NULL;
-    m_description_length = 0;
-    reallocate_memory_and_copy_string(p_error_description, description_length);
-    return ;
+    if(p_error_description!= nullptr)
+	{
+		m_error_description=std::string(p_error_description);
+	}
+	return ;
 }
 //赋值构造
 Error_manager::Error_manager(Error_code error_code, Error_level error_level , std::string & error_aggregate_string)
 {
     m_error_code = error_code;
     m_error_level = error_level;
-    pm_error_description = NULL;
-    m_description_length = 0;
-    reallocate_memory_and_copy_string(error_aggregate_string);
-    return ;
+    m_error_description=error_aggregate_string;
+	return ;
 }
 //析构函数
 Error_manager::~Error_manager()
 {
-    free_description();
 }
 
 //初始化
@@ -62,44 +55,49 @@ void Error_manager::error_manager_init()
     error_manager_clear_all();
     return;
 }
-//初始化
-void Error_manager::error_manager_init(Error_code error_code, Error_level error_level, const char* p_error_description, int description_length)
+void Error_manager::error_manager_init(Error_code error_code, Error_level error_level, const char* p_error_description)
 {
     m_error_code = error_code;
     m_error_level = error_level;
-    reallocate_memory_and_copy_string(p_error_description, description_length);
-    return ;
+	if(p_error_description!= nullptr)
+	{
+		m_error_description=std::string(p_error_description);
+	}
+	return ;
 }
 //初始化
 void Error_manager::error_manager_init(Error_code error_code, Error_level error_level , std::string & error_aggregate_string)
 {
     m_error_code = error_code;
     m_error_level = error_level;
-    reallocate_memory_and_copy_string(error_aggregate_string);
+    m_error_description=error_aggregate_string;
     return ;
 }
 //重置
-void Error_manager::error_manager_reset(Error_code error_code, Error_level error_level, const char* p_error_description, int description_length)
+void Error_manager::error_manager_reset(Error_code error_code, Error_level error_level, const char* p_error_description)
 {
     m_error_code = error_code;
     m_error_level = error_level;
-    reallocate_memory_and_copy_string(p_error_description, description_length);
-    return ;
+	if(p_error_description!= nullptr)
+	{
+		m_error_description=std::string(p_error_description);
+	}
+	return ;
 }
 //重置
 void Error_manager::error_manager_reset(Error_code error_code, Error_level error_level , std::string & error_aggregate_string)
 {
     m_error_code = error_code;
     m_error_level = error_level;
-    reallocate_memory_and_copy_string(error_aggregate_string);
-    return ;
+    m_error_description=error_aggregate_string;
+	return;
 }
 //重置
 void Error_manager::error_manager_reset(const Error_manager & error_manager)
 {
     this->m_error_code = error_manager.m_error_code;
     this->m_error_level = error_manager.m_error_level;
-    reallocate_memory_and_copy_string(error_manager.pm_error_description, error_manager.m_description_length);
+	this->m_error_description=error_manager.m_error_description;
     return ;
 }
 //清除所有内容
@@ -107,7 +105,7 @@ void Error_manager::error_manager_clear_all()
 {
     m_error_code = SUCCESS;
     m_error_level = NORMAL;
-    free_description();
+	m_error_description.clear();
 	return;
 }
 
@@ -177,51 +175,28 @@ Error_level Error_manager::get_error_level()
     return m_error_level;
 }
 //获取错误描述的指针,(浅拷贝)
-char* Error_manager::get_error_description()
-{
-    return pm_error_description;
-}
-
-int Error_manager::get_description_length()
+std::string Error_manager::get_error_description()
 {
-	return m_description_length;
+    return m_error_description;
 }
 
 //复制错误描述,(深拷贝)
 //output:p_error_description     错误描述的字符串指针,不可以为NULL,必须要有实际的内存
 //output:description_length      错误描述的字符串长度,不可以为0,长度最好足够大,一般256即可。
-void Error_manager::copy_error_description(const char* p_error_description, int description_length)
+void Error_manager::copy_error_description(const char* p_error_description)
 {
-    if(p_error_description != NULL && pm_error_description != NULL)
+    if(p_error_description != NULL)
     {
-        char *pt_source = (char *)p_error_description;
-        char* pt_destination = pm_error_description;
-
-        int t_length_min = m_description_length;
-        if(m_description_length > description_length)
-        {
-            t_length_min = description_length;
-        }
-
-        for(int i=0;i<t_length_min; i++)
-        {
-            *pt_destination = *pt_source;
-            pt_destination++;
-            pt_source++;
-        }
+        m_error_description=std::string(p_error_description);
     }
-
-    return;
+	return;
 }
 //复制错误描述,(深拷贝)
 //output:error_description_string     错误描述的string
 void Error_manager::copy_error_description(std::string & error_description_string)
 {
-    if( (!error_description_string.empty() ) && pm_error_description != NULL)
-    {
-        error_description_string = pm_error_description;
-    }
-    return;
+    m_error_description=error_description_string;
+	return;
 }
 
 //设置错误码
@@ -255,65 +230,33 @@ void Error_manager::set_error_level_location(Error_level error_level)
     return;
 }
 //设置错误描述
-void Error_manager::set_error_description(const char* p_error_description, int description_length)
+void Error_manager::set_error_description(const char* p_error_description)
 {
-    reallocate_memory_and_copy_string(p_error_description, description_length);
-    return ;
+	if(p_error_description != NULL)
+	{
+		m_error_description=std::string(p_error_description);
+	}
+	return;
 }
 //设置错误描述
 void Error_manager::set_error_description(std::string & error_description_string)
 {
-    reallocate_memory_and_copy_string(error_description_string);
-    return ;
+	m_error_description = error_description_string;
+	return ;
 }
 
 //尾部追加错误描述
-void Error_manager::add_error_description(const char* p_error_description, int description_length)
+void Error_manager::add_error_description(const char* p_error_description)
 {
     if(p_error_description !=NULL)
     {
-        char* pt_description_front = pm_error_description;
-        int t_description_front_length = m_description_length;
-        char* pt_description_back = (char *)p_error_description;
-        int t_description_back_length = 0;
-
-        if(description_length == 0)
-        {
-            t_description_back_length = 0;
-            while (*pt_description_back != '\0')
-            {
-                t_description_back_length++;
-                pt_description_back++;
-            }
-            t_description_back_length++;
-            pt_description_back = (char *)p_error_description;
-        }
-        else
-        {
-            t_description_back_length = description_length;
-        }
-
-        int t_description_new_length = t_description_front_length + 5 + t_description_back_length - 1;
-        char* pt_description_new =  (char*) malloc(t_description_new_length );
-
-        sprintf(pt_description_new, "%s ### %s", pt_description_front, pt_description_back);
-        free_description();
-        pm_error_description = pt_description_new;
-        m_description_length = t_description_new_length;
+        m_error_description+=std::string(p_error_description);
     }
-    return ;
 }
 //尾部追加错误描述
 void Error_manager::add_error_description(std::string & error_description_string)
 {
-    if( ! error_description_string.empty() )
-    {
-        std::string t_description_string = pm_error_description ;
-        t_description_string += (" ### "+ error_description_string);
-
-        reallocate_memory_and_copy_string(t_description_string);
-    }
-	return;
+    m_error_description+=error_description_string;
 }
 
 //比较错误是否相同,
@@ -345,24 +288,17 @@ void Error_manager::compare_and_cover_error(const Error_manager & error_manager)
     else
     {
         Error_manager t_error_manager_new;
-        char* pt_string_inside = NULL;
-        int t_string_inside_length = 0;
+        std::string pt_string_inside ;
         if(this->m_error_level < error_manager.m_error_level)
         {
-            t_string_inside_length = ERROR_NAMAGER_TO_STRING_FRONT_LENGTH + this->m_description_length;
-            pt_string_inside = (char*)malloc(t_string_inside_length);
-            translate_error_to_string(pt_string_inside, t_string_inside_length);
-
+            translate_error_to_string(pt_string_inside);
             error_manager_reset(error_manager);
-            add_error_description(pt_string_inside,t_string_inside_length);
+            add_error_description(pt_string_inside);
         }
         else
         {
-            t_string_inside_length = ERROR_NAMAGER_TO_STRING_FRONT_LENGTH + error_manager.m_description_length;
-            pt_string_inside = (char*)malloc(t_string_inside_length);
-			((Error_manager & )error_manager).translate_error_to_string(pt_string_inside, t_string_inside_length);
-
-            add_error_description(pt_string_inside,t_string_inside_length);
+			((Error_manager&)error_manager).translate_error_to_string(pt_string_inside);
+            add_error_description(pt_string_inside);
         }
     }
 	return;
@@ -377,93 +313,48 @@ void Error_manager::compare_and_cover_error( Error_manager * p_error_manager)
 	}
 	else if (p_error_manager->m_error_code == SUCCESS)
 	{
-		//
+		return;
 	}
 	else
 	{
 		Error_manager t_error_manager_new;
-		char* pt_string_inside = NULL;
-		int t_string_inside_length = 0;
+		std::string pt_string_inside;
 		if(this->m_error_level < p_error_manager->m_error_level)
 		{
-			t_string_inside_length = ERROR_NAMAGER_TO_STRING_FRONT_LENGTH + this->m_description_length;
-			pt_string_inside = (char*)malloc(t_string_inside_length);
-			translate_error_to_string(pt_string_inside, t_string_inside_length);
-
+			translate_error_to_string(pt_string_inside);
 			error_manager_reset(*p_error_manager);
-			add_error_description(pt_string_inside,t_string_inside_length);
+			add_error_description(pt_string_inside);
 		}
 		else
 		{
-			t_string_inside_length = ERROR_NAMAGER_TO_STRING_FRONT_LENGTH + p_error_manager->m_description_length;
-			pt_string_inside = (char*)malloc(t_string_inside_length);
-			p_error_manager->translate_error_to_string(pt_string_inside, t_string_inside_length);
-
-			add_error_description(pt_string_inside,t_string_inside_length);
+			p_error_manager->translate_error_to_string(pt_string_inside);
+			add_error_description(pt_string_inside);
 		}
 	}
-	return;
 }
 
-//将所有的错误信息,格式化为字符串,用作日志打印。
-//output:p_error_description     错误汇总的字符串指针,不可以为NULL,必须要有实际的内存
-//output:description_length      错误汇总的字符串长度,不可以为0,长度最好足够大,一般256即可。
-void Error_manager::translate_error_to_string(char* p_error_aggregate, int aggregate_length )
-{
-    char t_string_array[ERROR_NAMAGER_TO_STRING_FRONT_LENGTH] = {0};
-    char* pt_index_front = t_string_array;
-    char* pt_index_back = pm_error_description;
-    char* pt_index = p_error_aggregate;
-
-    sprintf(t_string_array, "error_code:0x%08x, error_level:%02d, error_description:", m_error_code , m_error_level );
 
-    int t_length_min = m_description_length + ERROR_NAMAGER_TO_STRING_FRONT_LENGTH -1;
-    if(t_length_min > aggregate_length)
-    {
-        t_length_min = aggregate_length;
-    }
-
-    for(int i=0;i<t_length_min; i++)
-    {
-        if(i < ERROR_NAMAGER_TO_STRING_FRONT_LENGTH -1)
-        {
-            *pt_index = *pt_index_front;
-            pt_index++;
-            pt_index_front++;
-        }
-        else
-        {
-            *pt_index = *pt_index_back;
-            pt_index++;
-            pt_index_back++;
-        }
-    }
-	return;
-}
 //output:error_description_string     错误汇总的string
 void Error_manager::translate_error_to_string(std::string & error_aggregate_string)
 {
-    char t_string_array[ERROR_NAMAGER_TO_STRING_FRONT_LENGTH] = {0};
-    sprintf(t_string_array, "error_code:0x%08x, error_level:%02d, error_description:", m_error_code , m_error_level );
+    char t_string_array[255] = {0};
+    sprintf(t_string_array, "error_code:0x%08x, error_level:%02d, error_description:",
+            m_error_code , m_error_level);
 
     error_aggregate_string = t_string_array ;
-    if(pm_error_description != NULL)
-    {
-        error_aggregate_string += pm_error_description;
-    }
-    else
-    {
-        //error_aggregate_string += "NULL";
-    }
+	error_aggregate_string+= m_error_description;
 	return;
 }
 //错误码转字符串的简易版,可支持cout<<
 //return     错误汇总的string
 std::string Error_manager::to_string()
 {
-    std::string t_string;
-    translate_error_to_string(t_string);
-    return t_string;
+	char t_string_array[255] = {0};
+	sprintf(t_string_array, "error_code:0x%08x, error_level:%02d, error_description:",
+            m_error_code , m_error_level);
+    std::string error_aggregate_string = t_string_array ;
+	error_aggregate_string+= m_error_description;
+	return error_aggregate_string;
 }
 
 
@@ -472,13 +363,6 @@ std::string Error_manager::to_string()
 //释放错误描述的内存,
 void Error_manager::free_description()
 {
-    if(pm_error_description != NULL)
-    {
-        free (pm_error_description);
-        pm_error_description = NULL;
-    }
-    m_description_length = 0;
-	return;
 }
 
 //重新分配错误描述的内存,并从外部拷贝新的(深拷贝)
@@ -486,40 +370,6 @@ void Error_manager::free_description()
 //input:description_length      错误描述的字符串长度,如果为0,则从p_error_description里面获取有效的长度
 void Error_manager::reallocate_memory_and_copy_string(const char* p_error_description, int description_length)
 {
-    free_description();
-
-    if(p_error_description != NULL)
-    {
-        char* pt_source = (char *)p_error_description;
-        char* pt_destination = NULL;
-
-        if(description_length == 0)
-        {
-            m_description_length = 0;
-            while (*pt_source != '\0')
-            {
-                m_description_length++;
-                pt_source++;
-            }
-            m_description_length++;
-            pt_source = (char *)p_error_description;
-        }
-        else
-        {
-            m_description_length = description_length;
-        }
-
-        pm_error_description =  (char*) malloc(m_description_length );
-        pt_destination = pm_error_description;
-
-        for(int i=0;i<m_description_length; i++)
-        {
-            *pt_destination = *pt_source;
-            pt_destination++;
-            pt_source++;
-        }
-    }
-
     return;
 }
 
@@ -528,17 +378,7 @@ void Error_manager::reallocate_memory_and_copy_string(const char* p_error_descri
 //input:error_aggregate_string     错误描述的string
 void Error_manager::reallocate_memory_and_copy_string(std::string & error_aggregate_string)
 {
-    free_description();
-
-    if( ! error_aggregate_string.empty())
-    {
-        m_description_length = error_aggregate_string.length()+1;
-
-        pm_error_description =  (char*) malloc( m_description_length );
-
-        strcpy(pm_error_description ,   error_aggregate_string.c_str()  );
-    }
-	return;
+    return;
 }
 
 

+ 251 - 81
error_code/error_code.h

@@ -1,4 +1,13 @@
 
+#define MAIN_TEST 1
+//#define PROCESS_TEST 1
+//#define TIME_TEST 1
+
+#define PLC_S7_COMMUNICATION 1	//是否开启plc的通信
+#define WAIT_PLC_RESPONSE 1		//是否等待plc的答复
+#define MEASURE_TO_PLC_CORRECTION 1		//修正感测数据
+
+
 //Error_code是错误码的底层通用模块,
 //功能:用作故障分析和处理。
 
@@ -57,6 +66,12 @@ enum Error_code
 	INVALID_MESSAGE					= 0x00000011, //无效的消息,
 	PARSE_FAILED					= 0x00000012,//解析失败
 
+    PAUSE                           = 0x00000013,   //急停
+    TASK_CANCEL                     = 0x00000014,   //任务取消
+
+    DISCONNECT                      = 0x00000020,   //通讯中断/断开连接
+    UNKNOW_STATU                    = 0x00000021,   //未知状态
+
     TASK_TIMEOVER					= 0x00000020,//任务超时
 	RESPONSE_TIMEOUT                = 0x00000021,//答复超时
 
@@ -81,6 +96,12 @@ enum Error_code
 //    注:错误码的制定从1开始,不要从0开始,
 //        0用作错误码的基数,用来位运算,来判断错误码的范围。
 
+
+
+
+
+
+
 //    laser扫描模块
     LASER_ERROR_BASE                = 0x01000000,
 
@@ -127,21 +148,20 @@ enum Error_code
 
 
      //PLC error code  ...
-    PLC_ERROR_BASE                  = 0x02010000,
-    PLC_UNKNOWN_ERROR,
-    PLC_EMPTY_TASK,
-    PLC_IP_PORT_ERROR,
-    PLC_SLAVE_ID_ERROR,
-    PLC_CONNECTION_FAILED,
-    PLC_READ_FAILED,
-    PLC_WRITE_FAILED,
-    PLC_NOT_ENOUGH_DATA_ERROR,
+    PLC_ERROR_BASE                  				= 0x02010000,
+    PLC_UNKNOWN_ERROR,								//plc未知错误
+    PLC_EMPTY_TASK,									//plc任务为空
+    PLC_IP_PORT_ERROR,								//plc的ip端口错误
+    PLC_SLAVE_ID_ERROR,								//plc的身份id错误
+    PLC_CONNECTION_FAILED,							//PLC连接失败
+    PLC_READ_FAILED,								//plc读取失败
+    PLC_WRITE_FAILED,								//plc写入失败
+    PLC_NOT_ENOUGH_DATA_ERROR,						//PLC没有足够的数据错误
 
 
 
     //locate 定位模块,
 	LOCATER_ERROR_BASE                				= 0x03000000,
-
 	//LASER_MANAGER 定位管理模块
 	LOCATER_MANAGER_ERROR_BASE                		= 0x03010000,
 	LOCATER_MANAGER_READ_PROTOBUF_ERROR,				//定位管理模块,读取参数错误
@@ -169,55 +189,63 @@ enum Error_code
 	LOCATER_INPUT_CLOUD_UNINIT,							//定位输入点云未初始化
 
 
-	//point	sift	from	0x03010100-0x030101FF
-	LOCATER_SIFT_ERROR_BASE							= 0x03020100,
-	LOCATER_SIFT_INIT_FAILED,							//定位过滤模块,初始化失败
-	LOCATER_SIFT_INPUT_CLOUD_UNINIT,					//定位过滤模块,输入点云未初始化
-	LOCATER_SIFT_INPUT_CLOUD_EMPTY,						//定位过滤模块,输入点云为空
-	LOCATER_SIFT_GRID_ERROR,							//定位过滤模块,筛选网格错误
-	LOCATER_SIFT_SELECT_ERROR,							//定位过滤模块,筛选选择错误
-	LOCATER_SIFT_CLOUD_VERY_LITTLE,						//定位过滤模块,筛选点云很少
-	LOCATER_SIFT_CREATE_INPUT_DATA_FAILED,				//定位过滤模块,筛选创建输入数据失败
-	LOCATER_SIFT_PREDICT_FAILED,						//定位过滤模块,预测失败
-	LOCATER_SIFT_PREDICT_TIMEOUT,						//定位过滤模块,预测超时
-	LOCATER_SIFT_PREDICT_NO_WHEEL_POINT,				//定位过滤模块,预测结果没有车轮点云
-	LOCATER_SIFT_PREDICT_NO_CAR_POINT,					//定位过滤模块,预测结果没有车身点云
-
-	LOCATER_SIFT_FILTE_OBS_FAILED,						//定位过滤模块,过滤OBS失败
-	LOCATER_SIFT_INPUT_BOX_PARAMETER_FAILED,			//定位过滤模块,输入范围参数错误
-
-//	//yolo	
-//	LOCATER_YOLO_ERROR_BASE	=0x03020200,
-//	LOCATER_YOLO_DETECT_FAILED,
-//	LOCATER_YOLO_DETECT_NO_TARGET,
-//	LOCATER_YOLO_PARAMETER_INVALID,
-//	LOCATER_YOLO_INPUT_CLOUD_UNINIT,
-
-	//3dcnn	from	0x03010300-0x030103FF
-	LOCATER_3DCNN_ERROR_BASE						=0x03020300,
-	LOCATER_3DCNN_INIT_FAILED,							//定位3DCNN模块,初始化失败
-	LOCATER_3DCNN_INPUT_CLOUD_UNINIT,					//定位3DCNN模块,输入点云未初始化
-	LOCATER_3DCNN_INPUT_CLOUD_EMPTY,					//定位3DCNN模块,输入点云为空
-	LOCATER_3DCNN_INPUT_CLOUD_MAP_ERROR,				//定位3DCNN模块,输入点云的map错误
-	LOCATER_3DCNN_PCA_OUT_ERROR,						//定位3DCNN模块,pca错误
-	LOCATER_3DCNN_EXTRACT_RECT_ERROR,					//定位3DCNN模块,提取矩形错误
-	LOCATER_3DCNN_RECT_SIZE_ERROR,						//定位3DCNN模块,矩形范围错误
-
-	LOCATER_3DCNN_PREDICT_FAILED,						//定位3DCNN模块,预测失败
-	LOCATER_3DCNN_VERIFY_RECT_FAILED_3,					//定位3DCNN模块,验证矩形失败3
-	LOCATER_3DCNN_VERIFY_RECT_FAILED_4,					//定位3DCNN模块,验证矩形失败4
-	LOCATER_3DCNN_KMEANS_FAILED,						//定位3DCNN模块,k均值失败
-	LOCATER_3DCNN_IIU_FAILED,							//定位3DCNN模块,IIU失败
-	LOCATER_3DCNN_PCA_OUT_CLOUD_EMPTY,					//定位3DCNN模块,pca输出点云为空
-
+    //point sift from 0x03010100-0x030101FF
+	LOCATER_SIFT_ERROR_BASE							=0x03020100,
+   	LOCATER_SIFT_INIT_FAILED,							//定位过滤模块,初始化失败
+    LOCATER_SIFT_INPUT_CLOUD_UNINIT,					//定位过滤模块,输入点云未初始化
+	LOCATER_SIFT_INPUT_CLOUD_EMPTY,						//定位过滤模块,输入点云为空
+	LOCATER_SIFT_GRID_ERROR,							//定位过滤模块,筛选网格错误
+	LOCATER_SIFT_SELECT_ERROR,							//定位过滤模块,筛选选择错误
+	LOCATER_SIFT_CLOUD_VERY_LITTLE,						//定位过滤模块,筛选点云很少
+	LOCATER_SIFT_CREATE_INPUT_DATA_FAILED,				//定位过滤模块,筛选创建输入数据失败
+	LOCATER_SIFT_PREDICT_FAILED,						//定位过滤模块,预测失败
+	LOCATER_SIFT_PREDICT_TIMEOUT,						//定位过滤模块,预测超时
+	LOCATER_SIFT_PREDICT_NO_WHEEL_POINT,				//定位过滤模块,预测结果没有车轮点云
+	LOCATER_SIFT_PREDICT_NO_CAR_POINT,					//定位过滤模块,预测结果没有车身点云
+
+    LOCATER_SIFT_FILTE_OBS_FAILED,						//定位过滤模块,过滤OBS失败
+    LOCATER_SIFT_INPUT_BOX_PARAMETER_FAILED,			//定位过滤模块,输入范围参数错误
+
+//    //yolo 
+//    LOCATER_YOLO_ERROR_BASE						=0x03020200,
+//    LOCATER_YOLO_DETECT_FAILED,
+//    LOCATER_YOLO_DETECT_NO_TARGET,
+//    LOCATER_YOLO_PARAMETER_INVALID,
+//    LOCATER_YOLO_INPUT_CLOUD_UNINIT,
+
+    //3dcnn from 0x03010300-0x030103FF
+    LOCATER_3DCNN_ERROR_BASE						=0x03020300,
+    LOCATER_3DCNN_INIT_FAILED,							//定位3DCNN模块,初始化失败
+    LOCATER_3DCNN_INPUT_CLOUD_UNINIT,					//定位3DCNN模块,输入点云未初始化
+	LOCATER_3DCNN_INPUT_CLOUD_EMPTY,					//定位3DCNN模块,输入点云为空
+	LOCATER_3DCNN_INPUT_CLOUD_MAP_ERROR,				//定位3DCNN模块,输入点云的map错误
+	LOCATER_3DCNN_PCA_OUT_ERROR,						//定位3DCNN模块,pca错误
+	LOCATER_3DCNN_EXTRACT_RECT_ERROR,					//定位3DCNN模块,提取矩形错误
+	LOCATER_3DCNN_RECT_SIZE_ERROR,						//定位3DCNN模块,矩形范围错误
+
+    LOCATER_3DCNN_PREDICT_FAILED,						//定位3DCNN模块,预测失败
+    LOCATER_3DCNN_VERIFY_RECT_FAILED_3,					//定位3DCNN模块,验证矩形失败3
+    LOCATER_3DCNN_VERIFY_RECT_FAILED_4,					//定位3DCNN模块,验证矩形失败4
+    LOCATER_3DCNN_KMEANS_FAILED,						//定位3DCNN模块,k均值失败
+    LOCATER_3DCNN_IIU_FAILED,							//定位3DCNN模块,IIU失败
+    LOCATER_3DCNN_PCA_OUT_CLOUD_EMPTY,					//定位3DCNN模块,pca输出点云为空
+
+	//感测和主控通信
+	LOCATER_MSG_TABLE_NOT_EXIST  				= 0x03030100,
+    LOCATER_MSG_RESPONSE_TYPE_ERROR,                                //测量反馈消息类型错误(致命)
+    LOCATER_MSG_RESPONSE_INFO_ERROR,
+    LOCATER_MSG_REQUEST_CANCELED,
+    LOCATER_MSG_REQUEST_INVALID,
+    LOCATER_MSG_RESPONSE_HAS_NO_REQUEST,
+    LOCATER_MSG_REQUEST_REPEATED,
 
     //System_manager error from 0x04010000-0x0401FFFF
-    SYSTEM_READ_PARAMETER_ERROR=0x04010100,
+    SYSTEM_READ_PARAMETER_ERROR						=0x04010100,
     SYSTEM_PARAMETER_ERROR,
     SYSTEM_INPUT_TERMINOR_NO_LASERS,
 
     //terminor_command_executor.cpp from 0x04010200-0x040102FF
-    TERMINOR_NOT_READY=0x04010200,
+    TERMINOR_NOT_READY								=0x04010200,
     TERMINOR_INPUT_LASER_NULL,
     TERMINOR_NOT_CONTAINS_LASER,
     TERMINOR_INPUT_PLC_NULL,
@@ -230,7 +258,7 @@ enum Error_code
 
     ////Hardware limit from 0x05010000 - 0x0501ffff
     ///railing.cpp from 0x05010100-0x050101ff
-    HARDWARE_LIMIT_LEFT_RAILING=0x05010100,         //左栏杆限制
+    HARDWARE_LIMIT_LEFT_RAILING						=0x05010100,         //左栏杆限制
     HARDWARE_LIMIT_RAILING_PARAMETER_ERROR,
     HARDWARE_LIMIT_RAILING_ERROR,
     HARDWARE_LIMIT_CENTER_X_LEFT,
@@ -261,8 +289,8 @@ enum Error_code
 	VELODYNE_LIDAR_DEVICE_NO_CLOUD,									//velodyne设备模块,没有点云
 
 
-//万集通信
-	WJ_LIDAR_COMMUNICATION_ERROR_BASE							=0x06010000,
+	//万集通信wj_lidar error from 0x06010000-0x0601FFFF
+	WJ_LIDAR_COMMUNICATION_ERROR_BASE				=0x06010000,
 	WJ_LIDAR_COMMUNICATION_UNINITIALIZED,							//万集通信,未初始化
 	WJ_LIDAR_COMMUNICATION_DISCONNECT,								//万集通信,断连
 	WJ_LIDAR_COMMUNICATION_FAULT,									//万集通信,故障
@@ -281,8 +309,8 @@ enum Error_code
     VELODYNE_LIDAR_WRITE_FAILED,											//velodyne通信,写入失败
     VELODYNE_LIDAR_GET_CLOUD_TIMEOUT,										//velodyne通信,获取点云超时
 
-//万集解析
-    WJ_PROTOCOL_ERROR_BASE										=0x06020000,
+    //万集解析 wj lidar protocol error from 0x06020000-0x0602FFFF
+        WJ_PROTOCOL_ERROR_BASE						=0x06020000,
 	WJ_PROTOCOL_STATUS_BUSY,										//万集解析, 状态正忙
 	WJ_PROTOCOL_STATUS_ERROR,										//万集解析, 状态错误
     WJ_PROTOCOL_INTEGRITY_ERROR,									//万集解析, 完整性错误								
@@ -290,8 +318,8 @@ enum Error_code
     WJ_PROTOCOL_EMPTY_PACKAGE,										//万集解析, 空包
     WJ_PROTOCOL_EXCEED_MAX_SIZE,									//万集解析, 超出最大范围
 
-    //万集测量范围
-	WJ_REGION_ERROR_BASE										= 0x06030000,
+    //万集测量范围 wj region detect error from 0x06030000-0x0603FFFF
+	WJ_REGION_ERROR_BASE							= 0x06030000,
 	WJ_REGION_EMPTY_CLOUD,											//万集测量,空点云	
 	WJ_REGION_EMPTY_NO_WHEEL_INFORMATION,							//万集测量,没有车轮信息
     WJ_REGION_RECTANGLE_ANGLE_ERROR,								//万集测量,矩形旋转角错误
@@ -309,7 +337,7 @@ enum Error_code
     VELODYNE_REGION_CLUSTER_SIZE_ERROR,									//velodyne测量,簇大小错误
     VELODYNE_REGION_CERES_SOLVE_ERROR,                                    //velodyne测量,优化失败
 
-//万集管理模块
+    //万集管理模块 wj manager error from 0x06040000-0x0604FFFF
 	WJ_MANAGER_ERROR_BASE										= 0x06040000,
     WJ_MANAGER_UNINITIALIZED,									//万集管理模块,未初始化
     WJ_MANAGER_LIDAR_DISCONNECTED,								//万集管理模块,雷达断链
@@ -364,6 +392,8 @@ enum Error_code
 	COMMUNICATION_EXCUTER_IS_BUSY,										//处理器正忙, 请稍等
 
 
+
+
 	//system module, 系统模块
 	SYSTEM_EXECUTOR_ERROR_BASE						= 0x12010000,		//系统执行模块,
 	SYSTEM_EXECUTOR_PARSE_ERROR,										//系统执行模块, 解析消息错误
@@ -371,11 +401,10 @@ enum Error_code
 	SYSTEM_EXECUTOR_STATUS_ERROR,										//系统执行模块, 状态错误
 	SYSTEM_EXECUTOR_CHECK_ERROR,										//系统执行模块, 检查错误
 
-	LOCATER_MSG_TABLE_NOT_EXIST ,
-    LOCATER_MSG_RESPONSE_TYPE_ERROR,
-    LOCATER_MSG_RESPONSE_INFO_ERROR,
-    LOCATER_MSG_REQUEST_INVALID,
-    LOCATER_MSG_RESPONSE_HAS_NO_REQUEST,
+
+
+	//Dispatch 调度 模块 错误码
+	DISPATCH_ERROR_BASE								= 0x13000000,
 
 	//Dispatch_manager 调度管理模块 错误码
 	DISPATCH_MANAGER_ERROR_BASE						= 0x13010000,
@@ -384,6 +413,84 @@ enum Error_code
 	DISPATCH_MANAGER_STATUS_ERROR,						//调度管理模块,状态错误
 	DISPATCH_MANAGER_TASK_TYPE_ERROR,					//调度管理模块,任务类型错误
 	DISPATCH_MANAGER_IS_NOT_READY,						//调度管理模块,不在准备状态
+	DISPATCH_MANAGER_SPACE_LOCK_ERROR,					//调度管理模块,空间锁错误
+
+
+	DISPATCH_PROCESS_ERROR_BASE								= 0x13020000,
+	DISPATCH_PROCESS_IS_NOT_READY,						//调度流程, 不在准备状态
+	DISPATCH_PROCESS_DEVICE_TYPE_ERROR,					//调度流程, 设备类型错误
+	DISPATCH_PROCESS_DEVICE_STATUS_ERROR,				//调度流程, 设备状态错误
+	DISPATCH_PROCESS_TASK_STATUS_ERROR,					//调度流程, 任务类型错误
+	DISPATCH_PROCESS_COMMAND_KEY_REPEAT,				//调度流程, 唯一码错误
+	DISPATCH_PROCESS_INIT_ERROR,						//调度流程, 初始化错误
+
+
+	DISPATCH_DEVICE_ERROR_BASE								= 0x13030000,
+	DISPATCH_DEVICE_READ_PROTOBUF_ERROR,				//调度设备模块,读取参数错误
+	DISPATCH_DEVICE_STATUS_BUSY,						//调度设备模块,状态正忙
+	DISPATCH_DEVICE_STATUS_ERROR,						//调度设备模块,状态错误
+	DISPATCH_DEVICE_STATUS_DISCONNECT,					//调度设备模块,状态断连
+	DISPATCH_DEVICE_TASK_TYPE_ERROR,					//调度设备模块,任务类型错误
+	DISPATCH_DEVICE_TASK_OVER_TIME,						//调度设备模块,任务超时
+	DISPATCH_DEVICE_TASK_REPEAT,						//调度设备模块,任务重复, 任务已经存在
+	DISPATCH_DEVICE_IS_NOT_READY,						//调度设备模块,不在准备状态
+	DISPATCH_DEVICE_RESPONS_ERROR,						//调度设备模块,指令的执行失败
+	DISPATCH_DEVICE_TASK_NOTHINGNESS,					//调度设备模块,任务不存在
+	DISPATCH_DEVICE_TASK_LEVEL_ERROR,					//调度设备模块,任务等级错误
+
+
+	CARRIER_ERROR_BASE								= 0x13040000,
+	CARRIER_READ_PROTOBUF_ERROR,				//搬运器模块,读取参数错误
+	CARRIER_STATUS_BUSY,						//搬运器模块,状态正忙
+	CARRIER_STATUS_ERROR,						//搬运器模块,状态错误
+	CARRIER_STATUS_DISCONNECT,					//搬运器模块,状态断连
+	CARRIER_TASK_TYPE_ERROR,					//搬运器模块,任务类型错误
+	CARRIER_TASK_OVER_TIME,						//搬运器模块,任务超时
+	CARRIER_IS_NOT_READY,						//搬运器模块,不在准备状态
+	CARRIER_RESPONS_ERROR,						//搬运器模块,指令的执行失败
+	CARRIER_TASK_NOTHINGNESS,					//搬运器模块,任务不存在
+	CARRIER_POSE_ERROR,							//搬运器模块,姿态错误
+	CARRIER_CONRTOL_PARAMETER_ERROR,			//搬运器模块,控制参数错误
+
+	CATCHER_ERROR_BASE								= 0x13050000,
+	CATCHER_READ_PROTOBUF_ERROR,				//抓取器模块,读取参数错误
+	CATCHER_STATUS_BUSY,						//抓取器模块,状态正忙
+	CATCHER_STATUS_ERROR,						//抓取器模块,状态错误
+	CATCHER_STATUS_DISCONNECT,					//抓取器模块,状态断连
+	CATCHER_TASK_TYPE_ERROR,					//抓取器模块,任务类型错误
+	CATCHER_TASK_OVER_TIME,						//抓取器模块,任务超时
+	CATCHER_IS_NOT_READY,						//抓取器模块,不在准备状态
+	CATCHER_RESPONS_ERROR,						//抓取器模块,指令的执行失败
+	CATCHER_TASK_NOTHINGNESS,					//抓取器模块,任务不存在
+	CATCHER_POSE_ERROR,							//抓取器模块,姿态错误
+	CATCHER_CONRTOL_PARAMETER_ERROR,			//抓取器模块,控制参数错误
+
+	PASSAGEWAY_ERROR_BASE								= 0x13060000,
+	PASSAGEWAY_READ_PROTOBUF_ERROR,				//通道口模块,读取参数错误
+	PASSAGEWAY_STATUS_BUSY,						//通道口模块,状态正忙
+	PASSAGEWAY_STATUS_ERROR,						//通道口模块,状态错误
+	PASSAGEWAY_STATUS_DISCONNECT,					//通道口模块,状态断连
+	PASSAGEWAY_TASK_TYPE_ERROR,					//通道口模块,任务类型错误
+	PASSAGEWAY_TASK_OVER_TIME,						//通道口模块,任务超时
+	PASSAGEWAY_IS_NOT_READY,						//通道口模块,不在准备状态
+	PASSAGEWAY_RESPONS_ERROR,						//通道口模块,指令的执行失败
+	PASSAGEWAY_TASK_NOTHINGNESS,					//通道口模块,任务不存在
+
+
+	//DISPATCH_COORDINATES module, 通信模块
+	DISPATCH_COORDINATES_ERROR_BASE					= 0x13060000,
+	DISPATCH_COORDINATES_READ_PROTOBUF_ERROR,				//调度坐标模块,读取参数错误
+	DISPATCH_COORDINATES_ID_ERROR,							//调度坐标模块,坐标id错误
+	DISPATCH_COORDINATES_PATH_ERROR,						//调度坐标模块,路径方向错误
+	DISPATCH_COORDINATES_CAN_NOT_LOCK,						//调度坐标模块,不能加锁
+
+	//Dispatch_plc 调度plc模块
+	DISPATCH_PLC_ERROR_BASE							= 0x13070000,
+	DISPATCH_PLC_REQUEST_ERROR,								//调度plc模块,请求错误
+	DISPATCH_PLC_RESPONS_ERROR,								//调度plc模块,指令的执行失败
+	DISPATCH_PLC_STATUS_ERROR,								//调度plc模块,状态错误
+	DISPATCH_PLC_TIME_OUT,									//调度plc模块,超时
+
 
 	//snap7 通信模块 错误码
 	SNAP7_ERROR_BASE								= 0x1401000,
@@ -394,6 +501,76 @@ enum Error_code
 	SNAP7_WRITE_ERROR,									//snap7通信模块,写入错误
 	SNAP7_ANALYSIS_TIME_OUT,									//解析超时,
 	SNAP7_EXCUTER_IS_BUSY,										//处理器正忙, 请稍等
+	
+
+	
+	
+    
+    //parkspace allocator,车位分配模块
+    PARKSPACE_ALLOCATOR_ERROR_BASE                  = 0x20010000,     
+    PARKSPACE_ALLOCATOR_MSG_REQUEST_TYPE_ERROR,    //反馈车位消息类型错误 
+    PARKSPACE_ALLOCATOR_MSG_RESPONSE_TYPE_ERROR,    //反馈车位消息类型错误
+    PARKSPACE_ALLOCATOR_MSG_PARSE_ERROR,            //请求消息解析错误
+    PARKSPACE_ALLOCATOR_SPACE_EMPTY,                //空车位异常,车库无车位。或许由模块初始化异常产生
+    PARKSPACE_ALLOCATOR_ALLOCATE_FAILED,            //无合适车位,分配失败
+    PARKSPACE_ALLOCATOR_SEARCH_FAILED,              //未找到车辆对应车位
+    PARKSPACE_ALLOCATOR_RELEASE_FAILED,             //未找到匹配的车位,车位未释放
+    PARKSPACE_ALLOCATOR_FORCE_UPDATE_FAILED,        //手动更新失败,未找到匹配车位
+    PARKSPACE_ALLOCATOR_PARAM_ERROR,                //传入参数错误
+    PARKSPACE_ALLOCATOR_CONFIRM_ALLOC_ERROR,        //确认分配车位错误
+    PARKSPACE_ALLOCATOR_CAR_ALREADY_EXIST,          //车辆已存在
+
+    // 数据库操作
+    DB_ERROR_BASE                                   = 0x20020000,
+    DB_INIT_FAILED,									//数据库初始化失败
+    DB_CONNECT_FAILED,                              //数据库连接失败
+    DB_STATUS_ERROR,								//数据库状态错误
+	DB_MANAGER_STATUS_ERROR,						//数据库管理状态错误
+    DB_INSERT_FAILED,                               //数据库插入失败
+    DB_DELETE_FAILED,                               //数据库删除失败
+    DB_UPDATE_FAILED,                               //数据库更新失败
+    DB_QUERY_FAILED,                                //数据库查询失败
+    DB_UNINITIALIZED,                               //数据库外层未初始化
+    DB_DISCONNECTED,                                //数据库外层连接失去
+    DB_RESULT_SET_EMPTY,                            //数据库外层查询返回结果空指针
+    DB_RESULT_SET_PARSE_ERROR,                      //数据库外层查询结果解析失败
+    DB_CONNECT_CHANNEL_NOT_FOUND,					//数据库连接通道未找到
+    DB_CONNECT_CHANNEL_NUMBER_ERROR,				//数据库连接通道数量错误
+    DB_QUERY_DATA_REPEAT,							//数据库查询数据重复
+    DB_QUERY_NOT_DATA,								//数据库未查询到数据
+	DB_QUERY_DATA_FAILED,							//数据库查询数据错误
+	DB_NOT_QUERY_EMPTY_PARKSPACE,					//数据库未查询到空车位
+	DB_PROTOBUF_ERROR,								//数据库配置参数读取错误
+
+
+
+
+    //parkspace error code
+    PARKSPACE_REQUEST_MSG_TYPE_ERROR            	= 0x20030000,
+    PARKSPACE_ALLOCMSG_RESPONSE_HAS_NO_REQUEST,
+    PARKSPACE_SEARCHMSG_RESPONSE_HAS_NO_REQUEST,
+    PARKSPACE_RELEASEMSG_RESPONSE_HAS_NO_REQUEST,
+    PARKSPACE_ALLOC_REQUEST_INVALID,
+    PARKSPACE_SEARCH_REQUEST_INVALID,
+    PARKSPACE_RELEASE_REQUEST_INVALID,
+
+    PARKSPACE_ALLOC_REQUEST_REPEATED,
+    PARKSPACE_SEARCH_REQUEST_REPEATED,
+    PARKSPACE_RELEASE_REQUEST_REPEATED,
+
+    PARKSPACE_ALLOC_RESPONSE_TYPE_ERROR,
+    PARKSPACE_SEARCH_RESPONSE_TYPE_ERROR,
+    PARKSPACE_RELEASE_RESPONSE_TYPE_ERROR,
+
+    PARKSPACE_ALLOC_RESPONSE_INFO_ERROR,
+    PARKSPACE_SEARCH_RESPONSE_INFO_ERROR,
+    PARKSPACE_RELEASE_RESPONSE_INFO_ERROR,
+
+    PARKSPACE_ALLOC_REQUEST_CANCELED,
+    PARKSPACE_SEARCH_REQUEST_CANCELED,
+    PARKSPACE_RELEASE_REQUEST_CANCELED,
+
+
 };
 
 //错误等级,用来做故障处理
@@ -445,7 +622,7 @@ public://外部接口函数
     Error_manager(const Error_manager & error_manager);
     //赋值构造
     Error_manager(Error_code error_code, Error_level error_level = NORMAL,
-                  const char* p_error_description = NULL, int description_length = 0);
+                  const char* p_error_description = NULL);
     //赋值构造
     Error_manager(Error_code error_code, Error_level error_level , std::string & error_aggregate_string);
     //析构函数
@@ -455,12 +632,12 @@ public://外部接口函数
     void error_manager_init();
     //初始化
     void error_manager_init(Error_code error_code, Error_level error_level = NORMAL,
-                            const char* p_error_description = NULL, int description_length = 0);
+                            const char* p_error_description = NULL);
     //初始化
     void error_manager_init(Error_code error_code, Error_level error_level , std::string & error_aggregate_string);
     //重置
     void error_manager_reset(Error_code error_code, Error_level error_level = NORMAL,
-                             const char* p_error_description = NULL, int description_length = 0);
+                             const char* p_error_description = NULL);
     //重置
     void error_manager_reset(Error_code error_code, Error_level error_level , std::string & error_aggregate_string);
     //重置
@@ -489,14 +666,12 @@ public://外部接口函数
     //获取错误等级
     Error_level get_error_level();
     //获取错误描述的指针,(浅拷贝)
-    char* get_error_description();
-
-	int get_description_length();
+    std::string get_error_description();
 
     //复制错误描述,(深拷贝)
     //output:p_error_description     错误描述的字符串指针,不可以为NULL,必须要有实际的内存
     //output:description_length      错误描述的字符串长度,不可以为0,长度最好足够大,一般256即可。
-    void copy_error_description(const char* p_error_description, int description_length);
+    void copy_error_description(const char* p_error_description);
     //复制错误描述,(深拷贝)
     //output:error_description_string     错误描述的string
     void copy_error_description(std::string & error_description_string);
@@ -510,12 +685,12 @@ public://外部接口函数
     //错误等级,设定到固定值
     void set_error_level_location(Error_level error_level);
     //设置错误描述
-    void set_error_description(const char* p_error_description, int description_length = 0);
+    void set_error_description(const char* p_error_description);
     //设置错误描述
     void set_error_description(std::string & error_description_string);
 
     //尾部追加错误描述
-    void add_error_description(const char* p_error_description, int description_length = 0);
+    void add_error_description(const char* p_error_description);
     //尾部追加错误描述
     void add_error_description(std::string & error_description_string);
 
@@ -529,10 +704,6 @@ public://外部接口函数
 	//如果错误相同,则保留this的,将输入参数转入描述。
 	void compare_and_cover_error( Error_manager * p_error_manager);
 
-	//将所有的错误信息,格式化为字符串,用作日志打印。
-    //output:p_error_description     错误汇总的字符串指针,不可以为NULL,必须要有实际的内存
-    //output:description_length      错误汇总的字符串长度,不可以为0,长度最好足够大,一般256即可。
-    void translate_error_to_string(char* p_error_aggregate, int aggregate_length);
     //output:error_description_string     错误汇总的string
     void translate_error_to_string(std::string & error_aggregate_string);
     //错误码转字符串的简易版,可支持cout<<
@@ -544,8 +715,7 @@ public://外部接口函数
 protected:
     Error_code              m_error_code;               //错误码
     Error_level             m_error_level;              //错误等级
-    char*                   pm_error_description;       //错误描述
-    int                     m_description_length;       //错误描述的字符长度
+    std::string             m_error_description;		// 错误描述
 
 protected://内部功能函数
 public:

+ 11 - 0
message/UnNormalized_module_message.proto

@@ -0,0 +1,11 @@
+syntax = "proto2";
+ package message;
+ import "message_base.proto";
+ //地面定位模块测量结果 
+message UnNormalized_module_statu_msg
+ {
+	required Base_info base_info=1; //消息类型 
+	required int32 id=2; 
+	required Error_manager statu_code=3; //模块状态 
+	optional string car_license=4; //号牌数据 
+}

+ 56 - 0
message/central_control_message.proto

@@ -0,0 +1,56 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+
+
+//针对流程的手动操作类型
+enum Process_operation_type
+{
+    eManual_cancel=0;                   //取消流程
+    eManual_retry=1;                    //重试
+    eManual_ignore=2;                   //忽略
+}
+
+enum Module_statu
+{
+    eConnected=0;               //连接
+    eDisconnected=1;            //连接丢失
+    eFault=2;                   //故障
+}
+
+//出入口状态
+message Entrance_statu
+{
+    required    bool                paused=1;
+    optional    Module_statu        parkspace_statu=2;
+    optional    Module_statu        dispatch_statu=3;
+    optional    Module_statu        notify_statu=4;
+}
+
+//中控状态消息
+message Central_controller_statu_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    repeated Entrance_statu             entrance_statu_vector=2;    //入口状态(关闭或者开放)
+    repeated Entrance_statu             export_statu_vector=3;      //出口状态
+}
+
+//出入口手动急停/启动消息
+message Entrance_manual_operation_msg
+{
+    required Base_info                  base_info=1;
+    required int32                      terminal_id=2;
+    required Process_type               process_type=3;
+    required bool                       paused=4;           //是否急停
+}
+
+//流程手动操作消息
+message Process_manual_operation_msg
+{
+    required Base_info                  base_info=1;
+    required string                     license=2;
+    required Step_type                  step_type=3;
+    required Process_operation_type     operate_type=4;
+}
+
+

+ 209 - 0
message/dispatch_control.proto

@@ -0,0 +1,209 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+
+
+//调度任务的类型
+enum Dispatch_task_type
+{
+    DISPATCH_TASK_TYPE_UNKNOW               = 0;
+
+    DISPATCH_PLAN_STORE                     = 101;  //总指令, 存车
+    DISPATCH_PLAN_PICKUP                    = 102;  //总指令, 取车
+
+
+    //机器手的动作
+    ROBOT_CATCH_CAR_FROM_INLET              = 1;    //机器手去入口抓车(例如:机器手移动到2号入口上方,然后下降到一楼抓车,最后上升到最上方)
+    ROBOT_PUT_CAR_TO_CARRIER                = 2;    //机器手把车放到中跑车上面(例如:机器手下降到中跑车上放车,最后上升到最上方)(通过目标点 指定放到哪一个中跑车上)
+    ROBOT_CATCH_CAR_FROM_CARRIER            = 3;    //机器手去中跑车上抓车(例如:机器手移动到1号中跑车上方,然后下降到中跑车抓车,最后上升到最上方)
+    ROBOT_PUT_CAR_TO_OUTLET                 = 4;    //机器手去出口放车(例如:机器手移动到3号出口上方,然后下降到一楼放车,最后上升到最上方)
+    ROBOT_MOVE                              = 5;    //机器手的自由移动(例如:机器手移动到6号出入口的上方4楼处,给其他设备避让)(不进行抓车和放车的操作)
+
+    //搬运器的动作(升降电梯 中跑车 小跑车 三合一为搬运器)
+    CARRIER_RECEIVE_CAR_FROM_ROBOT          = 11;   //搬运器从机器手上接车(例如:搬运器移动到2号入口的上方,然后等待机器手把车放到中跑车上,小跑车保持松夹杆状态)
+    CARRIER_STORE_CAR_TO_PARKINGSPACE       = 12;   //搬运器把车存到停车位上(例如:小跑车夹车后,搬运器移动到56号停车位,然后小跑车将车存入车位,之后搬运器退回至电梯井)
+    CARRIER_STORE_CAR_TO_PARKINGSPACE_EX    = 122;   //搬运器把车存到停车位上(例如:小跑车夹车后,搬运器移动到56号停车位,然后小跑车将车存入车位,之后搬运器退回至56车位外面即可)
+
+    CARRIER_PICKUP_CAR_FROM_PARKINGSPACE    = 13;   //搬运器从停车位上取车(例如:搬运器移动到56号停车位,然后小跑车将车从车位取出,之后搬运器退回至电梯井)
+    CARRIER_PICKUP_CAR_FROM_PARKINGSPACE_EX = 133;   //搬运器从停车位上取车(例如:搬运器移动到56号停车位,然后小跑车将车从车位取出,之后搬运器退回至56车位外面即可)
+    CARRIER_DELIVER_CAR_TO_ROBOT            = 14;   //搬运器把车交付给机器手(例如:搬运器移动到3号入口的上方,小跑车松夹杆,然后等待机器手把车从中跑车上取走)
+    CARRIER_MOVE                            = 15;   //搬运器的自由移动(可以提前到2楼来准备接车,或者为了避让就退回至电梯井)(小跑车不进行取车和存车)
+
+    //通道口的动作(1楼出入口的动作)
+    PASSAGEWAY_OPEN_OUTSIDE_DOOR            = 21;   //通道口开外侧大门(0~7号出入口都有)
+    PASSAGEWAY_CLOSE_OUTSIDE_DOOR           = 22;   //通道口关外侧大门(0~7号出入口都有)
+    PASSAGEWAY_OPEN_INSIDE_DOOR             = 23;   //通道口开内侧大门(0号和7号出入口特有的指令)
+    PASSAGEWAY_CLOSE_INSIDE_DOOR            = 24;   //通道口关内侧大门(0号和7号出入口特有的指令)
+    PASSAGEWAY_ROTATE_TURNTABLE_TO_CARRIER  = 25;   //通道口旋转转盘到搬运器(对接小跑车)
+    PASSAGEWAY_ROTATE_TURNTABLE_TO_OUTLET   = 26;   //通道口旋转转盘到出口
+
+    //结束指令
+    DISPATCH_FINISH                         = 30;   //整个调度流程完成, 正常完成(之后调度向总控汇报 正常完成任务)
+    DISPATCH_CANCEL                         = 31;   //整个调度流程取消, 异常完成(之后调度向总控汇报 异常完成任务, 并把错误码往上报)
+    DISPATCH_PAUSE                          = 40;   //调度暂停, 可以指定某一个设备暂时 停止动作,直接进入空闲状态(之后再次发送上面的正常指令,可以让其执行新的动作)
+    DISPATCH_RESERVED                       = 50;   //预留
+
+    //存车顺序  (1和15) ->11->2->12
+    //1~6取车顺序  13-> (14和5) ->3->15->4
+    //7取车顺序    13->12
+
+    //3楼存车  (5和15) ->1->15 -> (5和11) ->2->12
+    //3楼取车  (5和15) ->13->14->3-> (15和5) ->4->15
+
+    //例如:机器手和3楼搬运器在2号入口上方, 执行存车指令 4号入口 -> 3楼27号车位.
+    //同时抢占  搬运器和机器手的资源
+    //5和15      机器手去1404  搬运器去1303
+    //1         机器手去1104抓车, 并返回最高点
+    //15        搬运器去1304
+    //5和11     机器手去42    搬运器去27准备接车
+    //2         机器手把车放到中跑车上27
+    //12        搬运器把车存入27号车位
+    //同时释放  搬运器和机器手的资源
+
+    //例如:机器手和3楼搬运器在2号入口上方, 执行取车指令 3楼27号车位 -> 4号出口.
+    //同时抢占  搬运器和机器手的资源
+    //5和15      机器手去42  搬运器去27
+    //13        搬运器去27号车位取车
+    //14        搬运器去27号车位 把车交给机器手
+    //3         机器手去27号 抓车
+    //5和15      机器手去1404  搬运器去1305
+    //4         机器手把车放到1104出口, 并返回最高点
+    //15        搬运器去1304
+    //同时释放  搬运器和机器手的资源
+}
+
+
+
+//调度设备的目标状态, 设备完成 调度控制的任务请求 之后 将设备状态改为这个
+enum Dispatch_device_target_status
+{
+    E_TARGET_STATUS_UNKNOW               	= 0;    //未知
+    E_TARGET_STATUS_IDLE                    = 1;    //空闲
+    E_TARGET_STATUS_BUSY					= 2; 	//工作正忙
+    E_TARGET_STATUS_READY               	= 3;    //准备就绪
+    E_TARGET_STATUS_WAIT               	    = 4;    //等待
+}
+
+//调度设备的任务状态
+enum Dispatch_device_task_status
+{
+        E_TASK_CREATED              = 0;      		//任务创建; 发送方
+
+        E_TASK_ISSUE		        = 1; 			//任务下发; 发送方
+        E_TASK_SIGNED               = 2;      		//已签收; 接收方
+        E_TASK_WORKING              = 3;      		//处理中; 接收方
+        E_TASK_OVER                 = 4;   			//已结束; 接收方
+        E_TASK_STOP		            = 5; 			//任务暂停; 接收方
+
+    	E_TASK_ERROR                = 11;			//任务错误; 接收方
+
+    	E_TASK_CANCEL				= 21;			//任务取消; 发送方
+    	E_TASK_DEAD                 = 22;           //任务死亡; 接收方
+
+    	E_TASK_WITHDRAW		        = 31; 			//任务收回; 发送方
+    	E_TASK_FREE			        = 32; 			//任务释放; 接收方
+
+
+     //发送方 写 E_TASK_CREATED
+     //接收方 收到之后 写 E_TASK_WORKING
+     //接受方每隔1秒 周期性反馈消息
+     //接受方完成任务后, 最后一次发送 E_TASK_OVER
+}
+
+
+
+//调度总规划的请求, 用于启动整个调度算法(调度管理->调度算法)
+message Dispatch_plan_request_msg
+{
+    required Base_info                  base_info=1;                     //消息类型
+    required string                     command_key=2;                   //指令唯一标识符id
+
+    optional Dispatch_task_type         dispatch_task_type=3;            //调度任务的类型
+    optional int32                      dispatch_source=4;               //调度的起点,源头(暂时不写)(留给以后使用)
+    optional int32                      dispatch_destination=5;          //调度的终点,目的地(一般必须写, 特殊指令可以不写)
+
+    optional Error_manager              error_manager = 6;               //错误码,也是任务的完成结果(如果为0,则表示成功完成任务,非0则任务失败)
+}
+
+//调度总规划的答复(调度算法->调度管理)
+message Dispatch_plan_response_msg
+{
+    required Base_info                  base_info=1;                    //消息类型
+    required string                     command_key=2;                   //指令唯一标识符id
+
+    optional Dispatch_task_type         dispatch_task_type=3;            //调度任务的类型
+    optional int32                      dispatch_source=4;               //调度的起点,源头(可以不写)
+    optional int32                      dispatch_destination=5;          //调度的终点,目的地(必写,如果不写 任务就不会执行)
+
+    optional Error_manager              error_manager = 6;               //错误码,也是任务的完成结果(如果为0,则表示成功完成任务,非0则任务失败)
+}
+
+//调度控制的任务请求(调度算法->调度管理)
+message Dispatch_control_request_msg
+{
+    required Base_info                  base_info=1;                     //消息类型
+    required string                     command_key=2;                   //指令唯一标识符id
+
+    required Dispatch_task_type         dispatch_task_type=3;            //调度任务的类型
+    optional Dispatch_device_type       dispatch_device_type=4;          //调度设备的类型
+    optional int32                      dispatch_source=5;               //调度的起点,源头(暂时不写)(留给以后使用)
+    optional int32                      dispatch_destination=6;          //调度的终点,目的地(一般必须写, 特殊指令可以不写)
+
+    optional Error_manager              error_manager = 7;               //错误码,也是任务的完成结果(如果为0,则表示成功完成任务,非0则任务失败)
+
+    optional Dispatch_device_target_status  dispatch_device_target_status = 8;  //调度设备的目标状态
+
+    optional Dispatch_device_task_status    dispatch_device_task_status = 9;//调度设备的任务状态
+}
+
+//调度控制的任务答复(调度管理->调度算法)
+message Dispatch_control_response_msg
+{
+    required Base_info                  base_info=1;                     //消息类型
+    required string                     command_key=2;                   //指令唯一标识符id
+
+    optional Dispatch_task_type         dispatch_task_type=3;            //调度任务的类型
+    optional Dispatch_device_type       dispatch_device_type=4;          //调度设备
+    optional int32                      dispatch_source=5;               //调度的起点,源头(可以不写)
+    optional int32                      dispatch_destination=6;          //调度的终DISPATCH_FINISH点,目的地(必写,如果不写 任务就不会执行)
+
+    optional Error_manager              error_manager = 7;               //错误码,也是任务的完成结果(如果为0,则表示成功完成任务,非0则任务失败)
+
+    optional Dispatch_device_target_status  dispatch_device_target_status = 8;  //调度设备的目标状态
+    optional Dispatch_device_task_status    dispatch_device_task_status = 9;//调度设备的任务状态
+
+}
+
+
+/*
+        dispatch_source 和 dispatch_destination 的表示含义
+
+        1~165           2楼~12楼的停车位
+
+        1100            0号出口(在一楼)(目前没有)
+        1101~1106       1~6号出入口 (在一楼)
+        1107            7号出口(在一楼)
+        1201~1206       1~6号出入口上方2楼处
+        1301~1306       1~6号出入口上方3楼处
+        1401~1406       1~6号出入口上方4楼处
+
+        2101~2112       左侧电梯井(1楼~12楼)(一号搬运器的待机点)
+        2201~2212       右侧电梯井(1楼~12楼)(二号搬运器的待机点)
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 316 - 0
message/dispatch_message.proto

@@ -0,0 +1,316 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+
+
+
+//终端流程状态, 表示这个出入口到楼上停车位之间的所有设备总状态
+enum Terminal_status
+{
+    E_TERMINAL_UNKNOW               = 0;     //未知
+    E_TERMINAL_READY                = 1;     //准备,待机
+    E_TERMINAL_STORE                = 2;	    //正在存车
+    E_TERMINAL_PICKUP               = 3;	    //正在取车
+
+    E_TERMINAL_FAULT                = 10;     //故障
+}
+
+//通道口属性, 出入口的方向属性, 表示这个通道允许停车或者取车
+enum Passageway_direction
+{
+    E_INLET             =0;         //入口
+    E_OUTLET            =1;         //出口
+    E_BILATERAL         =2;         //双向口
+}
+
+//调度模块终端出入口的状态
+message Dispatch_terminal_status_msg
+{
+    required Base_info                  base_info=1;                    //消息类型
+    required int32                      terminal_id=2;                  //终端id
+    required Terminal_status            terminal_status = 3;            //终端流程状态, 表示这个出入口到楼上停车位之间的所有设备总状态
+    required Passageway_direction       passageway_direction = 4;       //通道口属性, 出入口的方向属性, 表示这个通道允许停车或者取车
+}
+
+//调度方向, 停车取车, 表示正在执行的动作
+enum Dispatch_motion_direction
+{
+    E_STORE_CAR             =0;         //停车, 出入口 -> 停车位
+    E_PICKUP_CAR            =1;         //取车, 停车位 -> 出入口
+}
+
+
+
+//执行搬运请求(主控->调度管理)
+message Dispatch_request_msg
+{
+    required Base_info                  base_info=1;                            //消息类型
+    required string                     command_key=2;                   //指令唯一标识符id
+
+    optional Dispatch_motion_direction  dispatch_motion_direction=3;            //调度方向, 停车取车
+    optional int32                      terminal_id=4;                          //终端id, 出入口
+    optional Locate_information         locate_information=5;                   //汽车测量信息, 只有停车时有数据, 取车时没有数据.
+
+    repeated Parkspace_info             parkspace_info_ex=6;                         //车位编号, 停车位(B方案, 分配3个停车位)
+    optional Car_type                   car_type=7;                             //汽车大小
+}
+
+//搬运动作执行完成后反馈结果(调度管理->主控)
+message Dispatch_response_msg
+{
+    required Base_info                  base_info=1;                    //消息类型
+    required string                     command_key=2;                   //指令唯一标识符id
+
+
+    optional Dispatch_motion_direction  dispatch_motion_direction=3;            //调度方向, 停车取车
+    optional int32                      terminal_id=4;                          //终端id, 出入口
+    optional Locate_information         locate_information=5;                   //汽车测量信息, 只有停车时有数据, 取车时没有数据.
+
+    repeated Parkspace_info             parkspace_info_ex=6;                         //车位编号, 停车位(B方案, 分配3个停车位)
+    optional Car_type                   car_type=7;                             //汽车大小
+
+    optional Error_manager              error_manager = 8;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//调度管理 的状态
+enum Dispatch_manager_status
+{
+    E_DISPATCH_MANAGER_UNKNOW               = 0;    //未知
+    E_DISPATCH_MANAGER_READY                = 1;    //准备,待机
+    E_DISPATCH_MANAGER_STORE                = 2;    //正在存车
+    E_DISPATCH_MANAGER_PICKUP               = 3;    //正在取车
+
+    E_DISPATCH_MANAGER_FAULT               = 100;    //故障
+}
+
+//设备状态,这个类的总状态,这里指工作任务流程
+	enum Dispatch_device_status
+	{
+	    DISPATCH_DEVICE_UNKNOW               	= 0;    //未知
+    	DISPATCH_DEVICE_READY               	= 1;    //准备,待机
+    	DISPATCH_DEVICE_BUSY					= 2; 	//工作正忙
+
+    	DISPATCH_DEVICE_ONE_LEVEL_OVER		= 3; 	//一级工作完成;
+    	DISPATCH_DEVICE_ONE_LEVEL_WORK		= 4;	//一级工作状态; 就是普通的移动任务
+    	DISPATCH_DEVICE_TWO_LEVEL_OVER		= 5; 	//一级工作完成;
+    	DISPATCH_DEVICE_TWO_LEVEL_WORK		= 6;	//二级工作状态; 就是紧急避让; 插队任务(会在执行一级任务的过程中; 插队并优先执行二级任务)
+    	DISPATCH_DEVICE_THREE_LEVEL_OVER		= 7; 	//一级工作完成;
+    	DISPATCH_DEVICE_THREE_LEVEL_WORK		= 8;	//三级工作任务; 就是锁定硬件资源; 不让插队; (除非急停或者取消任务)
+
+       	DISPATCH_DEVICE_FAULT					= 100;	//故障
+    	DISPATCH_DEVICE_DISCONNECT			= 101; 	//通信故障
+	};
+
+	//调度任务的等级
+	enum Dispatch_task_level
+	{
+//	    DISPATCH_TASK_UNKNOW_LEVEL          = 0;    //无效任务
+		DISPATCH_TASK_ONE_LEVEL             = 1;    //一级任务
+		DISPATCH_TASK_TWO_LEVEL				= 2;	//二级任务
+		DISPATCH_TASK_THREE_LEVEL			= 3;	//三级任务
+	};
+
+	//抓车的夹杆
+	enum Clamp_motion
+	{
+		E_CLAMP_NO_ACTION            	= 0;    //无动作.
+		E_CLAMP_TIGHT               	= 1;    //夹紧夹杆
+		E_CLAMP_LOOSE					= 2;	//松开夹杆
+	};
+
+	//中跑车和平层轨道的对接
+	enum Joint_motion
+	{
+		E_JOINT_NO_ACTION            	= 0;    //无动作.
+		E_JOINT_HOLD_OUT               	= 1;    //伸出对接,之后中跑车可以x轴移动,电梯不能Z轴移动
+		E_JOINT_TAKE_BACK				= 2;	//收回对接,之后中跑车固定在电梯上不能X轴移动,电梯可以Z轴移动
+	};
+
+	//小跑车的位置,是否在中跑车上面
+	enum Small_sports_car_motion
+	{
+		E_SMALL_SPORTS_NO_ACTION		= 0;    //无动作.
+		E_SMALL_SPORTS_CAR_GET_AWAY 	= 1;    //小跑车离开中跑车
+		E_SMALL_SPORTS_CAR_GET_BACK		= 2;	//小跑车返回中跑车
+	};
+
+
+	//指令完成状态, 设备答复指令, 返回任务完成的情况
+	enum Respons_status
+	{
+		RESPONS_WORKING            	= 0;    //任务进行中
+		RESPONS_OVER               	= 1;    //任务完成
+		RESPONS_MINOR_ERROR			= 100;	//一般故障, 可恢复
+		RESPONS_CRITICAL_ERROR		= 101;	//致命故障,不可恢复
+	};
+
+	//设备的硬件设备状态
+	enum Hardware_device_status
+	{
+		DEVICE_UNKNOWN              = 0;    //设备未知
+		DEVICE_READY                = 1;    //设备空闲(可以接受新的指令任务)
+		DEVICE_WORKING				= 2;	//设备工作中
+		DEVICE_EMERGENCY_STOP		= 3;	//设备急停
+		DEVICE_UNSAFETY				= 4;	//设备不安全(暂时不考虑是否处于安全位置)
+		DEVICE_COLLISION			= 5;	//设备发生碰撞
+		DEVICE_FAULT				= 6;	//设备故障
+	};
+
+	//设备的负载状态, 小跑车上面是否有车.
+	enum Load_status
+	{
+		LOAD_UNKNOWN				= 0;	//负载未知
+		HAVE_CAR               		= 1;    //有车
+		NO_CAR            			= 2;    //没车
+	};
+
+	//7号出口 转台方向
+	enum Turntable_direction
+	{
+		TURNTABLE_DIRECTION_UNKNOWN				= 0;	//方向未知,
+		TURNTABLE_DIRECTION_INSIDE 				= 1;    //方向朝里,对接内门的小跑车
+		TURNTABLE_DIRECTION_OUTSIDE  			= 2;    //没车朝外,对接外门的出口
+	};
+
+	//出入口 门的开关状态
+	enum Door_motion
+	{
+		DOOR_UNKNOWN            = 0;    //门的开关状态 未知, 或者工作到一半,正在工作中.
+	    DOOR_OPEN               = 1;    //开门
+		DOOR_CLOSE				= 2;	//关门
+		DOOR_ERROR				= 3;	//
+	};
+
+	//边界判断,是否超界
+	enum Overstep_the_boundary
+	{
+		BOUNDARY_NORMAL			= 0;	//边界 正常
+		BOUNDARY_OVERSTEP       = 1;    //超界
+	};
+
+
+
+
+//抓取器的状态(机器手)
+message Catcher_data
+{
+    required Dispatch_device_type               dispatch_device_type=1;         //调度设备的类型
+    required Dispatch_device_status             dispatch_device_status=2;       //设备总状态, 控制任务流程(长流程)
+
+    required int32                              device_id=3;                    //设备id,
+	optional Hardware_device_status				actual_device_status=4;			//机器人的硬件设备状态(短流程)
+	optional Load_status						actual_load_status=5;	        //机器人的负载状态, 机器人上面是否有车.
+
+    optional int32 								actual_coordinates_id=6;		//机器人真实 空间位置的id.
+	optional float 								actual_x=7;					    //机器人坐标x轴,
+	optional float 								actual_y=8;					    //机器人坐标y轴,
+	optional float 								actual_b=9;					    //机器人坐标b轴, 旋转范围80~280
+	optional float 								actual_z=10;				    //机器人坐标z轴,
+	optional float 								actual_d1=11;				    //机器人坐标d1轴, 机器人抓车杆纵向移动(前轮抓杆)
+	optional float 								actual_d2=12;				    //机器人坐标d2轴, 机器人抓车杆纵向移动(后轮抓杆)
+	optional Clamp_motion						actual_clamp_motion1=13;		//机器人夹车杆. 0=无动作,1=夹紧,2=松开
+	optional Clamp_motion						actual_clamp_motion2=14;		//机器人夹车杆. 0=无动作,1=夹紧,2=松开
+	optional Clamp_motion						actual_clamp_motion3=15;		//机器人夹车杆. 0=无动作,1=夹紧,2=松开
+	optional Clamp_motion						actual_clamp_motion4=16;		//机器人夹车杆. 0=无动作,1=夹紧,2=松开
+
+    optional string                             actual_error_code=17;	        //机器人设备的故障信息位
+    optional string                             actual_warning_code=18;     	//机器人设备的警告信息位
+    optional string							    actual_error_description=19;    //机器人设备的错误描述
+}
+
+//搬运器的状态
+message Carrier_data
+{
+    required Dispatch_device_type               dispatch_device_type=1;         //调度设备的类型
+    required Dispatch_device_status             dispatch_device_status=2;       //设备总状态, 控制任务流程(长流程)
+
+    required int32                              device_id=3;                    //设备id,
+	optional Hardware_device_status				actual_device_status=4;			//搬运器的硬件设备状态(短流程)
+	optional Load_status						actual_load_status=5;	        //搬运器的负载状态, 小跑车上面是否有车.
+
+    optional int32 								actual_coordinates_id=6;	    //搬运器真实 空间位置的id.
+	optional float 								actual_x=7;					    //搬运器坐标x轴, 中跑车控制横向移动
+	optional float 								actual_y=8;					    //搬运器坐标y轴, 小跑车控制纵向移动
+	optional float 								actual_z=9;					    //搬运器坐标z轴, 电梯控制上下移动
+	optional float 								actual_y1=10;				        //搬运器坐标y1轴, 小跑车控制纵向移动(前轮抓杆)
+	optional float 								actual_y2=11;				        //搬运器坐标y2轴, 小跑车控制纵向移动(后轮抓杆)
+	optional Clamp_motion						actual_clamp_motion1=12;		    //小跑车夹车杆. 0=无动作,1=夹紧,2=松开
+	optional Clamp_motion						actual_clamp_motion2=13;		    //小跑车夹车杆. 0=无动作,1=夹紧,2=松开
+	optional Small_sports_car_motion			actual_small_sports_car_motion=14;	//小跑车的位置,是否在中跑车上面, 0=无动作,1=出发到位,2=返回到位
+	optional Joint_motion						actual_joint_motion_x1=15;		    //电梯与X轴的横向轨道对接,0=无动作,1=伸出到位,2=收回到位
+	optional Joint_motion						actual_joint_motion_x2=16;		    //电梯与X轴的横向轨道对接,0=无动作,1=伸出到位,2=收回到位
+
+    optional string                             actual_error_code=17;	        //搬运器设备的故障信息位
+    optional string                             actual_warning_code=18;	        //搬运器设备的警告信息位
+    optional string							    actual_error_description=19;    //搬运器设备的错误描述
+}
+
+//出入口的状态
+message Passageway_data
+{
+    required Dispatch_device_type               dispatch_device_type=1;         //调度设备的类型
+    required Dispatch_device_status             dispatch_device_status=2;       //设备总状态, 控制任务流程(长流程)
+
+    required int32                              device_id=3;                    //设备id,
+    //通道口的设备状态数据,
+	optional Hardware_device_status				actual_device_status=4;			//通道口的硬件设备状态(短流程)
+	optional Load_status						actual_inside_load_status=5;	        //通道口的内部负载状态, 门内地感是否有车.
+	optional Load_status						actual_outside_load_status=6;	        //通道口的外部负载状态, 门外地感是否有车.
+	optional Overstep_the_boundary				actual_front_overstep_the_boundary=7;	//通道口 汽车前边界
+	optional Overstep_the_boundary				actual_back_overstep_the_boundary=8;	//通道口 汽车后边界
+	optional Overstep_the_boundary				actual_height_overstep_the_boundary=9;	//通道口 车辆是否超高
+	optional Load_status						actual_outside_door_sensor=10;	//通道口 的外门处的传感器, 判断是否有车经过外门
+	//通道口的真实状态, 可能是路径中间的坐标
+    optional Door_motion						actual_inside_door_motion=11;	//通道口 内门动作
+	optional Door_motion						actual_outside_door_motion=12;	//通道口 外门动作
+	optional Load_status						actual_turntable_load_status=13;	//通道口 转盘负载状态, 是否有车.
+	optional Turntable_direction				actual_turntable_direction=14;	//通道口 转台方向
+
+    optional string                             actual_error_code=15;	        //通道口设备的故障信息位
+    optional string                             actual_warning_code=16;	        //通道口设备的警告信息位
+    optional string							    actual_error_description=17;    //通道口设备的错误描述
+}
+
+
+//调度管理总管理的状态
+message Dispatch_manager_status_msg
+{
+    required Base_info                  base_info=1;                    //消息类型
+
+    required int32                      dispatch_id=2;                  //调度管理模块 id
+    required Dispatch_manager_status    dispatch_manager_status = 3;    //调度管理模块 状态
+
+    repeated Catcher_data               catcher_data_map = 4;           //机器手的数据
+    repeated Carrier_data               carrier_data_map = 5;           //搬运器的数据
+    repeated Passageway_data            passageway_data_map = 6;           //出入口的数据
+
+}
+
+
+
+
+
+//调度管理的设备详细的数据信息
+message Dispatch_manager_data_msg
+{
+    //后续再加
+}
+
+
+
+

+ 59 - 0
message/log_process.proto

@@ -0,0 +1,59 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+import "parkspace_allocation_message.proto";    //数据库消息
+import "measure_message.proto";                 //测量消息
+import "dispatch_message.proto";                //调度消息
+import "central_control_message.proto";         //手动操作消息
+
+
+//与节点通讯数据,请求反馈数据
+message Node_log
+{
+    oneof   request{
+        Parkspace_allocation_request_msg    alloc_request=1;
+        Parkspace_search_request_msg        search_request=3;
+        Parkspace_release_request_msg       release_request=5;
+        Parkspace_confirm_alloc_request_msg     confirm_request=7;
+        Measure_request_msg                 measure_request=9;
+        Dispatch_request_msg                dispatch_request=11;
+    }
+    oneof   response{
+        Parkspace_allocation_response_msg   alloc_response=2;
+        Parkspace_search_response_msg       search_response=4;
+        Parkspace_release_response_msg      release_response=6;
+        Parkspace_confirm_alloc_response_msg    confirm_response=8;
+        Measure_response_msg                measure_response=10;
+        Dispatch_response_msg               dispatch_response=12;
+    }
+    optional string         description=13;
+}
+
+//手动操作数据
+message Manual_operation_log
+{
+    required    Process_manual_operation_msg        manual_operation=1;
+    optional    string                              description=2;
+}
+
+message Log_data
+{
+    enum Severity
+    {
+        INFO=0;
+        WARNING=1;
+        ERROR=2;
+    }
+    required Severity      log_severity=1;
+    oneof    data               {
+            string          str_log=2;
+            Node_log        node_log=3;
+            Manual_operation_log    manual_operator_log=4;
+    }
+}
+
+message Process_log
+{
+    required Process_type       process_type=1;
+    repeated Log_data           log_data=2;
+}

+ 3 - 2
message/measure_message.proto

@@ -142,13 +142,14 @@ message Ground_status_msg
     required Region_worker_status       region_worker_status = 5;       //万集区域功能的状态
     required Locate_information         locate_information_realtime = 6;//地面雷达的 实时定位信息
     required Ground_statu               ground_status=7; // 电子围栏状态
-    required int32               border_status=8; // 超界状态,为0表示正常,从末尾开始123456位分别代表前、后、左、右、底盘、车高超界
+    required int32               	border_status=8; // 超界状态,为0表示正常,从末尾开始123456位分别代表前、后、左、右、底盘、车高超界
 
     required Error_manager              error_manager = 9;
     repeated Cloud_coordinate           cloud=10;     //点云坐标
 }
 
 
+
 //点云坐标
 message Cloud_coordinate
 {
@@ -181,4 +182,4 @@ message Locate_sift_response_msg
     required int32                      lidar_id=4;             //雷达id
     repeated Cloud_type                 cloud_type=5;            //点云类型
     required Error_manager              error_manager = 6;      //错误码
-}
+}

+ 4 - 4
message/message_base.proto

@@ -57,7 +57,7 @@ enum Message_type
     eNotify_status_msg=0xc2;                //等候区通知节点状态
 
     eUnNormalized_module_statu_msg = 0xd0; //非标节点状态
-;
+
     eDispatch_plan_request_msg          = 0xe0;     //调度总规划的请求(用于启动整个调度算法)(调度管理->调度算法)
     eDispatch_plan_response_msg         = 0xe1;     //调度总规划的答复(调度算法->调度管理)
     eDispatch_control_request_msg       = 0xe2;     //调度控制的任务请求(调度算法->调度管理)
@@ -154,9 +154,9 @@ message Locate_information
     optional bool locate_correct = 9[default = false];		    //整车的校准标记位
 
     optional float locate_front_theta = 10[default = 0];	    //整车的前轮的旋转角
-    optional float uniformed_car_x = 11;
-    optional float uniformed_car_y = 12;
-
+    
+    optional float uniformed_car_x = 11;        //转角复位后,车辆中心点x
+    optional float uniformed_car_y = 12;        //转角复位后,车辆中心点y
 }
 
 //车辆基本信息

+ 28 - 0
message/notify_message.proto

@@ -0,0 +1,28 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+
+message Notify_request_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    required string                     command_key=2;
+    required int32                      terminal_id=3;              //终端id
+    required Car_info                   car_info=4;                  //车辆标识(车牌号)
+}
+
+message Notify_response_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    required string                     command_key=2;
+    required int32                      terminal_id=3;              //终端id
+    required Error_manager              code=4;                     //请求结果码
+}
+
+
+//定位模块状态
+message Notify_status_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    required int32                      terminal_id=2;
+    required Error_manager              error_manager = 3;
+}

+ 169 - 0
message/parkspace_allocation_message.proto

@@ -0,0 +1,169 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+
+// 请求
+// 1.分配车位
+// 2.查询车辆位置
+// 3.解锁车位
+// 4.手动操作修改车位状态
+// 5.临时锁定车位
+
+//车辆状态枚举
+enum Vehicle_status
+{
+    eVehicle_unknown        = 0;         //未知状态
+    eVehicle_idle           = 1;         //车辆空闲
+    eVehicle_in_garage      = 2;         //车辆已入库
+    eVehicle_parking        = 3;         //车辆停车中
+    eVehicle_fetching       = 4;         //车辆取车中
+    eVehicle_reserved       = 5;         //已预约未停入
+}
+
+//数据库状态
+enum Database_controller_status
+{
+	    E_UNKNOWN               = 0;    //默认未知
+	    E_READY               	= 1;    //正常待机
+		E_DISCONNECT			= 2;	//断连
+	    E_FAULT					= 3;	//故障
+}
+//车位管理状态
+enum Parkspace_manager_satus
+{
+    eParkspace_manager_unknown      =0;//位置
+    eParkspace_manager_normal       =1;//正常
+    eParkspace_manager_fault        =2;//故障
+};
+
+//1.分配车位请求
+message Parkspace_allocation_request_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Car_info                   car_info=3;
+    required int32                      terminal_id=4;          //终端id,优化车位分配用
+}
+
+//分配车位反馈
+message Parkspace_allocation_response_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Error_manager              error_manager=3;        //分配成功与否标志
+    repeated Parkspace_info             allocated_parkspace_info_ex = 4;    //分配车位信息
+    optional Car_type                   car_type = 5;//汽车类型
+}
+
+//2.查询车辆位置请求(根据车辆唯一标识码查询)
+message Parkspace_search_request_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Car_info                   car_info=3;              //车辆凭证或号牌
+}
+
+//查询车辆位置反馈
+message Parkspace_search_response_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Error_manager              error_manager=3;        //分配成功与否标志
+    repeated Parkspace_info             query_parkspace_info_ex=4;         //待查询车辆存放位置
+}
+//手动查询车辆位置请求(根据车牌号查询)
+message Parkspace_manual_search_request_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Car_info                   car_info=3;              //车辆凭证或号牌
+}
+
+//手动查询车辆位置反馈
+message Parkspace_manual_search_response_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Error_manager              error_manager=3;        //分配成功与否标志
+    repeated Parkspace_info             query_parkspace_info_ex=4;         //待查询车辆存放位置
+}
+
+//3.释放车位请求
+message Parkspace_release_request_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    repeated Parkspace_info             release_parkspace_info_ex=3;   //待释放车位信息
+}
+
+//释放车位请求
+message Parkspace_release_response_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Error_manager              error_manager=3;        //分配成功与否标志
+    repeated Parkspace_info             release_parkspace_info_ex=4;   //待释放车位信息
+}
+
+// 4.手动操作修改车位状态
+message Parkspace_force_update_request_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    repeated Parkspace_info             manual_parkspace_info_ex=3;    //待手动修改车位信息,通过id定位
+}
+
+//手动操作反馈
+message Parkspace_force_update_response_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Error_manager              error_manager=3;        //分配成功与否标志
+    repeated Parkspace_info             manual_parkspace_info_ex=4;    //已修改后的车位信息
+}
+
+// 5.确认分配车位
+message Parkspace_confirm_alloc_request_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    repeated Parkspace_info             confirm_parkspace_info_ex = 3;    //分配车位信息
+    optional Car_type                   car_type = 4;//汽车类型
+
+}
+//确认分配车位反馈
+message Parkspace_confirm_alloc_response_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required string                     command_key=2;           //指令唯一标识符id
+    required Error_manager              error_manager=3;        //分配成功与否标志
+    repeated Parkspace_info             confirm_parkspace_info_ex = 4;    //已修改后的车位信息
+    optional Car_type                   car_type = 5;//汽车类型
+
+}
+
+// 车位心跳状态信息
+message Parkspace_allocation_status_msg
+{
+    required Base_info                      base_info=1;            //消息类型
+    required Error_manager                  error_manager=2;
+    required Database_controller_status     database_controller_status=3;           //数据库的状态
+    required Parkspace_manager_satus        parkspace_manager_satus=4;              //车位管理状态
+    required int32                          small_parkspace_remaining_number=5;    //小型车位剩余数量
+    required int32                          medium_parkspace_remaining_number=6;   //中型车位剩余数量
+    required int32                          large_parkspace_remaining_number=7;    //大型车位剩余数量
+    required int32                          total_parkspace_remaining_number=8;    //所有车位剩余数量
+}
+
+//更新车位数据请求
+message Parkspace_refresh_request_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+}
+// 车位数据信息
+message Parkspace_allocation_data_msg
+{
+    required Base_info                  base_info=1;            //消息类型
+    required Error_manager              error_manager=2;
+    repeated Parkspace_info             parkspace_info_ex=3;
+}

+ 156 - 0
message/process_message.proto

@@ -0,0 +1,156 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+
+//分配车位步骤状态
+message Alloc_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Car_info                   car_info=2;         //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+message Back_alloc_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             allocated_parkspace_info_ex=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//查询车位步骤状态
+message Search_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             search_parkspace_info_ex=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+message Back_search_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Car_info                   car_info=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//确认占用车位步骤状态
+message Confirm_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             confirm_parkspace_info_ex=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+message Back_confirm_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             confirm_parkspace_info_ex=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//解锁/释放车位步骤状态
+message Release_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             release_parkspace_info_ex=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+message Back_release_space_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             release_parkspace_info_ex=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//对比节点
+message Compare_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Locate_information         locate_info_wj=2;      //wj定位结果
+    optional Locate_information         locate_info_dj=3;      //dj定位结果
+    optional Locate_information         locate_info_result=4;      //定位结果
+    optional string                     description=5;      //状态说明/错误说明
+}
+message Back_compare_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Locate_information         locate_info_wj=2;      //wj定位结果
+    optional Locate_information         locate_info_dj=3;      //wj定位结果
+    optional Locate_information         locate_info_result=4;      //wj定位结果
+    optional string                     description=5;      //状态说明/错误说明
+}
+//停车调度步骤状态
+message Dispatch_store_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Locate_information         locate_info=2;      //定位结果
+    repeated Parkspace_info             allocated_parkspace_info_ex=3;//目标车位
+    optional string                     description=4;      //状态说明/错误说明
+}
+message Back_dispatch_store_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Locate_information         locate_info=2;      //定位结果
+    repeated Parkspace_info             allocated_parkspace_info_ex=3;//目标车位
+    optional string                     description=4;      //状态说明/错误说明
+}
+
+//取车调度步骤状态
+message Dispatch_pick_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             search_parkspace_info_ex=2;//目标车位
+    optional string                     description=3;      //状态说明/错误说明
+}
+message Back_dispatch_pick_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    repeated Parkspace_info             search_parkspace_info_ex=2;       //目标车位
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//取车等待车辆离开
+message Waitfor_leave_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Car_info                   car_info=2;         //车辆信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+message Back_waitfor_leave_step_statu
+{
+    optional Step_statu                 step_statu=1 [default=eWaiting];       //状态
+    optional Car_info                   car_info=2;         //车辆信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//停车流程进度消息
+message Storing_process_statu_msg
+{
+    required Base_info                          base_info=1;
+    required int32                              terminal_id=2;              //终端id
+    required string                             license=3;
+
+    optional Alloc_space_step_statu             alloc_space_step=4;
+    optional Compare_step_statu                 compare_step=6;
+    optional Dispatch_store_step_statu          dispatch_step=7;
+    optional Confirm_space_step_statu           confirm_space_step=8;
+    optional bool                               completed=9 [default=false];
+    optional Back_confirm_space_step_statu      back_confirm_step=10;
+    optional Back_dispatch_store_step_statu     back_dispatch_step=11;
+    optional Back_compare_step_statu            back_compare_step=12;
+    optional Back_alloc_space_step_statu        back_alloc_space_step=14;
+    optional bool                               back_completed=15 [default=false];
+}
+
+//取车流程进度消息
+message Picking_process_statu_msg
+{
+    required Base_info                          base_info=1;
+    required int32                              terminal_id=2;              //终端id
+    required string                             license=3;
+    optional Search_space_step_statu            search_space_step=4;
+    optional Dispatch_pick_step_statu           dispatch_step=5;
+    optional Release_space_step_statu           release_space_step=6;
+    optional Waitfor_leave_step_statu           waitfor_leave_step=7;
+    optional bool                               completed=8 [default=false];
+    optional Back_waitfor_leave_step_statu      back_waitfor_leave_step=9;
+    optional Back_dispatch_pick_step_statu      back_dispatch_step=10;
+    optional Back_search_space_step_statu       back_search_space_step_statu=11;
+    optional bool                               back_completed=12 [default=false];
+}

+ 189 - 0
message/singlechip_msg.proto

@@ -0,0 +1,189 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+//连接口
+message InputDi
+{
+	required int32	Di0 = 1;  //停车超前光电(0正常,1超界故障)
+	required int32	Di1 = 2;  //停车超后光电(0正常,1超界故障)
+	required int32	Di2 = 3;  //停车超左光电(0正常,1超界故障)
+	required int32	Di3 = 4;  //停车超1550光电(0正常,1超界故障)
+	required int32	Di4 = 5;  //2050高度(0默认,1被触发)
+	required int32	Di5 = 6;  //1750高度(0默认,1被触发)
+	required int32	Di6 = 7;  //2050高度(0默认,1被触发)
+	required int32	Di7 = 8;  //预留
+	required int32	Di8 = 9;  //停车库门开到位(1表示开到位)	
+	required int32	Di9 = 10; //停车库门关到位(1表示关到位)
+	required int32	Di10 = 11;//预留的门故障位(1表示门故障)
+	required int32	Di11 = 12;//调度完成标志位,是否允许终端放下一辆车进入入口(0调度正忙,1调度允许下一辆车)
+	required int32	Di12 = 13;//库内光电,判断门内是否有车(0无车,1有车)
+	required int32	Di13 = 14;//库外地磁 ,判断门外(0无车,1有车)
+	required int32	Di14 = 15;//重启
+	required int32	Di15 = 16;//急停
+}
+//连接口
+message OutputDo
+{
+	required int32	Do0 = 1;	//外门 开门(1)
+	required int32	Do1 = 2;    //外门 关门(1)
+	required int32	Do2 = 3;    //备用
+	required int32	Do3 = 4;	//备用
+	required int32	Do4 = 5;	//备用
+	required int32	Do5 = 6;	//备用
+	required int32	Do6 = 7;	//备用
+	required int32	Do7 = 8;	//备用
+
+}
+//流程控制
+enum Process_control
+{
+	PROCESS_CONTROL_UNKNOWN			= 0;//未知
+	PROCESS_CONTROL_FULL_AUTO		= 1;//全自动,
+	PROCESS_CONTROL_MANUAL			= 2;//手动
+	PROCESS_CONTROL_AUTO_CLOSE		= 3;//半自动关门
+	PROCESS_CONTROL_AUTO_OPEN		= 4;//半自动开门
+	PROCESS_CONTROL_TO_READY		= 5;//切换到待机
+
+
+	PROCESS_CONTROL_RESET			= 7;//重启
+	PROCESS_CONTROL_STOP			= 8;//急停
+	PROCESS_CONTROL_FAULT			= 9;//故障
+
+	
+	PROCESS_CONTROL_INLET_0		= 10 ;//未知
+	PROCESS_CONTROL_INLET_1		= 11 ;//未知
+	PROCESS_CONTROL_INLET_2		= 12 ;//未知
+	PROCESS_CONTROL_INLET_3		= 13 ;//未知
+	PROCESS_CONTROL_INLET_4		= 14 ;//未知
+	PROCESS_CONTROL_INLET_5		= 15 ;//未知
+	PROCESS_CONTROL_INLET_6		= 16 ;//未知
+	PROCESS_CONTROL_INLET_7		= 17 ;//未知
+	PROCESS_CONTROL_INLET_8		= 18 ;//未知
+	PROCESS_CONTROL_INLET_9		= 19 ;//未知
+	
+	PROCESS_CONTROL_OUTLET_0		= 30 ;//未知
+	PROCESS_CONTROL_OUTLET_1		= 31 ;//未知
+	PROCESS_CONTROL_OUTLET_2		= 32 ;//未知
+	PROCESS_CONTROL_OUTLET_3		= 33 ;//未知
+	PROCESS_CONTROL_OUTLET_4		= 34 ;//未知
+	PROCESS_CONTROL_OUTLET_5		= 35 ;//未知
+	PROCESS_CONTROL_OUTLET_6		= 36 ;//未知
+	PROCESS_CONTROL_OUTLET_7		= 37 ;//未知
+	PROCESS_CONTROL_OUTLET_8		= 38 ;//未知
+	PROCESS_CONTROL_OUTLET_9		= 39 ;//未知
+	
+};
+//终端给单片机
+message terminal_msg
+{
+    required    int32		        TerminalID = 1;		// 终端号(单片机号)
+    required    int32   		    DispatchDirection= 2;	// 方向(1入口,2出口)
+    required    Process_control 	ProcessControl= 3;	 	// 门控
+    required    OutputDo       	    OutPutDo= 4; 		// 输入口
+
+}
+//超界状态
+enum Over_border_status
+{
+	OVER_BORDER_STATUS_UNKNOWN		= 0 ;//未知
+	OVER_BORDER_STATUS_NORMAL		= 1 ;//正常
+	OVER_BORDER_STATUS_FRONT		= 2 ;//前超界
+	OVER_BORDER_STATUS_BACK			= 3 ;//后超界
+	OVER_BORDER_STATUS_LEFT			= 4 ;//左超界
+	OVER_BORDER_STATUS_RIGHT		= 5 ;//右超界
+};
+//车高状态
+enum Car_height_status	
+{
+	CAR_HEIGHT_STATUS_UNKNOWN		= 0 ;//未知
+	CAR_HEIGHT_STATUS_SMALL 		= 1 ;//小车
+	CAR_HEIGHT_STATUS_MEDIUM 		= 2 ;//中车
+	CAR_HEIGHT_STATUS_LARGE			= 3 ;//大车
+	CAR_HEIGHT_STATUS_HUGE			= 4 ;//巨大车
+	CAR_HEIGHT_STATUS_FAULT			= 5 ;//故障车
+};
+
+//外门的状态
+enum Outside_door_status
+{
+	OUTSIDE_DOOR_STATUS_UNKNOWN		= 0 ;//未知
+	OUTSIDE_DOOR_STATUS_OPEN		= 1 ;//外门开到位
+	OUTSIDE_DOOR_STATUS_CLOSE		= 2 ;//外门关到位
+	OUTSIDE_DOOR_STATUS_RUN			= 3 ;//外门运行中
+	OUTSIDE_DOOR_STATUS_FAULT		= 4 ;//外门故障
+};
+
+//外门的控制
+enum Outside_door_control
+{
+	OUTSIDE_DOOR_CONTROL_UNKNOWN	= 0 ;//未知
+	OUTSIDE_DOOR_CONTROL_OPEN		= 1 ;//外门开
+	OUTSIDE_DOOR_CONTROL_CLOSE		= 2 ;//外门关
+
+};
+//流程状态
+enum Process_status
+{
+	PROCESS_STATUS_UNKNOWN			= 0;//未知
+	PROCESS_STATUS_FULL_AUTO	    = 1;//全自动,
+	PROCESS_STATUS_MANUAL			= 2;//手动
+	PROCESS_STATUS_AUTO_CLOSE		= 3;//半自动关门
+	PROCESS_STATUS_AUTO_OPEN		= 4;//半自动开门
+	PROCESS_STATUS_TO_READY			= 5;//切换到待机
+	
+	PROCESS_STATUS_RESET			= 7;//重启
+	PROCESS_STATUS_STOP				= 8;//急停
+	PROCESS_STATUS_FAULT			= 9;//故障
+	
+	//自动模式的步骤
+	PROCESS_STATUS_INLET_0		= 10 ;//入口待机, 等待门外地感触发。
+	PROCESS_STATUS_INLET_1		= 11 ;//执行开门
+	PROCESS_STATUS_INLET_2		= 12 ;//等待门开到位
+	PROCESS_STATUS_INLET_3		= 13 ;//等待汽车进入
+	PROCESS_STATUS_INLET_4		= 14 ;//停车完成,统计汽车经过门口的车高。
+	PROCESS_STATUS_INLET_5		= 15 ;//等待终端关门,执行关门
+	PROCESS_STATUS_INLET_6		= 16 ;//等待门关到位
+	PROCESS_STATUS_INLET_7		= 17 ;//等待plc调度,或者终端重置
+	PROCESS_STATUS_INLET_8		= 18 ;//未知
+	PROCESS_STATUS_INLET_9		= 19 ;//未知
+	
+	PROCESS_STATUS_OUTLET_0		= 30 ;//出口待机,等待终端开门,执行开门
+	PROCESS_STATUS_OUTLET_1		= 31 ;//等待门开到位
+	PROCESS_STATUS_OUTLET_2		= 32 ;//等待门口的光电产生信号,表示汽车正从车库出去。汽车正在离开中。
+	PROCESS_STATUS_OUTLET_3		= 33 ;//汽车离开后,延迟5秒关门,执行关门
+	PROCESS_STATUS_OUTLET_4		= 34 ;//等待门关到位
+	PROCESS_STATUS_OUTLET_5		= 35 ;//等待plc调度,或者终端重置
+	PROCESS_STATUS_OUTLET_6		= 36 ;//未知
+	PROCESS_STATUS_OUTLET_7		= 37 ;//未知
+	PROCESS_STATUS_OUTLET_8		= 38 ;//未知
+	PROCESS_STATUS_OUTLET_9		= 39 ;//未知
+	
+};
+//单片机给终端
+message singlechip_data
+{
+    required  int32		            TerminalID= 1;	  	// 终端号(单片机号)
+    required  int32   		        DispatchDirection= 2;	// 方向(1入口,2出口)
+    required  Process_status	    ProcessStatus=   3;		//流程状态
+    required  InputDi		        InPutDi = 4; 		// 输入口
+    required  int32		            ResetFlag = 5;		//重置标志位
+    required  Process_control	    ProcessControl = 6;		//流程控制
+    required  int32		            InsideExistenceFlag = 7;	//内部存在标志
+    required  Over_border_status	OverBorderStatus = 8;	//边界状态
+    required  Car_height_status	    CarHeightStatusCurrent = 9;	//当前车高状态--斜角对射光电
+    required  Car_height_status	    CarHeightStatusPassing = 10;	//车高状态--门口经过式光电
+    required  int32		            StopFlag = 11;		//停车标志位
+    required  Outside_door_status	OutsideDoorStatus = 12;	//外门状态
+    required  Outside_door_control	OutsideDoorControl = 13;	//外门控制
+    required  int32		            DispatchFinishFlag = 14;	//调度完成标志
+    required  int32		            OutsideExistenceFlag = 15;	//外部存在标志
+}
+//终端状态消息
+message terminal_status_msg
+{
+	required Base_info	 	    base_info =1; //消息类型
+	required int32 	 	        terminal_id=2; //终端号
+	required singlechip_data	singlechipData=3; //单片机的数据
+}
+
+

+ 39 - 0
message/terminal_message.proto

@@ -0,0 +1,39 @@
+syntax = "proto2";
+package message;
+import "message_base.proto";
+
+
+message Store_command_request_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    required int32                      terminal_id=2;              //终端id
+    required Locate_information         locate_information=3;       //终端测量数据,主要需要车高和车宽
+    required Car_info                   car_info=4;                  //车辆标识(车牌号)
+}
+
+
+message Store_command_response_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    required int32                      terminal_id=2;              //终端id
+    required Error_manager              code=3;            //请求结果码
+    optional string                     license=4;
+}
+
+
+message Pickup_command_request_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    required int32                      terminal_id=2;              //终端id
+    required Car_info                    car_info=4;                  //车辆信息
+
+}
+
+
+message Pickup_command_response_msg
+{
+    required Base_info                  base_info=1;                 //消息类型
+    required int32                      terminal_id=2;              //终端id
+    required Error_manager              code=3;            //请求结果码
+    optional string                     license=4;
+}

+ 33 - 0
tool/TaskQueue/BaseTask.cpp

@@ -0,0 +1,33 @@
+//
+//  BaseTaskQueue.cpp
+//  LibDriveRating-CXX
+//
+//  Created by Melo Yao on 6/9/14.
+//  Copyright (c) 2014 AutoNavi. All rights reserved.
+//
+
+#include "BaseTask.h"
+
+namespace tq {
+    BaseTask::BaseTask():ITask(),_cancelled(false)
+    {
+    }
+    
+    void BaseTask::Cancel()
+    {
+        _cancelled = true;
+    }
+    
+    bool BaseTask::IsCancelled() const
+    {
+        return _cancelled;
+    }
+    
+    void BaseTask::Run()
+    {
+        if (_cancelled) {
+            return;
+        }
+        Main();
+    }
+}

+ 29 - 0
tool/TaskQueue/BaseTask.h

@@ -0,0 +1,29 @@
+//
+//  BaseTaskQueue.h
+//  LibDriveRating-CXX
+//
+//  Created by Melo Yao on 6/9/14.
+//  Copyright (c) 2014 AutoNavi. All rights reserved.
+//
+
+#ifndef __LibDriveRating_CXX__BaseTaskQueue__
+#define __LibDriveRating_CXX__BaseTaskQueue__
+
+#include "TQInterface.h"
+namespace tq
+{
+    class BaseTask : public ITask
+    {
+    private:
+        volatile bool _cancelled;
+    public:
+        BaseTask();
+        void Run();
+        virtual void Cancel();
+        bool IsCancelled() const;
+        
+        virtual void Main() = 0;
+        TaskCategory GetCategory() const {return NoCategory;}
+    };
+}
+#endif /* defined(__LibDriveRating_CXX__BaseTaskQueue__) */

+ 23 - 0
tool/TaskQueue/TQFactory.cpp

@@ -0,0 +1,23 @@
+//
+//  TQFactory.cpp
+//  LibDriveRating-CXX
+//
+//  Created by Melo Yao on 6/10/14.
+//  Copyright (c) 2014 AutoNavi. All rights reserved.
+//
+
+#include "TQFactory.h"
+#include "ThreadTaskQueue.h"
+namespace tq {
+    IQueue* TQFactory::CreateDefaultQueue()
+    {
+        return new ThreadTaskQueue();
+    }
+    
+    void TQFactory::ReleaseQueue(IQueue* queue)
+    {
+        delete queue;
+    }
+    
+    
+}

+ 24 - 0
tool/TaskQueue/TQFactory.h

@@ -0,0 +1,24 @@
+//
+//  TQFactory.h
+//  LibDriveRating-CXX
+//
+//  Created by Melo Yao on 6/10/14.
+//  Copyright (c) 2014 AutoNavi. All rights reserved.
+//
+
+#ifndef __LibDriveRating_CXX__TQFactory__
+#define __LibDriveRating_CXX__TQFactory__
+
+#include "TQInterface.h"
+
+namespace tq {
+    class TQFactory
+    {
+    public:
+        static IQueue* CreateDefaultQueue();
+
+        static void ReleaseQueue(IQueue* queue);
+    };
+}
+
+#endif /* defined(__LibDriveRating_CXX__TQFactory__) */

+ 58 - 0
tool/TaskQueue/TQInterface.h

@@ -0,0 +1,58 @@
+//
+//  TQInterface.h
+//  LibDriveRating-CXX
+//
+//  Created by Melo Yao on 6/9/14.
+//  Copyright (c) 2014 AutoNavi. All rights reserved.
+//
+
+#ifndef __LibDriveRating_CXX__TQInterface__
+#define __LibDriveRating_CXX__TQInterface__
+
+namespace tq {
+    typedef unsigned long TaskCategory;
+
+    const TaskCategory NoCategory = 0;
+
+    class ITask
+    {
+    public:
+        virtual void Run() = 0;
+        virtual void Cancel() = 0;
+        virtual bool IsCancelled() const = 0;
+        virtual TaskCategory GetCategory() const = 0;
+        virtual ~ITask(){}
+    };
+    
+    typedef void (*TaskRecycler)(ITask* task,void* context);
+
+    class IQueue
+    {
+    public:
+        virtual void Start(unsigned int nThreads = 1) = 0;
+
+        virtual void Stop() = 0;
+
+        virtual void AddTask(ITask* task) = 0;
+        
+        virtual void GetTasks(ITask** tasksBuf, unsigned int taskBufSize) const= 0;
+        
+        virtual unsigned int TaskCount() const = 0;
+        
+        virtual void CancelAll() = 0;
+        
+        virtual void WaitForFinish() = 0;
+
+        virtual void Suspend() = 0;
+        
+        virtual void Resume() = 0;
+        
+        virtual void SetTaskRecycler(TaskCategory cat, TaskRecycler recycler,void *context){}
+
+        virtual void ClearTaskRecycler(TaskCategory cat){}
+
+        virtual ~IQueue() {}
+    };
+}
+
+#endif /* defined(__LibDriveRating_CXX__TQInterface__) */

+ 89 - 0
tool/TaskQueue/TaskPool.h

@@ -0,0 +1,89 @@
+#ifndef H_TASK_POOL_H
+#define H_TASK_POOL_H
+#include <list>
+#include "threadpp/threadpp.h"
+#include <cstdlib>
+#include <cstdio>
+namespace tq
+{
+    template <typename TaskType>
+    class TaskPool
+    {
+    public:
+        TaskPool(unsigned capacity = 10);
+        ~TaskPool();
+        TaskType* GetTask(TaskType const& taskPrototype);
+        void RecycleTask(TaskType* task);
+        void Purge();
+    private:
+        threadpp::lock _mutex;
+        std::list<TaskType*> _tasks;
+        unsigned _capacity;
+    };
+
+    template <typename TaskType>
+    TaskType* TaskPool<TaskType>::GetTask(TaskType const& taskPrototype)
+    {
+        _mutex.lock();
+        if(!_tasks.empty())
+        {
+
+            TaskType* taskptr = _tasks.front();
+            _tasks.pop_front();
+            _mutex.unlock();
+            new (taskptr)TaskType(taskPrototype);
+            return taskptr;
+        }
+        else
+        {
+            _mutex.unlock();
+            static int newcount = 0;
+            TaskType* taskptr = new TaskType(taskPrototype);
+            return taskptr;
+        }
+    }
+
+    template <typename TaskType>
+    void TaskPool<TaskType>::RecycleTask(TaskType* task)
+    {
+        (*task).~TaskType();
+        _mutex.lock();
+        if(_tasks.size()<_capacity)
+        {
+            _tasks.push_back(task);
+        }
+        else
+        {
+            free(task);
+        }
+        _mutex.unlock();
+    }
+    
+    template <typename TaskType>
+    void TaskPool<TaskType>::Purge()
+    {
+        _mutex.lock();
+        if(!_tasks.empty())
+        {
+            for(typename std::list<TaskType*>::const_iterator it = _tasks.begin();it!=_tasks.end();++it)
+            {
+                free(*it);
+            }
+            _tasks.clear();
+        }
+        _mutex.unlock();
+    }
+
+    template <typename TaskType>
+    TaskPool<TaskType>::TaskPool(unsigned capacity):
+    _capacity(capacity)
+    {
+    }
+
+    template <typename TaskType>
+    TaskPool<TaskType>::~TaskPool()
+    {
+        this->Purge();
+    }
+}
+#endif

+ 288 - 0
tool/TaskQueue/ThreadTaskQueue.cpp

@@ -0,0 +1,288 @@
+//
+//  ThreadTaskQueue.cpp
+//  LibDriveRating-CXX
+//
+//  Created by Melo Yao on 6/9/14.
+//  Copyright (c) 2014 AutoNavi. All rights reserved.
+//
+
+#include "ThreadTaskQueue.h"
+#include <algorithm>
+#define WAIT_TIMEOUT 5000
+
+using namespace threadpp;
+
+namespace tq{
+    
+    class QueueRunnable
+    {
+        ThreadTaskQueue* queue;
+        ITask* currentTask;
+    protected:
+        static void run_callback(void*);
+        thread* th;
+        
+        QueueRunnable(ThreadTaskQueue* q):queue(q),currentTask(NULL){}
+        void run();
+        void CancelCurrentTask();
+        bool TaskIsRunning() const;
+        friend class ThreadTaskQueue;
+    };
+    
+    void QueueRunnable::run_callback(void *ctx)
+    {
+        ((QueueRunnable*) ctx)->run();
+    }
+    
+    void QueueRunnable::run()
+    {
+        while (queue->IsStarted()) {
+            queue->LockQueue();
+            ITask* task = queue->NextTask();
+            if (task == NULL) {
+                queue->UnlockQueue();
+                continue;
+            }
+            currentTask = task;
+            queue->UnlockQueue();
+            task->Run();
+
+            queue->LockQueue();
+            currentTask = NULL;
+            queue->FinishTask(task);
+            queue->NotifyQueue();
+            queue->UnlockQueue();
+        }
+    }
+    
+    void QueueRunnable::CancelCurrentTask()
+    {
+        queue->LockQueue();
+        if(currentTask)
+        {
+            currentTask->Cancel();
+        }
+        queue->UnlockQueue();
+    }
+    
+    bool QueueRunnable::TaskIsRunning() const
+    {
+        return currentTask != NULL;
+    }
+    
+    ThreadTaskQueue::ThreadTaskQueue():_tasklist(),_started(false),_suspended(false)
+    {
+        
+    }
+    
+    void ThreadTaskQueue::Start(unsigned int nThreads)
+    {
+        _mutex.lock();
+        if (_started) {
+            _mutex.unlock();
+            return;
+        }
+        _started = true;
+        _threads.reserve(nThreads);
+        for (int i = 0; i<nThreads; ++i) {
+            QueueRunnable* runnable = new QueueRunnable(this);
+            runnable->th = new thread(QueueRunnable::run_callback, runnable);
+            _threads.push_back(runnable);
+        }
+        _mutex.unlock();
+    }
+    
+    void ThreadTaskQueue::Stop()
+    {
+        _mutex.lock();
+        if (!_started) {
+            _mutex.unlock();
+            return;
+        }
+        _started = false;
+        for (std::list<ITask*>::iterator it = _tasklist.begin(); it!= _tasklist.end(); ++it) {
+            delete *it;
+        }
+        _tasklist.clear();
+        _mutex.notify_all();
+        std::vector<QueueRunnable*> copy(_threads);
+        _threads.clear();
+        _mutex.unlock();
+        for (std::vector<QueueRunnable*>::iterator it = copy.begin(); it!=copy.end(); ++it) {
+            (*it)->th->join();
+            thread* t = (*it)->th;
+            delete (*it);
+            delete t;
+        }
+    }
+    
+    bool ThreadTaskQueue::IsStarted() const
+    {
+        return _started;
+    }
+
+
+    void ThreadTaskQueue::AddTask(ITask* task)
+    {
+        _mutex.lock();
+        if (_started) {
+            _tasklist.push_back(task);
+            _mutex.notify_all();
+        }
+        _mutex.unlock();
+    }
+    
+    void ThreadTaskQueue::GetTasks(ITask** tasksBuf, unsigned int taskBufSize) const
+    {
+        recursivelock* mutex = const_cast<recursivelock*>(&_mutex);
+        mutex->lock();
+        size_t count = 0;
+        for (std::list<ITask*>::const_iterator it = _tasklist.begin(); it!=_tasklist.end(); ++it) {
+            if (count<taskBufSize) {
+                tasksBuf[count] = *it;
+                count++;
+            }
+            else
+            {
+                break;
+            }
+        }
+        mutex->unlock();
+    }
+    
+    unsigned int ThreadTaskQueue::TaskCount() const
+    {
+        recursivelock* mutex = const_cast<recursivelock*>(&_mutex);
+        mutex->lock();
+        unsigned int count = (unsigned int)_tasklist.size();
+        mutex->unlock();
+        return count;
+    }
+    
+    void ThreadTaskQueue::CancelAll()
+    {
+        _mutex.lock();
+        for (std::vector<QueueRunnable*>::iterator it = _threads.begin(); it!=_threads.end(); ++it) {
+            (*it)->CancelCurrentTask();
+        }
+        for (std::list<ITask*>::const_iterator it = _tasklist.begin(); it!=_tasklist.end(); ++it) {
+            (*it)->Cancel();
+        }
+        _mutex.unlock();
+        
+    }
+    
+    void ThreadTaskQueue::WaitForFinish()
+    {
+        
+        while (true) {
+            _mutex.lock();
+            bool isExecuting = false;
+            for (std::vector<QueueRunnable*>::iterator it = _threads.begin(); it!=_threads.end(); ++it) {
+                if ((*it)->TaskIsRunning()) {
+                    isExecuting = true;
+                    break;
+                }
+            }
+            if (!isExecuting&&_tasklist.size() == 0) {
+                _mutex.unlock();
+                break;
+            }
+            _mutex.wait(100);
+            _mutex.unlock();
+        }
+        
+    }
+    
+    void ThreadTaskQueue::Suspend()
+    {
+        _mutex.lock();
+        _suspended = true;
+        _mutex.unlock();
+    }
+    
+    void ThreadTaskQueue::Resume()
+    {
+        _mutex.lock();
+        _suspended = false;
+        _mutex.notify_all();
+        _mutex.unlock();
+
+    }
+    
+    void ThreadTaskQueue::NotifyQueue()
+    {
+        _mutex.notify_all();
+    }
+    
+    ITask* ThreadTaskQueue::NextTask()
+    {
+        while (_started && (_tasklist.empty()||_suspended)) {
+            _mutex.wait(WAIT_TIMEOUT);//defensive waiting time limit.
+        }
+        ITask* task = NULL;
+        if (_tasklist.size()>0) {
+            task = _tasklist.front();
+            _tasklist.pop_front();
+        }
+        return task;
+    }
+    
+    inline
+    void ThreadTaskQueue::LockQueue()
+    {
+        _mutex.lock();
+    }
+    
+    inline
+    void ThreadTaskQueue::UnlockQueue()
+    {
+        _mutex.unlock();
+    }
+
+    inline
+    void ThreadTaskQueue::FinishTask(ITask* task)
+    {
+        if(task->GetCategory() != NoCategory)
+        {
+            _recyclerMutex.lock();
+            std::map<TaskCategory,RecyclerPair>::iterator it = _recyclers.find(task->GetCategory());
+            if(it!=_recyclers.end())
+            {
+                RecyclerPair pair = it->second;
+                _recyclerMutex.unlock();
+                pair.recycler(task,pair.context);
+                return;
+            }
+            _recyclerMutex.unlock();
+        }
+        //析构任务
+        delete task;
+
+    }
+    
+    void ThreadTaskQueue::SetTaskRecycler(TaskCategory cat, TaskRecycler recycler,void *context)
+    {
+        _recyclerMutex.lock();
+        std::pair<TaskCategory,RecyclerPair> pair(cat, RecyclerPair(recycler,context));
+        _recyclers.insert(pair);
+        _recyclerMutex.unlock();
+    }
+
+    void ThreadTaskQueue::ClearTaskRecycler(TaskCategory cat)
+    {
+        _recyclerMutex.lock();
+        std::map<TaskCategory,RecyclerPair>::iterator it = _recyclers.find(cat);
+        if(it!=_recyclers.end())
+        {
+            _recyclers.erase(it);
+        }
+        _recyclerMutex.unlock();
+    }
+
+    ThreadTaskQueue::~ThreadTaskQueue()
+    {
+        this->Stop();//Defensive stop.
+    }
+    
+}

+ 89 - 0
tool/TaskQueue/ThreadTaskQueue.h

@@ -0,0 +1,89 @@
+//
+//  ThreadTaskQueue.h
+//  LibDriveRating-CXX
+//
+//  Created by Melo Yao on 6/9/14.
+//  Copyright (c) 2014 AutoNavi. All rights reserved.
+//
+
+#ifndef __LibDriveRating_CXX__ThreadTaskQueue__
+#define __LibDriveRating_CXX__ThreadTaskQueue__
+
+#include "TQInterface.h"
+#include "BaseTask.h"
+#include <list>
+#include <map>
+#include <vector>
+#include "threadpp/threadpp.h"
+
+namespace tq
+{
+    class QueueRunnable;
+    
+    class ThreadTaskQueue:public IQueue
+    {
+    public:
+        ThreadTaskQueue();
+        
+        void Start(unsigned int nThreads = 1);
+        
+        void Stop();
+        
+        bool IsStarted() const;
+
+        void AddTask(ITask* task);//Will transfer the ownership of task.
+        
+        void GetTasks(ITask** tasksBuf, unsigned int taskBufSize) const;
+        
+        unsigned int TaskCount() const;
+        
+        void CancelAll();
+        
+        void WaitForFinish() ;
+        
+        void Suspend();
+        
+        void Resume();
+
+        void SetTaskRecycler(TaskCategory cat, TaskRecycler recycler,void *context);
+
+        void ClearTaskRecycler(TaskCategory cat);
+        
+        ~ThreadTaskQueue();
+        
+    protected:
+        
+        void LockQueue();
+        
+        void UnlockQueue();
+        
+        void NotifyQueue();
+        
+        ITask* NextTask();
+
+        void FinishTask(ITask* task);
+        
+        friend class QueueRunnable;
+
+    private:
+        struct RecyclerPair
+        {
+            TaskRecycler recycler;
+            void *context;
+            RecyclerPair(TaskRecycler r,void* c):
+                recycler(r),context(c)
+            {
+            }
+        };
+
+        std::map<TaskCategory,RecyclerPair> _recyclers;
+        std::list<ITask*> _tasklist;
+        std::vector<QueueRunnable*> _threads;
+        threadpp::recursivelock _mutex;
+        threadpp::lock _recyclerMutex;
+        bool _started;
+        bool _suspended;
+    };
+}
+
+#endif /* defined(__LibDriveRating_CXX__ThreadTaskQueue__) */

+ 35 - 0
tool/TaskQueue/threadpp/impl/pthread_lock.h

@@ -0,0 +1,35 @@
+//
+//  pthread_lock.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef __threadpp__pthread_lock__
+#define __threadpp__pthread_lock__
+//extern "C"
+//{
+#include <pthread.h>
+//}
+namespace threadpp
+{
+    class pthread_lock
+    {
+        pthread_mutex_t _mutex;
+        pthread_cond_t _cond;
+        void operator=(const pthread_lock& l){};
+        pthread_lock(const pthread_lock& l){};
+    public:
+        pthread_lock();
+        ~pthread_lock();
+        void lock();
+        void unlock();
+        void wait();
+        void wait(unsigned long millisecs);
+        void notify();
+        void notify_all();
+    };
+}
+#include "pthread_lock.hpp"
+#endif /* defined(__threadpp__pthread_lock__) */

+ 73 - 0
tool/TaskQueue/threadpp/impl/pthread_lock.hpp

@@ -0,0 +1,73 @@
+//
+//  pthread_lock.cpp
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+#ifndef __threadpp__pthread_lock__hpp__
+#define __threadpp__pthread_lock__hpp__
+#include "../threadpp_assert.h"
+#include <errno.h>
+#include <cstring>
+
+#include <sys/time.h>
+
+static inline void timespec_for(struct timespec* t,unsigned long millisecs) {
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    t->tv_nsec = tv.tv_usec*1000 + millisecs*1000000;
+    t->tv_sec = tv.tv_sec + (t->tv_nsec/1000000000);
+    t->tv_nsec = t->tv_nsec%1000000000;
+}
+
+namespace threadpp{
+    inline pthread_lock::pthread_lock()
+    {
+        pthread_mutex_init(&_mutex, NULL);
+        pthread_cond_init(&_cond, NULL);
+    }
+    
+    inline pthread_lock::~pthread_lock()
+    {
+        pthread_mutex_destroy(&_mutex);
+        pthread_cond_destroy(&_cond);
+    }
+    
+    inline void pthread_lock::lock()
+    {
+        int code = pthread_mutex_lock(&_mutex);
+        ASSERT(code == 0, "lock failed,error:%s",strerror(code));
+    }
+    
+    inline void pthread_lock::unlock()
+    {
+        int code = pthread_mutex_unlock(&_mutex);
+        ASSERT(code == 0, "unlock failed,error:%s",strerror(code));
+    }
+    
+    inline void pthread_lock::wait()
+    {
+        int code = pthread_cond_wait(&_cond, &_mutex);
+        ASSERT(code == 0 || code == ETIMEDOUT, "wait failed,error:%s",strerror(code));
+    }
+    
+    inline void pthread_lock::wait(unsigned long millisecs)
+    {
+        struct timespec ts;
+        timespec_for(&ts,millisecs);
+        int code = pthread_cond_timedwait(&_cond, &_mutex, &ts);
+        ASSERT(code == 0 || code == ETIMEDOUT, "timed wait failed,error:%s",strerror(code));
+    }
+    
+    inline void pthread_lock::notify()
+    {
+        pthread_cond_signal(&_cond);
+    }
+    
+    inline void pthread_lock::notify_all()
+    {
+        pthread_cond_broadcast(&_cond);
+    }
+}
+#endif

+ 45 - 0
tool/TaskQueue/threadpp/impl/pthread_thread.h

@@ -0,0 +1,45 @@
+//
+//  pthread_thread.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef __threadpp__pthread_thread__
+#define __threadpp__pthread_thread__
+#include <pthread.h>
+namespace threadpp
+{
+    class pthread_thread
+    {
+        struct pthread_context
+        {
+            void(*fp)(void* context);
+            void* context;
+        } _context;
+        
+        pthread_t _thread;
+        pthread_thread(){};
+        void operator=(const pthread_thread& t){};
+        pthread_thread(const pthread_thread& t){};
+        static void* pthread_fp_delegate(void*);
+    public:
+        typedef void (*runnable)(void* ctx);
+        typedef unsigned long long id_type;
+        
+        static id_type null_id();
+        
+        pthread_thread(runnable r,void* t);
+        
+        ~pthread_thread();
+        void join();
+        void detach();
+        bool is_equal(const pthread_thread& t) const;
+        id_type get_id() const;
+        static id_type current_thread_id();
+        static void sleep(unsigned long millisecs);
+    };
+}
+#include "pthread_thread.hpp"
+#endif /* defined(__threadpp__pthread_thread__) */

+ 110 - 0
tool/TaskQueue/threadpp/impl/pthread_thread.hpp

@@ -0,0 +1,110 @@
+//
+//  pthread_thread.cpp
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef __threadpp__pthread_thread__hpp__
+#define __threadpp__pthread_thread__hpp__
+
+#include <errno.h>
+#include "../threadpp_assert.h"
+#include <cstring>
+#include <cmath>
+#include <unistd.h>
+namespace threadpp
+{
+    inline pthread_thread::id_type pthread_thread::null_id()
+    {
+        return 0;
+    }
+    
+    inline void* pthread_thread::pthread_fp_delegate(void* ctx)
+    {
+        pthread_thread::pthread_context* pctx =static_cast<pthread_thread::pthread_context*>(ctx);
+        pctx->fp(pctx->context);
+        return NULL;
+    }
+    
+    inline pthread_thread::pthread_thread(runnable r,void* t)
+    {
+        _context.fp = r;
+        _context.context = t;
+        int code = pthread_create(&_thread, NULL, pthread_thread::pthread_fp_delegate, &_context);
+        ASSERT(code==0,"create thread failed,error:%s",strerror(code));
+    }
+    
+//    pthread_thread::pthread_thread(runnable r,void* t,float priority)
+//    {
+//        _context.fp = r;
+//        _context.context = t;
+//        pthread_attr_t tattr;
+//        pthread_attr_init(&tattr);
+//        struct sched_param schp;
+//        int policy = SCHED_FIFO;
+//        pthread_attr_getschedpolicy(&tattr, &policy);
+//        pthread_attr_getschedparam(&tattr, &schp);
+//        float pr =fminf(1.0f,fmaxf(0.0f, priority));
+//        schp.sched_priority = sched_get_priority_min(policy) + pr*(sched_get_priority_max(policy) - sched_get_priority_min(policy));
+//        pthread_attr_setschedparam(&tattr, &schp);
+//        int code = pthread_create(&_thread, &tattr, pthread_thread::pthread_fp_delegate, &_context);
+//        ASSERT(code==0,"create thread failed,error:%s",strerror(code));
+//        pthread_attr_destroy(&tattr);
+//    }
+    
+    inline pthread_thread::~pthread_thread()
+    {
+        ASSERT(_thread == 0,"%s","must join or detach a thread before destructing it");
+    }
+    
+    inline void pthread_thread::join()
+    {
+        void* ret = NULL;
+        int code = pthread_join(_thread, &ret);
+        _thread = 0;
+        ASSERT(code==0,"join thread failed,error:%s",strerror(code));
+    }
+    
+    inline void pthread_thread::detach()
+    {
+        int code = pthread_detach(_thread);
+        _thread = 0;
+        ASSERT(code==0,"join thread failed,error:%s",strerror(code));
+
+    }
+    
+    inline bool pthread_thread::is_equal(const pthread_thread& t) const
+    {
+        return pthread_equal(_thread, t._thread);
+    }
+    
+    inline void pthread_thread::sleep(unsigned long millisecs)
+    {
+        usleep((useconds_t)millisecs*1000);
+    }
+    
+    inline pthread_thread::id_type pthread_thread::get_id() const
+    {
+#ifdef __APPLE__
+        __uint64_t tid;
+        return pthread_threadid_np(_thread, &tid);
+        return tid;
+#else
+        return (unsigned long long)(_thread);
+#endif
+    }
+    
+    inline pthread_thread::id_type pthread_thread::current_thread_id()
+    {
+#ifdef __APPLE__
+        __uint64_t tid;
+        pthread_threadid_np(pthread_self(), &tid);
+        return tid;
+#else
+        return (unsigned long long)(pthread_self());
+#endif
+    }
+}
+#endif

+ 33 - 0
tool/TaskQueue/threadpp/impl/std_lock.h

@@ -0,0 +1,33 @@
+//
+//  std_lock.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef __threadpp__std_lock__
+#define __threadpp__std_lock__
+#include <mutex>
+#include <condition_variable>
+namespace threadpp
+{
+    class std_lock
+    {
+        std::mutex _mutex;
+        std::condition_variable_any _cond;
+        void operator=(const std_lock& l){};
+        std_lock(const std_lock& l){};
+    public:
+        std_lock();
+        ~std_lock();
+        void lock();
+        void unlock();
+        void wait();
+        void wait(unsigned long millisecs);
+        void notify();
+        void notify_all();
+    };
+}
+#include "std_lock.hpp"
+#endif /* defined(__threadpp__std_lock__) */

+ 52 - 0
tool/TaskQueue/threadpp/impl/std_lock.hpp

@@ -0,0 +1,52 @@
+//
+//  std_lock.cpp
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+#ifndef __threadpp__std_lock__hpp__
+#define __threadpp__std_lock__hpp__
+#include "../threadpp_assert.h"
+
+namespace threadpp{
+    
+    inline std_lock::std_lock():_mutex(),_cond()
+    {
+    }
+    
+    inline std_lock::~std_lock()
+    {
+    }
+    
+    inline void std_lock::lock()
+    {
+        _mutex.lock();
+    }
+    
+    inline void std_lock::unlock()
+    {
+        _mutex.unlock();
+    }
+    
+    inline void std_lock::wait()
+    {
+        _cond.wait(_mutex);
+    }
+    
+    inline void std_lock::wait(unsigned long millisecs)
+    {
+        _cond.wait_for(_mutex, std::chrono::milliseconds(millisecs));
+    }
+    
+    inline void std_lock::notify()
+    {
+        _cond.notify_one();
+    }
+    
+    inline void std_lock::notify_all()
+    {
+        _cond.notify_all();
+    }
+}
+#endif

+ 40 - 0
tool/TaskQueue/threadpp/impl/std_thread.h

@@ -0,0 +1,40 @@
+//
+//  std_thread.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef __threadpp__std_thread__
+#define __threadpp__std_thread__
+#include <thread>
+
+namespace threadpp
+{
+    class std_thread
+    {
+        std::thread _thread;
+        std_thread(){};
+        void operator=(const std_thread& t){};
+        std_thread(const std_thread& t){};
+    public:
+        typedef unsigned long long id_type;
+        
+        typedef void (*runnable)(void* ctx);
+        
+        static id_type null_id();
+        
+        std_thread(runnable r,void* t);
+        
+        ~std_thread();
+        void join();
+        void detach();
+        bool is_equal(const std_thread& t) const;
+        id_type get_id() const;
+        static id_type current_thread_id();
+        static void sleep(unsigned long millisecs);
+    };
+}
+#include "std_thread.hpp"
+#endif /* defined(__threadpp__std_thread__) */

+ 64 - 0
tool/TaskQueue/threadpp/impl/std_thread.hpp

@@ -0,0 +1,64 @@
+//
+//  std_thread.cpp
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+#ifndef __threadpp__std_thread__hpp__
+#define __threadpp__std_thread__hpp__
+#include <functional>
+#include <algorithm>
+namespace threadpp
+{
+    inline std_thread::id_type std_thread::null_id()
+    {
+        return 0;
+    }
+    
+    inline void* std_fp_delegate(std_thread::runnable r, void* context)
+    {
+        r(context);
+        return nullptr;
+    }
+    
+    inline std_thread::std_thread(runnable r,void* t):_thread(std::bind(std_fp_delegate,r,t))
+    {
+    }
+    
+    inline std_thread::~std_thread()
+    {
+        
+    }
+    
+    inline void std_thread::join()
+    {
+        _thread.join();
+    }
+    
+    inline void std_thread::detach()
+    {
+        _thread.detach();
+    }
+    
+    inline bool std_thread::is_equal(const std_thread& t) const
+    {
+        return _thread.get_id() == t._thread.get_id();
+    }
+    
+    inline std_thread::id_type std_thread::get_id() const
+    {
+        return std::hash<std::thread::id>()(_thread.get_id());
+    }
+    
+    inline void std_thread::sleep(unsigned long millisecs)
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(millisecs));
+    }
+    
+    inline std_thread::id_type std_thread::current_thread_id()
+    {
+        return std::hash<std::thread::id>()(std::this_thread::get_id());
+    }
+}
+#endif

+ 37 - 0
tool/TaskQueue/threadpp/impl/win_lock.h

@@ -0,0 +1,37 @@
+//
+//  win_lock.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef __threadpp__win_lock__
+#define __threadpp__win_lock__
+
+#include <windows.h>
+
+namespace threadpp
+{
+    class win_lock
+    {
+        CRITICAL_SECTION _mutex;
+        CONDITION_VARIABLE _cond;
+        volatile unsigned int _owner;
+        volatile unsigned int _count;
+        void operator=(const win_lock& l){};
+        win_lock(const win_lock& l){};
+    public:
+        win_lock();
+        ~win_lock();
+        void lock();
+        void unlock();
+        void wait();
+        void wait(unsigned long millisecs);
+        void notify();
+        void notify_all();
+    };
+}
+
+#include "win_lock.hpp"
+#endif /* defined(__threadpp__win_lock__) */

+ 80 - 0
tool/TaskQueue/threadpp/impl/win_lock.hpp

@@ -0,0 +1,80 @@
+//
+//  win_lock.cpp
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+#ifndef __threadpp__win_lock__hpp__
+#define __threadpp__win_lock__hpp__
+
+#include "win_thread.h"
+#include "../threadpp_assert.h"
+#include "stdio.h"
+namespace threadpp{
+    
+    static inline void test_error(const char* title)
+    {
+        DWORD e = GetLastError();
+        ASSERT(e==0,"%s failed,error:%d",title,e);
+    }
+    
+    inline win_lock::win_lock():_owner(0),_count(0)
+    {
+        SetLastError(0);
+        InitializeCriticalSection(&_mutex);
+        InitializeConditionVariable(&_cond);
+        test_error("init");
+    }
+    
+    inline win_lock::~win_lock()
+    {
+        DeleteCriticalSection(&_mutex);
+    }
+    
+    inline void win_lock::lock()
+    {
+        SetLastError(0);
+        
+        EnterCriticalSection(&_mutex);
+        
+        test_error("lock");
+    }
+    
+    inline void win_lock::unlock()
+    {
+        SetLastError(0);
+        LeaveCriticalSection(&_mutex);
+        test_error("unlock");
+    }
+    
+    inline void win_lock::wait()
+    {
+        SetLastError(0);
+        SleepConditionVariableCS(&_cond,&_mutex,0xFFFFFFFF);
+        test_error("wait");
+    }
+    
+    inline void win_lock::wait(unsigned long millisecs)
+    {
+        SetLastError(0);
+        SleepConditionVariableCS(&_cond,&_mutex,millisecs);
+        DWORD e = GetLastError();
+        ASSERT(e==0||e == ERROR_TIMEOUT,"timed wait failed,error:",e);
+    }
+    
+    inline void win_lock::notify()
+    {
+        SetLastError(0);
+        WakeConditionVariable(&_cond);
+        test_error("notify");
+    }
+    
+    inline void win_lock::notify_all()
+    {
+        SetLastError(0);
+        WakeAllConditionVariable(&_cond);
+        test_error("notify all");
+    }
+}
+#endif

+ 53 - 0
tool/TaskQueue/threadpp/impl/win_thread.h

@@ -0,0 +1,53 @@
+//
+//  win_thread.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef __threadpp__win_thread__
+#define __threadpp__win_thread__
+
+#include <windows.h>
+
+namespace threadpp
+{
+    class win_thread
+    {
+        struct win_context
+        {
+            void(*fp)(void*);
+            void* context;
+        } _context;
+#if NO_CRT
+        typedef DWORD handle_t;
+#else
+		typedef unsigned handle_t;
+#endif
+		static handle_t __stdcall win_fp_delegate(void* context);
+        handle_t _thread_id;
+        HANDLE _handle;
+        win_thread(){};
+        void operator=(const win_thread& t){};
+        win_thread(const win_thread& t){};
+    public:
+        typedef void (*runnable)(void* ctx);
+        typedef unsigned int id_type;
+        
+        static id_type null_id();
+        
+        win_thread(runnable r,void* t);
+        
+        ~win_thread();
+        void join();
+        void detach();
+        bool is_equal(const win_thread& t) const;
+        id_type get_id() const;
+        static id_type current_thread_id();
+        static void sleep(unsigned long millisecs);
+    };
+}
+
+#include "win_thread.hpp"
+#endif /* defined(__threadpp__win_thread__) */

+ 81 - 0
tool/TaskQueue/threadpp/impl/win_thread.hpp

@@ -0,0 +1,81 @@
+//
+//  win_thread.cpp
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+#ifndef __threadpp__win_thread__hpp__
+#define __threadpp__win_thread__hpp__
+
+#include "../threadpp_assert.h"
+#if NO_CRT
+#else
+#include <process.h>
+#endif
+namespace threadpp
+{
+
+    inline win_thread::id_type win_thread::null_id()
+    {
+        return 0;
+    }
+    
+	inline win_thread::handle_t win_thread::win_fp_delegate(void *context)
+    {
+        win_context* wctx = static_cast<win_context*>(context);
+        wctx->fp(wctx->context);
+        return 0;
+    }
+    
+    inline win_thread::win_thread(runnable r,void* t)
+    {
+        _context.fp = r;
+        _context.context = t;
+#if NO_CRT
+		_handle = CreateThread(NULL,NULL,win_thread::win_fp_delegate,&_context,0,&_thread_id);
+#else
+		_handle = (HANDLE)_beginthreadex(NULL,0,win_thread::win_fp_delegate,&_context,0,&_thread_id);
+#endif		
+    }
+    
+    inline win_thread::~win_thread()
+    {
+        ASSERT(_handle == 0,"%s","must join or detach a thread before destructing it");
+    }
+    
+    inline void win_thread::join()
+    {
+        unsigned code = WaitForSingleObject(_handle,0xFFFFFFFF);
+        CloseHandle(_handle);
+        _handle = 0;
+        ASSERT(code == WAIT_OBJECT_0 || code == WAIT_ABANDONED, "failed to join,error:%d",code);
+    }
+    
+    inline void win_thread::detach()
+    {
+		CloseHandle(_handle);
+        _handle = 0;
+    }
+    
+    inline bool win_thread::is_equal(const win_thread& t) const
+    {
+        return _thread_id == t._thread_id;
+    }
+    
+    inline void win_thread::sleep(unsigned long millisecs)
+    {
+		Sleep(millisecs);
+    }
+    
+	inline win_thread::id_type win_thread::get_id() const
+	{
+		return static_cast<unsigned int>(_thread_id);
+	}
+
+	inline win_thread::id_type win_thread::current_thread_id()
+	{
+		return  static_cast<unsigned int>(GetCurrentThreadId());
+	}
+}
+#endif

+ 101 - 0
tool/TaskQueue/threadpp/recursive_lock.h

@@ -0,0 +1,101 @@
+//
+//  recursive_lock.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/16/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef threadpp_recursive_lock_h
+#define threadpp_recursive_lock_h
+#include "threadpp_assert.h"
+namespace threadpp
+{
+    template <typename locktype,typename threadtype>
+    class recursive_lock
+    {
+        locktype _lock;
+        volatile typename threadtype::id_type _owner;
+        volatile unsigned int _count;
+    public:
+        recursive_lock();
+        void lock();
+        void unlock();
+        void wait();
+        void wait(unsigned long millisecs);
+        void notify();
+        void notify_all();
+    };
+    
+    template <typename locktype,typename threadtype>
+    recursive_lock<locktype,threadtype>::recursive_lock():_owner(threadtype::null_id()),_count(0)
+    {
+    }
+    
+    template <typename locktype,typename threadtype>
+    void recursive_lock<locktype,threadtype>::lock()
+    {
+        typename threadtype::id_type tid = threadtype::current_thread_id();
+        if(tid == _owner)
+        {
+            _count++;
+        }
+        else
+        {
+            _lock.lock();
+            _owner = tid;
+            _count=1;
+        }
+    }
+    
+    template <typename locktype,typename threadtype>
+    void recursive_lock<locktype,threadtype>::unlock()
+    {
+        typename threadtype::id_type tid = threadtype::current_thread_id();
+        ASSERT(tid == _owner,"%s", "unlock failed,try to unlock not owned mutex");
+        _count--;
+        if (_count == 0) {
+            _owner = threadtype::null_id();
+            _lock.unlock();
+        }
+    }
+    
+    template <typename locktype,typename threadtype>
+    void recursive_lock<locktype,threadtype>::wait()
+    {
+        typename threadtype::id_type owner = _owner;
+        unsigned count = _count;
+        _owner = threadtype::null_id();
+        _count = 0;
+        _lock.wait();
+        _owner = owner;
+        _count = count;
+
+    }
+    
+    template <typename locktype,typename threadtype>
+    void recursive_lock<locktype,threadtype>::wait(unsigned long millisecs)
+    {
+        typename threadtype::id_type owner = _owner;
+        unsigned count = _count;
+        _owner = threadtype::null_id();
+        _count = 0;
+        _lock.wait(millisecs);
+        _owner = owner;
+        _count = count;
+    }
+    
+    template <typename locktype,typename threadtype>
+    void recursive_lock<locktype,threadtype>::notify()
+    {
+        _lock.notify();
+    }
+    
+    template <typename locktype,typename threadtype>
+    void recursive_lock<locktype,threadtype>::notify_all()
+    {
+        _lock.notify_all();
+    }
+}
+
+#endif

+ 40 - 0
tool/TaskQueue/threadpp/threadpp.h

@@ -0,0 +1,40 @@
+//
+//  threadpp.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef threadpp_threadpp_h
+#define threadpp_threadpp_h
+#include "recursive_lock.h"
+#if __posix || __APPLE__ || __linux
+#include "impl/pthread_thread.h"
+#include "impl/pthread_lock.h"
+namespace threadpp
+{
+    typedef pthread_thread thread;
+    typedef pthread_lock lock;
+    typedef recursive_lock<pthread_lock, pthread_thread> recursivelock;
+}
+#elif defined(WIN32)
+#include "impl/win_thread.h"
+#include "impl/win_lock.h"
+namespace threadpp
+{
+    typedef win_thread thread;
+    typedef win_lock lock;
+    typedef recursive_lock<win_lock, win_thread> recursivelock;
+}
+#elif __cplusplus>=201103L
+#include "impl/std_thread.h"
+#include "impl/std_lock.h"
+namespace threadpp
+{
+    typedef std_thread thread;
+    typedef std_lock lock;
+    typedef recursive_lock<std_lock, std_thread> recursivelock;
+}
+#endif
+#endif

+ 33 - 0
tool/TaskQueue/threadpp/threadpp_assert.h

@@ -0,0 +1,33 @@
+//
+//  defines.h
+//  threadpp
+//
+//  Created by Melo Yao on 1/15/15.
+//  Copyright (c) 2015 Melo Yao. All rights reserved.
+//
+
+#ifndef threadpp_assert_h
+#define threadpp_assert_h
+
+//forward VC++ DEBUG symbol.
+#if defined(_DEBUG) && !defined(DEBUG)
+#define DEBUG _DEBUG
+#endif
+
+#if DEBUG //assertions
+#ifdef __cplusplus
+#include <cassert>
+#include <cstdio>
+#else
+#include <assert.h>
+#include <stdio.h>
+#endif
+#define ASSERT0(__cond__) assert(__cond__)
+#define ASSERT(__cond__,__msg__,...) \
+do {if(!(__cond__)){printf(__msg__,__VA_ARGS__);printf("\n");assert(false);}}while(0)
+#else
+#define ASSERT0(__cond__)
+#define ASSERT(__cond__,__msg__,...)
+#endif //assertions
+
+#endif