Selaa lähdekoodia

add decition_brain_localplan

yuchuli 2 vuotta sitten
vanhempi
commit
af1ac04073

+ 73 - 0
src/decition/decition_brain_localplan/.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
+

+ 117 - 0
src/decition/decition_brain_localplan/brain_localplan_gpstype.cpp

@@ -0,0 +1,117 @@
+#include "brain_localplan_gpstype.h"
+
+#include "ivstdcolorout.h"
+
+brain_localplan_gpstype::brain_localplan_gpstype()
+{
+
+
+    ModuleFun funmap =std::bind(&brain_localplan_gpstype::UpadateMap,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpa_map = iv::modulecomm::RegisterRecvPlus("tracemap",funmap);
+
+    ModuleFun funfusion =std::bind(&brain_localplan_gpstype::UpadateFusion,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpa_fusion = iv::modulecomm::RegisterRecvPlus("li_ra_fusion",funfusion);
+
+    ModuleFun fungps =std::bind(&brain_localplan_gpstype::UpadateGPS,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpa_gps = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungps);
+
+    ModuleFun funhmi =std::bind(&brain_localplan_gpstype::UpadateHMI,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpa_hmi = iv::modulecomm::RegisterRecvPlus("tracemap",funhmi);
+
+
+    mbRun = true;
+    mpthreadplan = new std::thread(&brain_localplan_gpstype::threadplan,this);
+
+}
+
+brain_localplan_gpstype::~brain_localplan_gpstype()
+{
+
+    iv::modulecomm::Unregister(mpa_hmi);
+    iv::modulecomm::Unregister(mpa_gps);
+    iv::modulecomm::Unregister(mpa_fusion);
+    iv::modulecomm::Unregister(mpa_map);
+
+    mbRun = false;
+    mpthreadplan->join();
+}
+
+
+void brain_localplan_gpstype::threadplan()
+{
+    int nnogps = 0;
+    while(mbRun)
+    {
+        if(mbHaveMap == false)
+        {
+            static int nnotice = 0;
+            std::this_thread::sleep_for(std::chrono::milliseconds(100));
+            if(nnotice == 0)ivstdcolorout("No Map",iv::STDCOLOR_BOLDYELLOW);
+            nnotice++;
+            if(nnotice>=10)
+            {
+                nnotice = 0;
+            }
+            continue;
+        }
+        static int nnogpsprint = 0;
+        if(mbGPSUpdate == false)
+        {
+            nnogps++;
+
+            if(nnogps > 10)
+            {
+                if(nnogpsprint == 0)
+                {
+                    ivstdcolorout("No GPS",iv::STDCOLOR_BOLDYELLOW);
+
+                }
+                nnogpsprint++;
+                if(nnogpsprint >= 50)
+                {
+                    nnogpsprint =0;
+                }
+            }
+            continue;
+        }
+
+
+        nnogpsprint = 0;
+        nnogps = 0;
+
+        std::this_thread::sleep_for(std::chrono::milliseconds(10));
+    }
+}
+
+void brain_localplan_gpstype::UpadateMap(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+
+    (void)index;
+    (void)dt;
+    (void)strmemname;
+}
+
+void brain_localplan_gpstype::UpadateFusion(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+
+    (void)index;
+    (void)dt;
+    (void)strmemname;
+}
+
+void brain_localplan_gpstype::UpadateGPS(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+
+    (void)index;
+    (void)dt;
+    (void)strmemname;
+}
+
+void brain_localplan_gpstype::UpadateHMI(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+
+    (void)index;
+    (void)dt;
+    (void)strmemname;
+}
+

+ 39 - 0
src/decition/decition_brain_localplan/brain_localplan_gpstype.h

@@ -0,0 +1,39 @@
+#ifndef BRAIN_LOCALPLAN_GPSTYPE_H
+#define BRAIN_LOCALPLAN_GPSTYPE_H
+
+#include <thread>
+
+#include "modulecomm.h"
+
+class brain_localplan_gpstype
+{
+public:
+    brain_localplan_gpstype();
+    ~brain_localplan_gpstype();
+
+private:
+    void threadplan();
+
+    std::thread * mpthreadplan;
+
+    bool mbRun = true;
+
+    bool mbHaveMap = false;
+    bool mbMapUpdate = false;
+    bool mbGPSUpdate = false;
+    int64_t mLastms_gpsupdate = 0;
+
+private:
+    void * mpa_map;
+    void * mpa_fusion;
+    void * mpa_gps;
+    void * mpa_hmi;
+
+private:
+    void UpadateMap(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname);
+    void UpadateFusion(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname);
+    void UpadateGPS(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname);
+    void UpadateHMI(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname);
+};
+
+#endif // BRAIN_LOCALPLAN_GPSTYPE_H

+ 39 - 0
src/decition/decition_brain_localplan/decition_brain_localplan.pro

@@ -0,0 +1,39 @@
+QT -= gui
+
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as 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 you use 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 += main.cpp \
+    ../../include/msgtype/fusionobject.pb.cc \
+    ../../include/msgtype/fusionobjectarray.pb.cc \
+    ../../include/msgtype/hmi.pb.cc \
+    brain_localplan_gpstype.cpp \
+    ../../include/msgtype/gpsimu.pb.cc
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}
+
+HEADERS += \
+    ../../include/msgtype/fusionobject.pb.h \
+    ../../include/msgtype/fusionobjectarray.pb.h \
+    ../../include/msgtype/hmi.pb.h \
+    brain_localplan_gpstype.h \
+    ../../include/msgtype/gpsimu.pb.h
+
+

+ 16 - 0
src/decition/decition_brain_localplan/main.cpp

@@ -0,0 +1,16 @@
+#include <QCoreApplication>
+
+#include "brain_localplan_gpstype.h"
+
+static brain_localplan_gpstype * gplocalplan;
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication a(argc, argv);
+
+    brain_localplan_gpstype * pplocalpan = new brain_localplan_gpstype();
+    (void)pplocalpan;
+    gplocalplan = pplocalpan;
+
+    return a.exec();
+}