瀏覽代碼

增加流程状态信息

zx 4 年之前
父節點
當前提交
eb9ff6016a

+ 0 - 4
CMakeLists.txt

@@ -8,9 +8,6 @@ find_package(PkgConfig REQUIRED)
 pkg_check_modules(nanomsg REQUIRED nanomsg)
 FIND_PACKAGE(Protobuf REQUIRED)
 FIND_PACKAGE(Glog REQUIRED)
-FIND_PACKAGE(OpenCV REQUIRED)
-FIND_PACKAGE(PCL REQUIRED)
-
 
 include_directories(
         /usr/local/include
@@ -67,7 +64,6 @@ target_link_libraries(process
         /usr/local/lib/libglog.a
         /usr/local/lib/libgflags.a
         ${GLOG_LIBRARIES}
-
         )
 
 

+ 2 - 1
communication/communication_message.h

@@ -50,7 +50,8 @@ public:
         ePickup_command_request_msg=0x43,       //取车请求消息
         ePickup_command_response_msg=0x44,       //取车请求反馈消息
 
-        eEntrance_statu_msg=0x51,              //出入口状态消息
+        eStoring_process_statu_msg=0x90,      //停车进度条消息
+        ePicking_process_statu_msg=0x91,        //取车进度消息
 	};
 
 //通讯单元

+ 2 - 0
error_code/error_code.cpp

@@ -176,6 +176,8 @@ Error_level Error_manager::get_error_level()
 //获取错误描述的指针,(浅拷贝)
 char* Error_manager::get_error_description()
 {
+    if(pm_error_description== nullptr)
+        return "";
     return pm_error_description;
 }
 

+ 28 - 29
main.cpp

@@ -4,17 +4,13 @@
 #include <fcntl.h>
 #include <iostream>
 #include <glog/logging.h>
-#include "TaskQueue/TQFactory.h"
-#include "./communication/communication_socket_base.h"
-#include "StoreProcessTask.h"
-#include "PickupProcessTask.h"
+
 #include "system_communicator.h"
 #include "Locate_communicator.h"
 #include "command_manager.h"
 
 #include "pathcreator.h"
 
-#include <glog/logging.h>
 #include <Parkspace_communicator.h>
 #include <dispatch_communicator.h>
 //using google::protobuf::io::FileInputStream;
@@ -25,6 +21,12 @@ using google::protobuf::io::ZeroCopyOutputStream;
 using google::protobuf::io::CodedOutputStream;
 using google::protobuf::Message;
 
+#define MEASURE_CONNECT_STRING          "tcp://192.168.0.201:30001"
+#define DISPATCH_CONNECT_STRING         "tcp://192.168.0.202:30002"
+#define PARKSPACE_CONNECT_STRING        "tcp://192.168.0.202:30001"
+#define SYSTEM_BIND_STRING              "tcp://192.168.0.203:30001"
+
+#define INIT_TIME_OUT_SECONDS           300
 
 GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size);
 void init_glog();
@@ -49,6 +51,10 @@ int main(int argc,char* argv[])
 
 Error_manager init_communicators()
 {
+    ///初始化与终端通讯的对象
+    if(System_communicator::get_instance_pointer()== nullptr)
+        return FAILED;
+    System_communicator::get_instance_pointer()->communication_bind(SYSTEM_BIND_STRING);
     LOG(INFO)<<"初始化通讯子节点......";
     Error_manager code;
     /*
@@ -57,7 +63,7 @@ Error_manager init_communicators()
 
     if(Locate_communicator::get_instance_pointer()== nullptr)
         return FAILED;
-    code=Locate_communicator::get_instance_pointer()->communication_connect("tcp://192.168.2.192:4444");
+    code=Locate_communicator::get_instance_pointer()->communication_connect(MEASURE_CONNECT_STRING);
     if(code!=SUCCESS)
     {
         return code;
@@ -67,7 +73,7 @@ Error_manager init_communicators()
     //初始化车位分配通讯模块
     if(Parkspace_communicator::get_instance_pointer()== nullptr)
         return FAILED;
-    code=Parkspace_communicator::get_instance_pointer()->communication_connect("tcp://192.168.2.125:7001");
+    code=Parkspace_communicator::get_instance_pointer()->communication_connect(PARKSPACE_CONNECT_STRING);
     if(code!=SUCCESS)
     {
         return code;
@@ -77,7 +83,7 @@ Error_manager init_communicators()
     /*
      * 初始化调度模块
      */
-    Dispatch_communicator::get_instance_pointer()->communication_connect("tcp://192.168.2.192:5555");
+    Dispatch_communicator::get_instance_pointer()->communication_connect(DISPATCH_CONNECT_STRING);
     Dispatch_communicator::get_instance_pointer()->communication_run();
 
     /*
@@ -89,57 +95,50 @@ Error_manager init_communicators()
     do{
         if(locate_code!=SUCCESS) {
             locate_code = Locate_communicator::get_instance_pointer()->check_statu();
-            if (locate_code == SUCCESS) {
-                LOG(INFO) << "测量模块初始化完成!!!";
-            }
+            LOG_IF(INFO, locate_code == SUCCESS) << "测量模块初始化完成!!!";
         }
 
         if(parkspace_code!=SUCCESS) {
             parkspace_code = Parkspace_communicator::get_instance_pointer()->check_statu();
-            if (parkspace_code == SUCCESS) {
-                LOG(INFO) << "车位管理模块初始化完成!!!";
-            }
+            LOG_IF(INFO, parkspace_code == SUCCESS) << "车位管理模块初始化完成!!!";
         }
 
         if(dispatch_code!=SUCCESS) {
             dispatch_code = Dispatch_communicator::get_instance_pointer()->check_statu();
-            if (dispatch_code == SUCCESS) {
-                LOG(INFO) << "调度模块初始化完成!!!";
-            }
+            LOG_IF(INFO, dispatch_code == SUCCESS) << "调度模块初始化完成!!!";
         }
 
         if(locate_code==SUCCESS && parkspace_code==SUCCESS && dispatch_code==SUCCESS)
             break;
         t_end=std::chrono::system_clock::now();
-        usleep(1000*200);
-    }while(t_end-t_start<std::chrono::seconds(60));
+        usleep(1000*300);
+    }while(t_end-t_start<std::chrono::seconds(INIT_TIME_OUT_SECONDS));
+
+    LOG_IF(ERROR,locate_code!=SUCCESS)<<"测量节点连接超时";
+    LOG_IF(ERROR,parkspace_code!=SUCCESS)<<"车位管理节点连接超时";
+    LOG_IF(ERROR,dispatch_code!=SUCCESS)<<"调度节点连接超时";
 
     if(!(locate_code==SUCCESS && parkspace_code==SUCCESS && dispatch_code==SUCCESS))
     {
-        LOG(INFO)<<"初始化通讯子节点超时!!!";
         return Error_manager(ERROR,MAJOR_ERROR,"通讯节点初始化超时");
     }
 
-
-    ///最后初始化与终端通讯的对象
-    if(System_communicator::get_instance_pointer()== nullptr)
-        return FAILED;
-    System_communicator::get_instance_pointer()->communication_bind("tcp://127.0.0.1:9001");
-    System_communicator::get_instance_pointer()->communication_run();
-
-
     /*
      * 初始化指令执行模块
      */
     if(Command_manager::get_instance_pointer()== nullptr)
         return Error_manager(FAILED,CRITICAL_ERROR,"创建指令执行模块失败");
     code=Command_manager::get_instance_pointer()->init();
+
+    usleep(1000*1000);
+
     if(code!=SUCCESS)
     {
         return code;
     }
+    //运行接收指令通讯块,开始接收指令
+    System_communicator::get_instance_pointer()->communication_run();
 
-    usleep(1000*3000);
     LOG(INFO)<<"系统初始化完成 --------------------------------------------- !!!";
     return SUCCESS;
 }

+ 47 - 68
message/message_base.pb.cc

