瀏覽代碼

2021 0308, wangkang parkspace message修改

wk 4 年之前
父節點
當前提交
de9999b63b

+ 43 - 29
message/message_base.pb.cc

@@ -363,7 +363,7 @@ void AddDescriptorsImpl() {
       "h\030\r \001(\0162\027.message.Parkspace_path\022\032\n\022path"
       "_estimate_time\030\016 \001(\002\022:\n\027parkspace_status"
       "_target\030\017 \001(\0162\031.message.Parkspace_status"
-      "*\317\007\n\014Message_type\022\r\n\teBase_msg\020\000\022\020\n\014eCom"
+      "*\237\t\n\014Message_type\022\r\n\teBase_msg\020\000\022\020\n\014eCom"
       "mand_msg\020\001\022\026\n\022eLocate_status_msg\020\021\022\027\n\023eL"
       "ocate_request_msg\020\022\022\030\n\024eLocate_response_"
       "msg\020\023\022\030\n\024eDispatch_status_msg\020!\022\031\n\025eDisp"
@@ -387,36 +387,42 @@ void AddDescriptorsImpl() {
       "ePicking_process_statu_msg\020\221\001\022\"\n\035eCentra"
       "l_controller_statu_msg\020\240\001\022#\n\036eEntrance_m"
       "anual_operation_msg\020\260\001\022\"\n\035eProcess_manua"
-      "l_operation_msg\020\261\001*f\n\014Communicator\022\n\n\006eE"
-      "mpty\020\000\022\t\n\005eMain\020\001\022\016\n\teTerminor\020\200\002\022\017\n\nePa"
-      "rkspace\020\200\004\022\016\n\teMeasurer\020\200\006\022\016\n\teDispatch\020"
-      "\200\010**\n\014Process_type\022\014\n\010eStoring\020\001\022\014\n\010ePic"
-      "king\020\002*e\n\013Error_level\022\n\n\006NORMAL\020\000\022\024\n\020NEG"
-      "LIGIBLE_ERROR\020\001\022\017\n\013MINOR_ERROR\020\002\022\017\n\013MAJO"
-      "R_ERROR\020\003\022\022\n\016CRITICAL_ERROR\020\004*\207\001\n\020Parksp"
-      "ace_status\022\024\n\020eParkspace_empty\020\000\022\027\n\023ePar"
-      "kspace_occupied\020\001\022\027\n\023eParkspace_reserved"
-      "\020\002\022\025\n\021eParkspace_locked\020\003\022\024\n\020eParkspace_"
-      "error\020\004*(\n\tDirection\022\014\n\010eForward\020\001\022\r\n\teB"
-      "ackward\020\002*[\n\016Parkspace_path\022\020\n\014OPTIMAL_P"
-      "ATH\020\001\022\r\n\tLEFT_PATH\020\002\022\016\n\nRIGHT_PATH\020\003\022\030\n\024"
-      "TEMPORARY_CACHE_PATH\020\004*R\n\016Parkspace_type"
-      "\022\024\n\020MIN_PARKINGSPACE\020\001\022\024\n\020MID_PARKINGSPA"
-      "CE\020\002\022\024\n\020BIG_PARKINGSPACE\020\003*\335\002\n\tStep_type"
-      "\022\017\n\013eAlloc_step\020\000\022\021\n\reMeasure_step\020\001\022\021\n\r"
-      "eCompare_step\020\002\022\022\n\016eDispatch_step\020\003\022\021\n\re"
-      "Confirm_step\020\004\022\020\n\014eSearch_step\020\005\022\016\n\neWai"
-      "t_step\020\006\022\021\n\reRelease_step\020\007\022\r\n\teComplete"
-      "\020\010\022\025\n\021eBackConfirm_step\020\t\022\026\n\022eBack_compa"
-      "re_step\020\n\022\025\n\021eBackMeasure_step\020\013\022\023\n\017eBac"
-      "kAlloc_step\020\014\022\022\n\016eBackWait_step\020\r\022\026\n\022eBa"
-      "ckDispatch_step\020\016\022\024\n\020eBackSearch_step\020\017\022"
-      "\021\n\reBackComplete\020\020*C\n\nStep_statu\022\014\n\010eWai"
-      "ting\020\000\022\014\n\010eWorking\020\001\022\n\n\006eError\020\002\022\r\n\teFin"
-      "ished\020\003"
+      "l_operation_msg\020\261\001\022\037\n\032eDispatch_plan_req"
+      "uest_msg\020\340\001\022 \n\033eDispatch_plan_response_m"
+      "sg\020\341\001\022\"\n\035eDispatch_control_request_msg\020\342"
+      "\001\022#\n\036eDispatch_control_response_msg\020\343\001\022!"
+      "\n\034eDispatch_manager_status_msg\020\352\001\022\037\n\032eDi"
+      "spatch_manager_data_msg\020\353\001*\242\001\n\014Communica"
+      "tor\022\n\n\006eEmpty\020\000\022\t\n\005eMain\020\001\022\016\n\teTerminor\020"
+      "\200\002\022\017\n\neParkspace\020\200\004\022\016\n\teMeasurer\020\200\006\022\032\n\025e"
+      "Measurer_sift_server\020\201\006\022\026\n\021eDispatch_mam"
+      "ager\020\200\010\022\026\n\021eDispatch_control\020\201\010**\n\014Proce"
+      "ss_type\022\014\n\010eStoring\020\001\022\014\n\010ePicking\020\002*e\n\013E"
+      "rror_level\022\n\n\006NORMAL\020\000\022\024\n\020NEGLIGIBLE_ERR"
+      "OR\020\001\022\017\n\013MINOR_ERROR\020\002\022\017\n\013MAJOR_ERROR\020\003\022\022"
+      "\n\016CRITICAL_ERROR\020\004*\207\001\n\020Parkspace_status\022"
+      "\024\n\020eParkspace_empty\020\000\022\027\n\023eParkspace_occu"
+      "pied\020\001\022\027\n\023eParkspace_reserved\020\002\022\025\n\021ePark"
+      "space_locked\020\003\022\024\n\020eParkspace_error\020\004*(\n\t"
+      "Direction\022\014\n\010eForward\020\001\022\r\n\teBackward\020\002*["
+      "\n\016Parkspace_path\022\020\n\014OPTIMAL_PATH\020\001\022\r\n\tLE"
+      "FT_PATH\020\002\022\016\n\nRIGHT_PATH\020\003\022\030\n\024TEMPORARY_C"
+      "ACHE_PATH\020\004*R\n\016Parkspace_type\022\024\n\020MIN_PAR"
+      "KINGSPACE\020\001\022\024\n\020MID_PARKINGSPACE\020\002\022\024\n\020BIG"
+      "_PARKINGSPACE\020\003*\335\002\n\tStep_type\022\017\n\013eAlloc_"
+      "step\020\000\022\021\n\reMeasure_step\020\001\022\021\n\reCompare_st"
+      "ep\020\002\022\022\n\016eDispatch_step\020\003\022\021\n\reConfirm_ste"
+      "p\020\004\022\020\n\014eSearch_step\020\005\022\016\n\neWait_step\020\006\022\021\n"
+      "\reRelease_step\020\007\022\r\n\teComplete\020\010\022\025\n\021eBack"
+      "Confirm_step\020\t\022\026\n\022eBack_compare_step\020\n\022\025"
+      "\n\021eBackMeasure_step\020\013\022\023\n\017eBackAlloc_step"
+      "\020\014\022\022\n\016eBackWait_step\020\r\022\026\n\022eBackDispatch_"
+      "step\020\016\022\024\n\020eBackSearch_step\020\017\022\021\n\reBackCom"
+      "plete\020\020*C\n\nStep_statu\022\014\n\010eWaiting\020\000\022\014\n\010e"
+      "Working\020\001\022\n\n\006eError\020\002\022\r\n\teFinished\020\003"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 3287);
+      descriptor, 3556);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "message_base.proto", &protobuf_RegisterTypes);
 }
