Procházet zdrojové kódy

near complete group_grpc code.

yuchuli před 3 roky
rodič
revize
db3d62877c

+ 4 - 0
src/driver/driver_group_grpc_client/driver_group_grpc_client.pro

@@ -1,5 +1,7 @@
 QT -= gui
 
+QT += network
+
 CONFIG += c++11 console
 CONFIG -= app_bundle
 
@@ -24,6 +26,7 @@ SOURCES += \
         ../../include/msgtype/groupmsg.pb.cc \
         ../../include/msgtype/grpcgroup.pb.cc \
         ../../include/msgtype/imu.pb.cc \
+        get_interface.cpp \
         groupclient.cpp \
         grpcgroup.grpc.pb.cc \
         main.cpp
@@ -41,6 +44,7 @@ HEADERS += \
     ../../include/msgtype/groupmsg.pb.h \
     ../../include/msgtype/grpcgroup.pb.h \
     ../../include/msgtype/imu.pb.h \
+    get_interface.h \
     groupclient.h \
     grpcgroup.grpc.pb.h
 

+ 89 - 0
src/driver/driver_group_grpc_client/get_interface.cpp

@@ -0,0 +1,89 @@
+#include "get_interface.h"
+
+#include <QtNetwork/QNetworkInterface>
+
+int getmac(std::string & strmac)
+{
+    bool bFindeth0 = false;
+    std::string strmacaddr;
+    std::vector<std::string> xvectormac;
+    QList<QNetworkInterface> interfaceList = QNetworkInterface::allInterfaces();
+
+    foreach(QNetworkInterface interfaceItem, interfaceList)
+    {
+        if(interfaceItem.flags().testFlag(QNetworkInterface::CanBroadcast)
+                &&interfaceItem.flags().testFlag(QNetworkInterface::CanMulticast)
+                &&!interfaceItem.flags().testFlag(QNetworkInterface::IsLoopBack)
+                &&interfaceItem.hardwareAddress()!="00:50:56:C0:00:01"
+                &&interfaceItem.hardwareAddress()!="00:50:56:C0:00:08")
+        {
+            std::string str = interfaceItem.hardwareAddress().toStdString();
+            xvectormac.push_back(str);
+            if(interfaceItem.name() == "eth0")
+            {
+                strmacaddr = str;
+                bFindeth0 = true;
+            }
+            QList<QNetworkAddressEntry> addressEntryList=interfaceItem.addressEntries();
+            foreach(QNetworkAddressEntry addressEntryItem, addressEntryList)
+            {
+                if(addressEntryItem.ip().protocol()==QAbstractSocket::IPv4Protocol)
+                {
+                    qDebug()<<"------------------------------------------------------------";
+                    qDebug()<<"Adapter Name:"<<interfaceItem.name();
+                    qDebug()<<"Adapter Address:"<<interfaceItem.hardwareAddress();
+                    qDebug()<<"IP Address:"<<addressEntryItem.ip().toString();
+                    qDebug()<<"IP Mask:"<<addressEntryItem.netmask().toString();
+                }
+            }
+        }
+    }
+
+    if(bFindeth0)
+    {
+        strmac = strmacaddr;
+        return 1;
+    }
+
+    if(xvectormac.size()>0)
+    {
+        strmac = xvectormac[0];
+        return 1;
+    }
+
+    return 0;
+}
+
+
+void getAdapterInfoWithQt()
+{
+    QList<QNetworkInterface> interfaceList = QNetworkInterface::allInterfaces();
+
+    foreach(QNetworkInterface interfaceItem, interfaceList)
+    {
+        if(interfaceItem.flags().testFlag(QNetworkInterface::IsUp)
+                &&interfaceItem.flags().testFlag(QNetworkInterface::IsRunning)
+                &&interfaceItem.flags().testFlag(QNetworkInterface::CanBroadcast)
+                &&interfaceItem.flags().testFlag(QNetworkInterface::CanMulticast)
+                &&!interfaceItem.flags().testFlag(QNetworkInterface::IsLoopBack)
+                &&interfaceItem.hardwareAddress()!="00:50:56:C0:00:01"
+                &&interfaceItem.hardwareAddress()!="00:50:56:C0:00:08")
+        {
+            QList<QNetworkAddressEntry> addressEntryList=interfaceItem.addressEntries();
+            foreach(QNetworkAddressEntry addressEntryItem, addressEntryList)
+            {
+                if(addressEntryItem.ip().protocol()==QAbstractSocket::IPv4Protocol)
+                {
+                    qDebug()<<"------------------------------------------------------------";
+                    qDebug()<<"Adapter Name:"<<interfaceItem.name();
+                    qDebug()<<"Adapter Address:"<<interfaceItem.hardwareAddress();
+                    qDebug()<<"IP Address:"<<addressEntryItem.ip().toString();
+                    qDebug()<<"IP Mask:"<<addressEntryItem.netmask().toString();
+                }
+            }
+        }
+    }
+}
+
+
+

