Browse Source

根据Vbox给的红绿灯信息,将其实时显示

fujiankuan 4 years ago
parent
commit
a36dc3f33a

+ 195 - 0
src/ui/ui_ads_hmi/ADCIntelligentVehicle.cpp

@@ -338,6 +338,65 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
     mpamapreq = iv::modulecomm::RegisterSend("mapreq",1000,1);
     shareMapReqMsg();
 
+    ModuleFun funvbox = std::bind(&ADCIntelligentVehicle::UpdateVbox,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpaplantrace = iv::modulecomm::RegisterRecvPlus("vbox",funvbox);
+
+    ui->lcdNumber->setDigitCount(3); //设置显示几个数字
+    ui->lcdNumber->setMode(QLCDNumber::Dec);
+    ui->lcdNumber->setSegmentStyle(QLCDNumber::Flat);//设置数字字体:Outline,轮廓突出,颜色为背景色;Filled,内部填充型,颜色为黑色;Flat,平面型
+    // 设置数字颜色时要注意:  函数setSegmentStyle(QLCDNumber::Flat)中选择Flat属性,否则在setColor()设置数字颜色时不生效
+    // 设置背景色直接用setStyleSheet()函数设定就可以了。
+    //调色板
+    QPalette lcdpat = ui->lcdNumber->palette();
+    /*设置颜色,整体背景颜色 颜色蓝色,此函数的第一个参数可以设置多种。如文本、按钮按钮文字、多种*/
+    lcdpat.setColor(QPalette::Normal,QPalette::WindowText,Qt::red);
+    //设置当前窗口的调色板
+    ui->lcdNumber->setPalette(lcdpat);
+    //设置背景色
+    ui->lcdNumber->setStyleSheet("background-color: black");
+    //ui->lcdNumber->display(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
+    ui->lcdNumber->display(0);
+
+    ui->lcdNumber_2->setDigitCount(3);
+    ui->lcdNumber_2->setMode(QLCDNumber::Dec);
+    ui->lcdNumber_2->setSegmentStyle(QLCDNumber::Flat);
+    ui->lcdNumber_2->setPalette(lcdpat);
+    ui->lcdNumber_2->setStyleSheet("background-color: black");
+    ui->lcdNumber_2->display(0);
+
+    ui->lcdNumber_3->setDigitCount(3);
+    ui->lcdNumber_3->setMode(QLCDNumber::Dec);
+    ui->lcdNumber_3->setSegmentStyle(QLCDNumber::Flat);
+    ui->lcdNumber_3->setPalette(lcdpat);
+    ui->lcdNumber_3->setStyleSheet("background-color: black");
+    ui->lcdNumber_3->display(0);
+
+    ui->lcdNumber_4->setDigitCount(3);
+    ui->lcdNumber_4->setMode(QLCDNumber::Dec);
+    ui->lcdNumber_4->setSegmentStyle(QLCDNumber::Flat);
+    ui->lcdNumber_4->setPalette(lcdpat);
+    ui->lcdNumber_4->setStyleSheet("background-color: black");
+    ui->lcdNumber_4->display(0);
+
+    // 新建qimage
+    // QImage img,img2,img3,img4;
+    // 加载图片
+    img.load(":/light_image/diaotou-black.png");
+    img = img.scaled(66,66,Qt::IgnoreAspectRatio);
+    ui->label_38->setPixmap(QPixmap::fromImage(img));
+    img2.load(":/light_image/zuoguai-black.png");
+    img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
+    ui->label_33->setPixmap(QPixmap::fromImage(img2));
+    img3.load(":/light_image/zhixing-black.png");
+    img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
+    ui->label_35->setPixmap(QPixmap::fromImage(img3));
+    img4.load(":/light_image/youguai-black.png");
+    img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
+    ui->label_32->setPixmap(QPixmap::fromImage(img4));
+
+    mTimerState1.setTimerType(Qt::PreciseTimer);    //设置计时器的精确程度    Qt::PreciseTimer值为0,含义:精确定时器试图保持毫秒精度
+    connect(&mTimerState1,SIGNAL(timeout()),this,SLOT(onStateTimer1()));//广播发送UDP数据报
+    mTimerState1.start(100);   //定时100ms
 
 }
 