@@ -334,15 +334,15 @@ void AddDescriptorsImpl() {
       "eight\030\006 \001(\002\022\031\n\021locate_wheel_base\030\007 \001(\002\022\032"
       "\n\022locate_wheel_width\030\010 \001(\002\022\026\n\016locate_cor"
       "rect\030\t \001(\010\"V\n\010Car_info\022\022\n\ncar_length\030\001 \001"
-      "(\002\022\021\n\tcar_width\030\002 \002(\002\022\022\n\ncar_height\030\003 \002("
-      "\002\022\017\n\007license\030\004 \002(\t\"\234\002\n\016Parkspace_info\022\024\n"
+      "(\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"
       "\014parkspace_id\030\001 \001(\005\022\r\n\005index\030\002 \001(\005\022%\n\tdi"
       "rection\030\003 \001(\0162\022.message.Direction\022\r\n\005flo"
       "or\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("
       "\0162\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*\225\006\n\014Message_ty"
+      "\n \001(\t\022\022\n\nleave_time\030\013 \001(\t*\276\006\n\014Message_ty"
       "pe\022\r\n\teBase_msg\020\000\022\020\n\014eCommand_msg\020\001\022\026\n\022e"
       "Locate_status_msg\020\021\022\027\n\023eLocate_request_m"
       "sg\020\022\022\030\n\024eLocate_response_msg\020\023\022\030\n\024eDispa"
@@ -361,20 +361,21 @@ void AddDescriptorsImpl() {
       "alloc_response_msg\020;\022\036\n\032eStore_command_r"
       "equest_msg\020A\022\037\n\033eStore_command_response_"
       "msg\020B\022\037\n\033ePickup_command_request_msg\020C\022 "
-      "\n\034ePickup_command_response_msg\020D\022\027\n\023eEnt"
-      "rance_statu_msg\020Q*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*e\n\013Error_level\022\n\n\006NORMAL\020\000\022\024\n\020NEGLIGIB"
-      "LE_ERROR\020\001\022\017\n\013MINOR_ERROR\020\002\022\017\n\013MAJOR_ERR"
-      "OR\020\003\022\022\n\016CRITICAL_ERROR\020\004*q\n\020Parkspace_st"
-      "atus\022\024\n\020eParkspace_empty\020\000\022\027\n\023eParkspace"
-      "_occupied\020\001\022\030\n\024eParkspace_reserverd\020\002\022\024\n"
-      "\020eParkspace_error\020\003*(\n\tDirection\022\014\n\010eFor"
-      "ward\020\001\022\r\n\teBackward\020\002"
+      "\n\034ePickup_command_response_msg\020D\022\037\n\032eSto"
+      "ring_process_statu_msg\020\220\001\022\037\n\032ePicking_pr"
+      "ocess_statu_msg\020\221\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*e\n\013Error_level\022\n\n\006NORMAL\020\000\022\024\n\020NEGLIGI"
+      "BLE_ERROR\020\001\022\017\n\013MINOR_ERROR\020\002\022\017\n\013MAJOR_ER"
+      "ROR\020\003\022\022\n\016CRITICAL_ERROR\020\004*q\n\020Parkspace_s"
+      "tatus\022\024\n\020eParkspace_empty\020\000\022\027\n\023eParkspac"
+      "e_occupied\020\001\022\030\n\024eParkspace_reserverd\020\002\022\024"
+      "\n\020eParkspace_error\020\003*(\n\tDirection\022\014\n\010eFo"
+      "rward\020\001\022\r\n\teBackward\020\002"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 2101);
+      descriptor, 2142);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "message_base.proto", &protobuf_RegisterTypes);
 }
@@ -420,7 +421,8 @@ bool Message_type_IsValid(int value) {
     case 66:
     case 67:
     case 68:
-    case 81:
+    case 144:
+    case 145:
       return true;
     default:
       return false;
@@ -2166,7 +2168,7 @@ bool Car_info::MergePartialFromCodedStream(
         break;
       }
 
-      // required float car_width = 2;
+      // optional float car_width = 2;
       case 2: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
             static_cast< ::google::protobuf::uint8>(21u /* 21 & 0xFF */)) {
@@ -2180,7 +2182,7 @@ bool Car_info::MergePartialFromCodedStream(
         break;
       }
 
-      // required float car_height = 3;
+      // optional float car_height = 3;
       case 3: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
             static_cast< ::google::protobuf::uint8>(29u /* 29 & 0xFF */)) {
@@ -2194,7 +2196,7 @@ bool Car_info::MergePartialFromCodedStream(
         break;
       }
 
-      // required string license = 4;
+      // optional string license = 4;
       case 4: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
             static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
@@ -2242,17 +2244,17 @@ void Car_info::SerializeWithCachedSizes(
     ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->car_length(), output);
   }
 
-  // required float car_width = 2;
+  // optional float car_width = 2;
   if (cached_has_bits & 0x00000004u) {
     ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->car_width(), output);
   }
 
-  // required float car_height = 3;
+  // optional float car_height = 3;
   if (cached_has_bits & 0x00000008u) {
     ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->car_height(), output);
   }
 
-  // required string license = 4;
+  // optional string license = 4;
   if (cached_has_bits & 0x00000001u) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
       this->license().data(), static_cast<int>(this->license().length()),
@@ -2282,17 +2284,17 @@ void Car_info::SerializeWithCachedSizes(
     target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->car_length(), target);
   }
 
-  // required float car_width = 2;
+  // optional float car_width = 2;
   if (cached_has_bits & 0x00000004u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->car_width(), target);
   }
 
-  // required float car_height = 3;
+  // optional float car_height = 3;
   if (cached_has_bits & 0x00000008u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->car_height(), target);
   }
 
-  // required string license = 4;
+  // optional string license = 4;
   if (cached_has_bits & 0x00000001u) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
       this->license().data(), static_cast<int>(this->license().length()),
@@ -2311,29 +2313,6 @@ void Car_info::SerializeWithCachedSizes(
   return target;
 }
 
-size_t Car_info::RequiredFieldsByteSizeFallback() const {
-// @@protoc_insertion_point(required_fields_byte_size_fallback_start:message.Car_info)
-  size_t total_size = 0;
-
-  if (has_license()) {
-    // required string license = 4;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::StringSize(
-        this->license());
-  }
-
-  if (has_car_width()) {
-    // required float car_width = 2;
-    total_size += 1 + 4;
-  }
-
-  if (has_car_height()) {
-    // required float car_height = 3;
-    total_size += 1 + 4;
-  }
-
-  return total_size;
-}
 size_t Car_info::ByteSizeLong() const {
 // @@protoc_insertion_point(message_byte_size_start:message.Car_info)
   size_t total_size = 0;
@@ -2343,26 +2322,30 @@ size_t Car_info::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
         _internal_metadata_.unknown_fields());
   }
-  if (((_has_bits_[0] & 0x0000000d) ^ 0x0000000d) == 0) {  // All required fields are present.
-    // required string license = 4;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::StringSize(
-        this->license());
+  if (_has_bits_[0 / 32] & 15u) {
+    // optional string license = 4;
+    if (has_license()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::StringSize(
+          this->license());
+    }
 
-    // required float car_width = 2;
-    total_size += 1 + 4;
+    // optional float car_length = 1;
+    if (has_car_length()) {
+      total_size += 1 + 4;
+    }
 
-    // required float car_height = 3;
-    total_size += 1 + 4;
+    // optional float car_width = 2;
+    if (has_car_width()) {
+      total_size += 1 + 4;
+    }
 
-  } else {
-    total_size += RequiredFieldsByteSizeFallback();
-  }
-  // optional float car_length = 1;
-  if (has_car_length()) {
-    total_size += 1 + 4;
-  }
+    // optional float car_height = 3;
+    if (has_car_height()) {
+      total_size += 1 + 4;
+    }
 
+  }
   int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
   GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
   _cached_size_ = cached_size;
@@ -2426,7 +2409,6 @@ void Car_info::CopyFrom(const Car_info& from) {
 }
 
 bool Car_info::IsInitialized() const {
-  if ((_has_bits_[0] & 0x0000000d) != 0x0000000d) return false;
   return true;
 }
 
@@ -3121,9 +3103,6 @@ void Parkspace_info::CopyFrom(const Parkspace_info& from) {
 }
 
 bool Parkspace_info::IsInitialized() const {
-  if (has_car_info()) {
-    if (!this->car_info_->IsInitialized()) return false;
-  }
   return true;
 }
 

+ 9 - 11
message/message_base.pb.h

@@ -110,11 +110,12 @@ enum Message_type {
   eStore_command_response_msg = 66,
   ePickup_command_request_msg = 67,
   ePickup_command_response_msg = 68,
-  eEntrance_statu_msg = 81
+  eStoring_process_statu_msg = 144,
+  ePicking_process_statu_msg = 145
 };
 bool Message_type_IsValid(int value);
 const Message_type Message_type_MIN = eBase_msg;
-const Message_type Message_type_MAX = eEntrance_statu_msg;
+const Message_type Message_type_MAX = ePicking_process_statu_msg;
 const int Message_type_ARRAYSIZE = Message_type_MAX + 1;
 
 const ::google::protobuf::EnumDescriptor* Message_type_descriptor();
