فهرست منبع

add brainstate message process

jiaolili 3 سال پیش
والد
کامیت
2a027a5c0e

+ 9 - 4
src/v2x/CommunicatePlatform/CommunicatePlatform.pro

@@ -22,8 +22,11 @@ DEFINES += QT_DEPRECATED_WARNINGS
 # 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
-INCLUDEPATH += $$PWD/../../../include/
-LIBS += -L$$PWD/../../../bin/ -lxmlparam -lmodulecomm -livlog -livfault -lprotobuf
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+LIBS += -lprotobuf
 
 INCLUDEPATH += $$PWD/../../include/msgtype
 
@@ -38,7 +41,8 @@ SOURCES += \
         ../../include/msgtype/v2r.pb.cc \
         ../../include/msgtype/chassis.pb.cc \
         ../../include/msgtype/gpsimu.pb.cc \
-        ../../include/msgtype/hmi.pb.cc
+        ../../include/msgtype/hmi.pb.cc \
+        ../../include/msgtype/brainstate.pb.cc
 
 HEADERS += \
         mainwindow.h \
@@ -48,7 +52,8 @@ HEADERS += \
         ../../include/msgtype/v2r.pb.h \
         ../../include/msgtype/chassis.pb.h \
         ../../include/msgtype/gpsimu.pb.h \
-        ../../include/msgtype/hmi.pb.h
+        ../../include/msgtype/hmi.pb.h \
+        ../../include/msgtype/brainstate.pb.h
 
 FORMS += \
         mainwindow.ui

+ 59 - 0
src/v2x/CommunicatePlatform/mainwindow.cpp

@@ -28,6 +28,10 @@ MainWindow::MainWindow(QWidget *parent) :
     ModuleFun funControl =std::bind(&MainWindow::UpdateControl,this,std::placeholders::_1, \
                                    std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
     mpMemControl = iv::modulecomm::RegisterRecvPlus("hcp2_chassis",funControl);
+    //ShareMem: state
+    ModuleFun funState =std::bind(&MainWindow::UpdateState,this,std::placeholders::_1, \
+                                   std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpMemState = iv::modulecomm::RegisterRecvPlus("hcp2_brainstate",funControl);
 }
 
 MainWindow::~MainWindow()
@@ -488,6 +492,22 @@ void MainWindow::UpdateControl(const char *strdata, const unsigned int nSize, co
     }
 
 }
+
+void MainWindow::UpdateState(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+    iv::brain::brainstate xstate;
+    if(!xstate.ParseFromArray(strdata,nSize))
+    {
+        mivlog->warn("ADCIntelligentVehicle::UpdateGPSIMU parse error. nSize is %d",nSize);
+        return;
+    }
+    bool isSend=false;
+    //xstate.has
+    if(xstate.has_vehicle_state()) {
+        int type = xstate.vehicle_state();
+        m_radio->sendResponseMessage(type);
+    }
+}
 void MainWindow::setRadioControlMemory()
 {
     controlM mcontrol;
@@ -507,3 +527,42 @@ unsigned char MainWindow::getError()
         return 0x02;
     }
 }
+
+void MainWindow::on_pushButton_clear_clicked()
+{
+    ui->textEdit->clear();
+}
+
+void MainWindow::on_pushButton_outLight_clicked()
+{
+    lightMessage light;
+    light.lightType=0x01;
+    light.timeRemaining=30;
+    m_radio->outLight(light);
+}
+
+void MainWindow::on_pushButton_warning_clicked()
+{
+    collisionEarlyWarningMessage warning;
+    warning.warningType=0x01;
+    warning.speedLimit=30;
+    m_radio->outCollisionWarning(warning);
+}
+
+void MainWindow::on_pushButton_realTimeMessage_clicked()
+{
+    realtimeTrafficMessage realtime;
+    realtime.lat=39*1000000;
+    realtime.lng=137*1000000;
+    realtime.scope=100;
+    realtime.trafficInfo=0x01;
+    realtime.speedLimit=0xFF;
+    m_radio->outRealtimeTraffic(realtime);
+}
+
+void MainWindow::on_pushButton_busy_clicked()
+{
+    congestionIdentificationMessage identi;
+    identi.openCommand=0x01;
+    m_radio->outCongestionIdenti(identi);
+}

+ 9 - 0
src/v2x/CommunicatePlatform/mainwindow.h

@@ -3,6 +3,7 @@
 #include "tbox.h"
 #include <QMainWindow>
 #include "radio.h"
