瀏覽代碼

change for add vehicle type vin version show in PAD.

yuchuli 2 年之前
父節點
當前提交
7c3f522cb9

+ 5 - 0
src/driver/driver_grpc_server/driver_grpc_server.yaml

@@ -30,6 +30,11 @@ querymessage:
     msgname: brainstate
     buffersize: 10000
     buffercount: 1
+    
+  otavehinfo:
+    msgname: otavehinfo
+    buffersize: 1000
+    buffercount: 1
 
 
 ctrlmessage:

+ 4 - 2
src/driver/driver_ota_client/driver_ota_client.pro

@@ -21,7 +21,8 @@ SOURCES += \
         md5.cpp \
         md5file.cpp \
         ota.grpc.pb.cc \
-        otaclient.cpp
+        otaclient.cpp \
+    ../../include/msgtype/vehinfo.pb.cc
 
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin
@@ -35,7 +36,8 @@ HEADERS += \
     md5file.h \
     md5global.h \
     ota.grpc.pb.h \
-    otaclient.h
+    otaclient.h \
+    ../../include/msgtype/vehinfo.pb.h
 
 
 !include(../../../include/common.pri ) {

+ 46 - 1
src/driver/driver_ota_client/otaclient.cpp

@@ -23,6 +23,8 @@ extern std::string gstrwaitnettime;
 
 otaclient::otaclient()
 {
+    mpthreadinfo = new std::thread(&otaclient::threadbroadvehinfo,this);
+
     mstrserverip = gstrserverip;
     mstrserverport = gstrserverport;
     iv::xmlparam::Xmlparam xp("./vin.xml");
@@ -69,6 +71,15 @@ otaclient::otaclient()
         mbInitOK = false;
     }
     xFile.close();
+
+
+}
+
+otaclient::~otaclient()
+{
+    mbRun = false;
+    requestInterruption();
+    mpthreadinfo->join();
 }
 
 void otaclient::run()
