Browse Source

fix(driver_grpc_BS):turnstile recognization test and fix some mistake

fujiankuan 3 years ago
parent
commit
f21fceb3aa

+ 1 - 1
src/driver/driver_cloud_grpc_client_BS/main.cpp

@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
 
 //    std::cout<<patrol_str<<std::endl;
     VehiclePatrolExceptionClient vehiclepatrol(grpc::CreateChannel(patrol_str, grpc::InsecureChannelCredentials()));
-//    vehiclepatrol.start();
+    vehiclepatrol.start();
 
     return a.exec();
 }

+ 15 - 7
src/driver/driver_cloud_grpc_client_BS/vehicle_patrol.cpp

@@ -230,12 +230,14 @@ void VehiclePatrolExceptionClient::ListenTurnstileMsg(const char * strdata,const
 
     if(statusTSGM == 1)
     {
+        std::cout<<"Get Turnstile result"<<std::endl;
         //set TSGM resul
         isTSGM = true;
         if(xdata.state() == false)
             gateStatus = 1; //0 no gate 1 gate close 2 gate open
         else
             gateStatus = 2;
+        std::cout<<"gateStatus : "<<(int)gateStatus<<std::endl;
         gateImage.clear();
         gateImage.append(xdata.pic().picdata().data(),xdata.pic().picdata().size());
         gateTime = QDateTime::currentMSecsSinceEpoch(); //time when get gateImage
@@ -364,8 +366,12 @@ void VehiclePatrolExceptionClient::run()
     xTime.start();
     int lastTime = xTime.elapsed();
     uint64_t interval = std::atoi(gstrpatrolInterval.c_str());
+    org::jeecg::defsPatrol::grpc::GPSPoint tempPosition;
     //set isNeedTSGM
+    isNeedTSGM = true;
     //set gateDestination
+    gateDestination.set_latitude(39.0665855);
+    gateDestination.set_longitude(117.3554362);
     timerTSGM.start();
     while (!QThread::isInterruptionRequested())
     {
@@ -373,7 +379,6 @@ void VehiclePatrolExceptionClient::run()
         {
             // do something
             mutex_GPSIMU.lock();
-            org::jeecg::defsPatrol::grpc::GPSPoint tempPosition;
             tempPosition.CopyFrom(currentPosition);
             double tempSpeed = currentSpeed;
             mutex_GPSIMU.unlock();
@@ -382,10 +387,11 @@ void VehiclePatrolExceptionClient::run()
             {
                 if(tempSpeed < 0.1 && statusTSGM == 0 && isNeedTSGM == true)
                 {
+                    std::cout<<"Send startTurnstile"<<std::endl;
                     iv::vision::startturnstile xmsg;
 
                     xmsg.set_time(QDateTime::currentMSecsSinceEpoch());
-                    xmsg.set_cameraname(shmPicLeft.mstrmsgname);
+                    xmsg.set_cameraname(shmPicRight.mstrmsgname);
                     xmsg.set_start(true);
 
                     int ndatasize = xmsg.ByteSize();
@@ -402,9 +408,10 @@ void VehiclePatrolExceptionClient::run()
                 }
             }
 
-            if(statusTSGM == 1 && timerTSGM.elapsed() > 60000)
+            if(statusTSGM == 1 && timerTSGM.elapsed() > 80000)
             {
                 //timeout
+                std::cout<<"Turnstile timeout"<<std::endl;
                 iv::vision::startturnstile xmsg;
 
                 xmsg.set_time(QDateTime::currentMSecsSinceEpoch());
@@ -435,8 +442,9 @@ void VehiclePatrolExceptionClient::run()
 
             if(statusTSGM == 2 || statusTSGM == 3)
             {
-                if(fabs(tempPosition.latitude()-gateDestination.latitude()) > 0.0001 && fabs(tempPosition.longitude()-gateDestination.longitude()) > 0.0001)
+                if(fabs(tempPosition.latitude()-gateDestination.latitude()) > 0.0001 || fabs(tempPosition.longitude()-gateDestination.longitude()) > 0.0001)
                 {
+                    std::cout<<"Turnstile detect finish"<<std::endl;
                     iv::vision::startturnstile xmsg;
 
                     xmsg.set_time(QDateTime::currentMSecsSinceEpoch());
@@ -459,9 +467,9 @@ void VehiclePatrolExceptionClient::run()
             }
 
 
-            updatePatrolData();
-            std::string reply = uploadVehiclePatrolInfo();
-            std::cout<< reply <<std::endl;
+//            updatePatrolData();
+//            std::string reply = uploadVehiclePatrolInfo();
+//            std::cout<< reply <<std::endl;
             lastTime = xTime.elapsed();
         }
     }