+ 9 - 0
src/driver/driver_group_grpc_client/get_interface.h

@@ -0,0 +1,9 @@
+#ifndef GET_INTERFACE_H
+#define GET_INTERFACE_H
+
+#include <string>
+
+int getmac(std::string & strmac);
+void getAdapterInfoWithQt();
+
+#endif // GET_INTERFACE_H

+ 2 - 0
src/driver/driver_group_grpc_client/groupclient.cpp

@@ -91,6 +91,7 @@ void groupclient::run()
             iv::group::vehicleinfo xmsg;
             xmsg.set_vehicleid(mstrvehid);
             xmsg.set_roleid(mrole);
+            xmsg.set_groupid(mgroupid);
             qint64 nNow = QDateTime::currentMSecsSinceEpoch();
             if((nNow - mnbrainupdate) < mnMsgValidTime)
             {
@@ -141,6 +142,7 @@ void groupclient::run()
                     std::cout<<nid<<" upload successfully"<<std::endl;
                     if(reply.nres() == 1)
                     {
+                        std::cout<<"reply size is "<<reply.xdata().size()<<std::endl;
                         iv::group::groupinfo xinfo;
                         if(xinfo.ParseFromArray(reply.xdata().data(),reply.xdata().size()))
                         {

+ 3 - 2
src/driver/driver_group_grpc_client/groupclient.h

@@ -38,6 +38,7 @@ using grpc::Status;
 
 class groupclient : public QThread
 {
+    Q_OBJECT
 public:
     groupclient();
 
@@ -87,9 +88,9 @@ private:
     std::string mstrserverport = "31001";
 
 private:
-    std::string mstrvehid = 0;
+    std::string mstrvehid = "demo1";
     iv::group::vehicleinfo::ROLETYPE mrole = iv::group::vehicleinfo::ROLETYPE::vehicleinfo_ROLETYPE_MASTER;
-    int mgroupid = 0;  //If 0 No group
+    int mgroupid = 1;  //If 0 No group
 
 
 };

+ 15 - 0
src/driver/driver_group_grpc_client/main.cpp

@@ -1,11 +1,26 @@
 #include <QCoreApplication>
 
+#include <iostream>
+
+#include "groupclient.h"
+
+#include "get_interface.h"
+
 int gnGroupID = 1;  //if 0 no group
 std::string gstrVehid = "demo";
 
+
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
 
+    std::string strmac;
+    if(getmac(strmac ) == 1)
+    {
+        std::cout<<"mac addr is :"<<strmac.data()<<std::endl;
+    }
+
+    groupclient * pclient = new groupclient;
+    pclient->start();
     return a.exec();
 }

+ 73 - 0
src/driver/driver_group_grpc_server/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 54 - 0
src/driver/driver_group_grpc_server/driver_group_grpc_server.pro

@@ -0,0 +1,54 @@
+QT -= gui
+
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+
+system(protoc -I=./../../include/proto3 --cpp_out=./../../include/msgtype   ./../../include/proto3/grpcgroup.proto)
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+        ../../include/msgtype/brainstate.pb.cc \
+        ../../include/msgtype/decition.pb.cc \
+        ../../include/msgtype/gpsimu.pb.cc \
+        ../../include/msgtype/groupmsg.pb.cc \
+        ../../include/msgtype/grpcgroup.pb.cc \
+        ../driver_group_grpc_client/grpcgroup.grpc.pb.cc \
+        groupmsgbuf.cpp \
+        main.cpp
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}
+
+
+!include(../../../include/ivgrpc.pri ) {
+    error( "Couldn't find the ivgrpc.pri file!" )
+}
+
+HEADERS += \
+    ../../include/msgtype/brainstate.pb.h \
+    ../../include/msgtype/decition.pb.h \
+    ../../include/msgtype/gpsimu.pb.h \
+    ../../include/msgtype/groupmsg.pb.h \
+    ../../include/msgtype/grpcgroup.pb.h \
+    ../driver_group_grpc_client/grpcgroup.grpc.pb.h \
+    groupmsgbuf.h

+ 116 - 0
src/driver/driver_group_grpc_server/groupmsgbuf.cpp

@@ -0,0 +1,116 @@
+#include "groupmsgbuf.h"
+
+#include <QDateTime>
+
+groupmsgbuf::groupmsgbuf()
+{
+
+}
+
+int groupmsgbuf::ProcGroupMsg(const iv::group::groupRequest * preq,iv::group::groupReply* reply)
+{
+    iv::group::vehicleinfo xvinfo;
+    if(!xvinfo.ParseFromArray(preq->xdata().data(),preq->xdata().size()))
+    {
+        std::cout<<"Parse Vehicle info fail"<<std::endl;
+        reply->set_nres(0);
+        return 0;
+    }
+
+    iv::groupmsgunit * p = NULL;
+    unsigned int i;
+
+    mMutexGroup.lock();
+    for(i=0;i<mvectorgroupmsg.size();i++)
+    {
+        if(mvectorgroupmsg[i].strvehid == xvinfo.vehicleid())
+        {
+            p = &mvectorgroupmsg[i];
+            p->mnLastUpdateTime =  QDateTime::currentMSecsSinceEpoch();
+            p->minfo.CopyFrom(xvinfo);
+            break;
+        }
+    }
+    if(p == NULL)
+    {
+        iv::groupmsgunit xmsgunit;
+        xmsgunit.strvehid = xvinfo.vehicleid();
+        xmsgunit.mnLastUpdateTime = QDateTime::currentMSecsSinceEpoch();
+        xmsgunit.minfo.CopyFrom(xvinfo);
+        mvectorgroupmsg.push_back(xmsgunit);
+        p = &mvectorgroupmsg[mvectorgroupmsg.size()-1];
+    }
+
+    mMutexGroup.unlock();
+
+    if(preq->ngroup() == 0)
+    {
+        reply->set_nres(0);
+        return 0;
+    }
+
+    qint64 nNow = QDateTime::currentMSecsSinceEpoch();
+    iv::group::groupinfo xgroupinfo;
+
+    mMutexGroup.lock();
+    for(i=0;i<mvectorgroupmsg.size();i++)
+    {
+        if((nNow - mvectorgroupmsg[i].mnLastUpdateTime) < mnDataValidTime)
+        {
+            if(mvectorgroupmsg[i].minfo.groupid() == preq->ngroup())
+            {
+                iv::group::vehicleinfo * pvinfo = xgroupinfo.add_mvehinfo();
+                pvinfo->CopyFrom(mvectorgroupmsg[i].minfo);
+            }
+        }
+    }
+    mMutexGroup.unlock();
+
+    reply->set_nres(1);
+    reply->set_ngroup(preq->ngroup());
+    int ndatasize = xgroupinfo.ByteSize();
+    std::shared_ptr<char> pstr_buf = std::shared_ptr<char>(new char[ndatasize]);
+    if(xgroupinfo.SerializeToArray(pstr_buf.get(),ndatasize))
+    {
+        reply->set_xdata(pstr_buf.get(),ndatasize);
+    }
+    else
+    {
+        std::cout<<" xgroupinfo serialize fail."<<std::endl;
+    }
+    return 1;
+}
+
+int groupmsgbuf::ProcQueryMsg(const iv::group::groupRequest * preq,iv::group::groupReply* reply)
+{
+    (void)preq;
+    qint64 nNow = QDateTime::currentMSecsSinceEpoch();
+    iv::group::groupinfo xgroupinfo;
+
+    unsigned int i;
+    mMutexGroup.lock();
+    for(i=0;i<mvectorgroupmsg.size();i++)
+    {
+        if((nNow - mvectorgroupmsg[i].mnLastUpdateTime) < mnDataValidTime)
+        {
+                iv::group::vehicleinfo * pvinfo = xgroupinfo.add_mvehinfo();
+                pvinfo->CopyFrom(mvectorgroupmsg[i].minfo);
+
+        }
+    }
+    mMutexGroup.unlock();
+
+    reply->set_nres(1);
+    reply->set_ngroup(preq->ngroup());
+    int ndatasize = xgroupinfo.ByteSize();
+    std::shared_ptr<char> pstr_buf = std::shared_ptr<char>(new char[ndatasize]);
+    if(xgroupinfo.SerializeToArray(pstr_buf.get(),ndatasize))
+    {
+        reply->set_xdata(pstr_buf.get(),ndatasize);
+    }
+    else
+    {
+        std::cout<<" xgroupinfo serialize fail."<<std::endl;
+    }
+    return 1;
+}

+ 38 - 0
src/driver/driver_group_grpc_server/groupmsgbuf.h

@@ -0,0 +1,38 @@
+#ifndef GROUPMSGBUF_H
+#define GROUPMSGBUF_H
+
+#include <QThread>
+#include <QMutex>
+
+#include "./../driver_group_grpc_client/grpcgroup.grpc.pb.h"
+
+#include "groupmsg.pb.h"
+
+namespace iv {
+struct groupmsgunit
+{
+    qint64 mnLastUpdateTime;
+    std::string strvehid;
+    iv::group::vehicleinfo minfo;
+};
+}
+
+
+class groupmsgbuf
+{
+public:
+    groupmsgbuf();
+
+public:
+    int ProcGroupMsg(const iv::group::groupRequest * preq,iv::group::groupReply* reply);
+    int ProcQueryMsg(const iv::group::groupRequest * preq,iv::group::groupReply* reply);
+
+private:
+    std::vector<iv::groupmsgunit> mvectorgroupmsg;
+    QMutex mMutexGroup;
+
+private:
+    qint64 mnDataValidTime = 3000; //3 sceonds
+};
+
+#endif // GROUPMSGBUF_H

+ 87 - 0
src/driver/driver_group_grpc_server/main.cpp

@@ -0,0 +1,87 @@
+#include <QCoreApplication>
+
+#include <QDateTime>
+#include <iostream>
+#include <vector>
+
+#include <iostream>
+#include <memory>
+#include <string>
+
+#include <grpcpp/grpcpp.h>
+#include <grpcpp/health_check_service_interface.h>
+#include <grpcpp/ext/proto_server_reflection_plugin.h>
+
+#include "grpcgroup.pb.h"
+#include "groupmsgbuf.h"
+
+using grpc::Server;
+using grpc::ServerBuilder;
+using grpc::ServerContext;
+using grpc::Status;
+
+#include "./../driver_group_grpc_client/grpcgroup.grpc.pb.h"
+
+static groupmsgbuf gmsgbuf;
+
+// Logic and data behind the server's behavior.
+class GroupServiceImpl final : public iv::group::groupservice::Service{
+  Status grpcgroup(ServerContext* context, const iv::group::groupRequest* request,
+                  iv::group::groupReply* reply) override {
+
+    gmsgbuf.ProcGroupMsg(request,reply);
+
+    return Status::OK;
+  }
+
+  Status queryallgroup(ServerContext* context, const iv::group::groupRequest* request,
+                  iv::group::groupReply* reply) override {
+
+    gmsgbuf.ProcQueryMsg(request,reply);
+
+      return Status::OK;
+
+
+  }
+
+
+
+};
+
+void RunServer() {
+  std::string server_address("0.0.0.0:31001");
+  GroupServiceImpl service;
+
+  grpc::EnableDefaultHealthCheckService(true);
+//  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+  ServerBuilder builder;
+  // Listen on the given address without any authentication mechanism.
+  builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
+
+  builder.SetMaxReceiveMessageSize(300000000);
+ // builder.SetMaxMessageSize(100000000);
+
+
+//  builder.SetMaxSendMessageSize(100000000);
+  // Register "service" as the instance through which we'll communicate with
+  // clients. In this case it corresponds to an *synchronous* service.
+  builder.RegisterService(&service);
+  // Finally assemble the server.
+  std::unique_ptr<Server> server(builder.BuildAndStart());
+  std::cout << "Server listening on " << server_address << std::endl;
+
+  // Wait for the server to shutdown. Note that some other thread must be
+  // responsible for shutting down the server for this call to ever return.
+  server->Wait();
+}
+
+
+
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication a(argc, argv);
+
+    RunServer();
+    return a.exec();
+}

