Browse Source

parkspace add block id, allocate according to block

youchen 4 years ago
parent
commit
a742365539

+ 14 - 14
CMakeLists.txt

@@ -61,20 +61,20 @@ target_link_libraries(parkspace_test
         /usr/local/lib/libgflags.a
         libmysqlcppconn.so
         )
-# add_executable(parkspace_client
-#         ./test/parkspace_client.cpp
-#         ${error_src}
-#         ${message_src}
-#         ${TOOL_SRC}
-#         ${COMMUNICATION_SRC}
-#         )
-# target_link_libraries(parkspace_client
-#         nnxx
-#         nanomsg
-#         ${PROTOBUF_LIBRARIES}
-#         /usr/local/lib/libglog.a
-#         /usr/local/lib/libgflags.a
-#         )
+add_executable(parkspace_client
+        ./test/parkspace_client.cpp
+        ${error_src}
+        ${message_src}
+        ${TOOL_SRC}
+        ${COMMUNICATION_SRC}
+        )
+target_link_libraries(parkspace_client
+        nnxx
+        nanomsg
+        ${PROTOBUF_LIBRARIES}
+        /usr/local/lib/libglog.a
+        /usr/local/lib/libgflags.a
+        )
 
 # db test
 add_executable(db_test

+ 1 - 3
communication/communication_socket_base.h

@@ -29,8 +29,6 @@
 #include "../communication/communication_message.h"
 
 #include "../message/message_base.pb.h"
-#include "../message/measure_message.pb.h"
-
 
 
 #define COMMUNICATION_PARAMETER_PATH "../setting/communication.prototxt"
@@ -162,4 +160,4 @@ private:
 
 
 
-#endif //__COMMUNICATION_SOCKET_BASE__HH__
+#endif //__COMMUNICATION_SOCKET_BASE__HH__

File diff suppressed because it is too large
+ 0 - 1716
message/measure_message.pb.cc


File diff suppressed because it is too large
+ 0 - 1185
message/measure_message.pb.h


+ 0 - 69
message/measure_message.proto

@@ -1,69 +0,0 @@
-syntax = "proto2";
-package message;
-import "message_base.proto";
-
-//雷达管理模块的工作状态
-enum Laser_manager_status
-{
-    LASER_MANAGER_UNKNOW               	= 0;    //未知
-    LASER_MANAGER_READY               	= 1;    //准备,待机
-	LASER_MANAGER_ISSUED_TASK			= 2;	//工作下发任务
-	LASER_MANAGER_WAIT_REPLY			= 3;	//工作等待答复
-	LASER_MANAGER_FAULT					= 4;	//故障
-}
-	
-//子雷达状态
-enum Laser_statu
-{
-	LASER_DISCONNECT	=0;	        //雷达断连
-	LASER_READY			=1;			//雷达正常待机,空闲
-	LASER_BUSY			=2;	        //雷达正在工作,正忙
-	LASER_FAULT			=3;         //雷达错误
-}
-
-//定位管理模块的工作状态
-enum Locate_manager_status
-{
-	LOCATE_MANAGER_UNKNOW               	= 0;    //未知
-	LOCATE_MANAGER_READY               		= 1;    //准备,待机
-	LOCATE_MANAGER_SIFT						= 2;	//sift点云筛选; 将车身和轮胎的点剥离出来
-	LOCATE_MANAGER_CAR						= 3;	//通过车身 计算汽车的定位信息.
-	LOCATE_MANAGER_WHEEL					= 4;	//通过车轮 计算汽车的定位信息.
-	LOCATE_MANAGER_FAULT					= 5;	//故障
-}
-	
-	
-//定位模块状态
-message Measure_status_msg
-{
-    required Base_info                  base_info=1;                 //消息类型
-
-    required Laser_manager_status       laser_manager_status = 2;
-    repeated Laser_statu                laser_statu_vector = 3;
-    required Locate_manager_status      locate_manager_status = 4;
-
-    optional Locate_information         locate_information_realtime=5;  //地面雷达的 实时定位信息
-    required Error_manager              error_manager = 6;
-}
-
-
-//定位请求消息
-message Measure_request_msg
-{
-    required Base_info                  base_info=1;        //消息类型
-    required int32                      command_id=2;                   //指令唯一标识符id
-    required int32                      terminal_id=3;          //终端id
-}
-
-//定位测量返回消息
-message Measure_response_msg
-{
-    required Base_info                  base_info=1;                         //消息类型
-    required int32                      command_id=2;                   //指令唯一标识符id
-    required int32                      terminal_id=3;
-
-    optional Locate_information         locate_information=4;
-    required Error_manager              error_manager = 5;
-}
-
-

+ 84 - 46
message/message_base.pb.cc

@@ -304,9 +304,10 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, car_info_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, entry_time_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, leave_time_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, block_id_),
   3,
   4,
-  10,
+  11,
   5,
   6,
   7,
@@ -315,6 +316,7 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   2,
   0,
   1,
+  10,
 };
 static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
   { 0, 9, sizeof(::message::Base_info)},
@@ -323,7 +325,7 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROT
   { 31, 39, sizeof(::message::Error_manager)},
   { 42, 56, sizeof(::message::Locate_information)},
   { 65, 74, sizeof(::message::Car_info)},