@@ -468,6 +474,12 @@ bool Message_type_IsValid(int value) {
     case 160:
     case 176:
     case 177:
+    case 224:
+    case 225:
+    case 226:
+    case 227:
+    case 234:
+    case 235:
       return true;
     default:
       return false;
@@ -485,7 +497,9 @@ bool Communicator_IsValid(int value) {
     case 256:
     case 512:
     case 768:
+    case 769:
     case 1024:
+    case 1025:
       return true;
     default:
       return false;

+ 12 - 4
message/message_base.pb.h

@@ -115,11 +115,17 @@ enum Message_type {
   ePicking_process_statu_msg = 145,
   eCentral_controller_statu_msg = 160,
   eEntrance_manual_operation_msg = 176,
-  eProcess_manual_operation_msg = 177
+  eProcess_manual_operation_msg = 177,
+  eDispatch_plan_request_msg = 224,
+  eDispatch_plan_response_msg = 225,
+  eDispatch_control_request_msg = 226,
+  eDispatch_control_response_msg = 227,
+  eDispatch_manager_status_msg = 234,
+  eDispatch_manager_data_msg = 235
 };
 bool Message_type_IsValid(int value);
 const Message_type Message_type_MIN = eBase_msg;
-const Message_type Message_type_MAX = eProcess_manual_operation_msg;
+const Message_type Message_type_MAX = eDispatch_manager_data_msg;
 const int Message_type_ARRAYSIZE = Message_type_MAX + 1;
 
 const ::google::protobuf::EnumDescriptor* Message_type_descriptor();
@@ -138,11 +144,13 @@ enum Communicator {
   eTerminor = 256,
   eParkspace = 512,
   eMeasurer = 768,
-  eDispatch = 1024
+  eMeasurer_sift_server = 769,
+  eDispatch_mamager = 1024,
+  eDispatch_control = 1025
 };
 bool Communicator_IsValid(int value);
 const Communicator Communicator_MIN = eEmpty;
-const Communicator Communicator_MAX = eDispatch;
+const Communicator Communicator_MAX = eDispatch_control;
 const int Communicator_ARRAYSIZE = Communicator_MAX + 1;
 
 const ::google::protobuf::EnumDescriptor* Communicator_descriptor();

+ 12 - 2
message/message_base.proto

@@ -48,6 +48,12 @@ enum Message_type
     eEntrance_manual_operation_msg=0xb0;            //针对出入口状态操作的手动消息
     eProcess_manual_operation_msg=0xb1;             //针对流程的手动消息
 
+    eDispatch_plan_request_msg          = 0xe0;     //调度总规划的请求(用于启动整个调度算法)(调度管理->调度算法)
+    eDispatch_plan_response_msg         = 0xe1;     //调度总规划的答复(调度算法->调度管理)
+    eDispatch_control_request_msg       = 0xe2;     //调度控制的任务请求(调度算法->调度管理)
+    eDispatch_control_response_msg      = 0xe3;     //调度控制的任务答复(调度管理->调度算法)
+    eDispatch_manager_status_msg        = 0xea;     //调度管理的设备状态消息(调度底下所有硬件设备状态的汇总)
+    eDispatch_manager_data_msg          = 0xeb;     //调度管理的设备详细的数据信息
 
 }
 
@@ -62,8 +68,12 @@ enum Communicator
     eParkspace=0x0200;
     //测量单元
     eMeasurer=0x0300;
+    //测量单元的服务器
+    eMeasurer_sift_server=0x0301;
+    //调度管理
+    eDispatch_mamager=0x0400;
     //调度机构
-    eDispatch=0x0400;
+    eDispatch_control=0x0401;
     //...
 
 
@@ -142,7 +152,7 @@ enum Parkspace_status
 {
     eParkspace_empty            = 0;         //空闲,可分配
     eParkspace_occupied         = 1;         //被占用,不可分配
-    eParkspace_reserved        = 2;         //被预约,预约车辆可分配
+    eParkspace_reserved        = 2;         //被预约,预约车辆可分配,zhanshi buyong
     eParkspace_locked           = 3;         //临时锁定,不可分配
     eParkspace_error            = 4;         //车位机械结构或硬件故障   
 }

文件差異過大導致無法顯示
+ 387 - 352
message/parkspace_allocation_message.pb.cc


文件差異過大導致無法顯示
+ 400 - 360
message/parkspace_allocation_message.pb.h


+ 15 - 12
message/parkspace_allocation_message.proto

@@ -51,9 +51,9 @@ message Parkspace_allocation_response_msg
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
     required Error_manager              error_manager=3;        //分配成功与否标志
-    required Parkspace_info             allocated_space_info=4; //分配车位信息
+    optional Parkspace_info             allocated_parkspace_info=4; //分配车位信息
 
-    repeated Parkspace_info             allocated_space_info_ex = 5;    //分配车位信息
+    repeated Parkspace_info             allocated_parkspace_info_ex = 5;    //分配车位信息
 }
 
 //2.查询车辆位置请求