+ 73 - 0
src/tool/view_group_grpc/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 140 - 0
src/tool/view_group_grpc/groupqueryclient.cpp

@@ -0,0 +1,140 @@
+#include "groupqueryclient.h"
+
+groupqueryclient::groupqueryclient()
+{
+
+}
+
+void groupqueryclient::run()
+{
+    int ninterval = 100;
+ //   if(ninterval<=0)ninterval = 1000;
+
+    QTime xTime;
+    xTime.start();
+    int nlastsend = xTime.elapsed();
+
+    std::string target_str = mstrserver;
+    auto cargs = grpc::ChannelArguments();
+    cargs.SetMaxReceiveMessageSize(1024 * 1024 * 1024); // 1 GB
+    cargs.SetMaxSendMessageSize(1024 * 1024 * 1024);
+
+    std::shared_ptr<Channel> channel = grpc::CreateCustomChannel(
+             target_str, grpc::InsecureChannelCredentials(),cargs);
+
+    std::unique_ptr<iv::group::groupservice::Stub> stub_ = iv::group::groupservice::NewStub(channel);
+
+
+    iv::group::groupRequest request;
+
+    int nid = 0;
+
+    // Container for the data we expect from the server.
+    iv::group::groupReply reply;
+
+    gpr_timespec timespec;
+      timespec.tv_sec = 30;//设置阻塞时间为2秒
+      timespec.tv_nsec = 0;
+      timespec.clock_type = GPR_TIMESPAN;
+
+ //   ClientContext context;
+
+
+
+    while(!QThread::isInterruptionRequested())
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(1));
+        if(abs(xTime.elapsed()-nlastsend)<ninterval)
+        {
+            continue;
+        }
+
+
+
+
+
+                ClientContext context ;
+                context.set_deadline(timespec);
+
+                request.set_strvehid("testid");
+                request.set_ngroup(-1);
+                request.set_msgtime(QDateTime::currentMSecsSinceEpoch());
+                nid++;
+
+                nlastsend = xTime.elapsed();
+                // The actual RPC.
+                Status status = stub_->queryallgroup(&context, request, &reply);
+                if (status.ok()) {
+                    std::cout<<nid<<" query successfully"<<std::endl;
+                    if(reply.nres() == 1)
+                    {
+                        std::cout<<"reply size is "<<reply.xdata().size()<<std::endl;
+                        iv::group::groupinfo xinfo;
+                        if(reply.xdata().size() > 0)
+                        {
+                        if(xinfo.ParseFromArray(reply.xdata().data(),reply.xdata().size()))
+                        {
+                            if(xinfo.mvehinfo_size() > 0)
+                            {
+                                unsigned int j;
+                                for(j=0;j<xinfo.mvehinfo_size();j++)
+                                {
+                                    iv::group::vehicleinfo * pvehinfo = xinfo.mutable_mvehinfo(j);
+                                    mMutexInfo.lock();
+                                    bool bExist = false;
+                                    unsigned int i;
+                                    for(i=0;i<mvectorvehinfo.size();i++)
+                                    {
+                                        if(mvectorvehinfo[i].strvehid == pvehinfo->vehicleid())
+                                        {
+                                            bExist = true;
+                                            mvectorvehinfo[i].mnLastUpdateTime = QDateTime::currentMSecsSinceEpoch();
+                                            mvectorvehinfo[i].mvehinfo.CopyFrom(*pvehinfo);
+                                            break;
+                                        }
+                                    }
+                                    if(bExist == false)
+                                    {
+                                        iv::vehinfo xveh;
+                                        xveh.mnLastUpdateTime = QDateTime::currentMSecsSinceEpoch();
+                                        xveh.strvehid = pvehinfo->vehicleid();
+                                        xveh.mvehinfo.CopyFrom(*pvehinfo);
+                                        mvectorvehinfo.push_back(xveh);
+                                    }
+                                    mMutexInfo.unlock();
+                                }
+
+                            }
+                        }
+                        }
+                    }
+                } else {
+                  std::cout << status.error_code() << ": " << status.error_message()
+                            << std::endl;
+                  std::cout<<"RPC failed"<<std::endl;
+                  if(status.error_code() == 4)
+                  {
+                      std::cout<<" RPC Exceed Time, Create New stub_"<<std::endl;
+                      channel = grpc::CreateCustomChannel(
+                               target_str, grpc::InsecureChannelCredentials(),cargs);
+
+                      stub_ = iv::group::groupservice::NewStub(channel);
+                  }
+                  std::this_thread::sleep_for(std::chrono::milliseconds(900));
+
+                }
+
+
+
+
+    }
+}
+
+std::vector<iv::vehinfo> groupqueryclient::GetVehinfo()
+{
+    std::vector<iv::vehinfo> xrtn;
+    mMutexInfo.lock();
+    xrtn = mvectorvehinfo;
+    mMutexInfo.unlock();
+    return xrtn;
+}