-  { 78, 94, sizeof(::message::Parkspace_info)},
+  { 78, 95, sizeof(::message::Parkspace_info)},
 };
 
 static ::google::protobuf::Message const * const file_default_instances[] = {
@@ -376,49 +378,49 @@ void AddDescriptorsImpl() {
       "\022locate_wheel_width\030\010 \001(\002\022\026\n\016locate_corr"
       "ect\030\t \001(\010\"V\n\010Car_info\022\022\n\ncar_length\030\001 \001("
       "\002\022\021\n\tcar_width\030\002 \001(\002\022\022\n\ncar_height\030\003 \001(\002"
-      "\022\017\n\007license\030\004 \001(\t\"\234\002\n\016Parkspace_info\022\024\n\014"
+      "\022\017\n\007license\030\004 \001(\t\"\256\002\n\016Parkspace_info\022\024\n\014"
       "parkspace_id\030\001 \001(\005\022\r\n\005index\030\002 \001(\005\022%\n\tdir"
       "ection\030\003 \001(\0162\022.message.Direction\022\r\n\005floo"
       "r\030\004 \001(\005\022\016\n\006length\030\005 \001(\002\022\r\n\005width\030\006 \001(\002\022\016"
       "\n\006height\030\007 \001(\002\0223\n\020parkspace_status\030\010 \001(\016"
       "2\031.message.Parkspace_status\022#\n\010car_info\030"
       "\t \001(\0132\021.message.Car_info\022\022\n\nentry_time\030\n"
-      " \001(\t\022\022\n\nleave_time\030\013 \001(\t*\276\006\n\014Message_typ"
-      "e\022\r\n\teBase_msg\020\000\022\020\n\014eCommand_msg\020\001\022\026\n\022eL"
-      "ocate_status_msg\020\021\022\027\n\023eLocate_request_ms"
-      "g\020\022\022\030\n\024eLocate_response_msg\020\023\022\030\n\024eDispat"
-      "ch_status_msg\020!\022\031\n\025eDispatch_request_msg"
-      "\020\"\022\032\n\026eDispatch_response_msg\020#\022$\n eParks"
-      "pace_allocation_status_msg\0201\022%\n!eParkspa"
-      "ce_allocation_request_msg\0202\022&\n\"eParkspac"
-      "e_allocation_response_msg\0203\022!\n\035eParkspac"
-      "e_search_request_msg\0204\022\"\n\036eParkspace_sea"
-      "rch_response_msg\0205\022\"\n\036eParkspace_release"
-      "_request_msg\0206\022#\n\037eParkspace_release_res"
-      "ponse_msg\0207\022\'\n#eParkspace_force_update_r"
-      "equest_msg\0208\022(\n$eParkspace_force_update_"
-      "response_msg\0209\022(\n$eParkspace_confirm_all"
-      "oc_request_msg\020:\022)\n%eParkspace_confirm_a"
-      "lloc_response_msg\020;\022\036\n\032eStore_command_re"
-      "quest_msg\020A\022\037\n\033eStore_command_response_m"
-      "sg\020B\022\037\n\033ePickup_command_request_msg\020C\022 \n"
-      "\034ePickup_command_response_msg\020D\022\037\n\032eStor"
-      "ing_process_statu_msg\020\220\001\022\037\n\032ePicking_pro"
-      "cess_statu_msg\020\221\001*f\n\014Communicator\022\n\n\006eEm"
-      "pty\020\000\022\t\n\005eMain\020\001\022\016\n\teTerminor\020\200\002\022\017\n\nePar"
-      "kspace\020\200\004\022\016\n\teMeasurer\020\200\006\022\016\n\teDispatch\020\200"
-      "\010*#\n\005Event\022\014\n\010eStoring\020\001\022\014\n\010ePicking\020\002*e"
-      "\n\013Error_level\022\n\n\006NORMAL\020\000\022\024\n\020NEGLIGIBLE_"
-      "ERROR\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_stat"
-      "us\022\024\n\020eParkspace_empty\020\000\022\027\n\023eParkspace_o"
-      "ccupied\020\001\022\027\n\023eParkspace_reserved\020\002\022\025\n\021eP"
-      "arkspace_locked\020\003\022\024\n\020eParkspace_error\020\004*"
-      "(\n\tDirection\022\014\n\010eForward\020\001\022\r\n\teBackward\020"
-      "\002"
+      " \001(\t\022\022\n\nleave_time\030\013 \001(\t\022\020\n\010block_id\030\014 \001"
+      "(\005*\276\006\n\014Message_type\022\r\n\teBase_msg\020\000\022\020\n\014eC"
+      "ommand_msg\020\001\022\026\n\022eLocate_status_msg\020\021\022\027\n\023"
+      "eLocate_request_msg\020\022\022\030\n\024eLocate_respons"
+      "e_msg\020\023\022\030\n\024eDispatch_status_msg\020!\022\031\n\025eDi"
+      "spatch_request_msg\020\"\022\032\n\026eDispatch_respon"
+      "se_msg\020#\022$\n eParkspace_allocation_status"
+      "_msg\0201\022%\n!eParkspace_allocation_request_"
+      "msg\0202\022&\n\"eParkspace_allocation_response_"
+      "msg\0203\022!\n\035eParkspace_search_request_msg\0204"
+      "\022\"\n\036eParkspace_search_response_msg\0205\022\"\n\036"
+      "eParkspace_release_request_msg\0206\022#\n\037ePar"
+      "kspace_release_response_msg\0207\022\'\n#eParksp"
+      "ace_force_update_request_msg\0208\022(\n$eParks"
+      "pace_force_update_response_msg\0209\022(\n$ePar"
+      "kspace_confirm_alloc_request_msg\020:\022)\n%eP"
+      "arkspace_confirm_alloc_response_msg\020;\022\036\n"
+      "\032eStore_command_request_msg\020A\022\037\n\033eStore_"
+      "command_response_msg\020B\022\037\n\033ePickup_comman"
+      "d_request_msg\020C\022 \n\034ePickup_command_respo"
+      "nse_msg\020D\022\037\n\032eStoring_process_statu_msg\020"
+      "\220\001\022\037\n\032ePicking_process_statu_msg\020\221\001*f\n\014C"
+      "ommunicator\022\n\n\006eEmpty\020\000\022\t\n\005eMain\020\001\022\016\n\teT"
+      "erminor\020\200\002\022\017\n\neParkspace\020\200\004\022\016\n\teMeasurer"
+      "\020\200\006\022\016\n\teDispatch\020\200\010*#\n\005Event\022\014\n\010eStoring"
+      "\020\001\022\014\n\010ePicking\020\002*e\n\013Error_level\022\n\n\006NORMA"
+      "L\020\000\022\024\n\020NEGLIGIBLE_ERROR\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_occupied\020\001\022\027\n\023eParkspac"
+      "e_reserved\020\002\022\025\n\021eParkspace_locked\020\003\022\024\n\020e"
+      "Parkspace_error\020\004*(\n\tDirection\022\014\n\010eForwa"
+      "rd\020\001\022\r\n\teBackward\020\002"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 2281);
+      descriptor, 2299);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "message_base.proto", &protobuf_RegisterTypes);
 }
@@ -2911,6 +2913,7 @@ const int Parkspace_info::kParkspaceStatusFieldNumber;
 const int Parkspace_info::kCarInfoFieldNumber;
 const int Parkspace_info::kEntryTimeFieldNumber;
 const int Parkspace_info::kLeaveTimeFieldNumber;
+const int Parkspace_info::kBlockIdFieldNumber;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
 
 Parkspace_info::Parkspace_info()
@@ -2951,8 +2954,8 @@ void Parkspace_info::SharedCtor() {
   entry_time_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   leave_time_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   ::memset(&car_info_, 0, static_cast<size_t>(
-      reinterpret_cast<char*>(&parkspace_status_) -
-      reinterpret_cast<char*>(&car_info_)) + sizeof(parkspace_status_));
+      reinterpret_cast<char*>(&block_id_) -
+      reinterpret_cast<char*>(&car_info_)) + sizeof(block_id_));
   direction_ = 1;
 }
 
@@ -3016,10 +3019,10 @@ void Parkspace_info::Clear() {
         reinterpret_cast<char*>(&width_) -
         reinterpret_cast<char*>(&parkspace_id_)) + sizeof(width_));
   }
-  if (cached_has_bits & 1792u) {
+  if (cached_has_bits & 3840u) {
     ::memset(&height_, 0, static_cast<size_t>(
-        reinterpret_cast<char*>(&parkspace_status_) -
-        reinterpret_cast<char*>(&height_)) + sizeof(parkspace_status_));
+        reinterpret_cast<char*>(&block_id_) -
+        reinterpret_cast<char*>(&height_)) + sizeof(block_id_));
     direction_ = 1;
   }
   _has_bits_.Clear();
@@ -3204,6 +3207,20 @@ bool Parkspace_info::MergePartialFromCodedStream(
         break;
       }
 
+      // optional int32 block_id = 12;
+      case 12: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(96u /* 96 & 0xFF */)) {
+          set_has_block_id();
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+                 input, &block_id_)));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
       default: {
       handle_unusual:
         if (tag == 0) {
@@ -3242,7 +3259,7 @@ void Parkspace_info::SerializeWithCachedSizes(
   }
 
   // optional .message.Direction direction = 3;
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000800u) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       3, this->direction(), output);
   }
@@ -3299,6 +3316,11 @@ void Parkspace_info::SerializeWithCachedSizes(
       11, this->leave_time(), output);
   }
 
+  // optional int32 block_id = 12;
+  if (cached_has_bits & 0x00000400u) {
+    ::google::protobuf::internal::WireFormatLite::WriteInt32(12, this->block_id(), output);
+  }
+
   if (_internal_metadata_.have_unknown_fields()) {
     ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
         _internal_metadata_.unknown_fields(), output);
@@ -3325,7 +3347,7 @@ void Parkspace_info::SerializeWithCachedSizes(
   }
 
   // optional .message.Direction direction = 3;
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000800u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       3, this->direction(), target);
   }
@@ -3385,6 +3407,11 @@ void Parkspace_info::SerializeWithCachedSizes(
         11, this->leave_time(), target);
   }
 
+  // optional int32 block_id = 12;
+  if (cached_has_bits & 0x00000400u) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(12, this->block_id(), target);
+  }
+
   if (_internal_metadata_.have_unknown_fields()) {
     target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
         _internal_metadata_.unknown_fields(), target);
@@ -3456,7 +3483,7 @@ size_t Parkspace_info::ByteSizeLong() const {
     }
 
   }