@@ -70,24 +70,24 @@ message Parkspace_search_response_msg
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
     required Error_manager              error_manager=3;        //分配成功与否标志
-    optional Parkspace_info             car_position=4;         //待查询车辆存放位置
+    optional Parkspace_info             query_parkspace_info=4;         //待查询车辆存放位置
 }
 
-//3.解锁车位请求
+//3.释放车位请求
 message Parkspace_release_request_msg
 {
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
-    required Parkspace_info             release_space_info=3;   //待释放车位信息
+    required Parkspace_info             release_parkspace_info=3;   //待释放车位信息
 }
 
-//解锁车位反馈
+//释放车位请求
 message Parkspace_release_response_msg
 {
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
     required Error_manager              error_manager=3;        //分配成功与否标志
-    required Parkspace_info             release_space_info=4;   //待释放车位信息
+    required Parkspace_info             release_parkspace_info=4;   //待释放车位信息
 }
 
 // 4.手动操作修改车位状态
@@ -95,7 +95,7 @@ message Parkspace_force_update_request_msg
 {
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
-    required Parkspace_info             update_space_info=3;    //待手动修改车位信息,通过id定位
+    required Parkspace_info             manual_parkspace_info=3;    //待手动修改车位信息,通过id定位
 }
 
 //手动操作反馈