@@ -886,7 +887,7 @@ class Car_info : public ::google::protobuf::Message /* @@protoc_insertion_point(
 
   // accessors -------------------------------------------------------
 
-  // required string license = 4;
+  // optional string license = 4;
   bool has_license() const;
   void clear_license();
   static const int kLicenseFieldNumber = 4;
@@ -908,14 +909,14 @@ class Car_info : public ::google::protobuf::Message /* @@protoc_insertion_point(
   float car_length() const;
   void set_car_length(float value);
 
-  // required float car_width = 2;
+  // optional float car_width = 2;
   bool has_car_width() const;
   void clear_car_width();
   static const int kCarWidthFieldNumber = 2;
   float car_width() const;
   void set_car_width(float value);
 
-  // required float car_height = 3;
+  // optional float car_height = 3;
   bool has_car_height() const;
   void clear_car_height();
   static const int kCarHeightFieldNumber = 3;
@@ -933,9 +934,6 @@ class Car_info : public ::google::protobuf::Message /* @@protoc_insertion_point(
   void set_has_license();
   void clear_has_license();
 
-  // helper for ByteSizeLong()
-  size_t RequiredFieldsByteSizeFallback() const;
-
   ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
   ::google::protobuf::internal::HasBits<1> _has_bits_;
   mutable int _cached_size_;
@@ -1706,7 +1704,7 @@ inline void Car_info::set_car_length(float value) {
   // @@protoc_insertion_point(field_set:message.Car_info.car_length)
 }
 
-// required float car_width = 2;
+// optional float car_width = 2;
 inline bool Car_info::has_car_width() const {
   return (_has_bits_[0] & 0x00000004u) != 0;
 }
@@ -1730,7 +1728,7 @@ inline void Car_info::set_car_width(float value) {
   // @@protoc_insertion_point(field_set:message.Car_info.car_width)
 }
 
-// required float car_height = 3;
+// optional float car_height = 3;
 inline bool Car_info::has_car_height() const {
   return (_has_bits_[0] & 0x00000008u) != 0;
 }
@@ -1754,7 +1752,7 @@ inline void Car_info::set_car_height(float value) {
   // @@protoc_insertion_point(field_set:message.Car_info.car_height)
 }
 
-// required string license = 4;
+// optional string license = 4;
 inline bool Car_info::has_license() const {
   return (_has_bits_[0] & 0x00000001u) != 0;
 }

+ 7 - 4
message/message_base.proto

@@ -35,7 +35,10 @@ enum Message_type
     ePickup_command_request_msg=0x43;       //取车请求消息
     ePickup_command_response_msg=0x44;       //取车请求反馈消息
 
-    eEntrance_statu_msg=0x51;               //出入口状态消息
+
+
+    eStoring_process_statu_msg=0x90;        //停车进度条消息
+    ePicking_process_statu_msg=0x91;        //取车进度消息
 
 
 }
@@ -110,9 +113,9 @@ message Locate_information
 message Car_info
 {
     optional float                      car_length=1;           //车长
-    required float                      car_width=2;            //车宽
-    required float                      car_height=3;           //车高
-    required string                     license=4;              //车辆凭证号
+    optional float                      car_width=2;            //车宽
+    optional float                      car_height=3;           //车高
+    optional string                     license=4;              //车辆凭证号
 }
 
 //车位状态枚举

+ 0 - 25
message/parkspace_allocation_message.pb.cc

@@ -910,9 +910,6 @@ bool Parkspace_allocation_request_msg::IsInitialized() const {
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }
-  if (has_car_info()) {
-    if (!this->car_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -1361,9 +1358,6 @@ bool Parkspace_allocation_response_msg::IsInitialized() const {
   if (has_error_manager()) {
     if (!this->error_manager_->IsInitialized()) return false;
   }
-  if (has_allocated_space_info()) {
-    if (!this->allocated_space_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -1752,9 +1746,6 @@ bool Parkspace_search_request_msg::IsInitialized() const {
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }
-  if (has_car_info()) {
-    if (!this->car_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -2197,9 +2188,6 @@ bool Parkspace_search_response_msg::IsInitialized() const {
   if (has_error_manager()) {
     if (!this->error_manager_->IsInitialized()) return false;
   }
-  if (has_car_position()) {
-    if (!this->car_position_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -2588,9 +2576,6 @@ bool Parkspace_release_request_msg::IsInitialized() const {
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }
-  if (has_release_space_info()) {
-    if (!this->release_space_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -3038,9 +3023,6 @@ bool Parkspace_release_response_msg::IsInitialized() const {
   if (has_error_manager()) {
     if (!this->error_manager_->IsInitialized()) return false;
   }
-  if (has_release_space_info()) {
-    if (!this->release_space_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -3429,9 +3411,6 @@ bool Parkspace_confirm_alloc_request_msg::IsInitialized() const {
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }
-  if (has_confirm_space_info()) {
-    if (!this->confirm_space_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -3879,9 +3858,6 @@ bool Parkspace_confirm_alloc_response_msg::IsInitialized() const {
   if (has_error_manager()) {
     if (!this->error_manager_->IsInitialized()) return false;
   }
-  if (has_confirm_alloc_space_info()) {
-    if (!this->confirm_alloc_space_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -4268,7 +4244,6 @@ void Parkspace_allocation_status_msg::CopyFrom(const Parkspace_allocation_status
 
 bool Parkspace_allocation_status_msg::IsInitialized() const {
   if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-  if (!::google::protobuf::internal::AllAreInitialized(this->parkspace_info())) return false;
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }

文件差異過大導致無法顯示
+ 4419 - 399
message/process_message.pb.cc


文件差異過大導致無法顯示
+ 3323 - 229
message/process_message.pb.h


+ 89 - 8
message/process_message.proto

@@ -2,17 +2,98 @@ syntax = "proto2";
 package message;
 import "message_base.proto";
 
+enum Step_statu
+{
+    eWaiting=0;               //完成/空闲
+    eWorking=1;
+    eError=2;
+    eComplete=3;
+}
+
+//分配车位步骤状态
+message Alloc_space_step_statu
+{
+    required Step_statu                 step_statu=1;       //状态
+    optional Car_info                   car_info=2;         //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//查询车位步骤状态
+message Check_space_step_statu
+{
+    required Step_statu                 step_statu=1;       //状态
+    optional Parkspace_info             space_info=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//确认占用车位步骤状态
+message Confirm_space_step_statu
+{
+    required Step_statu                 step_statu=1;       //状态
+    optional Parkspace_info             space_info=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//解锁/释放车位步骤状态
+message Release_space_step_statu
+{
+    required Step_statu                 step_statu=1;       //状态
+    optional Parkspace_info             space_info=2;       //当前状态附带信息
+    optional string                     description=3;      //状态说明/错误说明
+}
 
-enum Entrance_statu
+//测量步骤状态
+message Measure_step_statu
 {
-    eWorking=0;             //正在执行
-    eReady=1;               //完成/空闲
+    required Step_statu                 step_statu=1;       //状态
+    optional Locate_information         locate_info=2;      //定位结果
+    optional string                     description=3;      //状态说明/错误说明
 }
 
+//停车调度步骤状态
+message Dispatch_store_step_statu
+{
+    required Step_statu                 step_statu=1;       //状态
+    optional Locate_information         locate_info=2;      //定位结果
+    optional Parkspace_info             space_info=3;       //目标车位
+    optional string                     description=4;      //状态说明/错误说明
+}
 
-message Entrance_statu_msg
+//取车调度步骤状态
+message Dispatch_pick_step_statu
 {
-    required Base_info                          base_info=1;                 //消息类型
-    map<int32,Entrance_statu>                   store_msg_map=2;
-    map<int32,Entrance_statu>                   pickup_msg_map=3;
-}
+    required Step_statu                 step_statu=1;       //状态
+    optional Parkspace_info             space_info=2;       //目标车位
+    optional string                     description=3;      //状态说明/错误说明
+}
+
+//取车等待车辆离开
+message Waitfor_leave_step_statu
+{
+    required Step_statu                 step_statu=1;       //状态
+    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 Alloc_space_step_statu     alloc_space_step=3;
+    required Measure_step_statu         measure_step=4;
+    required Dispatch_store_step_statu  dispatch_step=5;
+    required Confirm_space_step_statu   confirm_space_step=6;
+    optional Release_space_step_statu   failed_release_space_step=7;
+}
+
+//取车流程进度消息
+message Picking_process_statu_msg
+{
+    required Base_info                  base_info=1;
+    required int32                      terminal_id=2;              //终端id
+    required Check_space_step_statu     check_space_step=3;
+    required Dispatch_pick_step_statu   dispatch_step=4;
+    required Release_space_step_statu   release_space_step=5;
+    required Waitfor_leave_step_statu   waitfor_leave=6;
+}

+ 0 - 6
message/terminal_message.pb.cc

@@ -679,9 +679,6 @@ bool Store_command_request_msg::IsInitialized() const {
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }
-  if (has_car_info()) {
-    if (!this->car_info_->IsInitialized()) return false;
-  }
   return true;
 }
 
@@ -1460,9 +1457,6 @@ bool Pickup_command_request_msg::IsInitialized() const {
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }
-  if (has_car_info()) {
-    if (!this->car_info_->IsInitialized()) return false;
-  }
   return true;
 }
 

+ 159 - 10
system/PickupProcessTask.cpp

@@ -7,15 +7,96 @@
 #include "PickupProcessTask.h"
 #include "process_message.pb.h"
 #include "command_manager.h"
+#include "system_communicator.h"
 
-PickupProcessTask::PickupProcessTask(){}
-PickupProcessTask::~PickupProcessTask(){}
-Error_manager PickupProcessTask::init_task(unsigned int command_id, unsigned int terminor_id,message::Car_info car_info)
+PickupProcessTask::PickupProcessTask(unsigned int terminal_id)
+    :m_publish_statu_thread(nullptr)
+{
+    m_terminor_id=terminal_id;
+    m_command_id=-1;
+
+    message::Base_info base_info;
+    base_info.set_msg_type(message::eStoring_process_statu_msg);
+    base_info.set_sender(message::eMain);
+    base_info.set_receiver(message::eEmpty);
+    m_picking_process_statu_msg.mutable_base_info()->CopyFrom(base_info);
+    m_picking_process_statu_msg.set_terminal_id(terminal_id);
+    reset_process_statu();
+}
+PickupProcessTask::~PickupProcessTask()
+{
+    //退出线程
+    m_publish_exit_condition.set_pass_ever(true);
+    if(m_publish_statu_thread!= nullptr)
+    {
+        if(m_publish_statu_thread->joinable())
+        {
+            m_publish_statu_thread->join();
+        }
+        delete m_publish_statu_thread;
+        m_publish_statu_thread=nullptr;
+    }
+}
+Error_manager PickupProcessTask::init_task(unsigned int command_id, message::Car_info car_info)
 {
     m_command_id=command_id;
-    m_terminor_id=terminor_id;
     m_car_info=car_info;
-    return SUCCESS;
+
+    message::Base_info base_info;
+    base_info.set_msg_type(message::ePicking_process_statu_msg);
+    base_info.set_sender(message::eMain);
+    base_info.set_receiver(message::eEmpty);
+    m_picking_process_statu_msg.mutable_base_info()->CopyFrom(base_info);
+    reset_process_statu();
+
+    ///创建状态发布线程
+    if(m_publish_statu_thread== nullptr)
+    {
+        m_publish_exit_condition.reset(false, false, false);
+        m_publish_statu_thread=new std::thread(publish_thread_func,this);
+    }
+
+    if(is_ready()) {
+        return SUCCESS;
+    }
+    else
+    {
+        return Error_manager(ERROR,MINOR_ERROR,"终端未准备!!!");
+    }
+}
+
+/*
+     * reset 进度信息
+     */
+void PickupProcessTask::reset_process_statu()
+{
+    message::Check_space_step_statu check_step;
+    check_step.set_step_statu(message::eWaiting);
+
+    message::Dispatch_pick_step_statu  pick_step;
+    pick_step.set_step_statu(message::eWaiting);
+
+    message::Release_space_step_statu   release_step;
+    release_step.set_step_statu(message::eWaiting);
+
+    m_picking_process_statu_msg.mutable_check_space_step()->CopyFrom(check_step);
+    m_picking_process_statu_msg.mutable_dispatch_step()->CopyFrom(pick_step);
+    m_picking_process_statu_msg.mutable_release_space_step()->CopyFrom(release_step);
+
+}
+
+/*
+     * 检查当前任务是否处于空闲准备状态
+     */
+bool PickupProcessTask::is_ready()
+{
+    bool cond_check_space = m_picking_process_statu_msg.check_space_step().step_statu()==message::eWaiting
+                            ||m_picking_process_statu_msg.check_space_step().step_statu()==message::eComplete;
+    bool cond_dispatch = m_picking_process_statu_msg.dispatch_step().step_statu()==message::eWaiting
+                         ||m_picking_process_statu_msg.dispatch_step().step_statu()==message::eComplete;
+    bool cond_release_space = m_picking_process_statu_msg.release_space_step().step_statu()==message::eWaiting
+                              ||m_picking_process_statu_msg.release_space_step().step_statu()==message::eComplete;
+    return cond_check_space && cond_dispatch && cond_release_space;
 }
 
 /*
@@ -23,12 +104,17 @@ Error_manager PickupProcessTask::init_task(unsigned int command_id, unsigned int
  */
 Error_manager PickupProcessTask::search_space()
 {
+    //更新状态
+    m_picking_process_statu_msg.mutable_check_space_step()->set_step_statu(message::eWorking);
+
     /*
      * 检验汽车信息是否正常
      */
     if(m_car_info.has_car_width()==false||m_car_info.has_car_height()== false
         ||m_car_info.has_license()==false)
     {
+        m_picking_process_statu_msg.mutable_check_space_step()->set_step_statu(message::eError);
+        m_picking_process_statu_msg.mutable_check_space_step()->set_description("查询车位请求汽车信息错误");
         return Error_manager(INVALID_MESSAGE,CRITICAL_ERROR,"查询车位请求汽车信息错误");
     }
 
@@ -37,7 +123,11 @@ Error_manager PickupProcessTask::search_space()
      */
     Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
     if(code!=SUCCESS)
+    {
+        m_picking_process_statu_msg.mutable_check_space_step()->set_description(code.get_error_description());
+        m_picking_process_statu_msg.mutable_check_space_step()->set_step_statu(message::eError);
         return code;
+    }
 
     message::Base_info base_info;
     base_info.set_msg_type(message::eParkspace_search_request_msg);
@@ -49,19 +139,34 @@ Error_manager PickupProcessTask::search_space()
     request.set_command_id(m_command_id);
     request.mutable_base_info()->CopyFrom(base_info);
     request.mutable_car_info()->CopyFrom(m_car_info);
-    return Parkspace_communicator::get_instance_pointer()->search_request(request,m_parcspace_search_response_msg);
+
+
+    code = Parkspace_communicator::get_instance_pointer()->search_request(request,m_parcspace_search_response_msg);
+    if(code==SUCCESS)
+    {
+        m_picking_process_statu_msg.mutable_check_space_step()->mutable_space_info()->CopyFrom(m_parcspace_search_response_msg.car_position());
+        m_picking_process_statu_msg.mutable_check_space_step()->set_step_statu(message::eComplete);
+    }
+    else {
+        m_picking_process_statu_msg.mutable_check_space_step()->set_step_statu(message::eError);
+        m_picking_process_statu_msg.mutable_check_space_step()->set_description(code.get_error_description());
+    }
+    return code;
 }
 void PickupProcessTask::Main()
 {
     Error_manager code;
 
-    Command_manager::get_instance_pointer()->updata_pickup_entrance_statu(m_command_id,message::eWorking);
     //进入取车流程
     switch (0)
     {
         //第一步,执行取车动作
         case 0:
         {
+            //更新状态
+            m_picking_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eWorking);
+            m_picking_process_statu_msg.mutable_dispatch_step()->mutable_space_info()->CopyFrom(m_parcspace_search_response_msg.car_position());
+            //开始工作
             code=pickup_step();
             if(code!=SUCCESS)
             {
@@ -71,8 +176,11 @@ void PickupProcessTask::Main()
                             <<", 车位序号:"<<m_parcspace_search_response_msg.car_position().index()
                             <<", 车牌号:"<<m_car_info.license()
                             <<", 库内车牌号:"<<m_parcspace_search_response_msg.car_position().car_info().license();
+                m_picking_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eError);
+                m_picking_process_statu_msg.mutable_dispatch_step()->set_description(code.get_error_description());
                 break;
             }
+            m_picking_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eComplete);
             LOG(WARNING)<<"取车调度成功,取车终端:"<<m_terminor_id<<"指令id:"<<m_command_id
                         <<", 车位id:"<<m_parcspace_search_response_msg.car_position().parkspace_id()
                         <<", 车位楼层:"<<m_parcspace_search_response_msg.car_position().floor()