-  if (_has_bits_[8 / 32] & 1792u) {
+  if (_has_bits_[8 / 32] & 3840u) {
     // optional float height = 7;
     if (has_height()) {
       total_size += 1 + 4;
@@ -3468,6 +3495,13 @@ size_t Parkspace_info::ByteSizeLong() const {
         ::google::protobuf::internal::WireFormatLite::EnumSize(this->parkspace_status());
     }
 
+    // optional int32 block_id = 12;
+    if (has_block_id()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::Int32Size(
+          this->block_id());
+    }
+
     // optional .message.Direction direction = 3;
     if (has_direction()) {
       total_size += 1 +
@@ -3534,7 +3568,7 @@ void Parkspace_info::MergeFrom(const Parkspace_info& from) {
     }
     _has_bits_[0] |= cached_has_bits;
   }
-  if (cached_has_bits & 1792u) {
+  if (cached_has_bits & 3840u) {
     if (cached_has_bits & 0x00000100u) {
       height_ = from.height_;
     }
@@ -3542,6 +3576,9 @@ void Parkspace_info::MergeFrom(const Parkspace_info& from) {
       parkspace_status_ = from.parkspace_status_;
     }
     if (cached_has_bits & 0x00000400u) {
+      block_id_ = from.block_id_;
+    }
+    if (cached_has_bits & 0x00000800u) {
       direction_ = from.direction_;
     }
     _has_bits_[0] |= cached_has_bits;
@@ -3582,6 +3619,7 @@ void Parkspace_info::InternalSwap(Parkspace_info* other) {
   swap(width_, other->width_);
   swap(height_, other->height_);
   swap(parkspace_status_, other->parkspace_status_);
+  swap(block_id_, other->block_id_);
   swap(direction_, other->direction_);
   swap(_has_bits_[0], other->_has_bits_[0]);
   _internal_metadata_.Swap(&other->_internal_metadata_);

+ 37 - 3
message/message_base.pb.h

@@ -1298,6 +1298,13 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   ::message::Parkspace_status parkspace_status() const;
   void set_parkspace_status(::message::Parkspace_status value);
 
+  // optional int32 block_id = 12;
+  bool has_block_id() const;
+  void clear_block_id();
+  static const int kBlockIdFieldNumber = 12;
+  ::google::protobuf::int32 block_id() const;
+  void set_block_id(::google::protobuf::int32 value);
+
   // optional .message.Direction direction = 3;
   bool has_direction() const;
   void clear_direction();
@@ -1329,6 +1336,8 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   void clear_has_entry_time();
   void set_has_leave_time();
   void clear_has_leave_time();
+  void set_has_block_id();
+  void clear_has_block_id();
 
   ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
   ::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -1343,6 +1352,7 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   float width_;
   float height_;
   int parkspace_status_;
+  ::google::protobuf::int32 block_id_;
   int direction_;
   friend struct ::protobuf_message_5fbase_2eproto::TableStruct;
   friend void ::protobuf_message_5fbase_2eproto::InitDefaultsParkspace_infoImpl();
@@ -2199,13 +2209,13 @@ inline void Parkspace_info::set_index(::google::protobuf::int32 value) {
 
 // optional .message.Direction direction = 3;
 inline bool Parkspace_info::has_direction() const {
-  return (_has_bits_[0] & 0x00000400u) != 0;
+  return (_has_bits_[0] & 0x00000800u) != 0;
 }
 inline void Parkspace_info::set_has_direction() {
-  _has_bits_[0] |= 0x00000400u;
+  _has_bits_[0] |= 0x00000800u;
 }
 inline void Parkspace_info::clear_has_direction() {
-  _has_bits_[0] &= ~0x00000400u;
+  _has_bits_[0] &= ~0x00000800u;
 }
 inline void Parkspace_info::clear_direction() {
   direction_ = 1;
@@ -2523,6 +2533,30 @@ inline void Parkspace_info::set_allocated_leave_time(::std::string* leave_time)
   // @@protoc_insertion_point(field_set_allocated:message.Parkspace_info.leave_time)
 }
 
+// optional int32 block_id = 12;
+inline bool Parkspace_info::has_block_id() const {
+  return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void Parkspace_info::set_has_block_id() {
+  _has_bits_[0] |= 0x00000400u;
+}
+inline void Parkspace_info::clear_has_block_id() {
+  _has_bits_[0] &= ~0x00000400u;
+}
+inline void Parkspace_info::clear_block_id() {
+  block_id_ = 0;
+  clear_has_block_id();
+}
+inline ::google::protobuf::int32 Parkspace_info::block_id() const {
+  // @@protoc_insertion_point(field_get:message.Parkspace_info.block_id)
+  return block_id_;
+}
+inline void Parkspace_info::set_block_id(::google::protobuf::int32 value) {
+  set_has_block_id();
+  block_id_ = value;
+  // @@protoc_insertion_point(field_set:message.Parkspace_info.block_id)
+}
+
 #ifdef __GNUC__
   #pragma GCC diagnostic pop
 #endif  // __GNUC__

+ 1 - 0
message/message_base.proto

@@ -166,4 +166,5 @@ message Parkspace_info
     optional Car_info           car_info=9;              //当前车位存入车辆的凭证号
     optional string             entry_time=10;          //入场时间
     optional string             leave_time=11;          //离场时间
+    optional int32              block_id=12;            //区块编号
 }

+ 3 - 0
message/parkspace_allocation_message.proto

@@ -8,6 +8,7 @@ import "message_base.proto";
 // 3.解锁车位
 // 4.手动操作修改车位状态
 // 5.临时锁定车位
+// 6.计算费用
 
 //车辆状态枚举
 enum Vehicle_status
@@ -105,6 +106,8 @@ message Parkspace_confirm_alloc_response_msg
     required Parkspace_info             confirm_alloc_space_info=4;    //已修改后的车位信息
 }
 
+// 6.计算费用
+
 // 车位心跳状态信息
 message Parkspace_allocation_status_msg
 {

+ 2 - 1
parkspace_allocation/parkspace_allocation_communicator.cpp

@@ -117,6 +117,7 @@ Error_manager Parkspace_allocation_communicator::check_msg(Communication_message
                 return Error_code::INVALID_MESSAGE;
         }
     }
+    return ERROR;
 }
 
 Error_manager Parkspace_allocation_communicator::check_executer(Communication_message*  p_msg)
@@ -169,4 +170,4 @@ Error_manager Parkspace_allocation_communicator::encapsulate_send_data()
 							 " Parkspace_allocation_communicator::send status error ");
 	}
 	return Error_code::SUCCESS;
-}
+}

+ 31 - 16
parkspace_allocation/parkspace_allocator.cpp

@@ -2,7 +2,7 @@
  * @Description: 车位分配算法模块,使用单例模式,接收外部请求并通过调用通信块接口发送反馈
  * @Author: yct
  * @Date: 2020-07-10 11:02:40
- * @LastEditTime: 2020-08-06 10:32:28
+ * @LastEditTime: 2020-09-11 12:23:48
  * @LastEditors: yct
  */ 
 
@@ -19,7 +19,7 @@ Parkspace_allocator::~Parkspace_allocator()
 }
 
 //初始化