@@ -1867,3 +1926,139 @@ void ADCIntelligentVehicle::shareMapReqMsg()
     std::cout<<"iv::map::mapreq serialize OK."<<std::endl;
     delete str;
 }
+
+void ADCIntelligentVehicle::UpdateVbox(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    iv::vbox::vbox xvbox;
+    if(!xvbox.ParseFromArray(strdata,nSize))
+    {
+        gIvlog->warn("ADCIntelligentVehicle::UpdateVbox parse errror. nSize is %d",nSize);
+        return;
+    }
+    ServiceCarStatus.st_straight = xvbox.st_straight();
+    ServiceCarStatus.st_left = xvbox.st_left();
+    ServiceCarStatus.st_right = xvbox.st_right();
+    ServiceCarStatus.st_turn = xvbox.st_turn();
+    ServiceCarStatus.time_straight = xvbox.time_straight();
+    ServiceCarStatus.time_left = xvbox.time_left();
+    ServiceCarStatus.time_right = xvbox.time_right();
+    ServiceCarStatus.time_turn = xvbox.time_turn();
+
+
+}
+
+void ADCIntelligentVehicle::onStateTimer1()
+{
+    ui->lcdNumber->display((int)ServiceCarStatus.time_turn);
+    ui->lcdNumber_2->display((int)ServiceCarStatus.time_left);
+    ui->lcdNumber_3->display((int)ServiceCarStatus.time_straight);
+    ui->lcdNumber_4->display((int)ServiceCarStatus.time_right);
+    switch (ServiceCarStatus.st_turn) {
+    case 0:
+        img.load(":/light_image/diaotou-black.png");
+        img = img.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_38->setPixmap(QPixmap::fromImage(img));
+        break;
+    case 1:
+        img.load(":/light_image/diaotou-green.png");
+        img = img.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_38->setPixmap(QPixmap::fromImage(img));
+        break;
+    case 2:
+        img.load(":/light_image/diaotou-red.png");
+        img = img.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_38->setPixmap(QPixmap::fromImage(img));
+        break;
+    case 3:
+        img.load(":/light_image/diaotou-yellow.png");
+        img = img.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_38->setPixmap(QPixmap::fromImage(img));
+        break;
+    default:
+        img.load(":/light_image/diaotou-black.png");
+        img = img.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_38->setPixmap(QPixmap::fromImage(img));
+        break;
+    }
+    switch (ServiceCarStatus.st_left) {
+    case 0:
+        img2.load(":/light_image/zuoguai-black.png");
+        img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_33->setPixmap(QPixmap::fromImage(img2));
+        break;
+    case 1:
+        img2.load(":/light_image/zuoguai-green.png");
+        img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_33->setPixmap(QPixmap::fromImage(img2));
+        break;
+    case 2:
+        img2.load(":/light_image/zuoguai-red.png");
+        img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_33->setPixmap(QPixmap::fromImage(img2));
+        break;
+    case 3:
+        img2.load(":/light_image/zuoguai-yellow.png");
+        img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_33->setPixmap(QPixmap::fromImage(img2));
+        break;
+    default:
+        img2.load(":/light_image/zuoguai-black.png");
+        img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_33->setPixmap(QPixmap::fromImage(img2));
+        break;
+    }
+    switch (ServiceCarStatus.st_straight) {
+    case 0:
+        img3.load(":/light_image/zhixing-black.png");
+        img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_35->setPixmap(QPixmap::fromImage(img3));
+        break;
+    case 1:
+        img3.load(":/light_image/zhixing-green.png");
+        img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_35->setPixmap(QPixmap::fromImage(img3));
+        break;
+    case 2:
+        img3.load(":/light_image/zhixing-red.png");
+        img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_35->setPixmap(QPixmap::fromImage(img3));
+        break;
+    case 3:
+        img3.load(":/light_image/zhixing-yellow.png");
+        img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_35->setPixmap(QPixmap::fromImage(img3));
+        break;
+    default:
+        img3.load(":/light_image/zhixing-black.png");
+        img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_35->setPixmap(QPixmap::fromImage(img3));
+        break;
+    }
+    switch (ServiceCarStatus.st_right) {
+    case 0:
+        img4.load(":/light_image/youguai-black.png");
+        img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_32->setPixmap(QPixmap::fromImage(img4));
+        break;
+    case 1:
+        img4.load(":/light_image/youguai-green.png");
+        img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_32->setPixmap(QPixmap::fromImage(img4));
+        break;
+    case 2:
+        img4.load(":/light_image/youguai-red.png");
+        img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_32->setPixmap(QPixmap::fromImage(img4));
+        break;
+    case 3:
+        img4.load(":/light_image/youguai-yellow.png");
+        img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_32->setPixmap(QPixmap::fromImage(img4));
+        break;
+    default:
+        img4.load(":/light_image/youguai-black.png");
+        img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
+        ui->label_32->setPixmap(QPixmap::fromImage(img4));
+        break;
+    }
+}