@@ -104,7 +104,7 @@ message Parkspace_force_update_response_msg
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
     required Error_manager              error_manager=3;        //分配成功与否标志
-    required Parkspace_info             update_space_info=4;    //已修改后的车位信息
+    required Parkspace_info             manual_parkspace_info=4;    //已修改后的车位信息
 }
 
 // 5.确认占有车位
@@ -112,9 +112,9 @@ message Parkspace_confirm_alloc_request_msg
 {
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
-    required Parkspace_info             confirm_space_info=3;    //已修改后的车位信息
+    optional Parkspace_info             confirm_parkspace_info=3;    //已修改后的车位信息
 
-    repeated Parkspace_info             confirm_space_info_ex = 4;    //分配车位信息
+    repeated Parkspace_info             confirm_parkspace_info_ex = 4;    //分配车位信息
 }
 
 message Parkspace_confirm_alloc_response_msg
@@ -122,7 +122,10 @@ message Parkspace_confirm_alloc_response_msg
     required Base_info                  base_info=1;            //消息类型
     required string                     command_key=2;           //指令唯一标识符id
     required Error_manager              error_manager=3;        //分配成功与否标志
-    required Parkspace_info             confirm_alloc_space_info=4;    //已修改后的车位信息
+    optional Parkspace_info             confirm_alloc_parkspace_info=4;    //已修改后的车位信息
+
+    repeated Parkspace_info             confirm_parkspace_info_ex = 5;    //已修改后的车位信息
+
 }
 
 // 车位心跳状态信息

文件差異過大導致無法顯示
+ 426 - 250
parkspace_allocation/parkspace_manager.cpp