-Error_manager Parkspace_allocator::parkspace_allocator_init(int threads_size, parkspace_proto::database_config db_config)
+Error_manager Parkspace_allocator::parkspace_allocator_init(int threads_size, parkspace_proto::garage_config config)
 {
     // 初始化db连接
     mp_db_manager = Parkspace_db_manager::get_instance_pointer();
@@ -27,7 +27,8 @@ Error_manager Parkspace_allocator::parkspace_allocator_init(int threads_size, pa
     {
         return POINTER_IS_NULL;
     }
-    Error_manager ec = mp_db_manager->Parkspace_db_manager_init(db_config);
+    m_config.CopyFrom(config);
+    Error_manager ec = mp_db_manager->Parkspace_db_manager_init(m_config.db_config());
     if(ec != SUCCESS)
     {
         return ec;
@@ -194,6 +195,31 @@ bool Parkspace_allocator::check_car_existence(std::string license, message::Park
     return false;
 }
 
+// 分配车位函数
+// input: 当前完整车位状态信息, 终端id(从0开始),
+// output: 分配的车位下标
+// 注: 区块号范围1-3
+int Parkspace_allocator::allocate_parkspace(message::Parkspace_allocation_status_msg parkspace_status, message::Car_info car_info, int terminal_id)
+{
+    for (size_t i = 0; i < parkspace_status.parkspace_info_size(); i++)
+    {
+        // 条件包括:
+        // 1.车位区块号合法,并且与终端id属于相同区块
+        // 2.宽高超过车辆尺寸
+        // 3.空闲车位
+        if (parkspace_status.parkspace_info(i).has_block_id()
+            && parkspace_status.parkspace_info(i).block_id() <= m_config.block_size()
+            && parkspace_status.parkspace_info(i).block_id() == (terminal_id / m_config.terminal_size_in_block() + 1 )
+            /* && t_current_parkspace_status.parkspace_info(i).height() > car_info.car_height() 
+            && t_current_parkspace_status.parkspace_info(i).width() > car_info.car_width() */
+            && parkspace_status.parkspace_info(i).parkspace_status() == message::Parkspace_status::eParkspace_empty)
+        {
+            return i;
+        }
+    }
+    return -1;
+}
+
 //分配车位线程函数
 void Parkspace_allocator::execute_for_allocate(message::Car_info car_info, int terminal_id, message::Command_info command_info)
 {
@@ -225,19 +251,8 @@ void Parkspace_allocator::execute_for_allocate(message::Car_info car_info, int t
     }
     else
     {   
-        for (size_t i = 0; i < t_current_parkspace_status.parkspace_info_size(); i++)
-        {
-            // 找到高于车高且空闲车位,则分配
-            if (t_current_parkspace_status.parkspace_info(i).has_car_info() 
-            /* && t_current_parkspace_status.parkspace_info(i).height() > car_info.car_height() 
-            && t_current_parkspace_status.parkspace_info(i).width() > car_info.car_width() */
-            && t_current_parkspace_status.parkspace_info(i).parkspace_status() == message::Parkspace_status::eParkspace_empty)
-            {
-                index = i;
-                break;
-            }
-        }
-        
+        index = allocate_parkspace(t_current_parkspace_status, car_info, terminal_id);
+
         if(index<0){
             t_error.set_error_code(PARKSPACE_ALLOCATOR_ALLOCATE_FAILED);
             t_error.set_error_level(message::Error_level::MAJOR_ERROR);

+ 11 - 5
parkspace_allocation/parkspace_allocator.h

@@ -2,7 +2,7 @@
  * @Description: 车位分配算法模块,使用单例模式,接收外部请求并通过调用通信块接口发送反馈
  * @Author: yct
  * @Date: 2020-07-10 09:25:56
- * @LastEditTime: 2020-08-06 10:18:56
+ * @LastEditTime: 2020-09-11 11:44:47
  * @LastEditors: yct
  */ 
 
@@ -38,7 +38,7 @@ public:
     ~Parkspace_allocator();
 public://API functions
 	//初始化
-	Error_manager parkspace_allocator_init(int threads_size, parkspace_proto::database_config db_config);
+	Error_manager parkspace_allocator_init(int threads_size, parkspace_proto::garage_config config);
 	//反初始化
 	Error_manager parkspace_allocator_uninit();
 
@@ -56,7 +56,7 @@ public://API functions
     // 检查车辆是否已存在,通常分配前调用
     bool check_car_existence(std::string license, message::Parkspace_allocation_status_msg status_msg);
 
-public://execute_msg创建各线程进行处理
+private://execute_msg创建各线程进行处理
 	//分配车位线程函数
     void execute_for_allocate(message::Car_info car_info, int terminal_id, message::Command_info command_info);
     //查询车位线程函数
@@ -68,9 +68,15 @@ public://execute_msg创建各线程进行处理
     //确认分配车位线程函数
     void execute_for_confirm_alloc(message::Parkspace_info space_info, message::Command_info command_info);
 
+    // 分配车位函数
+    // input: 当前完整车位状态信息, 终端id, 
+    // output: 分配的车位下标
+    int allocate_parkspace(message::Parkspace_allocation_status_msg parkspace_status, message::Car_info car_info, int terminal_id);
+
 private:
-    parkspace_allocator_status  m_current_status;               //分配器当前状态
-	Thread_pool 				m_thread_pool;					//执行多任务的线程池
+    parkspace_proto::garage_config m_config;                    //车位配置文件
+    parkspace_allocator_status m_current_status;                //分配器当前状态
+    Thread_pool 				m_thread_pool;					//执行多任务的线程池
     std::mutex                  m_mutex;                        //车位变动锁
     Parkspace_db_manager*       mp_db_manager;                  //车位模块数据库管理句柄
 

+ 2 - 1
parkspace_allocation/parkspace_db_manager.cpp

@@ -2,7 +2,7 @@
  * @Description: 车位数据库管理
  * @Author: yct
  * @Date: 2020-07-19 09:57:45
- * @LastEditTime: 2020-07-22 19:07:45
+ * @LastEditTime: 2020-09-11 11:41:09
  * @LastEditors: yct
  */
 
@@ -117,6 +117,7 @@ Error_manager Parkspace_db_manager::get_all_parkspace_info(message::Parkspace_al
                         t_parkspace->set_parkspace_status(message::Parkspace_status::eParkspace_error);
                         break;
                     }
+                    t_parkspace->set_block_id(tp_result->getInt("parkingSpaceBlockID"));
                     t_parkspace->set_width(tp_result->getDouble("parkSpaceWidth"));
                     t_parkspace->set_height(tp_result->getDouble("parkSpaceHeight"));
                     t_parkspace->mutable_car_info()->set_license(tp_result->getString("parkSpaceCarLicense"));

+ 417 - 4
parkspace_allocation/parkspace_parameter.pb.cc

@@ -25,6 +25,11 @@ class database_configDefaultTypeInternal {
   ::google::protobuf::internal::ExplicitlyConstructed<database_config>
       _instance;
 } _database_config_default_instance_;
+class garage_configDefaultTypeInternal {
+ public:
+  ::google::protobuf::internal::ExplicitlyConstructed<garage_config>
+      _instance;
+} _garage_config_default_instance_;
 }  // namespace parkspace_proto
 namespace protobuf_parkspace_5fparameter_2eproto {
 void InitDefaultsdatabase_configImpl() {
@@ -48,7 +53,29 @@ void InitDefaultsdatabase_config() {
   ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsdatabase_configImpl);
 }
 
-::google::protobuf::Metadata file_level_metadata[1];
+void InitDefaultsgarage_configImpl() {
+  GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
+  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
+#else
+  ::google::protobuf::internal::InitProtobufDefaults();
+#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
+  protobuf_parkspace_5fparameter_2eproto::InitDefaultsdatabase_config();
+  {
+    void* ptr = &::parkspace_proto::_garage_config_default_instance_;
+    new (ptr) ::parkspace_proto::garage_config();
+    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
+  }
+  ::parkspace_proto::garage_config::InitAsDefaultInstance();
+}
+
+void InitDefaultsgarage_config() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsgarage_configImpl);
+}
+
+::google::protobuf::Metadata file_level_metadata[2];
 
 const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, _has_bits_),
@@ -68,13 +95,26 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   2,
   3,
   5,
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::garage_config, _has_bits_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::garage_config, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  ~0u,  // no _weak_field_map_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::garage_config, block_size_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::garage_config, terminal_size_in_block_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::garage_config, db_config_),
+  1,
+  2,
+  0,
 };
 static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
   { 0, 11, sizeof(::parkspace_proto::database_config)},
+  { 17, 25, sizeof(::parkspace_proto::garage_config)},
 };
 
 static ::google::protobuf::Message const * const file_default_instances[] = {
   reinterpret_cast<const ::google::protobuf::Message*>(&::parkspace_proto::_database_config_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&::parkspace_proto::_garage_config_default_instance_),
 };
 
 void protobuf_AssignDescriptors() {
@@ -93,7 +133,7 @@ void protobuf_AssignDescriptorsOnce() {
 void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
 void protobuf_RegisterTypes(const ::std::string&) {
   protobuf_AssignDescriptorsOnce();
-  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
+  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 2);
 }
 
 void AddDescriptorsImpl() {
@@ -103,10 +143,13 @@ void AddDescriptorsImpl() {
       "roto\"\207\001\n\017database_config\022\r\n\005db_ip\030\001 \002(\t\022"
       "\017\n\007db_port\030\002 \002(\003\022\023\n\013db_username\030\003 \002(\t\022\023\n"
       "\tdb_passwd\030\004 \001(\t:\000\022\017\n\007db_name\030\005 \002(\t\022\031\n\021d"
-      "b_conn_pool_size\030\006 \001(\003"
+      "b_conn_pool_size\030\006 \001(\003\"x\n\rgarage_config\022"
+      "\022\n\nblock_size\030\001 \002(\003\022\036\n\026terminal_size_in_"
+      "block\030\002 \002(\003\0223\n\tdb_config\030\003 \002(\0132 .parkspa"
+      "ce_proto.database_config"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 182);
+      descriptor, 304);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "parkspace_parameter.proto", &protobuf_RegisterTypes);
 }