+#include "brainstate.pb.h"
 struct chassisRaw
 {
     float soc;
@@ -38,6 +39,7 @@ private:
     void * mpMemGps;
     void * mpMemUI;
     void * mpMemControl;
+    void * mpMemState;
     iv::Ivlog *mivlog;
 
     gpsImuM m_structMGpsImu;
@@ -62,6 +64,8 @@ public:
                                   const QDateTime * dt,const char * strmemname);
     void UpdateControl(const char * strdata,const unsigned int nSize,const unsigned int index,\
                                   const QDateTime * dt,const char * strmemname);
+    void UpdateState(const char * strdata,const unsigned int nSize,const unsigned int index,\
+                                  const QDateTime * dt,const char * strmemname);
 private slots:
     void on_pushButton_connect_clicked();
     void on_pushButton_vinChange_clicked(); 
@@ -71,6 +75,11 @@ private slots:
     void on_checkBox_dangerousDrive_stateChanged(int arg1);
     void on_pushButton_setVirtualVehicle_clicked();
     void on_pushButton_radioConnect_clicked();
+    void on_pushButton_clear_clicked();
+    void on_pushButton_outLight_clicked();
+    void on_pushButton_warning_clicked();
+    void on_pushButton_realTimeMessage_clicked();
+    void on_pushButton_busy_clicked();
 };
 
 #endif // MAINWINDOW_H

+ 59 - 3
src/v2x/CommunicatePlatform/mainwindow.ui

@@ -475,8 +475,8 @@
    <widget class="QPushButton" name="pushButton_clear">
     <property name="geometry">
      <rect>
-      <x>100</x>
-      <y>440</y>
+      <x>220</x>
+      <y>420</y>
       <width>89</width>
       <height>25</height>
      </rect>
@@ -498,6 +498,58 @@
      <string>共享内存数据:</string>
     </property>
    </widget>
+   <widget class="QPushButton" name="pushButton_outLight">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>460</y>
+      <width>89</width>
+      <height>25</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>light</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_realTimeMessage">
+    <property name="geometry">
+     <rect>
+      <x>28</x>
+      <y>510</y>
+      <width>101</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>real-time info</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_warning">
+    <property name="geometry">
+     <rect>
+      <x>190</x>
+      <y>460</y>
+      <width>89</width>
+      <height>25</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>warning</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_busy">
+    <property name="geometry">
+     <rect>
+      <x>190</x>
+      <y>510</y>
+      <width>89</width>
+      <height>25</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>busy road</string>
+    </property>
+   </widget>
    <zorder>groupBox</zorder>
    <zorder>groupBox_2</zorder>
    <zorder>label</zorder>
@@ -507,6 +559,10 @@
    <zorder>textEdit</zorder>
    <zorder>pushButton_clear</zorder>
    <zorder>label_3</zorder>
+   <zorder>pushButton_outLight</zorder>
+   <zorder>pushButton_realTimeMessage</zorder>
+   <zorder>pushButton_warning</zorder>
+   <zorder>pushButton_busy</zorder>
   </widget>
   <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
@@ -514,7 +570,7 @@
      <x>0</x>
      <y>0</y>
      <width>1019</width>
-     <height>28</height>
+     <height>22</height>
     </rect>
    </property>
   </widget>

+ 7 - 1
src/v2x/CommunicatePlatform/radio.cpp

@@ -91,6 +91,12 @@ void Radio::setGpsImuMemory(gpsImuM m)
 {
     m_structMGpsImu=m;
 }
+
+void Radio::sendResponseMessage(int type)
+{
+    m_responseType=type&0xFF;
+    upRespondMessage();
+}
 void Radio::outRealtimeTraffic(realtimeTrafficMessage realtimeTraffic)
 {
     if(m_bEnTrafficBroadcast) {
@@ -307,7 +313,7 @@ void Radio::upVirtualVehicleRaw()
 }
 void Radio::upRespondMessage()
 {
-    m_iResponse=-1;
+    m_iResponse=0;
     upRespondMessageRaw();
 }
 void Radio::upRespondMessageRaw()

+ 1 - 0
src/v2x/CommunicatePlatform/radio.h

@@ -154,6 +154,7 @@ public:
     void sendProto(iv::v2r::v2r_send radio_protobuf_send);
     void setControlMemory(controlM m);
     void setGpsImuMemory(gpsImuM m);
+    void sendResponseMessage(int type);
 private:
     QSerialPort *m_serialPort_Radio;
     bool m_bSerialOpen;