+ 9 - 2
parkspace_allocation/parkspace_manager.h

@@ -35,7 +35,7 @@ public:
 #define MIN_CAR_HIGH			1.55
 //中型车高判断标准 (暂时未定)   手写1.75
 #define MID_CAR_HIGH			1.75
-//大型车高判断标准 (暂时未定)   手写1.65
+//大型车高判断标准 (暂时未定)
 #define BIG_CAR_HIGH			2
 //中跑车速度 米每秒
 #define MEDIUM_CAR_SPEED		0.8
@@ -49,6 +49,8 @@ public:
 #define UPSTAIRS_SPORTS_TIME	1
 //电梯运动时间
 #define ELEVATOR_MOVEMENT_TIME	1
+//方案选择  为0时选择A方案停车  为非0时选择B方案停车
+#define PLAN 1
 private:
     // 父类的构造函数必须保护,子类的构造函数必须私有。
     Parkspace_manager();
@@ -98,9 +100,14 @@ public://execute_msg创建各线程进行处理
     //强制更新车位信息线程函数
 	void execute_for_force_update(message::Parkspace_info space_info, std::string command_key);
     //确认分配车位线程函数
-    void execute_for_confirm_alloc(message::Parkspace_info space_info, std::string command_key);
+    void execute_for_confirm_alloc(message::Parkspace_confirm_alloc_request_msg space_info);
 
 
+    //确认分配操作函数
+	Error_manager confirm_alloc_function(message::Parkspace_info target_space_info,message::Parkspace_info& confirm_alloc_space_info);
+    //释放车位操作函数---bool flag表示是否需要更新停车记录表和车辆表,当采用方案B的时候真正分配的车位才需要更行停车记录表和车辆表
+	Error_manager release_parkspace_function(message::Parkspace_info target_space_info,message::Parkspace_info& release_space_info,bool flag);
+
 private:
 	Parkspace_manager_satus 		m_parkspace_manager_satus;      //分配器当前状态
 	Thread_pool 					m_thread_pool;					//执行多任务的线程池

+ 12 - 5
parkspace_allocation/parkspace_operating_function.cpp

@@ -95,13 +95,13 @@ Error_manager Parkspace_operating_function::get_all_parkspace_info(message::Park
 	    return ec;
 	}
 }