@@ -689,6 +732,376 @@ void database_config::InternalSwap(database_config* other) {
 }
 
 
+// ===================================================================
+
+void garage_config::InitAsDefaultInstance() {
+  ::parkspace_proto::_garage_config_default_instance_._instance.get_mutable()->db_config_ = const_cast< ::parkspace_proto::database_config*>(
+      ::parkspace_proto::database_config::internal_default_instance());
+}
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int garage_config::kBlockSizeFieldNumber;
+const int garage_config::kTerminalSizeInBlockFieldNumber;
+const int garage_config::kDbConfigFieldNumber;
+#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+garage_config::garage_config()
+  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+    ::protobuf_parkspace_5fparameter_2eproto::InitDefaultsgarage_config();
+  }
+  SharedCtor();
+  // @@protoc_insertion_point(constructor:parkspace_proto.garage_config)
+}
+garage_config::garage_config(const garage_config& from)
+  : ::google::protobuf::Message(),
+      _internal_metadata_(NULL),
+      _has_bits_(from._has_bits_),
+      _cached_size_(0) {
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  if (from.has_db_config()) {
+    db_config_ = new ::parkspace_proto::database_config(*from.db_config_);
+  } else {
+    db_config_ = NULL;
+  }
+  ::memcpy(&block_size_, &from.block_size_,
+    static_cast<size_t>(reinterpret_cast<char*>(&terminal_size_in_block_) -
+    reinterpret_cast<char*>(&block_size_)) + sizeof(terminal_size_in_block_));
+  // @@protoc_insertion_point(copy_constructor:parkspace_proto.garage_config)
+}
+
+void garage_config::SharedCtor() {
+  _cached_size_ = 0;
+  ::memset(&db_config_, 0, static_cast<size_t>(
+      reinterpret_cast<char*>(&terminal_size_in_block_) -
+      reinterpret_cast<char*>(&db_config_)) + sizeof(terminal_size_in_block_));
+}
+
+garage_config::~garage_config() {
+  // @@protoc_insertion_point(destructor:parkspace_proto.garage_config)
+  SharedDtor();
+}
+
+void garage_config::SharedDtor() {
+  if (this != internal_default_instance()) delete db_config_;
+}
+
+void garage_config::SetCachedSize(int size) const {
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* garage_config::descriptor() {
+  ::protobuf_parkspace_5fparameter_2eproto::protobuf_AssignDescriptorsOnce();
+  return ::protobuf_parkspace_5fparameter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
+}
+
+const garage_config& garage_config::default_instance() {
+  ::protobuf_parkspace_5fparameter_2eproto::InitDefaultsgarage_config();
+  return *internal_default_instance();
+}
+
+garage_config* garage_config::New(::google::protobuf::Arena* arena) const {
+  garage_config* n = new garage_config;
+  if (arena != NULL) {
+    arena->Own(n);
+  }
+  return n;
+}
+
+void garage_config::Clear() {
+// @@protoc_insertion_point(message_clear_start:parkspace_proto.garage_config)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  // Prevent compiler warnings about cached_has_bits being unused
+  (void) cached_has_bits;
+
+  cached_has_bits = _has_bits_[0];
+  if (cached_has_bits & 0x00000001u) {
+    GOOGLE_DCHECK(db_config_ != NULL);
+    db_config_->Clear();
+  }
+  if (cached_has_bits & 6u) {
+    ::memset(&block_size_, 0, static_cast<size_t>(
+        reinterpret_cast<char*>(&terminal_size_in_block_) -
+        reinterpret_cast<char*>(&block_size_)) + sizeof(terminal_size_in_block_));
+  }
+  _has_bits_.Clear();
+  _internal_metadata_.Clear();
+}
+
+bool garage_config::MergePartialFromCodedStream(
+    ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+  ::google::protobuf::uint32 tag;
+  // @@protoc_insertion_point(parse_start:parkspace_proto.garage_config)
+  for (;;) {
+    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+    tag = p.first;
+    if (!p.second) goto handle_unusual;
+    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+      // required int64 block_size = 1;
+      case 1: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
+          set_has_block_size();
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
+                 input, &block_size_)));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // required int64 terminal_size_in_block = 2;
+      case 2: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
+          set_has_terminal_size_in_block();
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
+                 input, &terminal_size_in_block_)));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // required .parkspace_proto.database_config db_config = 3;
+      case 3: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+               input, mutable_db_config()));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      default: {
+      handle_unusual:
+        if (tag == 0) {
+          goto success;
+        }
+        DO_(::google::protobuf::internal::WireFormat::SkipField(
+              input, tag, _internal_metadata_.mutable_unknown_fields()));
+        break;
+      }
+    }
+  }
+success:
+  // @@protoc_insertion_point(parse_success:parkspace_proto.garage_config)
+  return true;
+failure:
+  // @@protoc_insertion_point(parse_failure:parkspace_proto.garage_config)
+  return false;
+#undef DO_
+}
+
+void garage_config::SerializeWithCachedSizes(
+    ::google::protobuf::io::CodedOutputStream* output) const {
+  // @@protoc_insertion_point(serialize_start:parkspace_proto.garage_config)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  cached_has_bits = _has_bits_[0];
+  // required int64 block_size = 1;
+  if (cached_has_bits & 0x00000002u) {
+    ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->block_size(), output);
+  }
+
+  // required int64 terminal_size_in_block = 2;
+  if (cached_has_bits & 0x00000004u) {
+    ::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->terminal_size_in_block(), output);
+  }
+
+  // required .parkspace_proto.database_config db_config = 3;
+  if (cached_has_bits & 0x00000001u) {
+    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+      3, *this->db_config_, output);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+        _internal_metadata_.unknown_fields(), output);
+  }
+  // @@protoc_insertion_point(serialize_end:parkspace_proto.garage_config)
+}
+
+::google::protobuf::uint8* garage_config::InternalSerializeWithCachedSizesToArray(
+    bool deterministic, ::google::protobuf::uint8* target) const {
+  (void)deterministic; // Unused
+  // @@protoc_insertion_point(serialize_to_array_start:parkspace_proto.garage_config)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  cached_has_bits = _has_bits_[0];
+  // required int64 block_size = 1;
+  if (cached_has_bits & 0x00000002u) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->block_size(), target);
+  }
+
+  // required int64 terminal_size_in_block = 2;
+  if (cached_has_bits & 0x00000004u) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(2, this->terminal_size_in_block(), target);
+  }
+
+  // required .parkspace_proto.database_config db_config = 3;
+  if (cached_has_bits & 0x00000001u) {
+    target = ::google::protobuf::internal::WireFormatLite::
+      InternalWriteMessageToArray(
+        3, *this->db_config_, deterministic, target);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+        _internal_metadata_.unknown_fields(), target);
+  }
+  // @@protoc_insertion_point(serialize_to_array_end:parkspace_proto.garage_config)
+  return target;
+}
+
+size_t garage_config::RequiredFieldsByteSizeFallback() const {
+// @@protoc_insertion_point(required_fields_byte_size_fallback_start:parkspace_proto.garage_config)
+  size_t total_size = 0;
+
+  if (has_db_config()) {
+    // required .parkspace_proto.database_config db_config = 3;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::MessageSize(
+        *this->db_config_);
+  }
+
+  if (has_block_size()) {
+    // required int64 block_size = 1;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int64Size(
+        this->block_size());
+  }
+
+  if (has_terminal_size_in_block()) {
+    // required int64 terminal_size_in_block = 2;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int64Size(
+        this->terminal_size_in_block());
+  }
+
+  return total_size;
+}
+size_t garage_config::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:parkspace_proto.garage_config)
+  size_t total_size = 0;
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    total_size +=
+      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+        _internal_metadata_.unknown_fields());
+  }
+  if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) {  // All required fields are present.
+    // required .parkspace_proto.database_config db_config = 3;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::MessageSize(
+        *this->db_config_);
+
+    // required int64 block_size = 1;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int64Size(
+        this->block_size());
+
+    // required int64 terminal_size_in_block = 2;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int64Size(
+        this->terminal_size_in_block());
+
+  } else {
+    total_size += RequiredFieldsByteSizeFallback();
+  }
+  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = cached_size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+  return total_size;
+}
+
+void garage_config::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:parkspace_proto.garage_config)
+  GOOGLE_DCHECK_NE(&from, this);
+  const garage_config* source =
+      ::google::protobuf::internal::DynamicCastToGenerated<const garage_config>(
+          &from);
+  if (source == NULL) {
+  // @@protoc_insertion_point(generalized_merge_from_cast_fail:parkspace_proto.garage_config)
+    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+  } else {
+  // @@protoc_insertion_point(generalized_merge_from_cast_success:parkspace_proto.garage_config)
+    MergeFrom(*source);
+  }
+}
+
+void garage_config::MergeFrom(const garage_config& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:parkspace_proto.garage_config)
+  GOOGLE_DCHECK_NE(&from, this);
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  cached_has_bits = from._has_bits_[0];
+  if (cached_has_bits & 7u) {
+    if (cached_has_bits & 0x00000001u) {
+      mutable_db_config()->::parkspace_proto::database_config::MergeFrom(from.db_config());
+    }
+    if (cached_has_bits & 0x00000002u) {
+      block_size_ = from.block_size_;
+    }
+    if (cached_has_bits & 0x00000004u) {
+      terminal_size_in_block_ = from.terminal_size_in_block_;
+    }
+    _has_bits_[0] |= cached_has_bits;
+  }
+}
+
+void garage_config::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:parkspace_proto.garage_config)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+void garage_config::CopyFrom(const garage_config& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:parkspace_proto.garage_config)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+bool garage_config::IsInitialized() const {
+  if ((_has_bits_[0] & 0x00000007) != 0x00000007) return false;
+  if (has_db_config()) {
+    if (!this->db_config_->IsInitialized()) return false;
+  }
+  return true;
+}
+
+void garage_config::Swap(garage_config* other) {
+  if (other == this) return;
+  InternalSwap(other);
+}
+void garage_config::InternalSwap(garage_config* other) {
+  using std::swap;
+  swap(db_config_, other->db_config_);
+  swap(block_size_, other->block_size_);
+  swap(terminal_size_in_block_, other->terminal_size_in_block_);
+  swap(_has_bits_[0], other->_has_bits_[0]);
+  _internal_metadata_.Swap(&other->_internal_metadata_);
+  swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata garage_config::GetMetadata() const {
+  protobuf_parkspace_5fparameter_2eproto::protobuf_AssignDescriptorsOnce();
+  return ::protobuf_parkspace_5fparameter_2eproto::file_level_metadata[kIndexInFileMessages];
+}
+
+
 // @@protoc_insertion_point(namespace_scope)
 }  // namespace parkspace_proto
 