@@ -83,25 +191,36 @@ void PickupProcessTask::Main()
         //第二步,清除车位
         case 1:
         {
+            //更新状态
+            m_picking_process_statu_msg.mutable_release_space_step()->set_step_statu(message::eWorking);
+            m_picking_process_statu_msg.mutable_release_space_step()->mutable_space_info()->CopyFrom(m_parcspace_search_response_msg.car_position());
             code=release_space_step();
             if(code!=SUCCESS)
             {
-                LOG(ERROR)<<"取车释放车位失败:"<<code.to_string();
+                m_picking_process_statu_msg.mutable_release_space_step()->set_step_statu(message::eError);
+                m_picking_process_statu_msg.mutable_release_space_step()->set_description(code.get_error_description());
+                LOG(ERROR)<<"取车释放车位失败:"<<code.get_error_description();
                 break;
             }
+            m_picking_process_statu_msg.mutable_release_space_step()->set_step_statu(message::eComplete);
         }
         //第三步,等待车辆离开
         case 2:
         {
+            //更新状态
+            m_picking_process_statu_msg.mutable_waitfor_leave()->set_step_statu(message::eWorking);
+            m_picking_process_statu_msg.mutable_waitfor_leave()->mutable_car_info()->CopyFrom(m_car_info);
+            //等待离开
             code=wait_for_leave_step();
             if(code!=SUCCESS)
             {
+                m_picking_process_statu_msg.mutable_waitfor_leave()->set_step_statu(message::eError);
+                m_picking_process_statu_msg.mutable_waitfor_leave()->set_description(code.get_error_description());
                 break;
             }
+            m_picking_process_statu_msg.mutable_waitfor_leave()->set_step_statu(message::eComplete);
         }
     }
-    Command_manager::get_instance_pointer()->updata_pickup_entrance_statu(m_terminor_id,message::eReady);
-    ////资源回收
 
 }
 
@@ -202,4 +321,34 @@ Error_manager PickupProcessTask::release_space_step()
     }
     else
         return Error_manager(FAILED,MINOR_ERROR,"取车流程parkspace release response error_code error");
+}
+
+/*
+ * 发布状态线程
+ */
+void PickupProcessTask::publish_thread_func(PickupProcessTask* ptask)
+{
+    if(ptask)
+    {
+        ptask->publish_step_status();
+    }
+}
+void PickupProcessTask::publish_step_status()
+{
+    //未收到退出信号
+    while(false==m_publish_exit_condition.wait_for_ex(std::chrono::milliseconds(200)))
+    {
+        /*
+         * 通过communicator 发布状态
+         */
+        if(System_communicator::get_instance_pointer())
+        {
+            if(m_picking_process_statu_msg.has_base_info()==true)
+            {
+                System_communicator::get_instance_pointer()->post_entrance_statu(m_picking_process_statu_msg);
+            }
+
+        }
+
+    }
 }

+ 24 - 2
system/PickupProcessTask.h

@@ -5,15 +5,21 @@
 #ifndef NNXX_TESTS_TAKEPROCESS_H
 #define NNXX_TESTS_TAKEPROCESS_H
 #include <parkspace_allocation_message.pb.h>
+#include "process_message.pb.h"
 #include "error_code.h"
 #include "TaskQueue/BaseTask.h"
 #include "dispatch_communicator.h"
 
 class PickupProcessTask :public tq::BaseTask{
 public:
-    PickupProcessTask();
+    PickupProcessTask(unsigned int terminal_id);
     virtual  ~PickupProcessTask();
-    Error_manager init_task(unsigned int command_id, unsigned int terminor_id,message::Car_info car_info);
+    Error_manager init_task(unsigned int command_id,message::Car_info car_info);
+
+    /*
+     * 检查当前任务是否处于空闲准备状态
+     */
+    bool is_ready();
 
     /*
      * 查询车位
@@ -37,17 +43,33 @@ protected:
      */
     Error_manager release_space_step();
 
+    /*
+     * reset 进度信息
+     */
+    void reset_process_statu();
+
+    /*
+     * 发布进度
+     */
+    static void publish_thread_func(PickupProcessTask* p_commander);
+    void publish_step_status();
+
 protected:
     unsigned int                m_command_id;
     unsigned int                m_terminor_id;
     message::Car_info           m_car_info;          //当前流程的车辆信息
 
+    std::thread*                    m_publish_statu_thread;             //广播状态线程
+    Thread_condition				m_publish_exit_condition;			//发送的条件变量
 private:
     //查询到的车位信息
     message::Parkspace_search_response_msg                  m_parcspace_search_response_msg;
     //取车调度反馈信息
     message::Dispatch_response_msg                          m_dispatch_response_msg;
 
+    //取车车位的进度状态
+    message::Picking_process_statu_msg                      m_picking_process_statu_msg;
+
 };
 
 