+ 11 - 0
src/ui/ui_ads_hmi/ADCIntelligentVehicle.h

@@ -62,6 +62,7 @@
 #include "v2x.pb.h"
 #include "ivlog.h"
 #include "mapreq.pb.h"
+#include "vbox.pb.h"
 
 extern iv::Ivlog * gIvlog;
 
@@ -175,6 +176,7 @@ public slots:
 
     void onRecvUDP();
     void onStateTimer();
+    void onStateTimer1();
 protected:
 
     void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;// 加/减键进行缩放
@@ -336,6 +338,15 @@ private:
 public:
     void * mpamapreq;   //请求地图
     void shareMapReqMsg();
+
+private:
+    void * mpaVbox;
+public:
+    void UpdateVbox(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+
+private:
+    QImage img,img2,img3,img4;
+    QTimer mTimerState1;
 };
 
 

+ 16 - 0
src/ui/ui_ads_hmi/ADCIntelligentVehicle.qrc

@@ -9,5 +9,21 @@
     </qresource>
     <qresource prefix="/">
         <file>adsuiicon.png</file>
+        <file>light_image/zuoguai-yellow.png</file>
+        <file>light_image/zuoguai-red.png</file>
+        <file>light_image/zuoguai-green.png</file>
+        <file>light_image/zuoguai-black.png</file>
+        <file>light_image/zhixing-yellow.png</file>
+        <file>light_image/zhixing-red.png</file>
+        <file>light_image/zhixing-green.png</file>
+        <file>light_image/zhixing-black.png</file>
+        <file>light_image/youguai-yellow.png</file>
+        <file>light_image/youguai-red.png</file>
+        <file>light_image/youguai-green.png</file>
+        <file>light_image/youguai-black.png</file>
+        <file>light_image/diaotou-yellow.png</file>
+        <file>light_image/diaotou-red.png</file>
+        <file>light_image/diaotou-green.png</file>
+        <file>light_image/diaotou-black.png</file>
     </qresource>
 </RCC>

+ 184 - 8
src/ui/ui_ads_hmi/ADCIntelligentVehicle.ui

@@ -98,14 +98,14 @@
      </rect>
     </property>
     <property name="currentIndex">
-     <number>2</number>
+     <number>0</number>
     </property>
     <widget class="QWidget" name="page_0">
      <widget class="QGroupBox" name="groupBox_2">
       <property name="geometry">
        <rect>
-        <x>120</x>
-        <y>440</y>
+        <x>110</x>
+        <y>310</y>
         <width>261</width>
         <height>191</height>
        </rect>
@@ -178,8 +178,8 @@
      <widget class="QGroupBox" name="groupBox_3">
       <property name="geometry">
        <rect>
-        <x>520</x>
-        <y>440</y>
+        <x>470</x>
+        <y>310</y>
         <width>221</width>
         <height>191</height>
        </rect>
@@ -355,7 +355,7 @@
       <property name="geometry">
        <rect>
         <x>150</x>