+ 250 - 1
parkspace_allocation/parkspace_parameter.pb.h

@@ -36,7 +36,7 @@ namespace protobuf_parkspace_5fparameter_2eproto {
 struct TableStruct {
   static const ::google::protobuf::internal::ParseTableField entries[];
   static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
-  static const ::google::protobuf::internal::ParseTable schema[1];
+  static const ::google::protobuf::internal::ParseTable schema[2];
   static const ::google::protobuf::internal::FieldMetadata field_metadata[];
   static const ::google::protobuf::internal::SerializationTable serialization_table[];
   static const ::google::protobuf::uint32 offsets[];
@@ -44,14 +44,20 @@ struct TableStruct {
 void AddDescriptors();
 void InitDefaultsdatabase_configImpl();
 void InitDefaultsdatabase_config();
+void InitDefaultsgarage_configImpl();
+void InitDefaultsgarage_config();
 inline void InitDefaults() {
   InitDefaultsdatabase_config();
+  InitDefaultsgarage_config();
 }
 }  // namespace protobuf_parkspace_5fparameter_2eproto
 namespace parkspace_proto {
 class database_config;
 class database_configDefaultTypeInternal;
 extern database_configDefaultTypeInternal _database_config_default_instance_;
+class garage_config;
+class garage_configDefaultTypeInternal;
+extern garage_configDefaultTypeInternal _garage_config_default_instance_;
 }  // namespace parkspace_proto
 namespace parkspace_proto {
 
@@ -250,6 +256,141 @@ class database_config : public ::google::protobuf::Message /* @@protoc_insertion
   friend struct ::protobuf_parkspace_5fparameter_2eproto::TableStruct;
   friend void ::protobuf_parkspace_5fparameter_2eproto::InitDefaultsdatabase_configImpl();
 };
+// -------------------------------------------------------------------
+
+class garage_config : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:parkspace_proto.garage_config) */ {
+ public:
+  garage_config();
+  virtual ~garage_config();
+
+  garage_config(const garage_config& from);
+
+  inline garage_config& operator=(const garage_config& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  #if LANG_CXX11
+  garage_config(garage_config&& from) noexcept
+    : garage_config() {
+    *this = ::std::move(from);
+  }
+
+  inline garage_config& operator=(garage_config&& from) noexcept {
+    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
+      if (this != &from) InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+  #endif
+  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+    return _internal_metadata_.unknown_fields();
+  }
+  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+    return _internal_metadata_.mutable_unknown_fields();
+  }
+
+  static const ::google::protobuf::Descriptor* descriptor();
+  static const garage_config& default_instance();
+
+  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
+  static inline const garage_config* internal_default_instance() {
+    return reinterpret_cast<const garage_config*>(
+               &_garage_config_default_instance_);
+  }
+  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+    1;
+
+  void Swap(garage_config* other);
+  friend void swap(garage_config& a, garage_config& b) {
+    a.Swap(&b);
+  }
+
+  // implements Message ----------------------------------------------
+
+  inline garage_config* New() const PROTOBUF_FINAL { return New(NULL); }
+
+  garage_config* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void CopyFrom(const garage_config& from);
+  void MergeFrom(const garage_config& from);
+  void Clear() PROTOBUF_FINAL;
+  bool IsInitialized() const PROTOBUF_FINAL;
+
+  size_t ByteSizeLong() const PROTOBUF_FINAL;
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const PROTOBUF_FINAL;
+  void InternalSwap(garage_config* other);
+  private:
+  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+    return NULL;
+  }
+  inline void* MaybeArenaPtr() const {
+    return NULL;
+  }
+  public:
+
+  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  // required .parkspace_proto.database_config db_config = 3;
+  bool has_db_config() const;
+  void clear_db_config();
+  static const int kDbConfigFieldNumber = 3;
+  const ::parkspace_proto::database_config& db_config() const;
+  ::parkspace_proto::database_config* release_db_config();
+  ::parkspace_proto::database_config* mutable_db_config();
+  void set_allocated_db_config(::parkspace_proto::database_config* db_config);
+
+  // required int64 block_size = 1;
+  bool has_block_size() const;
+  void clear_block_size();
+  static const int kBlockSizeFieldNumber = 1;
+  ::google::protobuf::int64 block_size() const;
+  void set_block_size(::google::protobuf::int64 value);
+
+  // required int64 terminal_size_in_block = 2;
+  bool has_terminal_size_in_block() const;
+  void clear_terminal_size_in_block();
+  static const int kTerminalSizeInBlockFieldNumber = 2;
+  ::google::protobuf::int64 terminal_size_in_block() const;
+  void set_terminal_size_in_block(::google::protobuf::int64 value);
+
+  // @@protoc_insertion_point(class_scope:parkspace_proto.garage_config)
+ private:
+  void set_has_block_size();
+  void clear_has_block_size();
+  void set_has_terminal_size_in_block();
+  void clear_has_terminal_size_in_block();
+  void set_has_db_config();
+  void clear_has_db_config();
+
+  // helper for ByteSizeLong()
+  size_t RequiredFieldsByteSizeFallback() const;
+
+  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+  ::google::protobuf::internal::HasBits<1> _has_bits_;
+  mutable int _cached_size_;
+  ::parkspace_proto::database_config* db_config_;
+  ::google::protobuf::int64 block_size_;
+  ::google::protobuf::int64 terminal_size_in_block_;
+  friend struct ::protobuf_parkspace_5fparameter_2eproto::TableStruct;
+  friend void ::protobuf_parkspace_5fparameter_2eproto::InitDefaultsgarage_configImpl();
+};
 // ===================================================================
 
 
@@ -561,9 +702,117 @@ inline void database_config::set_db_conn_pool_size(::google::protobuf::int64 val
   // @@protoc_insertion_point(field_set:parkspace_proto.database_config.db_conn_pool_size)
 }
 
+// -------------------------------------------------------------------
+
+// garage_config
+
+// required int64 block_size = 1;
+inline bool garage_config::has_block_size() const {
+  return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void garage_config::set_has_block_size() {
+  _has_bits_[0] |= 0x00000002u;
+}
+inline void garage_config::clear_has_block_size() {
+  _has_bits_[0] &= ~0x00000002u;
+}
+inline void garage_config::clear_block_size() {
+  block_size_ = GOOGLE_LONGLONG(0);
+  clear_has_block_size();
+}
+inline ::google::protobuf::int64 garage_config::block_size() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.garage_config.block_size)
+  return block_size_;
+}
+inline void garage_config::set_block_size(::google::protobuf::int64 value) {
+  set_has_block_size();
+  block_size_ = value;
+  // @@protoc_insertion_point(field_set:parkspace_proto.garage_config.block_size)
+}
+
+// required int64 terminal_size_in_block = 2;
+inline bool garage_config::has_terminal_size_in_block() const {
+  return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void garage_config::set_has_terminal_size_in_block() {
+  _has_bits_[0] |= 0x00000004u;
+}
+inline void garage_config::clear_has_terminal_size_in_block() {
+  _has_bits_[0] &= ~0x00000004u;
+}
+inline void garage_config::clear_terminal_size_in_block() {
+  terminal_size_in_block_ = GOOGLE_LONGLONG(0);
+  clear_has_terminal_size_in_block();
+}
+inline ::google::protobuf::int64 garage_config::terminal_size_in_block() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.garage_config.terminal_size_in_block)
+  return terminal_size_in_block_;
+}
+inline void garage_config::set_terminal_size_in_block(::google::protobuf::int64 value) {
+  set_has_terminal_size_in_block();
+  terminal_size_in_block_ = value;
+  // @@protoc_insertion_point(field_set:parkspace_proto.garage_config.terminal_size_in_block)
+}
+
+// required .parkspace_proto.database_config db_config = 3;
+inline bool garage_config::has_db_config() const {
+  return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void garage_config::set_has_db_config() {
+  _has_bits_[0] |= 0x00000001u;
+}
+inline void garage_config::clear_has_db_config() {
+  _has_bits_[0] &= ~0x00000001u;
+}
+inline void garage_config::clear_db_config() {
+  if (db_config_ != NULL) db_config_->Clear();
+  clear_has_db_config();
+}
+inline const ::parkspace_proto::database_config& garage_config::db_config() const {
+  const ::parkspace_proto::database_config* p = db_config_;
+  // @@protoc_insertion_point(field_get:parkspace_proto.garage_config.db_config)
+  return p != NULL ? *p : *reinterpret_cast<const ::parkspace_proto::database_config*>(
+      &::parkspace_proto::_database_config_default_instance_);
+}
+inline ::parkspace_proto::database_config* garage_config::release_db_config() {
+  // @@protoc_insertion_point(field_release:parkspace_proto.garage_config.db_config)
+  clear_has_db_config();
+  ::parkspace_proto::database_config* temp = db_config_;
+  db_config_ = NULL;
+  return temp;
+}
+inline ::parkspace_proto::database_config* garage_config::mutable_db_config() {
+  set_has_db_config();
+  if (db_config_ == NULL) {
+    db_config_ = new ::parkspace_proto::database_config;
+  }
+  // @@protoc_insertion_point(field_mutable:parkspace_proto.garage_config.db_config)
+  return db_config_;
+}
+inline void garage_config::set_allocated_db_config(::parkspace_proto::database_config* db_config) {
+  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
+  if (message_arena == NULL) {
+    delete db_config_;
+  }
+  if (db_config) {
+    ::google::protobuf::Arena* submessage_arena = NULL;
+    if (message_arena != submessage_arena) {
+      db_config = ::google::protobuf::internal::GetOwnedMessage(
+          message_arena, db_config, submessage_arena);
+    }
+    set_has_db_config();
+  } else {
+    clear_has_db_config();
+  }
+  db_config_ = db_config;
+  // @@protoc_insertion_point(field_set_allocated:parkspace_proto.garage_config.db_config)
+}
+
 #ifdef __GNUC__
   #pragma GCC diagnostic pop
 #endif  // __GNUC__
+// -------------------------------------------------------------------
+
 
 // @@protoc_insertion_point(namespace_scope)
 

+ 7 - 0
parkspace_allocation/parkspace_parameter.proto

@@ -10,3 +10,10 @@ message database_config
     required string db_name=5;
     optional int64 db_conn_pool_size=6;
 }