+ 176 - 28
system/StoreProcessTask.cpp

@@ -8,27 +8,59 @@
 #include "StoreProcessTask.h"
 #include "process_message.pb.h"
 #include "command_manager.h"
+#include "system_communicator.h"
 
-StoreProcessTask::StoreProcessTask()
+StoreProcessTask::StoreProcessTask(unsigned int terminor_id)
+    :m_publish_statu_thread(nullptr)
 {
     m_command_id=-1;
-    m_terminor_id=-1;
-    mb_completed=false;
+    m_terminor_id=terminor_id;
+
+    message::Base_info base_info;
+    base_info.set_msg_type(message::eStoring_process_statu_msg);
+    base_info.set_sender(message::eMain);
+    base_info.set_receiver(message::eEmpty);
+    m_storing_process_statu_msg.mutable_base_info()->CopyFrom(base_info);
+    m_storing_process_statu_msg.set_terminal_id(terminor_id);
+    reset_process_statu();
 }
 
 StoreProcessTask::~StoreProcessTask()
 {
-
+    //退出线程
+    m_publish_exit_condition.set_pass_ever(true);
+    if(m_publish_statu_thread!= nullptr)
+    {
+        if(m_publish_statu_thread->joinable())
+        {
+            m_publish_statu_thread->join();
+        }
+        delete m_publish_statu_thread;
+        m_publish_statu_thread=nullptr;
+    }
 }
 
-Error_manager StoreProcessTask::init_task(unsigned int command_id, unsigned int terminor_id,
+Error_manager StoreProcessTask::init_task( unsigned int command_id,
         message::Locate_information locate_info,message::Car_info car_info)
 {
     m_command_id=command_id;
-    m_terminor_id=terminor_id;
     m_car_info=car_info;
     m_locate_info=locate_info;
-    return SUCCESS;
+
+    ///创建状态发布线程
+    if(m_publish_statu_thread== nullptr)
+    {
+        m_publish_exit_condition.reset(false, false, false);
+        m_publish_statu_thread=new std::thread(publish_thread_func,this);
+    }
+
+    if(is_ready()) {
+        return SUCCESS;
+    }
+    else
+    {
+        return Error_manager(ERROR,MINOR_ERROR,"终端未准备!!!");
+    }
 }
 
 Error_manager StoreProcessTask::locate_step() {
@@ -43,7 +75,7 @@ Error_manager StoreProcessTask::locate_step() {
     base_info.set_msg_type(message::eLocate_request_msg);
     base_info.set_sender(message::eMain);
     base_info.set_receiver(message::eMeasurer);
-    base_info.set_timeout_ms(5000); //测量超时5s
+    base_info.set_timeout_ms(20000); //测量超时5s
     request.mutable_base_info()->CopyFrom(base_info);
 
     request.set_command_id(m_command_id);
@@ -57,7 +89,7 @@ Error_manager StoreProcessTask::locate_step() {
         return SUCCESS;
     }
     else
-        return Error_manager(FAILED,MINOR_ERROR,"measure response error_code error");
+        return Error_manager(FAILED,MINOR_ERROR,m_measure_response_msg.error_manager().error_description().c_str());
 
 }
 
@@ -108,16 +140,68 @@ Error_manager StoreProcessTask::dispatch_step()
         return Error_manager(FAILED,MINOR_ERROR,"dispatch response error_code error");
 }
 
+/*
+     * reset 进度信息
+     */
+void StoreProcessTask::reset_process_statu()
+{
+    message::Alloc_space_step_statu alloc_step;
+    alloc_step.set_step_statu(message::eWaiting);
+
+    message::Measure_step_statu     measure_step;
+    measure_step.set_step_statu(message::eWaiting);
+
+    message::Dispatch_store_step_statu  store_step;
+    store_step.set_step_statu(message::eWaiting);
+
+    message::Confirm_space_step_statu   confirm_step;
+    confirm_step.set_step_statu(message::eWaiting);
+
+    message::Release_space_step_statu   release_step;
+    release_step.set_step_statu(message::eWaiting);
+
+    m_storing_process_statu_msg.mutable_alloc_space_step()->CopyFrom(alloc_step);
+    m_storing_process_statu_msg.mutable_measure_step()->CopyFrom(measure_step);
+    m_storing_process_statu_msg.mutable_dispatch_step()->CopyFrom(store_step);
+    m_storing_process_statu_msg.mutable_confirm_space_step()->CopyFrom(confirm_step);
+    m_storing_process_statu_msg.mutable_failed_release_space_step()->CopyFrom(release_step);
+
+}
+
+/*
+     * 检查当前任务是否处于空闲准备状态
+     */
+bool StoreProcessTask::is_ready()
+{
+    bool cond_alloc_space = m_storing_process_statu_msg.alloc_space_step().step_statu()==message::eWaiting
+                            ||m_storing_process_statu_msg.alloc_space_step().step_statu()==message::eComplete;
+    bool cond_measure = m_storing_process_statu_msg.measure_step().step_statu()==message::eWaiting
+                            ||m_storing_process_statu_msg.measure_step().step_statu()==message::eComplete;
+    bool cond_dispatch = m_storing_process_statu_msg.dispatch_step().step_statu()==message::eWaiting
+                            ||m_storing_process_statu_msg.dispatch_step().step_statu()==message::eComplete;
+    bool cond_confirm_space = m_storing_process_statu_msg.confirm_space_step().step_statu()==message::eWaiting
+                            ||m_storing_process_statu_msg.confirm_space_step().step_statu()==message::eComplete;
+    bool cond_release_space = m_storing_process_statu_msg.failed_release_space_step().step_statu()==message::eWaiting
+                            ||m_storing_process_statu_msg.failed_release_space_step().step_statu()==message::eComplete;
+    return cond_alloc_space && cond_measure && cond_dispatch && cond_confirm_space && cond_release_space;
+}
+
 /*
      * 分配车位
      */
 Error_manager StoreProcessTask::alloc_space()
 {
+    //更新车位分配步骤状态
+    m_storing_process_statu_msg.mutable_alloc_space_step()->mutable_car_info()->CopyFrom(m_locate_info);
+    m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eWorking);
+
     /*
      * 检查是否有测量数据
      */
     if(m_locate_info.has_locate_height()==false||m_locate_info.has_locate_width()==false)
     {
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_description("停车请求缺少车辆高度和宽度信息");
         return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
     }
     /*
@@ -125,8 +209,13 @@ Error_manager StoreProcessTask::alloc_space()
      */
     Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
     if(code!=SUCCESS)
+    {
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_description(code.get_error_description());
         return code;
+    }
 
+    //发送分配请求
     message::Parkspace_allocation_request_msg request;
     message::Base_info base_info;
     base_info.set_msg_type(message::eParkspace_allocation_request_msg);
@@ -142,19 +231,23 @@ Error_manager StoreProcessTask::alloc_space()
 
     code=Parkspace_communicator::get_instance_pointer()->alloc_request(request,m_parcspace_alloc_response_msg);
     if(code!=SUCCESS)
+    {
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_description(code.get_error_description());
         return code;
+    }
 
     if(m_parcspace_alloc_response_msg.error_manager().error_code()==0)
     {
-        /*LOG(INFO)<<"分配车位成功,停车终端:"<<m_terminor_id
-            <<", 指令id:"<<m_command_id
-            <<", 车位楼层:"<<m_parcspace_alloc_response_msg.allocated_space_info().floor()
-            <<", 车位序号:"<<m_parcspace_alloc_response_msg.allocated_space_info().index()
-            <<", 车牌号:"<<m_parcspace_alloc_response_msg.allocated_space_info().car_info().license();*/
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eComplete);
         return SUCCESS;
     }
     else
-        return Error_manager(FAILED,MINOR_ERROR,"parkspace alloc response error_code error");
+    {
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_step_statu(message::eError);
+        m_storing_process_statu_msg.mutable_alloc_space_step()->set_description("分配车位反馈结果错误");
+        return Error_manager(FAILED,MINOR_ERROR,"分配车位反馈结果错误");
+    }
 }
 
 /*
@@ -270,7 +363,6 @@ void StoreProcessTask::Main()
      * 外部已经分配好车位,进入到此流程说明车位已经分配好, 存放在 m_parcspace_alloc_response_msg
      */
     Error_manager code;
-    Command_manager::get_instance_pointer()->updata_store_entrance_statu(m_terminor_id,message::eWorking);
     //开始执行停车指令
     //第一步测量
     switch (0)
@@ -278,38 +370,61 @@ void StoreProcessTask::Main()
         //第一步,测量
         case 0:
         {
+            //更新状态信息
+            m_storing_process_statu_msg.mutable_measure_step()->set_step_statu(message::eWorking);
+            //开始定位
             code=locate_step();
             if(code!=SUCCESS)
             {
-                LOG(ERROR)<<"测量失败:"<<code.to_string();
+                m_storing_process_statu_msg.mutable_measure_step()->set_step_statu(message::eError);
+                m_storing_process_statu_msg.mutable_measure_step()->set_description(code.get_error_description());
+                LOG(ERROR)<<"测量失败:"<<code.get_error_description();
                 break;
             }
+            //更新状态信息
+            m_storing_process_statu_msg.mutable_measure_step()->mutable_locate_info()->CopyFrom(m_measure_response_msg.locate_information());
+            m_storing_process_statu_msg.mutable_measure_step()->set_step_statu(message::eComplete);
         }
         //第二步,调度
         case 1:
         {
+            //更新状态信息
+            m_storing_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eWorking);
+            m_storing_process_statu_msg.mutable_dispatch_step()->mutable_locate_info()->CopyFrom(m_measure_response_msg.locate_information());
+            m_storing_process_statu_msg.mutable_dispatch_step()->mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
+            //开始调度
             code=dispatch_step();
             if(code!=SUCCESS)
             {
-                LOG(ERROR)<<"调度失败:"<<code.to_string();
+                m_storing_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eError);
+                m_storing_process_statu_msg.mutable_dispatch_step()->set_description(code.get_error_description());
+                LOG(ERROR)<<"调度失败:"<<code.get_error_description();
                 break;
             }