@@ -276,7 +287,7 @@ void otaclient::run()
         }
         else
         {
-            qDebug("nFileSize is %ld pos is %ld baFile size is %ld",xFileReply.nfilesize(),nPos,
+            qDebug("nFileSize is %ld pos is %lld baFile size is %d",xFileReply.nfilesize(),nPos,
                    baFile.size());
 #ifndef UBUNTU1604
             givlog->verbose("nFileSize is %ld pos is %ld baFile size is %ld",xFileReply.nfilesize(),nPos,
@@ -294,3 +305,37 @@ void otaclient::run()
 
 
 }
+
+void otaclient::threadbroadvehinfo()
+{
+    void * pa = iv::modulecomm::RegisterSend("otavehinfo",1000,1);
+
+    int ncount = 100;
+
+    while(mbRun)
+    {
+        if(ncount>=100)
+        {
+            iv::veh::vehinfo xvehinfo;
+            xvehinfo.set_vin(mstrVIN);
+            xvehinfo.set_type(mstrVehicleType);
+            xvehinfo.set_version(mstrVersion);
+            int ndatasize = xvehinfo.ByteSize();
+            std::shared_ptr<char> pstr_ptr = std::shared_ptr<char>(new char[ndatasize]);
+            if(xvehinfo.SerializeToArray(pstr_ptr.get(),ndatasize))
+            {
+                iv::modulecomm::ModuleSendMsg(pa,pstr_ptr.get(),ndatasize);
+                std::cout<<"share veh info."<<std::endl;
+            }
+            else
+            {
+                std::cout<<"warning: "<<"serialize vehinfo fail."<<std::endl;
+            }
+            ncount = 0;
+        }
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        ncount++;
+    }
+
+    iv::modulecomm::Unregister(pa);
+}

+ 11 - 3
src/driver/driver_ota_client/otaclient.h

@@ -5,8 +5,12 @@
 
 #include <grpcpp/grpcpp.h>
 
+#include <thread>
+
 #include "ota.grpc.pb.h"
 #include "ota.pb.h"
+#include "modulecomm.h"
+#include "vehinfo.pb.h"
 
 using grpc::Channel;
 using grpc::ClientContext;
@@ -16,17 +20,21 @@ class otaclient : public QThread
 {
 public:
     otaclient();
+    ~otaclient();
 private:
     std::string mstrserverip =  "0.0.0.0";//"123.57.212.138";
     std::string mstrserverport = "60051";//"9000";
 
-    std::string mstrVIN = "AAAAAAAAAAAAAAAAA";
-    std::string mstrVehicleType = "GE3";
-    std::string mstrVersion = "0.0.0";
+    std::string mstrVIN = "UnKnown";
+    std::string mstrVehicleType = "UnKnown";
+    std::string mstrVersion = "UnKnown";
 
 private:
     void run();
     bool mbInitOK = true;
+    void threadbroadvehinfo();
+    bool mbRun = true;
+    std::thread * mpthreadinfo;
 };
 
 #endif // OTACLIENT_H

+ 15 - 0
src/include/proto/vehinfo.proto

@@ -0,0 +1,15 @@
+syntax = "proto2";
+
+package iv.veh;
+
+
+
+message vehinfo
+{
+	required string VIN 		= 1;//车辆VIN
+	required string type		= 2;//type
+	required string	version		= 3;//version
+
+};
+
+

+ 4 - 2
src/ui/ADCIntelligentShow_grpc/ADCIntelligentShow_grpc_android.pro

@@ -45,7 +45,8 @@ SOURCES += \
     ivview.cpp \
         main.cpp \
     adcintelligentshow.cpp \
-    myview.cpp
+    myview.cpp \
+    proto1804/msgtype/vehinfo.pb.cc
 
 HEADERS += \
 #        ../../decition/common/common/gps_type.h \
@@ -66,7 +67,8 @@ HEADERS += \
         ivmapview.h \
         ivview.h \
         myview.h \
-        pos_def.h
+        pos_def.h \
+        proto1804/msgtype/vehinfo.pb.h
 
 FORMS += \
         adcintelligentshow.ui \

+ 54 - 6
src/ui/ADCIntelligentShow_grpc/adcintelligentshow.cpp

@@ -126,6 +126,20 @@ void ListenBrainState(const char * strdata,const unsigned int nSize,const unsign
     gAShow->UpdateBrainState(xbrainstate);
 }
 
+void ListenVehInfo(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    (void)&index;
+    (void)dt;
+    (void)strmemname;
+    iv::veh::vehinfo xvehinfo;
+    if(!xvehinfo.ParseFromArray(strdata,nSize))
+    {
+        std::cout<<"ListenVehInfo Parse error."<<std::endl;
+        return;
+    }
+    gAShow->UpdateOTAVehInfo(xvehinfo);
+}
+
 void ListenTraceMap(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
 {
     (void)&index;
@@ -161,6 +175,10 @@ void ListenTraceMap(const char * strdata,const unsigned int nSize,const unsigned
         {
             ListenRadar(strdata,nDataLen,0,0,0);
         }
+        if(strncmp(msgname,"otavehinfo",256) == 0)
+        {
+            ListenVehInfo(strdata,nDataLen,0,0,0);
+        }
     }
 #endif
 
@@ -257,6 +275,8 @@ ADCIntelligentShow::ADCIntelligentShow(QWidget *parent) :
     pa = iv::modulecomm::RegisterRecv("radar",ListenRadar);
     mparadar = pa;
 
+    pa = iv::modulecomm::RegisterRecv("otavehinfo",ListenVehInfo);
+
     mpadst = iv::modulecomm::RegisterSend("xodrreq",1000,1);
 
 
@@ -288,6 +308,10 @@ ADCIntelligentShow::ADCIntelligentShow(QWidget *parent) :
     ui->label_station->setStyleSheet("background: transparent; color: white;font: 50px 'Arial';");
     ui->label_station->setText("");
 
+    ui->label_vehinfo->setStyleSheet("color: rgb(220, 220, 220);font: 15px 'Arial';");
+
+    ui->label_vehinfo->setText("No Vehicle Type & VIN Info");
+
 
 
     if(gvectorpos.size()>0)
@@ -299,6 +323,7 @@ ADCIntelligentShow::ADCIntelligentShow(QWidget *parent) :
     mpDS = new DialogSetting(this);
     connect(mpDS,SIGNAL(signalswith(int)),this,SLOT(onSwitchClick(int)));
     connect(mpDS,SIGNAL(signalMode(int)),this,SLOT(onModeClick(int)));
+    connect(this,SIGNAL(signalvehinfoupdate()),this,SLOT(onOTAVehInfoUpdate()));
 //    ui->pushButton_go->setStyleSheet("color: red");
 
     ///////////////////////////////////////////////////////////////////////
@@ -575,7 +600,7 @@ void ADCIntelligentShow::onconnTimer()
     {
         //ui->connect->setText(QStringLiteral("已连接"));
         ui->connect->setStyleSheet("image: url(:/new/pic/connect.png);");
-        if(((xTime - mnTimeGPS)>1000) &&(mnstylegps != 0))
+        if((abs(xTime - mnTimeGPS)>1000) &&(mnstylegps != 0))
         {
             ui->lng->setText(" ");
             ui->lat->setText(" ");
@@ -584,29 +609,29 @@ void ADCIntelligentShow::onconnTimer()
             mnstylegps = 0;
         }
 
-        if(((xTime - mnTimeLidar)>1000) &&(mnstylelidar != 1))
+        if((abs(xTime - mnTimeLidar)>1000) &&(mnstylelidar != 1))
         {
             ui->lidarimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
             mnstylelidar = 1;
         }
-        if(((xTime - mnTimeLidar)<1000) &&(mnstylelidar != 2))
+        if((abs(xTime - mnTimeLidar)<1000) &&(mnstylelidar != 2))
         {
             ui->lidarimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
             mnstylelidar = 2;
         }
 
-        if(((xTime - mnTimeRADAR)>1000) && (mnstyleradar != 1))
+        if((abs(xTime - mnTimeRADAR)>1000) && (mnstyleradar != 1))
         {
             ui->radarimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
             mnstyleradar = 1;
         }
-        if(((xTime - mnTimeRADAR)<1000) && (mnstyleradar != 2))
+        if(abs((xTime - mnTimeRADAR)<1000) && (mnstyleradar != 2))
         {
             ui->radarimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
             mnstyleradar = 2;
         }
 
-        if((xTime- mnTimeDection)>1000)
+        if(abs(xTime- mnTimeDection)>1000)
         {
             ui->acc->setText(" ");
             ui->swerve->setText(" ");
@@ -621,6 +646,7 @@ void ADCIntelligentShow::onconnTimer()
             }
         }
 
+
         if(navigation_data.size()>0)
         {
             ui->mapimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
@@ -1125,6 +1151,16 @@ void ADCIntelligentShow::UpdateRADAR(iv::radar::radarobjectarray *pxobj)
     mpivmapview->setradar(pxobj);
 }
 
+void ADCIntelligentShow::UpdateOTAVehInfo(iv::veh::vehinfo &pvehinfo)
+{
+    mMutexVehInfo.lock();
+    mvehinfo.CopyFrom(pvehinfo);
+    mMutexVehInfo.unlock();
+    mnVehInfoTime = QDateTime::currentMSecsSinceEpoch();
+
+    emit signalvehinfoupdate();
+}
+
 
 void ADCIntelligentShow::on_pushButton_nextstation_clicked()
 {
@@ -1411,3 +1447,15 @@ bool ADCIntelligentShow::WritePos()
 
     return true;
 }
+
+void ADCIntelligentShow::onOTAVehInfoUpdate()
+{
+    iv::veh::vehinfo xvehinfo;
+    mMutexVehInfo.lock();
+    xvehinfo.CopyFrom(mvehinfo);
+    mMutexVehInfo.unlock();
+
+    char strout[1000];
+    snprintf(strout,1000,"Type:%s   Version:%s   VIN:%s",xvehinfo.type().data(),xvehinfo.version().data(),xvehinfo.vin().data());
+    ui->label_vehinfo->setText(strout);
+}

+ 11 - 1
src/ui/ADCIntelligentShow_grpc/adcintelligentshow.h

@@ -29,6 +29,7 @@
 #include "decition.pb.h"
 #include "hmi.pb.h"
 #include "radarobjectarray.pb.h"
+#include "vehinfo.pb.h"
 
 #include "gps_nbtype.h"
 #include "myview.h"
@@ -195,6 +196,7 @@ signals:
     void signalGPSIMU();
     void signalbrainstate();
     void signaldection();
+    void signalvehinfoupdate();
 
 private slots:
     void onUpdateGPSIMU();
@@ -217,9 +219,12 @@ private slots:
 
     void on_pushButton_DelStation_clicked();
 
+    void onOTAVehInfoUpdate();
+
 public slots:
     void slotAlarm();
 
+
 public:
     QSound *soundAlarm;
 
@@ -230,6 +235,7 @@ public:
     void UpdateBrainState(iv::brain::brainstate xbrainstate);
     void UpdateDection(iv::brain::decition xdecision);
     void UpdateRADAR(iv::radar::radarobjectarray * pxobj);
+    void UpdateOTAVehInfo(iv::veh::vehinfo & pvehinfo);
 
 
 #ifdef Android
@@ -255,6 +261,9 @@ private:
     iv::radar::radarobjectarray mradarobj;
     QMutex mMutexRadar;
 
+    iv::veh::vehinfo mvehinfo;
+    QMutex mMutexVehInfo;
+
     ivmapview * mpivmapview;
 
     qint64 mnTimeGPS = 0;
@@ -262,9 +271,10 @@ private:
     qint64 mnTimeBrain = 0;
     qint64 mnTimeDection = 0;
     qint64 mnTimeRADAR = 0;
+    qint64 mnVehInfoTime = 0;
 
 
-    void * mpagps, * mpatracemap, * mpalidarobs, * mpabrainstate, * mpadecision, * mparadar;
+    void * mpagps, * mpatracemap, * mpalidarobs, * mpabrainstate, * mpadecision, * mparadar,* mpavehinfo;
 
     void *mpadst;
     int mnStationIndex = 0;

+ 14 - 0
src/ui/ADCIntelligentShow_grpc/adcintelligentshow.ui

@@ -1043,6 +1043,19 @@ border:7px groove rgb(0,45,70);</string>
      <string/>
     </property>
    </widget>
+   <widget class="QLabel" name="label_vehinfo">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>1010</y>
+      <width>621</width>
+      <height>20</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>TextLabel</string>
+    </property>
+   </widget>
    <zorder>pushButton_2</zorder>
    <zorder>run</zorder>
    <zorder>mapimg</zorder>
@@ -1083,6 +1096,7 @@ border:7px groove rgb(0,45,70);</string>
    <zorder>label_17</zorder>
    <zorder>break_1</zorder>
    <zorder>pushButton_Setting</zorder>
+   <zorder>label_vehinfo</zorder>
   </widget>
  </widget>
  <layoutdefault spacing="6" margin="11"/>

+ 1 - 0
src/ui/ADCIntelligentShow_grpc/main.cpp

@@ -211,6 +211,7 @@ int main(int argc, char *argv[])
        xrpcthread.addquerymsgunit("radar",100000,1);
        xrpcthread.addctrlmsgunit("pad",1000,1);
        xrpcthread.addctrlmsgunit("xodrreq",1000,1);
+       xrpcthread.addquerymsgunit("otavehinfo",1000,1);
 
 #ifndef Android
        xrpcthread.startlisten();