+
+message garage_config
+{
+    required int64 block_size=1;//每层独立区域块个数
+    required int64 terminal_size_in_block=2;//每个区域块包含终端数
+    required database_config db_config=3;
+}

+ 12 - 0
setting/parkspace_config.prototxt

@@ -0,0 +1,12 @@
+
+block_size:3,
+terminal_size_in_block:2,
+db_config
+{
+    db_ip:"127.0.0.1",
+    db_port:3306,
+    db_username:"yct",
+    db_passwd:"123456",
+    db_name:"test",
+    db_conn_pool_size:5
+}

+ 49 - 31
test/parkspace_client.cpp

@@ -2,7 +2,7 @@
  * @Description: 模拟主程序发送车位分配请求,并监听状态信息
  * @Author: yct
  * @Date: 2020-07-08 15:44:43
- * @LastEditTime: 2020-07-22 18:15:55
+ * @LastEditTime: 2020-09-11 14:25:50
  * @LastEditors: yct
  */
 
@@ -29,11 +29,15 @@ std::string send_allocation_request(int n)
     base_info.set_timeout_ms(2000);
     car_info.set_car_height(1.0);
     car_info.set_car_width(1.0);
-    car_info.set_license("鄂A12345");
+    car_info.set_license((std::string("鄂A1234")+std::to_string(n)).c_str());
 
     request.mutable_base_info()->CopyFrom(base_info);