-// 从数据库获得所有指定类型车位信息,用于车位模块初始化
+// 从数据库获得所有指定类型空车位车位信息,用于车位模块初始化
 Error_manager Parkspace_operating_function::get_specify_the_type_parkspace_info(message::Parkspace_allocation_data_msg &all_specify_the_type_parkspace_info,int parkspace_type)
 {
 	//执行sql操作
 	char all_specify_the_type_sql[1024];
 	memset(all_specify_the_type_sql, 0, 1024);
-	sprintf(all_specify_the_type_sql,"select * from parkingspace where parkingspace_type= %d",parkspace_type);
+	sprintf(all_specify_the_type_sql,"select * from parkingspace where parkingspace_type= %d and parkingspace_status = 0",parkspace_type);
 	boost::shared_ptr<sql::ResultSet>  tp_result = nullptr;
 	Error_manager ec = Database_controller::get_instance_pointer()->sql_query(all_specify_the_type_sql, tp_result);
 	if(ec == SUCCESS)
@@ -254,6 +254,7 @@ Error_manager Parkspace_operating_function::update_vehicle_with_parkspace(messag
 		return Error_manager(Error_code::PARAMETER_ERROR, Error_level::MINOR_ERROR,
 							"参数错误 Parkspace_operating_function::update_vehicle_with_parkspace error ");;
 	}
+
 	std::string find_vehicle_sql = std::string("select * from vehicle where numberPlate = '").append(parkspace_info.car_info().license()).append("'");
 	boost::shared_ptr<sql::ResultSet> query_vehicle_result = nullptr;
 	Database_controller::get_instance_pointer()->sql_query(find_vehicle_sql, query_vehicle_result);
@@ -264,6 +265,7 @@ Error_manager Parkspace_operating_function::update_vehicle_with_parkspace(messag
 	}
 	else
 	{
+
 		char update_vehicle_sql[1024];
 		memset(update_vehicle_sql, 0, 1024);
 		int vehicle_status_code = -1;
@@ -289,8 +291,13 @@ Error_manager Parkspace_operating_function::update_vehicle_with_parkspace(messag
 								 "参数错误 Parkspace_operating_function::update_vehicle_with_parkspace error ");
 			break;
 		}
+		if ( vehicle_status_code == 0 )
+		{
+			sprintf(update_vehicle_sql, "update vehicle set vehicleParkState = 0,carLength=NULL,carWidth=NULL,carHeight=NULL,carWheelBase = NULL,carWheelWidth = NULL,parkingSpaceID=NULL,parkingRecordsID=NULL where numberPlate = '%s'",
+				   parkspace_info.car_info().license().c_str());
+		}
 		//车位为空,仅更新车辆状态与长宽高
-		if(parkspace_info.parkingspace_index_id() <= 0)
+		else if(parkspace_info.parkingspace_index_id() <= 0)
 		{
 			sprintf(update_vehicle_sql, "update vehicle set vehicleParkState = %d,carLength=%.3f,carWidth=%.3f,carHeight=%.3f,carWheelBase = %.3f,carWheelWidth = %.3f where numberPlate = '%s'",
 					vehicle_status_code,
@@ -374,7 +381,7 @@ Error_manager Parkspace_operating_function::insert_vehicle_with_parkspace(messag
 	//车位为空,仅更新车辆状态与长宽高
 	if(parkspace_info.parkingspace_index_id() <= 0)
 	{
-		sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth) values ('%s',%d,%.3f,%.3f,%.3f)",
+		sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth) values ('%s',%d,%.3f,%.3f,%.3f,%.3f,%.3f)",
 				parkspace_info.car_info().license().c_str(),
 				vehicle_status_code,
 				parkspace_info.car_info().car_length(),
@@ -386,7 +393,7 @@ Error_manager Parkspace_operating_function::insert_vehicle_with_parkspace(messag
 	//车位不为空,表示车辆在车位,同时更新
 	else
 	{
-		sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth,parkingSpaceID) values ('%s',%d,%.3f,%.3f,%.3f,%d)",
+		sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth,parkingSpaceID) values ('%s',%d,%.3f,%.3f,%.3f,%.3f,%.3f,%d)",
 			parkspace_info.car_info().license().c_str(),
 			vehicle_status_code,
 			parkspace_info.car_info().car_length(),

+ 1 - 1
parkspace_allocation/parkspace_operating_function.h

@@ -27,7 +27,7 @@ public:
     // ******** 数据库具体操作函数 *********
     // 从数据库获得所有车位信息,用于车位模块初始化
     Error_manager get_all_parkspace_info(message::Parkspace_allocation_data_msg &all_parkspace_info);
-    // 获取置顶类型车位信息,用于车位分配
+    // 获取指定类型车位信息,用于车位分配
 	Error_manager get_specify_the_type_parkspace_info(message::Parkspace_allocation_data_msg &all_specify_the_type_parkspace_info,int parkspace_type);
     // 清除数据库中所有车位号牌,状态全修改为空闲
     Error_manager clear_all_parkspace_info();

+ 5 - 2
test/parkspace_client.cpp

@@ -137,12 +137,15 @@ std::string send_confirm_request(int n)
 int main()
 {
     nnxx::socket socket{nnxx::SP, nnxx::BUS};
-    socket.bind("tcp://127.0.0.1:7000");
+//    socket.bind("tcp://127.0.0.1:7000");
 //    socket.connect("tcp://192.168.2.113:30008");
 
 //	socket.connect("tcp://127.0.0.1:30005");
 
-//	socket.connect("tcp://192.168.2.127:30005");
+	socket.connect("tcp://192.168.2.113:30008");
+
+
+
 //
 	int n = 0;
     message::Base_msg base_msg;