Browse Source

change driver_cloud_grpc_thread. add skip setting.

yuchuli 3 years ago
parent
commit
d494ac6218

+ 0 - 1
src/driver/driver_cloud_grpc_thread/driver_cloud_grpc_thread.pro

@@ -57,4 +57,3 @@ HEADERS += \
     ../../include/msgtype/uploadthreadmsg.pb.h \
     grpcclient.h \
     uploadthreadmsg.grpc.pb.h
-

+ 1 - 0
src/driver/driver_cloud_grpc_thread/driver_cloud_grpc_thread.yaml

@@ -1,6 +1,7 @@
 server : 47.96.250.93
 port : 50051
 uploadinterval : 100
+skip : 2  # 1 no skip 2 skip 50%  3 skip %66
 
 VIN : AAAAAAAAAAAAAAAAA
 queryMD5 : 5d41402abc4b2a76b9719d911017c592

+ 34 - 3
src/driver/driver_cloud_grpc_thread/grpcclient.cpp

@@ -20,6 +20,7 @@ grpcclient::grpcclient(std::string stryamlpath)
     ggrpcclient = this;
     dec_yaml(stryamlpath.data());
 
+
     mstrpicmsgname[0] = "picfront";
     mstrpicmsgname[1] = "picrear";
     mstrpicmsgname[2] = "picleft";
@@ -52,6 +53,11 @@ grpcclient::grpcclient(std::string stryamlpath)
         }
     }
 
+    for(i=0;i<NUM_CAM;i++)
+    {
+        mpicbuf[i].mnSkipBase = mnskip;
+    }
+
 }
 
 grpcclient::~grpcclient()
@@ -263,6 +269,12 @@ void grpcclient::dec_yaml(const char * stryamlpath)
     {
         gstruploadinterval = config["uploadinterval"].as<std::string>();
     }
+    if(config["skip"])
+    {
+        std::string strskip = config["skip"].as<std::string>();
+        mnskip = atoi(strskip.data());
+        if(mnskip<1)mnskip = 1;
+    }
 
     if(config["VIN"])
     {
@@ -473,8 +485,6 @@ void grpcclient::threadpicupload(int nCamPos)
 
  //   ClientContext context;
 
-
-
     while(mbPicUpload)
     {
         std::shared_ptr<char> pstr_ptr;
@@ -489,6 +499,8 @@ void grpcclient::threadpicupload(int nCamPos)
         qint64 nMsgTime = 0;
         int nSize = 0;
         qint64 npiclatency;
+        int nSkipBase = 1;
+        int nCount;
 
         mpicbuf[nCamPos].mWaitMutex.lock();
         mpicbuf[nCamPos].mwc.wait(&mpicbuf[nCamPos].mWaitMutex,100);
@@ -504,7 +516,19 @@ void grpcclient::threadpicupload(int nCamPos)
             pstr_ptr = mpicbuf[nCamPos].mpstrmsgdata;
             nSize = mpicbuf[nCamPos].mDataSize;
             npiclatency = CalcLateny(mpicbuf[nCamPos].mvectorlatency);
-            std::cout<<"upload "<<nMsgTime<<"  latency:  "<<npiclatency<<std::endl;
+            nSkipBase = mpicbuf[nCamPos].mnSkipBase;
+            nCount = mpicbuf[nCamPos].mnCount;
+            mpicbuf[nCamPos].mnCount++;
+//            if(npiclatency >  500)
+//            {
+//                if(mpicbuf[nCamPos].mnSkipBase<30)mpicbuf[nCamPos].mnSkipBase++;
+//            }
+//            else
+//            {
+//                if(npiclatency<300)
+//                    if(mpicbuf[nCamPos].mnSkipBase > mpicbuf[nCamPos].mnDefSkipBase)mpicbuf[nCamPos].mnSkipBase--;
+//            }
+            std::cout<<"upload "<<nMsgTime<<"  latency:  "<<npiclatency<<" skip param: "<<nSkipBase<<std::endl;
         }
         mpicbuf[nCamPos].mMutex.unlock();
         if(bUpdate == false)
@@ -513,6 +537,13 @@ void grpcclient::threadpicupload(int nCamPos)
             continue;
         }
 
+        if(nCount%nSkipBase != 0)
+        {
+            continue;
+        }
+
+
+
         ClientContext context ;
         context.set_deadline(timespec);
         qint64 time1 = QDateTime::currentMSecsSinceEpoch();

+ 6 - 0
src/driver/driver_cloud_grpc_thread/grpcclient.h

@@ -28,6 +28,7 @@
 
 #include <grpcpp/grpcpp.h>
 
+
 #include "uploadthreadmsg.grpc.pb.h"
 
 #define NUM_CAM 4
@@ -58,6 +59,9 @@ struct  threadpicunit
      QWaitCondition mwc;
      QMutex mMutex;
      std::vector<qint64> mvectorlatency;
+     int mnSkipBase = 2;
+     int mnDefSkipBase = 1;
+     int mnCount = 0;
 };
 }
 
@@ -117,6 +121,8 @@ private:
 
     qint64 CalcLateny(std::vector<qint64> & xvectorlatency);
 
+    int mnskip = 2;
+
 };
 
 #endif // GRPCCLIENT_H