-    request.set_command_id(n);
-    request.set_terminal_id(1);
+    message::Command_info cmd_info;
+    cmd_info.set_time("12345");
+    cmd_info.set_location("aaaaaa");
+    cmd_info.set_event(message::Event::ePicking);
+    request.mutable_command_info()->CopyFrom(cmd_info);
+    request.set_terminal_id(n);
     request.mutable_car_info()->CopyFrom(car_info);
 
     // socket.send(request.SerializeAsString());
@@ -57,7 +61,11 @@ std::string send_search_requests(int n, std::string license="鄂A12345")
     car_info.set_license(license);
 
     request.mutable_base_info()->CopyFrom(base_info);
-    request.set_command_id(n);
+    message::Command_info cmd_info;
+    cmd_info.set_time("12345");
+    cmd_info.set_location("aaaaaa");
+    cmd_info.set_event(message::Event::ePicking);
+    request.mutable_command_info()->CopyFrom(cmd_info);
     request.mutable_car_info()->CopyFrom(car_info);
 
     // socket.send(request.SerializeAsString());
@@ -90,7 +98,11 @@ std::string send_release_request(int n)
     space_info.mutable_car_info()->CopyFrom(car_info);
 
     request.mutable_base_info()->CopyFrom(base_info);
-    request.set_command_id(n);
+    message::Command_info cmd_info;
+    cmd_info.set_time("12345");
+    cmd_info.set_location("aaaaaa");
+    cmd_info.set_event(message::Event::ePicking);
+    request.mutable_command_info()->CopyFrom(cmd_info);
     request.mutable_release_space_info()->CopyFrom(space_info);
 
     // socket.send(request.SerializeAsString());
@@ -123,7 +135,11 @@ std::string send_confirm_request(int n)
     space_info.mutable_car_info()->CopyFrom(car_info);
 
     request.mutable_base_info()->CopyFrom(base_info);
-    request.set_command_id(n);
+    message::Command_info cmd_info;
+    cmd_info.set_time("12345");
+    cmd_info.set_location("aaaaaa");
+    cmd_info.set_event(message::Event::ePicking);
+    request.mutable_command_info()->CopyFrom(cmd_info);
     request.mutable_confirm_space_info()->CopyFrom(space_info);
 
     // socket.send(request.SerializeAsString());
@@ -140,29 +156,31 @@ int main()
 
     usleep(1000 * 3000);
 
-    std::string alloc_req = send_allocation_request(1);
+    std::string alloc_req = send_allocation_request(0);
+    socket.send(alloc_req);
+    // usleep(1000 * 500);
+    alloc_req = send_allocation_request(1);
+    socket.send(alloc_req);
+    alloc_req = send_allocation_request(2);
+    socket.send(alloc_req);
+    alloc_req = send_allocation_request(3);
+    socket.send(alloc_req);
+    alloc_req = send_allocation_request(4);
     socket.send(alloc_req);
-    usleep(1000 * 500);
-    // alloc_req = send_allocation_request(2);
-    // socket.send(alloc_req);
-    // alloc_req = send_allocation_request(3);
-    // socket.send(alloc_req);
-    // alloc_req = send_allocation_request(4);
-    // socket.send(alloc_req);
-    // alloc_req = send_allocation_request(5);
-    // socket.send(alloc_req);
-
-    std::string confirm_req = send_confirm_request(1);
-    socket.send(confirm_req);
-    usleep(1000 * 500);
+    alloc_req = send_allocation_request(5);
+    socket.send(alloc_req);
+
+    // std::string confirm_req = send_confirm_request(1);
+    // socket.send(confirm_req);
+    // usleep(1000 * 500);
     
-    std::string search_req = send_search_requests(1);
-    socket.send(search_req);
-    usleep(1000 * 500);
+    // std::string search_req = send_search_requests(1);
+    // socket.send(search_req);
+    // usleep(1000 * 500);
 
-    std::string release_req = send_release_request(1);
-    socket.send(release_req);
-    usleep(1000 * 500);
+    // std::string release_req = send_release_request(1);
+    // socket.send(release_req);
+    // usleep(1000 * 500);
 
     // usleep(1000*200);
     // search_req = send_search_requests(3);
@@ -197,10 +215,10 @@ int main()
                 std::cout << "cycle " << n << std::endl;
                 if (base_msg.base_info().msg_type() == message::Message_type::eParkspace_allocation_status_msg)
                 {
-                    message::Parkspace_allocation_status_msg parkspace_status;
-                    std::cout << "----------------- 车位状态 -----------------" << std::endl;
-                    parkspace_status.ParseFromString(t_receive_string);
-                    std::cout << parkspace_status.DebugString() << std::endl;
+                    // message::Parkspace_allocation_status_msg parkspace_status;
+                    // std::cout << "----------------- 车位状态 -----------------" << std::endl;
+                    // parkspace_status.ParseFromString(t_receive_string);
+                    // std::cout << parkspace_status.DebugString() << std::endl;
                     // continue;
                 }
                 else if (base_msg.base_info().msg_type() == message::Message_type::eParkspace_allocation_response_msg)

+ 16 - 10
test/test_parkspace_sample.cpp

@@ -2,31 +2,37 @@
  * @Description: 测试车位分配模块通信情况
  * @Author: yct
  * @Date: 2020-07-08 15:51:46
- * @LastEditTime: 2020-07-24 10:54:17
+ * @LastEditTime: 2020-09-18 11:21:22
  * @LastEditors: yct
  */ 
 #include "../parkspace_allocation/parkspace_allocation_communicator.h"
 #include "../parkspace_allocation/parkspace_allocator.h"
+#include "../tool/proto_tool.h"
 
 int main()
 {
     google::InitGoogleLogging("parkspace_allocator");
     google::SetStderrLogging(google::INFO);
     google::InstallFailureSignalHandler();
-    FLAGS_colorlogtostderr = true; 
+    FLAGS_colorlogtostderr = true;
+
+    parkspace_proto::garage_config config;
+    // // parkspace_proto::database_config config;
+    // config.mutable_db_config()->set_db_ip("127.0.0.1");
+    // config.mutable_db_config()->set_db_port(3306);
+    // config.mutable_db_config()->set_db_username("yct");
+    // config.mutable_db_config()->set_db_passwd("123456");
+    // config.mutable_db_config()->set_db_name("test");
+    // config.mutable_db_config()->set_db_conn_pool_size(5);
+    // config.set_block_size(3);
+    // config.set_terminal_size_in_block(2);
+    proto_tool::get_instance_references().read_proto_param("../setting/parkspace_config.prototxt", config);
 
     Parkspace_allocation_communicator *p_parkspace_allocation_communicater = Parkspace_allocation_communicator::get_instance_pointer();
     Parkspace_allocator *p_parkspace_allocator = Parkspace_allocator::get_instance_pointer();
 
-    parkspace_proto::database_config config;
-    config.set_db_ip("127.0.0.1");
-    config.set_db_port(3306);
-    config.set_db_username("yct");
-    config.set_db_passwd("123456");
-    config.set_db_name("test");
-    config.set_db_conn_pool_size(5);
     p_parkspace_allocator->parkspace_allocator_init(4, config);
-    p_parkspace_allocation_communicater->communication_bind("tcp://192.168.0.202:30001");
+    p_parkspace_allocation_communicater->communication_bind("tcp://127.0.0.1:7001");
     // p_parkspace_allocation_communicater->communication_bind("tcp://192.168.2.125:7001");
     // p_parkspace_allocation_communicater->communication_connect("tcp://127.0.0.1:7000");
     p_parkspace_allocation_communicater->communication_run();