+            //更新状态信息
+            m_storing_process_statu_msg.mutable_dispatch_step()->set_step_statu(message::eComplete);
         }
         //第三步,占据车位
         case 2:
         {
-            ////
+            //更新状态信息
+            m_storing_process_statu_msg.mutable_confirm_space_step()->set_step_statu(message::eWorking);
+            m_storing_process_statu_msg.mutable_confirm_space_step()->mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
+            //开始工作
             code=confirm_space_step();
             if(code!=SUCCESS)
             {
-                LOG(ERROR)<<"停车流程:"<<code.to_string();
+                m_storing_process_statu_msg.mutable_confirm_space_step()->set_step_statu(message::eError);
+                m_storing_process_statu_msg.mutable_confirm_space_step()->set_description(code.get_error_description());
+                LOG(ERROR)<<"停车流程:"<<code.get_error_description();
                 break;
             }
+            //更新状态信息
+            m_storing_process_statu_msg.mutable_confirm_space_step()->set_step_statu(message::eComplete);
         }
-        //第四步,更新状态
+        //第四步,打印...  日志 .... 记录.....
         case 3:
         {
-            Command_manager::get_instance_pointer()->updata_store_entrance_statu(m_terminor_id,message::eReady);
             LOG(INFO)<<"停车成功,停车终端:"<<m_terminor_id<<"指令id:"<<m_command_id
                      <<", 车位id:"<<m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()
                      <<", 车位楼层:"<<m_parcspace_alloc_response_msg.allocated_space_info().floor()
@@ -325,17 +440,50 @@ void StoreProcessTask::Main()
      */
 
     //失败,清理车位
+    m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eWorking);
     code=release_space_step();
     if(code!=SUCCESS)
     {
-        LOG(ERROR)<<"致命故障,停车失败,清理车位故障:"<<code.to_string();
-        /*
-         * 此处应暂停系统,待管理员介入
-         */
+        m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eError);
+        m_storing_process_statu_msg.mutable_failed_release_space_step()->set_description(code.get_error_description());
+        LOG(ERROR)<<"致命故障,停车失败,清理车位故障:"<<code.get_error_description();
+
+    }
+    else
+    {
+        m_storing_process_statu_msg.mutable_failed_release_space_step()->set_step_statu(message::eComplete);
     }
+    /*
+    *   流程异常,此处应暂停系统,待管理员介入
+    */
+}
 
-    //更新状态
-    Command_manager::get_instance_pointer()->updata_store_entrance_statu(m_terminor_id,message::eReady);
+/*
+ * 发布状态线程
+ */
+void StoreProcessTask::publish_thread_func(StoreProcessTask* ptask)
+{
+    if(ptask)
+    {
+        ptask->publish_step_status();
+    }
+}
+void StoreProcessTask::publish_step_status()
+{
+    //未收到退出信号
+    while(false==m_publish_exit_condition.wait_for_ex(std::chrono::milliseconds(200)))
+    {
+        /*
+         * 通过communicator 发布状态
+         */
+        if(System_communicator::get_instance_pointer())
+        {
+            if(m_storing_process_statu_msg.has_base_info()==true)
+            {
+                System_communicator::get_instance_pointer()->post_entrance_statu(m_storing_process_statu_msg);
+            }
 
+        }
 
+    }
 }

+ 24 - 5
system/StoreProcessTask.h

@@ -9,20 +9,25 @@
 #include "dispatch_communicator.h"
 #include "TaskQueue/BaseTask.h"
 #include "Locate_communicator.h"
+#include "process_message.pb.h"
 
 class StoreProcessTask :public tq::BaseTask{
 public:
-    StoreProcessTask();
+    StoreProcessTask(unsigned int command_id);
     virtual  ~StoreProcessTask();
-    Error_manager init_task(unsigned int command_id, unsigned int terminor_id,
+    Error_manager init_task(unsigned int terminor_id,
             message::Locate_information locate_info,message::Car_info car_info);
 
+    /*
+     * 检查当前任务是否处于空闲准备状态
+     */
+    bool is_ready();
+
     /*
      * 分配车位
      */
     Error_manager alloc_space();
 
-
 protected:
     virtual void Main();
 
@@ -46,6 +51,17 @@ protected:
     */
     Error_manager release_space_step();
 
+    /*
+     * reset 进度信息
+     */
+    void reset_process_statu();
+
+    /*
+     * 发布进度
+     */
+    static void publish_thread_func(StoreProcessTask* p_commander);
+    void publish_step_status();
+
 protected:
     unsigned int                m_command_id;
     unsigned int                m_terminor_id;
@@ -60,8 +76,11 @@ protected:
 
     message::Dispatch_response_msg                  m_dispatch_response_msg;        //调度模块的反馈数据
 
-public:
-    bool                        mb_completed;
+    message::Storing_process_statu_msg              m_storing_process_statu_msg;    //停车流程进度信息
+
+private:
+    std::thread*                    m_publish_statu_thread;             //广播状态线程
+    Thread_condition				m_publish_exit_condition;			//发送的条件变量
 
 };
 

+ 85 - 109
system/command_manager.cpp

@@ -2,14 +2,14 @@
 // Created by zx on 2020/7/14.
 //
 
+#include <Parkspace_communicator.h>
 #include "command_manager.h"
 #include "StoreProcessTask.h"
 #include "PickupProcessTask.h"
 #include "system_communicator.h"
 
 Command_manager::Command_manager()
-    :m_publish_statu_thread(nullptr)
-    ,m_thread_queue_process(nullptr)
+    :m_thread_queue_process(nullptr)
 {
 
 }
@@ -22,18 +22,6 @@ Command_manager::~Command_manager()
         m_thread_queue_process->Stop();
     }
 
-    //退出线程
-    m_publish_exit_condition.set_pass_ever(true);
-    if(m_publish_statu_thread!= nullptr)
-    {
-        if(m_publish_statu_thread->joinable())
-        {
-            m_publish_statu_thread->join();
-        }
-        delete m_publish_statu_thread;
-        m_publish_statu_thread=nullptr;
-    }
-
 }
 
 Error_manager Command_manager::init()
@@ -45,12 +33,6 @@ Error_manager Command_manager::init()
         m_thread_queue_process->Start(12);
     }
 
-    m_publish_exit_condition.reset(false, false, false);
-    ///创建状态发布线程
-    if(m_publish_statu_thread== nullptr)
-    {
-        m_publish_statu_thread=new std::thread(publish_thread_func,this);
-    }
     return SUCCESS;
 }
 