-        <y>200</y>
+        <y>90</y>
         <width>541</width>
         <height>81</height>
        </rect>
@@ -377,7 +377,7 @@
       <property name="geometry">
        <rect>
         <x>280</x>
-        <y>290</y>
+        <y>220</y>
         <width>281</width>
         <height>21</height>
        </rect>
@@ -398,6 +398,183 @@
        <string>Start A Journey Of Autopilot</string>
       </property>
      </widget>
+     <widget class="QGroupBox" name="groupBox_11">
+      <property name="geometry">
+       <rect>
+        <x>100</x>
+        <y>520</y>
+        <width>591</width>
+        <height>311</height>
+       </rect>
+      </property>
+      <property name="font">
+       <font>
+        <family>AR PL UKai CN</family>
+       </font>
+      </property>
+      <property name="styleSheet">
+       <string notr="true">color: rgb(238, 238, 236);</string>
+      </property>
+      <property name="title">
+       <string>V2X红绿灯</string>
+      </property>
+      <widget class="QLabel" name="label_31">
+       <property name="geometry">
+        <rect>
+         <x>320</x>
+         <y>220</y>
+         <width>54</width>
+         <height>26</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>直行</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_32">
+       <property name="geometry">
+        <rect>
+         <x>420</x>
+         <y>90</y>
+         <width>66</width>
+         <height>66</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_33">
+       <property name="geometry">
+        <rect>
+         <x>190</x>
+         <y>90</y>
+         <width>66</width>
+         <height>66</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_34">
+       <property name="geometry">
+        <rect>
+         <x>90</x>
+         <y>220</y>
+         <width>54</width>
+         <height>26</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>掉头</string>
+       </property>
+      </widget>
+      <widget class="QLCDNumber" name="lcdNumber_2">
+       <property name="geometry">
+        <rect>
+         <x>190</x>
+         <y>170</y>
+         <width>64</width>
+         <height>33</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">color: rgb(204, 0, 0);</string>
+       </property>
+      </widget>
+      <widget class="QLCDNumber" name="lcdNumber_3">
+       <property name="geometry">
+        <rect>
+         <x>310</x>
+         <y>170</y>
+         <width>64</width>
+         <height>33</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">color: rgb(204, 0, 0);</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_35">
+       <property name="geometry">
+        <rect>
+         <x>310</x>
+         <y>90</y>
+         <width>66</width>
+         <height>66</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
+      </widget>
+      <widget class="QLCDNumber" name="lcdNumber">
+       <property name="geometry">
+        <rect>
+         <x>80</x>
+         <y>170</y>
+         <width>64</width>
+         <height>33</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">color: rgb(204, 0, 0);</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_36">
+       <property name="geometry">
+        <rect>
+         <x>200</x>
+         <y>220</y>
+         <width>54</width>
+         <height>26</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>左转</string>
+       </property>
+      </widget>
+      <widget class="QLCDNumber" name="lcdNumber_4">
+       <property name="geometry">
+        <rect>
+         <x>420</x>
+         <y>170</y>
+         <width>64</width>
+         <height>33</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">color: rgb(204, 0, 0);</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_37">
+       <property name="geometry">
+        <rect>
+         <x>430</x>
+         <y>220</y>
+         <width>54</width>
+         <height>26</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>右转</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_38">
+       <property name="geometry">
+        <rect>
+         <x>80</x>
+         <y>90</y>
+         <width>66</width>
+         <height>66</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
+      </widget>
+     </widget>
     </widget>
     <widget class="QWidget" name="page_1">
      <widget class="QLabel" name="lb_current_speed_big">
@@ -2062,7 +2239,6 @@ p, li { white-space: pre-wrap; }
  <resources>
   <include location="ADCIntelligentVehicle.qrc"/>
   <include location="ADCIntelligentVehicle.qrc"/>
-  <include location="ADCIntelligentVehicle.qrc"/>
  </resources>
  <connections>
   <connection>

+ 12 - 0
src/ui/ui_ads_hmi/common/car_status.h