+ 65 - 0
src/tool/view_group_grpc/groupqueryclient.h

@@ -0,0 +1,65 @@
+#ifndef GROUPQUERYCLIENT_H
+#define GROUPQUERYCLIENT_H
+#include <QThread>
+
+#include <QDateTime>
+
+#include <iostream>
+
+#include <vector>
+
+#include <memory>
+
+#include <QMutex>
+
+#include <thread>
+
+#include "modulecommext.h"
+
+#include <iostream>
+#include <memory>
+#include <string>
+
+#include <grpcpp/grpcpp.h>
+
+#include "../../driver/driver_group_grpc_client/grpcgroup.grpc.pb.h"
+
+#include "gpsimu.pb.h"
+#include "brainstate.pb.h"
+#include "decition.pb.h"
+#include "grpcgroup.pb.h"
+#include "groupmsg.pb.h"
+
+using grpc::Channel;
+using grpc::ClientContext;
+using grpc::Status;
+
+
+namespace  iv {
+struct  vehinfo
+{
+     std::string strvehid;
+     qint64 mnLastUpdateTime;
+     iv::group::vehicleinfo mvehinfo;
+};
+}
+
+class groupqueryclient : public QThread
+{
+public:
+    groupqueryclient();
+
+private:
+    void run();
+
+private:
+    std::string mstrserver = "127.0.0.1:31001";
+
+    std::vector<iv::vehinfo> mvectorvehinfo;
+    QMutex mMutexInfo;
+
+public:
+    std::vector<iv::vehinfo> GetVehinfo();
+};
+
+#endif // GROUPQUERYCLIENT_H