@@ -59,7 +41,8 @@ Error_manager Command_manager::init()
  */
 Error_manager Command_manager::execute_store_command(message::Store_command_request_msg& request,message::Store_command_response_msg& response)
 {
-    if(m_publish_statu_thread==nullptr)
+
+    if(m_thread_queue_process==nullptr)
     {
         return Error_manager(ERROR,CRITICAL_ERROR,"线程池未初始化,bug");
     }
@@ -78,6 +61,9 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
                        &&locate_info.has_locate_x()&&locate_info.has_locate_y()
                        &&locate_info.has_locate_angle()&&locate_info.has_locate_wheel_base())
                     {
+                        /*
+                         * 检查消息完毕,开始处理
+                         */
                         message::Base_info base_info;
                         base_info.set_msg_type(message::eStore_command_response_msg);
                         base_info.set_sender(message::eMain);
@@ -88,17 +74,51 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
                         message::Error_manager error_msg;
                         error_msg.set_error_code(0);
 
-                        StoreProcessTask* task=new StoreProcessTask();
+                        /*
+                        * 检查各个节点是否正常
+                        */
+                        Error_manager parkspace_code= Parkspace_communicator::get_instance_pointer()->check_statu();
+                        if(parkspace_code!=SUCCESS)
+                        {
+                            error_msg.set_error_code(parkspace_code.get_error_code());
+                            error_msg.set_error_description(parkspace_code.get_error_description());
+                            response.mutable_code()->CopyFrom(error_msg);
+                            return parkspace_code;
+                        }
+                        Error_manager locate_code= Locate_communicator::get_instance_pointer()->check_statu();
+                        if(locate_code!=SUCCESS)
+                        {
+                            error_msg.set_error_code(locate_code.get_error_code());
+                            error_msg.set_error_description(locate_code.get_error_description());
+                            response.mutable_code()->CopyFrom(error_msg);
+                            return locate_code;
+                        }
+                        Error_manager dispatch_code= Dispatch_communicator::get_instance_pointer()->check_statu();
+                        if(dispatch_code!=SUCCESS)
+                        {
+                            error_msg.set_error_code(dispatch_code.get_error_code());
+                            error_msg.set_error_description(dispatch_code.get_error_description());
+                            response.mutable_code()->CopyFrom(error_msg);
+                            return dispatch_code;
+                        }
+
+                        //一切正常,接受指令
                         int command_id=request.terminal_id()+10000;
+                        tq::BaseTask* ptask;
+                        if(false==m_store_command_task_map.find(request.terminal_id(),ptask))
+                        {
+                            ptask=new StoreProcessTask(request.terminal_id());
+                            m_store_command_task_map[request.terminal_id()]=ptask;
+                        }
+                        StoreProcessTask* pStore_task=(StoreProcessTask*)ptask;
                         //初始化流程
-                        task->init_task(command_id,request.terminal_id(),locate_info,request.car_info());
+                        pStore_task->init_task(command_id,locate_info,request.car_info());
+
                         //获取车位
-                        Error_manager code=task->alloc_space();
+                        Error_manager code=pStore_task->alloc_space();
                         if(code==SUCCESS)
                         {
-                            //更新状态
-                            Command_manager::get_instance_pointer()->updata_store_entrance_statu(request.terminal_id(),message::eWorking);
-                            m_thread_queue_process->AddTask(task);
+                            m_thread_queue_process->AddTask(pStore_task);
                             response.mutable_code()->CopyFrom(error_msg);
                             return SUCCESS;
 
@@ -129,7 +149,8 @@ Error_manager Command_manager::execute_store_command(message::Store_command_requ
  */
 Error_manager Command_manager::execute_pickup_command(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response)
 {
-    if(m_publish_statu_thread==nullptr)
+
+    if(m_thread_queue_process==nullptr)
     {
         return Error_manager(ERROR,CRITICAL_ERROR,"线程池未初始化,bug");
     }
@@ -145,20 +166,48 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
         response.mutable_base_info()->CopyFrom(baseInfo);
         response.set_terminal_id(request.terminal_id());
 
+        message::Error_manager error_msg;
+        error_msg.set_error_code(0);
+
+        /*
+        * 检查各个节点是否正常
+        */
+        Error_manager parkspace_code= Parkspace_communicator::get_instance_pointer()->check_statu();
+        if(parkspace_code!=SUCCESS)
+        {
+            error_msg.set_error_code(parkspace_code.get_error_code());
+            error_msg.set_error_description(parkspace_code.get_error_description());
+            response.mutable_code()->CopyFrom(error_msg);
+            return parkspace_code;
+        }
+
+        Error_manager dispatch_code= Dispatch_communicator::get_instance_pointer()->check_statu();
+        if(dispatch_code!=SUCCESS)
+        {
+            error_msg.set_error_code(dispatch_code.get_error_code());
+            error_msg.set_error_description(dispatch_code.get_error_description());
+            response.mutable_code()->CopyFrom(error_msg);
+            return dispatch_code;
+        }
+
+        //一切正常,接受指令
         Error_manager code;
-        PickupProcessTask *task = new PickupProcessTask();
         int command_id = request.terminal_id()+20000;
+        tq::BaseTask* ptask;
+        if(false==m_pick_command_task_map.find(request.terminal_id(),ptask))
+        {
+            ptask=new PickupProcessTask(request.terminal_id());
+            m_pick_command_task_map[request.terminal_id()]=ptask;
+        }
+        PickupProcessTask* pPick_task=(PickupProcessTask*)ptask;
         //初始化流程
-        task->init_task(command_id, request.terminal_id(), request.car_info());
+        pPick_task->init_task(command_id, request.car_info());
         /////查询车位
-        code=task->search_space();
-        message::Error_manager error_msg;
-        error_msg.set_error_code(0);
+        code=pPick_task->search_space();
+
         if(code==SUCCESS)
         {
-            //更新状态
-            Command_manager::get_instance_pointer()->updata_pickup_entrance_statu(request.terminal_id(),message::eWorking);
-            m_thread_queue_process->AddTask(task);
+            m_thread_queue_process->AddTask(pPick_task);
             response.mutable_code()->CopyFrom(error_msg);
             return SUCCESS;
         }
@@ -174,76 +223,3 @@ Error_manager Command_manager::execute_pickup_command(message::Pickup_command_re
         return Error_manager(INVALID_MESSAGE,MAJOR_ERROR,"停车请求信息错误");
     }
 }
-
-/*
-     * 更新状态
-     */
-void Command_manager::updata_store_entrance_statu(int command_id,message::Entrance_statu  msg)
-{
-    if(command_id<0 || command_id>100)
-        return;
-    ///
-    std::lock_guard<std::mutex> lk(m_entrance_msg_lock);
-    auto it=m_entrance_status.mutable_store_msg_map()->find(command_id);
-    if(it==m_entrance_status.mutable_store_msg_map()->end())
-    {
-        m_entrance_status.mutable_store_msg_map()->insert(google::protobuf::MapPair<int,message::Entrance_statu >(command_id,msg));
-    }
-    else
-    {
-        it->second=msg;
-    }
-    //立刻发送
-    System_communicator::get_instance_pointer()->send_entrance_statu(m_entrance_status);
-}
-void Command_manager::updata_pickup_entrance_statu(int command_id,message::Entrance_statu statu)
-{
-    if(command_id<0 || command_id>100)
-        return;
-    ///
-    std::lock_guard<std::mutex> lk(m_entrance_msg_lock);
-    auto it=m_entrance_status.mutable_pickup_msg_map()->find(command_id);
-    if(it==m_entrance_status.mutable_pickup_msg_map()->end())
-    {
-        m_entrance_status.mutable_pickup_msg_map()->insert(google::protobuf::MapPair<int,message::Entrance_statu>(command_id,statu));
-    }
-    else
-    {
-        it->second=statu;
-    }
-    System_communicator::get_instance_pointer()->send_entrance_statu(m_entrance_status);
-}
-
-/*
- * 发布状态线程
- */
-void Command_manager::publish_thread_func(Command_manager* p_commander)
-{
-    if(p_commander)
-    {
-        p_commander->publish_status();
-    }
-}
-void Command_manager::publish_status()
-{
-    //未收到退出信号
-    while(false==m_publish_exit_condition.wait_for_ex(std::chrono::milliseconds(100)))
-    {
-        /*
-         * 通过communicator 发布状态
-         */
-        if(System_communicator::get_instance_pointer())
-        {
-            if(m_entrance_status.has_base_info()==false)
-            {
-                message::Base_info baseInfo;
-                baseInfo.set_msg_type(message::eEntrance_statu_msg);
-                baseInfo.set_sender(message::eMain);
-                baseInfo.set_receiver(message::eEmpty); //所有对象都可接收
-                m_entrance_status.mutable_base_info()->CopyFrom(baseInfo);
-            }
-            System_communicator::get_instance_pointer()->send_entrance_statu(m_entrance_status);
-        }
-
-    }
-}

+ 7 - 14
system/command_manager.h

@@ -10,12 +10,13 @@
 
 #include <error_code.h>
 #include <terminal_message.pb.h>
-#include <thread>
 #include <communication_message.h>
 #include "thread_condition.h"
 #include "singleton.h"
 #include "TaskQueue/TQFactory.h"
+#include "TaskQueue/BaseTask.h"
 #include "process_message.pb.h"
+#include "thread_safe_map.h"
 
 class Command_manager :public Singleton<Command_manager>{
     friend Singleton<Command_manager>;
@@ -37,24 +38,16 @@ public:
      */
     Error_manager execute_pickup_command(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response);
 
-    /*
-     * 更新状态
-     */
-    void updata_store_entrance_statu(int command_id,message::Entrance_statu statu);
-    void updata_pickup_entrance_statu(int command_id,message::Entrance_statu statu);
 private:
     Command_manager();
 
-    static void publish_thread_func(Command_manager* p_commander);
-    void publish_status();
-
 protected:
-    std::thread*                    m_publish_statu_thread;             //广播状态线程
-    Thread_condition				m_publish_exit_condition;			//发送的条件变量
-
-    std::mutex                                                      m_entrance_msg_lock;
-    message::Entrance_statu_msg                                     m_entrance_status;                 //出入口状态
 
+    /*
+     * 停取车终端 map,key值为终端编号,value为终端指令执行器task,可放入线程池执行流程
+     */
+    thread_safe_map<int,tq::BaseTask*>                              m_store_command_task_map;
+    thread_safe_map<int,tq::BaseTask*>                              m_pick_command_task_map;
 
     tq::IQueue*                     m_thread_queue_process;         //指令流程线程池
 };

+ 16 - 3
system/system_communicator.cpp

@@ -21,12 +21,21 @@ Error_manager System_communicator::encapsulate_send_data()
 	return Error_code::SUCCESS;
 }
 
-Error_manager System_communicator::send_entrance_statu(message::Entrance_statu_msg& msg)
+//发送停车流程进度
+Error_manager System_communicator::post_entrance_statu(message::Storing_process_statu_msg& msg)
 {
     Communication_message message;
     message.reset(msg.base_info(),msg.SerializeAsString());
     return encapsulate_msg(&message);
 }
+//发送取车流程进度
+Error_manager System_communicator::post_entrance_statu(message::Picking_process_statu_msg& msg)
+{
+    Communication_message message;
+    message.reset(msg.base_info(),msg.SerializeAsString());
+    return encapsulate_msg(&message);
+}
+
 
 /*
  * 发送消息函数
@@ -59,6 +68,8 @@ Error_manager System_communicator::execute_msg(Communication_message* p_msg)
     /*
      * 接收终端指令, 生成流程
      */
+    Error_manager code;
+
     switch(p_msg->get_message_type())
     {
 
@@ -74,7 +85,8 @@ Error_manager System_communicator::execute_msg(Communication_message* p_msg)
                 }
                 message::Store_command_response_msg response;
 
-                Command_manager::get_instance_pointer()->execute_store_command(request,response);
+                code=Command_manager::get_instance_pointer()->execute_store_command(request,response);
+                LOG_IF(ERROR,code!=SUCCESS)<<code.get_error_description();
                 Communication_message send_response;
                 send_response.reset(response.base_info(),response.SerializeAsString());
                 //发送反馈
@@ -95,7 +107,8 @@ Error_manager System_communicator::execute_msg(Communication_message* p_msg)
                 }
                 message::Pickup_command_response_msg response;
                 //调用请求回调,无需判断返回值,错误信息保存在response中
-                Command_manager::get_instance_pointer()->execute_pickup_command(request,response);
+                code=Command_manager::get_instance_pointer()->execute_pickup_command(request,response);
+                LOG_IF(ERROR,code!=SUCCESS)<<code.get_error_description();
                 Communication_message send_response;
                 send_response.reset(response.base_info(),response.SerializeAsString());
                 //发送反馈

+ 2 - 1
system/system_communicator.h

@@ -25,7 +25,8 @@ public:
     System_communicator(const System_communicator& other) = delete;
     System_communicator& operator =(const System_communicator& other) = delete;
 
-    Error_manager send_entrance_statu(message::Entrance_statu_msg& msg);
+    Error_manager post_entrance_statu(message::Storing_process_statu_msg& msg);
+    Error_manager post_entrance_statu(message::Picking_process_statu_msg& msg);
     ~System_communicator();
 
 protected:

+ 18 - 47
test/Terminal_communication.cpp

@@ -83,17 +83,31 @@ Error_manager Terminal_communication::execute_msg(Communication_message* p_msg)
         }
     }
 