@@ -87,6 +87,18 @@ public:
     iv::GPSData location;		//当前车辆位置
     boost::array<iv::ObstacleBasic, 64> obs_radar;//毫米波雷达的障碍物数据
     iv::ultrasonic_obs multrasonic_obs;
+
+    /*Vbox红绿灯*/
+    uint32_t st_straight;
+    uint32_t st_left;
+    uint32_t st_right;
+    uint32_t st_turn;
+    uint32_t time_straight;
+    uint32_t time_left;
+    uint32_t time_right;
+    uint32_t time_turn;
+
+
 };
 typedef boost::serialization::singleton<iv::CarStatus> CarStatusSingleton;//非线程安全,注意多线程加锁,单例模式
 }

BIN
src/ui/ui_ads_hmi/light_image/diaotou-black.png


BIN
src/ui/ui_ads_hmi/light_image/diaotou-green.png


BIN
src/ui/ui_ads_hmi/light_image/diaotou-red.png


BIN
src/ui/ui_ads_hmi/light_image/diaotou-yellow.png


BIN
src/ui/ui_ads_hmi/light_image/youguai-black.png


BIN
src/ui/ui_ads_hmi/light_image/youguai-green.png


BIN
src/ui/ui_ads_hmi/light_image/youguai-red.png


BIN
src/ui/ui_ads_hmi/light_image/youguai-yellow.png


BIN
src/ui/ui_ads_hmi/light_image/zhixing-black.png


BIN
src/ui/ui_ads_hmi/light_image/zhixing-green.png


BIN
src/ui/ui_ads_hmi/light_image/zhixing-red.png


BIN
src/ui/ui_ads_hmi/light_image/zhixing-yellow.png


BIN
src/ui/ui_ads_hmi/light_image/zuoguai-black.png


BIN
src/ui/ui_ads_hmi/light_image/zuoguai-green.png


BIN
src/ui/ui_ads_hmi/light_image/zuoguai-red.png


BIN
src/ui/ui_ads_hmi/light_image/zuoguai-yellow.png


+ 8 - 1
src/ui/ui_ads_hmi/look.cpp

@@ -104,8 +104,15 @@ Look_decition::~Look_decition()
 
 void Look_decition::timeoutslot()
 {
+    look1 = ServiceCarStatus.mfAcc;
+    look2 = ServiceCarStatus.mfBrake;
+    look3 = ServiceCarStatus.mfWheel;
+    look4 = ServiceCarStatus.speed;
+    look5 = ServiceCarStatus.mLidarObs;
+    look6 = ServiceCarStatus.mRadarObs;
+    look7 = ServiceCarStatus.mObs;
     lineEdit->setText(QString::number(look1));//决策油门
-    lineEdit_2->setText(QString::number(0.0));//决策刹车
+    lineEdit_2->setText(QString::number(look2));//决策刹车
     lineEdit_3->setText(QString::number(look3));//决策转向
     lineEdit_4->setText(QString::number(look4));//决策速度
     lineEdit_5->setText(QString::number(look5));//激光雷达距离

+ 4 - 2
src/ui/ui_ads_hmi/ui_ads_hmi.pro

@@ -51,7 +51,8 @@ SOURCES += \
     ../../include/msgtype/canstate.pb.cc \
     ../../include/msgtype/v2x.pb.cc \
     ../../include/msgtype/chassis.pb.cc \
-    ../../include/msgtype/mapreq.pb.cc
+    ../../include/msgtype/mapreq.pb.cc  \
+    ../../include/msgtype/vbox.pb.cc
 
 HEADERS += \
         ADCIntelligentVehicle.h \
@@ -69,7 +70,8 @@ HEADERS += \
     ../../include/msgtype/gpsimu.pb.h \
     ../../include/msgtype/v2x.pb.h \
     ../../include/msgtype/chassis.pb.h \
-    ../../include/msgtype/mapreq.pb.h
+    ../../include/msgtype/mapreq.pb.h \
+    ../../include/msgtype/vbox.pb.h
 
 
 FORMS += \