+ 11 - 0
src/tool/view_group_grpc/main.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+    return a.exec();
+}

+ 68 - 0
src/tool/view_group_grpc/mainwindow.cpp

@@ -0,0 +1,68 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QTimer>
+
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+#include "google/protobuf/text_format.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    mpquery = new groupqueryclient();
+    mpquery->start();
+
+    QTimer * timer = new QTimer(this);
+    connect(timer,SIGNAL(timeout()),this,SLOT(onTimer()));
+    timer->start(100);
+
+    setWindowTitle("View Group Message");
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+void MainWindow::onTimer()
+{
+    minfo = mpquery->GetVehinfo();
+
+    int noldindex = ui->comboBox->currentIndex();
+
+    if(mvectoritem.size() != minfo.size())
+    {
+        ui->comboBox->clear();
+        unsigned int i;
+        for(i=0;i<minfo.size();i++)
+        {
+            mvectoritem.push_back(minfo[i].strvehid);
+            ui->comboBox->addItem(minfo[i].strvehid.data());
+        }
+    }
+
+    if(noldindex>=0)ui->comboBox->setCurrentIndex(noldindex);
+
+    if(mvectoritem.size() == 0)return;
+
+    using google::protobuf::TextFormat;
+    using google::protobuf::io::FileOutputStream;
+    using google::protobuf::io::ZeroCopyOutputStream;
+    std::string strout;
+    ZeroCopyOutputStream *output = new google::protobuf::io::StringOutputStream(&strout);//new FileOutputStream(file_descriptor);
+
+
+    int index = ui->comboBox->currentIndex();
+    if(minfo[index].mvehinfo.has_mgpsimu())
+    {
+        bool success = TextFormat::Print(*(minfo[index].mvehinfo.mutable_mgpsimu()), output);
+        if(success)
+        {
+            ui->plainTextEdit->setPlainText(strout.data());
+        }
+    }
+}
+

