|
@@ -129,6 +129,7 @@ void grpcclient::run()
|
|
|
|
|
|
// ClientContext context;
|
|
|
|
|
|
+ std::vector<qint64> xvectorlatency;
|
|
|
|
|
|
|
|
|
while(!QThread::isInterruptionRequested())
|
|
@@ -178,6 +179,8 @@ void grpcclient::run()
|
|
|
context.set_deadline(timespec);
|
|
|
qint64 time1 = QDateTime::currentMSecsSinceEpoch();
|
|
|
|
|
|
+
|
|
|
+
|
|
|
request.set_id(nid);
|
|
|
request.set_ntime(time1);
|
|
|
request.set_strquerymd5(gstrqueryMD5);
|
|
@@ -186,6 +189,8 @@ void grpcclient::run()
|
|
|
request.set_xdata(strbuf,nbytesize);
|
|
|
request.set_kepptime(nkeeptime);
|
|
|
request.set_bimportant(bImportant);
|
|
|
+ request.set_nsendtime(QDateTime::currentMSecsSinceEpoch());
|
|
|
+ request.set_nlatency(CalcLateny(xvectorlatency));
|
|
|
nid++;
|
|
|
|
|
|
nlastsend = xTime.elapsed();
|
|
@@ -194,6 +199,8 @@ void grpcclient::run()
|
|
|
if (status.ok()) {
|
|
|
std::cout<<" data size is "<<nbytesize<<std::endl;
|
|
|
std::cout<<nid<<" upload successfully"<<std::endl;
|
|
|
+ xvectorlatency.push_back((QDateTime::currentMSecsSinceEpoch() - reply.nreqsendtime()));
|
|
|
+ while(xvectorlatency.size()>10)xvectorlatency.erase(xvectorlatency.begin());
|
|
|
if(reply.nres() == 1)
|
|
|
{
|
|
|
iv::cloud::cloudmsg xmsg;
|
|
@@ -481,6 +488,7 @@ void grpcclient::threadpicupload(int nCamPos)
|
|
|
bool bUpdate = false;
|
|
|
qint64 nMsgTime = 0;
|
|
|
int nSize = 0;
|
|
|
+ qint64 npiclatency;
|
|
|
|
|
|
mpicbuf[nCamPos].mWaitMutex.lock();
|
|
|
mpicbuf[nCamPos].mwc.wait(&mpicbuf[nCamPos].mWaitMutex,100);
|
|
@@ -491,10 +499,12 @@ void grpcclient::threadpicupload(int nCamPos)
|
|
|
if(bUpdate == true)
|
|
|
{
|
|
|
nMsgTime = mpicbuf[nCamPos].mnMsgTime;
|
|
|
- std::cout<<"upload "<<nMsgTime<<std::endl;
|
|
|
+
|
|
|
mpicbuf[nCamPos].mbRefresh = false;
|
|
|
pstr_ptr = mpicbuf[nCamPos].mpstrmsgdata;
|
|
|
nSize = mpicbuf[nCamPos].mDataSize;
|
|
|
+ npiclatency = CalcLateny(mpicbuf[nCamPos].mvectorlatency);
|
|
|
+ std::cout<<"upload "<<nMsgTime<<" latency: "<<npiclatency<<std::endl;
|
|
|
}
|
|
|
mpicbuf[nCamPos].mMutex.unlock();
|
|
|
if(bUpdate == false)
|
|
@@ -511,6 +521,7 @@ void grpcclient::threadpicupload(int nCamPos)
|
|
|
request.set_ncampos(nCamPos);
|
|
|
request.set_strvin(gstrVIN);
|
|
|
request.set_xdata(pstr_ptr.get(),nSize);
|
|
|
+ request.set_nlatency(npiclatency);
|
|
|
nid++;
|
|
|
|
|
|
nlastsend = xTime.elapsed();
|
|
@@ -518,6 +529,11 @@ void grpcclient::threadpicupload(int nCamPos)
|
|
|
Status status = stub_->uploadpic(&context, request, &reply);
|
|
|
if (status.ok()) {
|
|
|
|
|
|
+ qint64 nlaten = QDateTime::currentMSecsSinceEpoch() - time1;
|
|
|
+ mpicbuf[nCamPos].mMutex.lock();
|
|
|
+ mpicbuf[nCamPos].mvectorlatency.push_back(nlaten);
|
|
|
+ while(mpicbuf[nCamPos].mvectorlatency.size()>10)mpicbuf[nCamPos].mvectorlatency.erase(mpicbuf[nCamPos].mvectorlatency.begin());
|
|
|
+ mpicbuf[nCamPos].mMutex.unlock();
|
|
|
if(reply.nres() == 1)
|
|
|
{
|
|
|
// iv::cloud::cloudmsg xmsg;
|
|
@@ -547,3 +563,16 @@ void grpcclient::threadpicupload(int nCamPos)
|
|
|
|
|
|
std::cout<<"threadpicupload cam pos: "<<nCamPos<<" exit."<<std::endl;
|
|
|
}
|
|
|
+
|
|
|
+qint64 grpcclient::CalcLateny(std::vector<qint64> &xvectorlatency)
|
|
|
+{
|
|
|
+ if(xvectorlatency.size() == 0)return 1000;
|
|
|
+ unsigned int i;
|
|
|
+ qint64 nLatencyTotal = 0;
|
|
|
+ for(i=0;i<xvectorlatency.size();i++)
|
|
|
+ {
|
|
|
+ nLatencyTotal = nLatencyTotal + xvectorlatency[i];
|
|
|
+ }
|
|
|
+ qint64 nLatencyAvg = nLatencyTotal/xvectorlatency.size();
|
|
|
+ return nLatencyAvg;
|
|
|
+}
|