Browse Source

debug init space height missed problem. add header info for force update and confirm alloc.

youchen 4 years ago
parent
commit
383e09c613

+ 13 - 1
parkspace_allocation/parkspace_allocator.cpp

@@ -2,7 +2,7 @@
  * @Description: 车位分配算法模块,使用单例模式,接收外部请求并通过调用通信块接口发送反馈
  * @Author: yct
  * @Date: 2020-07-10 11:02:40
- * @LastEditTime: 2020-07-22 15:33:48
+ * @LastEditTime: 2020-07-22 17:15:43
  * @LastEditors: yct
  */ 
 
@@ -292,6 +292,8 @@ void Parkspace_allocator::execute_for_search(message::Car_info car_info, int com
         if(index<0){
             t_error.set_error_code(PARKSPACE_ALLOCATOR_SEARCH_FAILED);
             t_error.set_error_level(message::Error_level::MAJOR_ERROR);
+            // 默认第一个车位
+            t_car_position.CopyFrom(t_current_parkspace_status.parkspace_info(0));
             LOG(INFO) << "查询车位失败";
         }else{
             t_error.set_error_code(SUCCESS);
@@ -357,6 +359,8 @@ void Parkspace_allocator::execute_for_release(message::Parkspace_info space_info
         if(index<0){
             t_error.set_error_code(PARKSPACE_ALLOCATOR_RELEASE_FAILED);
             t_error.set_error_level(message::Error_level::MAJOR_ERROR);
+            // 传入默认车位信息
+            t_release_space.CopyFrom(space_info);
             LOG(WARNING) << "释放车位失败";
         }else{
             t_error.set_error_code(SUCCESS);
@@ -426,6 +430,9 @@ void Parkspace_allocator::execute_for_force_update(message::Parkspace_info space
     //!!!!!此处跳过外部处理与调用的过程,直接在内部调用,发送分配结果用于测试,目前一直发布第一个车位
     message::Parkspace_force_update_response_msg response_msg;
     message::Base_info t_response_header;
+    t_response_header.set_msg_type(message::eParkspace_force_update_response_msg);
+    t_response_header.set_sender(message::eParkspace);
+    t_response_header.set_receiver(message::eMain);
     message::Error_manager t_error;
     message::Parkspace_info t_update_space;
     //获取当前所有车位状态,找到待释放的车位
@@ -451,6 +458,7 @@ void Parkspace_allocator::execute_for_force_update(message::Parkspace_info space
         if(index<0){
             t_error.set_error_code(PARKSPACE_ALLOCATOR_FORCE_UPDATE_FAILED);
             t_error.set_error_level(message::Error_level::MAJOR_ERROR);
+            t_update_space.CopyFrom(space_info);
             LOG(WARNING) << "手动更新车位失败";
         }else{
             t_error.set_error_code(SUCCESS);
@@ -484,6 +492,9 @@ void Parkspace_allocator::execute_for_confirm_alloc(message::Parkspace_info spac
     //根据车位信息定位待确认占用车位
     message::Parkspace_confirm_alloc_response_msg response_msg;
     message::Base_info t_response_header;
+    t_response_header.set_msg_type(message::eParkspace_confirm_alloc_response_msg);
+    t_response_header.set_sender(message::eParkspace);
+    t_response_header.set_receiver(message::eMain);
     message::Error_manager t_error;
     message::Parkspace_info t_confirm_space;
     //获取当前所有车位状态,找到待释放的车位
@@ -518,6 +529,7 @@ void Parkspace_allocator::execute_for_confirm_alloc(message::Parkspace_info spac
         if(index<0){
             t_error.set_error_code(PARKSPACE_ALLOCATOR_CONFIRM_ALLOC_ERROR);
             t_error.set_error_level(message::Error_level::MAJOR_ERROR);
+            t_confirm_space.CopyFrom(space_info);
             LOG(WARNING) << "确认占用车位失败";
         }else{
             t_error.set_error_code(SUCCESS);

+ 2 - 2
parkspace_allocation/parkspace_db_manager.cpp

@@ -2,7 +2,7 @@
  * @Description: 车位数据库管理
  * @Author: yct
  * @Date: 2020-07-19 09:57:45
- * @LastEditTime: 2020-07-22 15:13:17
+ * @LastEditTime: 2020-07-22 17:06:57
  * @LastEditors: yct
  */
 
@@ -118,7 +118,7 @@ Error_manager Parkspace_db_manager::get_all_parkspace_info(message::Parkspace_al
                         break;
                     }
                     t_parkspace->set_width(tp_result->getDouble("parkSpaceWidth"));
-                    t_parkspace->set_width(tp_result->getDouble("parkSpaceHeight"));
+                    t_parkspace->set_height(tp_result->getDouble("parkSpaceHeight"));
                     t_parkspace->mutable_car_info()->set_license(tp_result->getString("parkSpaceCarLicense"));
                     t_parkspace->mutable_car_info()->set_car_length(tp_result->getDouble("parkSpaceCarLength"));
                     t_parkspace->mutable_car_info()->set_car_width(tp_result->getDouble("parkSpaceCarWidth"));

+ 3 - 3
test/parkspace_client.cpp

@@ -2,7 +2,7 @@
  * @Description: 模拟主程序发送车位分配请求,并监听状态信息
  * @Author: yct
  * @Date: 2020-07-08 15:44:43
- * @LastEditTime: 2020-07-22 15:28:22
+ * @LastEditTime: 2020-07-22 17:07:36
  * @LastEditors: yct
  */
 
@@ -80,7 +80,7 @@ std::string send_release_request(int n)
     car_info.set_car_height(1.5);
     car_info.set_car_width(1.85);
     car_info.set_license("鄂A12345");
-    space_info.set_parkspace_id(5);
+    space_info.set_parkspace_id(1);
     space_info.set_index(1);
     space_info.set_direction(message::Direction::eForward);
     space_info.set_floor(33);
@@ -134,7 +134,7 @@ int main()
 {
     nnxx::socket socket{nnxx::SP, nnxx::BUS};
     // socket.bind("tcp://127.0.0.1:7000");
-    socket.connect("tcp://127.0.01:7001");
+    socket.connect("tcp://127.0.0.1:7001");
     int n = 0;
     message::Base_msg base_msg;