+ 32 - 0
src/tool/view_group_grpc/mainwindow.h

@@ -0,0 +1,32 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "groupqueryclient.h"
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+private slots:
+    void onTimer();
+
+private:
+    Ui::MainWindow *ui;
+
+    groupqueryclient * mpquery;
+
+    std::vector<iv::vehinfo>  minfo;
+
+    std::vector<std::string> mvectoritem;
+};
+#endif // MAINWINDOW_H

+ 111 - 0
src/tool/view_group_grpc/mainwindow.ui

@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1280</width>
+    <height>800</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QComboBox" name="comboBox">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>20</y>
+      <width>221</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>90</y>
+      <width>101</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>GPS:</string>
+    </property>
+   </widget>
+   <widget class="QPlainTextEdit" name="plainTextEdit">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>130</y>
+      <width>350</width>
+      <height>600</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPlainTextEdit" name="plainTextEdit_2">
+    <property name="geometry">
+     <rect>
+      <x>460</x>
+      <y>130</y>
+      <width>350</width>
+      <height>600</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPlainTextEdit" name="plainTextEdit_3">
+    <property name="geometry">
+     <rect>
+      <x>860</x>
+      <y>130</y>
+      <width>350</width>
+      <height>600</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_2">
+    <property name="geometry">
+     <rect>
+      <x>460</x>
+      <y>90</y>
+      <width>101</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>BrainState:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_3">
+    <property name="geometry">
+     <rect>
+      <x>860</x>
+      <y>90</y>
+      <width>101</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Decision:</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>1280</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 61 - 0
src/tool/view_group_grpc/view_group_grpc.pro