-    if(p_msg->get_message_type()==Communication_message::eEntrance_statu_msg)
+    if(p_msg->get_message_type()==Communication_message::eStoring_process_statu_msg)
     {
-        message::Entrance_statu_msg msg;
+        message::Storing_process_statu_msg msg;
         if(msg.ParseFromString(p_msg->get_message_buf())==false)
         {
-            std::cout<<" ERROR 解析Entrance_statu_msg 失败"<<std::endl;
+            std::cout<<" ERROR : Storing_process_statu_msg 失败"<<std::endl;
         }
         message::Base_info base_info=msg.base_info();
         if(base_info.sender()==message::eMain)
         {
-            m_entrance_status=msg;
+            //m_entrance_status=msg;
+        }
+    }
+
+    if(p_msg->get_message_type()==Communication_message::ePicking_process_statu_msg)
+    {
+        message::Picking_process_statu_msg msg;
+        if(msg.ParseFromString(p_msg->get_message_buf())==false)
+        {
+            std::cout<<" ERROR : Picking_process_statu_msg 失败"<<std::endl;
+        }
+        message::Base_info base_info=msg.base_info();
+        if(base_info.sender()==message::eMain)
+        {
+            //m_entrance_status=msg;
         }
     }
 
@@ -252,46 +266,3 @@ Error_manager Terminal_communication::pickup_request(message::Pickup_command_req
     return Error_manager(RESPONSE_TIMEOUT,MINOR_ERROR,"parkspace release request timeout");
 
 }
-
-
-/*
-    * 检查入口完成状态
-    */
-Error_manager Terminal_communication::check_store_entrance_statu(int terminal_id,message::Entrance_statu& statu)
-{
-    std::lock_guard<std::mutex> lk(m_statu_lock);
-    if(m_entrance_status.has_base_info()==false)
-        return ERROR;
-    auto map=m_entrance_status.store_msg_map();
-    auto it=map.find(terminal_id);
-    if(it==map.end())
-    {
-        return ERROR;
-    }
-    else
-    {
-        statu=it->second;
-        return SUCCESS;
-    }
-}
-
-/*
- * 检查出口完成状态
- */
-Error_manager Terminal_communication::check_pickup_entrance_statu(int terminal_id,message::Entrance_statu& statu)
-{
-    std::lock_guard<std::mutex> lk(m_statu_lock);
-    if(m_entrance_status.has_base_info()==false)
-        return ERROR;
-    auto map=m_entrance_status.pickup_msg_map();
-    auto it=map.find(terminal_id);
-    if(it==map.end())
-    {
-        return ERROR;
-    }
-    else
-    {
-        statu=it->second;
-        return SUCCESS;
-    }
-}

+ 0 - 11
test/Terminal_communication.h

@@ -38,15 +38,6 @@ public:
      */
     Error_manager pickup_request(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response);
 
-    /*
-     * 检查入口完成状态
-     */
-    Error_manager check_store_entrance_statu(int terminal_id,message::Entrance_statu& statu);
-
-    /*
-     * 检查出口完成状态
-     */
-    Error_manager check_pickup_entrance_statu(int terminal_id,message::Entrance_statu& statu);
 
 protected:
     //重载函数
@@ -68,8 +59,6 @@ private:
     message::Pickup_command_response_msg            m_pickup_response_msg;
     int                                             m_terminal_id;
 
-    std::mutex                                      m_statu_lock;
-    message::Entrance_statu_msg                     m_entrance_status;
 
 
 };

+ 2 - 2
test/pickup_terminal.cpp

@@ -54,7 +54,7 @@ Error_manager pickup_terminal::pickup(message::Car_info& car_info)
         return ERROR;
     }
     //等待停车完成
-    message::Entrance_statu statu;
+    /*message::Entrance_statu statu;
     while(m_exit_cond.wait_for_millisecond(200)==false)
     {
         code = Terminal_communication::get_instance_pointer()->check_pickup_entrance_statu(m_terminal_id, statu);
@@ -65,7 +65,7 @@ Error_manager pickup_terminal::pickup(message::Car_info& car_info)
         if (statu == message::eReady) {
             return SUCCESS;
         }
-    }
+    }*/
     return FAILED;
 }
 

+ 5 - 5
test/store_terminal.cpp

@@ -64,10 +64,10 @@ Error_manager store_terminal::storing(message::Car_info& car_info)
     }
     usleep(1000*100);
     //等待停车完成
-    message::Entrance_statu statu;
+
     while(m_exit_cond.wait_for_millisecond(200)==false) {
 
-        code = Terminal_communication::get_instance_pointer()->check_store_entrance_statu(m_terminal_id, statu);
+        /*code = Terminal_communication::get_instance_pointer()->check_store_entrance_statu(m_terminal_id, statu);
         if (code != SUCCESS) {
             continue;
         }
@@ -75,7 +75,7 @@ Error_manager store_terminal::storing(message::Car_info& car_info)
             if (m_thread_safe_output_queue)
                 m_thread_safe_output_queue->push(car_info);
             return SUCCESS;
-        }
+        }*/
     }
     return FAILED;
 }
@@ -92,11 +92,11 @@ void store_terminal::storing_thread(store_terminal* pStore)
         if(pStore->m_thread_safe_queue->try_pop(car_info)==true)
         {
             if(pStore->storing(car_info)==SUCCESS)
-                LOG(INFO)<<"停车终端:"<<pStore->m_terminal_id<<",车辆:"<<car_info.license().c_str()<<",已经停车完成,剩余in:"
+                LOG(INFO)<<"停车终端:"<<pStore->m_terminal_id<<",车辆:"<<car_info.license().c_str()<<",停车完成,剩余in:"
                 <<pStore->m_thread_safe_queue->size();
             else
             {
-                LOG(ERROR)<<"停车终端:"<<pStore->m_terminal_id<<",车辆:"<<car_info.license().c_str()<<",已经停车失败,剩余in:"
+                LOG(ERROR)<<"停车终端:"<<pStore->m_terminal_id<<",车辆:"<<car_info.license().c_str()<<",停车失败,剩余in:"
                          <<pStore->m_thread_safe_queue->size();
             }
         }

+ 16 - 7
test/terminal_client.cpp

@@ -79,14 +79,14 @@ void init_glog()
 
 int main() {
     init_glog();
-    Terminal_communication::get_instance_pointer()->communication_connect("tcp://127.0.0.1:9001");
+    Terminal_communication::get_instance_pointer()->communication_connect("tcp://192.168.0.203:30001");
     Terminal_communication::get_instance_pointer()->communication_run();
     usleep(2000*1000);
     threadsafe_queue<message::Car_info> input_queue;
     threadsafe_queue<message::Car_info> output_queue;
 
     const int n_input=1;
-    const int n_output=2;
+    const int n_output=1;
     std::vector<store_terminal*> input_terminals;
     std::vector<pickup_terminal*> output_terminals;
     for(int i=0;i<n_input;++i)
@@ -106,7 +106,8 @@ int main() {
     int n = 0;
     bool run = true;
     Error_manager code;
-    while (run) {
+    char c=0;
+    while (c!='q') {
 
         int license_id = rand() % 90000 + 10000;
         char C=rand()%10+'A';
@@ -119,13 +120,21 @@ int main() {
         input_queue.push(car_info);
        // std::cout<<" input : "<<++n<<std::endl;
 
+        n++;
+
         int in_count=input_queue.size();
         int out_count=output_queue.size();
 
-        //暂停 5-15s 代替
-        int delay=10*1000;//in_count*200;
-        usleep(1000*delay+1);
-        std::this_thread::yield();
+        if(n%20==0 && n!=0) {
+            std::cout<<"输入 q 退出,其他继续";
+            std::cin >> c;
+        }
+        else {
+            //暂停 5-15s 代替
+            int delay=10*1000;//in_count*200;
+            usleep(1000*delay+1);
+            std::this_thread::yield();
+        }
     }
 }
 

+ 1 - 1
tool/TaskQueue/ThreadTaskQueue.cpp

@@ -257,7 +257,7 @@ namespace tq{
             _recyclerMutex.unlock();
         }
         //禁止析构
-        delete task;
+        //delete task;
 
     }