|
@@ -35,7 +35,7 @@ static pcmsgbuffer gpcmsgbuf;
|
|
|
|
|
|
|
|
|
void uploadsend(::grpc::ServerReaderWriter<iv::UploadReplyStream, iv::UploadRequestStream>* stream,bool * pbrun,
|
|
|
- std::string * pstrvin,std::string * pstrmd5,bool *pbUpdatemd4orvin,QMutex * pmutex)
|
|
|
+ std::string * pstrvin,std::string * pstrmd5,bool *pbUpdatemd4orvin,QMutex * pmutex,int * preqid,qint64 * pnsendtime,QMutex * pmutexidtime)
|
|
|
{
|
|
|
std::string strvin;
|
|
|
std::string strmd5;
|
|
@@ -60,16 +60,23 @@ void uploadsend(::grpc::ServerReaderWriter<iv::UploadReplyStream, iv::UploadRequ
|
|
|
|
|
|
int id;
|
|
|
qint64 ntime;
|
|
|
+ float framerate;
|
|
|
|
|
|
std::vector<char > xvectorctrldata;
|
|
|
|
|
|
- int nres = gpcmsgbuf.getmsg(strvin,strmd5,id,ntime,&xvectorctrldata);
|
|
|
+ int nres = gpcmsgbuf.getmsg(strvin,strmd5,id,ntime,&xvectorctrldata,&framerate);
|
|
|
|
|
|
iv::UploadReplyStream reply;
|
|
|
+
|
|
|
+ pmutexidtime->lock();
|
|
|
+ reply.set_nreqsendtime(*pnsendtime);
|
|
|
+ reply.set_nreqid(*preqid);
|
|
|
+ pmutexidtime->unlock();
|
|
|
if(nres == 1)
|
|
|
{
|
|
|
reply.set_nres(nres);
|
|
|
reply.set_xdata(xvectorctrldata.data(),xvectorctrldata.size());
|
|
|
+ reply.set_framerate(framerate);
|
|
|
stream->Write(reply);
|
|
|
nlastsend = xTime.elapsed();
|
|
|
}
|
|
@@ -78,7 +85,9 @@ void uploadsend(::grpc::ServerReaderWriter<iv::UploadReplyStream, iv::UploadRequ
|
|
|
if(abs(xTime.elapsed() - nlastsend)>1000)
|
|
|
{
|
|
|
reply.set_nres(nres);
|
|
|
+ reply.set_framerate(0);
|
|
|
stream->Write(reply);
|
|
|
+
|
|
|
nlastsend = xTime.elapsed();
|
|
|
}
|
|
|
}
|
|
@@ -125,6 +134,7 @@ void queryctrlsend(::grpc::ServerReaderWriter<iv::queryReplyStream, iv::queryReq
|
|
|
reply.set_nres(nres);
|
|
|
if(nres > 0)
|
|
|
{
|
|
|
+
|
|
|
reply.set_xdata(xvectorquerydata.data(),xvectorquerydata.size());
|
|
|
reply.set_id(id);
|
|
|
reply.set_ntime(ntime);
|
|
@@ -158,8 +168,14 @@ class UploadServiceImpl final : public iv::UploadStream::Service {
|
|
|
std::string strvin = "aaa";
|
|
|
bool bUpdatemd4orvin = false;
|
|
|
QMutex uploadmutex;
|
|
|
- std::thread * pthread = new std::thread(uploadsend,stream,&brun,&strvin,&strctrlmd5,&bUpdatemd4orvin,&uploadmutex);
|
|
|
+ int reqid = -1;
|
|
|
+ qint64 pnsendtime = 0;
|
|
|
+ QMutex mutexidtime;
|
|
|
+ std::thread * pthread = new std::thread(uploadsend,stream,&brun,&strvin,&strctrlmd5,&bUpdatemd4orvin,&uploadmutex,
|
|
|
+ &reqid,&pnsendtime,&mutexidtime);
|
|
|
std::cout<<"new connect."<<std::endl;
|
|
|
+
|
|
|
+
|
|
|
while (stream->Read(&request))
|
|
|
{
|
|
|
std::cout<<" rec req."<<std::endl;
|
|
@@ -180,6 +196,9 @@ class UploadServiceImpl final : public iv::UploadStream::Service {
|
|
|
memcpy(xvectordata.data(),request.xdata().data(),request.xdata().size());
|
|
|
}
|
|
|
|
|
|
+ reqid = request.id();
|
|
|
+ pnsendtime = request.nsendtime();
|
|
|
+
|
|
|
gcumsgbuf.addmsg(request.id(),request.ntime(),request.strvin(),request.strquerymd5(),request.strctrlmd5(),
|
|
|
&xvectordata,request.bimportant(),request.kepptime());
|
|
|
// std::cout << "收到请求,类型为" << request.askmsg() <<"\n"<<std::endl;
|
|
@@ -225,7 +244,7 @@ class UploadServiceImpl final : public iv::UploadStream::Service {
|
|
|
static int tempid = 0;
|
|
|
tempid++;
|
|
|
int nid = gpcmsgbuf.addmsg(tempid,request.ntime(),request.strvin(),request.strctrlmd5(),&xvectordata,
|
|
|
- request.bimportant(),request.kepptime());
|
|
|
+ request.bimportant(),request.kepptime(),request.nsuggestframerate());
|
|
|
|
|
|
(void)&nid;
|
|
|
|