@@ -0,0 +1,61 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+system(protoc -I=./../../include/proto3 --cpp_out=./../../include/msgtype   ./../../include/proto3/grpcgroup.proto)
+
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    ../../driver/driver_group_grpc_client/grpcgroup.grpc.pb.cc \
+    ../../include/msgtype/brainstate.pb.cc \
+    ../../include/msgtype/decition.pb.cc \
+    ../../include/msgtype/gpsimu.pb.cc \
+    ../../include/msgtype/groupmsg.pb.cc \
+    ../../include/msgtype/grpcgroup.pb.cc \
+    groupqueryclient.cpp \
+    main.cpp \
+    mainwindow.cpp
+
+HEADERS += \
+    ../../driver/driver_group_grpc_client/grpcgroup.grpc.pb.h \
+    ../../include/msgtype/brainstate.pb.h \
+    ../../include/msgtype/decition.pb.h \
+    ../../include/msgtype/gpsimu.pb.h \
+    ../../include/msgtype/groupmsg.pb.h \
+    ../../include/msgtype/grpcgroup.pb.h \
+    groupqueryclient.h \
+    mainwindow.h
+
+FORMS += \
+    mainwindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}
+
+
+!include(../../../include/ivgrpc.pri ) {
+    error( "Couldn't find the ivgrpc.pri file!" )
+}