Преглед на файлове

change modulecomm. Old modulecomm to modulecomm_classic

yuchuli преди 3 години
родител
ревизия
09808b1d0d
променени са 69 файла, в които са добавени 5836 реда и са изтрити 55 реда
  1. 73 0
      src/common/modulecomm/.gitignore
  2. 50 0
      src/common/modulecomm/andmainwindow.cpp
  3. 37 0
      src/common/modulecomm/andmainwindow.h
  4. 65 0
      src/common/modulecomm/andmainwindow.ui
  5. 90 0
      src/common/modulecomm/android/AndroidManifest.xml
  6. 57 0
      src/common/modulecomm/android/build.gradle
  7. BIN
      src/common/modulecomm/android/gradle/wrapper/gradle-wrapper.jar
  8. 5 0
      src/common/modulecomm/android/gradle/wrapper/gradle-wrapper.properties
  9. 172 0
      src/common/modulecomm/android/gradlew
  10. 84 0
      src/common/modulecomm/android/gradlew.bat
  11. 25 0
      src/common/modulecomm/android/res/values/libs.xml
  12. 327 0
      src/common/modulecomm/fastrtps/Topics.cxx
  13. 253 0
      src/common/modulecomm/fastrtps/Topics.h
  14. 13 0
      src/common/modulecomm/fastrtps/Topics.idl
  15. 141 0
      src/common/modulecomm/fastrtps/TopicsPubSubTypes.cxx
  16. 61 0
      src/common/modulecomm/fastrtps/TopicsPubSubTypes.h
  17. 217 0
      src/common/modulecomm/fastrtps/TopicsPublisher.cxx
  18. 56 0
      src/common/modulecomm/fastrtps/TopicsPublisher.h
  19. 232 0
      src/common/modulecomm/fastrtps/TopicsSubscriber.cxx
  20. 72 0
      src/common/modulecomm/fastrtps/TopicsSubscriber.h
  21. 22 0
      src/common/modulecomm/fastrtps/modulecomm_fastrtps.pri
  22. 64 0
      src/common/modulecomm/fastrtps/modulecomm_fastrtps_shm.cpp
  23. 29 0
      src/common/modulecomm/fastrtps/modulecomm_fastrtps_shm.h
  24. 64 0
      src/common/modulecomm/fastrtps/modulecomm_fastrtps_tcp.cpp
  25. 26 0
      src/common/modulecomm/fastrtps/modulecomm_fastrtps_tcp.h
  26. 142 0
      src/common/modulecomm/fastrtps/modulecomm_impl_shm.cpp
  27. 41 0
      src/common/modulecomm/fastrtps/modulecomm_impl_shm.h
  28. 143 0
      src/common/modulecomm/fastrtps/modulecomm_impl_tcp.cpp
  29. 41 0
      src/common/modulecomm/fastrtps/modulecomm_impl_tcp.h
  30. 491 0
      src/common/modulecomm/inter/intercomm.cpp
  31. 109 0
      src/common/modulecomm/inter/intercomm.h
  32. 60 0
      src/common/modulecomm/inter/modulecomm_inter.cpp
  33. 30 0
      src/common/modulecomm/inter/modulecomm_inter.h
  34. 7 0
      src/common/modulecomm/inter/modulecomm_inter.pri
  35. BIN
      src/common/modulecomm/libfast.zip
  36. 172 0
      src/common/modulecomm/main.cpp
  37. 11 0
      src/common/modulecomm/main1.cpp
  38. 11 0
      src/common/modulecomm/main2.cpp
  39. 242 23
      src/common/modulecomm/modulecomm.cpp
  40. 35 7
      src/common/modulecomm/modulecomm.h
  41. 49 25
      src/common/modulecomm/modulecomm.pro
  42. 4 0
      src/common/modulecomm/modulecomm.xml
  43. 11 0
      src/common/modulecomm/modulecomm_base.cpp
  44. 33 0
      src/common/modulecomm/modulecomm_base.h
  45. 9 0
      src/common/modulecomm/modulecommext.cpp
  46. 208 0
      src/common/modulecomm/modulecommext.h
  47. 54 0
      src/common/modulecomm/shm/b/modulecomm_shm.cpp
  48. 42 0
      src/common/modulecomm/shm/b/modulecomm_shm.h
  49. 61 0
      src/common/modulecomm/shm/modulecomm_shm.cpp
  50. 28 0
      src/common/modulecomm/shm/modulecomm_shm.h
  51. 9 0
      src/common/modulecomm/shm/modulecomm_shm.pri
  52. 572 0
      src/common/modulecomm/shm/procsm.cpp
  53. 131 0
      src/common/modulecomm/shm/procsm.h
  54. 310 0
      src/common/modulecomm/shm/procsm_if.cpp
  55. 0 0
      src/common/modulecomm/shm/procsm_if.h
  56. 66 0
      src/common/modulecomm/testmodulecomm.pro
  57. 83 0
      src/common/modulecomm/testmodulecomm_android.pro
  58. 31 0
      src/common/modulecomm/testmodulecomm_android2.pro
  59. 73 0
      src/common/modulecomm/testmodulecommext.pro
  60. 0 0
      src/common/modulecomm_classic/ReadMe.md
  61. 13 0
      src/common/modulecomm_classic/ivmodulemsg_type.h
  62. 56 0
      src/common/modulecomm_classic/modulecomm.cpp
  63. 39 0
      src/common/modulecomm_classic/modulecomm.h
  64. 44 0
      src/common/modulecomm_classic/modulecomm.pro
  65. 41 0
      src/common/modulecomm_classic/modulecomm_android.pro
  66. 0 0
      src/common/modulecomm_classic/procsm.cpp
  67. 0 0
      src/common/modulecomm_classic/procsm.h
  68. 0 0
      src/common/modulecomm_classic/procsm_if.cpp
  69. 99 0
      src/common/modulecomm_classic/procsm_if.h

+ 73 - 0
src/common/modulecomm/.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
+

+ 50 - 0
src/common/modulecomm/andmainwindow.cpp

@@ -0,0 +1,50 @@
+#include "andmainwindow.h"
+#include "ui_andmainwindow.h"
+
+AndMainWindow::AndMainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::AndMainWindow)
+{
+    ui->setupUi(this);
+
+#ifdef Module1
+    mpasend = iv::modulecomm::RegisterSend("testand1",1000,1,iv::modulecomm::ModuleComm_FASTRTPS_TCP,10001);
+    ModuleFun funcan = std::bind(&AndMainWindow::UpdateMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mparecv = iv::modulecomm::RegisterRecvPlus("testand2",funcan,iv::modulecomm::ModuleComm_FASTRTPS_TCP,"0.0.0.0",10001);
+#endif
+
+#ifdef Module2
+    mpasend = iv::modulecomm::RegisterSend("testand2",1000,1,iv::modulecomm::ModuleComm_FASTRTPS);
+    ModuleFun funcan = std::bind(&AndMainWindow::UpdateMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mparecv = iv::modulecomm::RegisterRecvPlus("testand1",funcan);
+#endif
+
+    connect(this,SIGNAL(newmsg(char*)),this,SLOT(onnewmsg(char*)));
+
+}
+
+AndMainWindow::~AndMainWindow()
+{
+    delete ui;
+}
+
+
+void AndMainWindow::on_pushButton_clicked()
+{
+    QString str = ui->lineEdit_sendvalue->text();
+    iv::modulecomm::ModuleSendMsg(mpasend,str.toLatin1().data(),str.length());
+
+}
+
+void AndMainWindow::onnewmsg(char *strmsg)
+{
+    ui->lineEdit_recvvalue->setText(strmsg);
+}
+
+void AndMainWindow::UpdateMsg(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+    char * strvalue = new char[nSize+1];
+    strvalue[nSize] = 0;
+    memcpy(strvalue,strdata,nSize);
+    emit newmsg(strvalue);
+}

+ 37 - 0
src/common/modulecomm/andmainwindow.h

@@ -0,0 +1,37 @@
+#ifndef ANDMAINWINDOW_H
+#define ANDMAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "modulecomm.h"
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class AndMainWindow; }
+QT_END_NAMESPACE
+
+class AndMainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    AndMainWindow(QWidget *parent = nullptr);
+    ~AndMainWindow();
+
+private slots:
+    void on_pushButton_clicked();
+
+    void onnewmsg(char * strmsg);
+
+signals:
+    void newmsg(char * strmsg);
+
+private:
+    Ui::AndMainWindow *ui;
+
+    void * mpasend;
+    void * mparecv;
+
+private:
+    void UpdateMsg(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname);
+};
+#endif // ANDMAINWINDOW_H

+ 65 - 0
src/common/modulecomm/andmainwindow.ui

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AndMainWindow</class>
+ <widget class="QMainWindow" name="AndMainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>AndMainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QPushButton" name="pushButton">
+    <property name="geometry">
+     <rect>
+      <x>420</x>
+      <y>60</y>
+      <width>191</width>
+      <height>71</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Send</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_sendvalue">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>50</y>
+      <width>261</width>
+      <height>81</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_recvvalue">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>210</y>
+      <width>271</width>
+      <height>91</height>
+     </rect>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 90 - 0
src/common/modulecomm/android/AndroidManifest.xml

@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<manifest package="adc.iv.testmodulecomm_android" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
+    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
+
+    <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
+         Remove the comment if you do not require these default permissions. -->
+    <!-- %%INSERT_PERMISSIONS -->
+
+    <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
+         Remove the comment if you do not require these default features. -->
+    <!-- %%INSERT_FEATURES -->
+
+    <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
+
+    <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
+        <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
+
+            <!-- Application arguments -->
+            <!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
+            <!-- Application arguments -->
+
+            <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
+            <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
+            <meta-data android:name="android.app.repository" android:value="default"/>
+            <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
+            <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
+            <!-- Deploy Qt libs as part of package -->
+            <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
+            <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
+            <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
+            <!-- Run with local libs -->
+            <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
+            <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
+            <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
+            <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
+            <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
+            <!-- Used to specify custom system library path to run with local system libs -->
+            <!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
+            <!--  Messages maps -->
+            <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
+            <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
+            <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
+            <meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
+            <!--  Messages maps -->
+
+            <!-- Splash screen -->
+            <!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
+                 then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
+                 use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
+                 are done populating your window with content. -->
+            <!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
+            <!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
+            <!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
+            <!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
+            <!-- Splash screen -->
+
+            <!-- Background running -->
+            <!-- Warning: changing this value to true may cause unexpected crashes if the
+                          application still try to draw after
+                          "applicationStateChanged(Qt::ApplicationSuspended)"
+                          signal is sent! -->
+            <meta-data android:name="android.app.background_running" android:value="false"/>
+            <!-- Background running -->
+
+            <!-- auto screen scale factor -->
+            <meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
+            <!-- auto screen scale factor -->
+
+            <!-- extract android style -->
+            <!-- available android:values :
+                * default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
+                * full - useful QWidget & Quick Controls 1 apps
+                * minimal - useful for Quick Controls 2 apps, it is much faster than "full"
+                * none - useful for apps that don't use any of the above Qt modules
+                -->
+            <meta-data android:name="android.app.extract_android_style" android:value="default"/>
+            <!-- extract android style -->
+    </activity>
+
+    <!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
+
+    </application>
+
+<uses-permission android:name="android.permission.INTERNET"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+</manifest>

+ 57 - 0
src/common/modulecomm/android/build.gradle

@@ -0,0 +1,57 @@
+buildscript {
+    repositories {
+        google()
+        jcenter()
+    }
+
+    dependencies {
+        classpath 'com.android.tools.build:gradle:3.2.0'
+    }
+}
+
+repositories {
+    google()
+    jcenter()
+}
+
+apply plugin: 'com.android.application'
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
+}
+
+android {
+    /*******************************************************
+     * The following variables:
+     * - androidBuildToolsVersion,
+     * - androidCompileSdkVersion
+     * - qt5AndroidDir - holds the path to qt android files
+     *                   needed to build any Qt application
+     *                   on Android.
+     *
+     * are defined in gradle.properties file. This file is
+     * updated by QtCreator and androiddeployqt tools.
+     * Changing them manually might break the compilation!
+     *******************************************************/
+
+    compileSdkVersion androidCompileSdkVersion.toInteger()
+
+    buildToolsVersion '28.0.3'
+
+    sourceSets {
+        main {
+            manifest.srcFile 'AndroidManifest.xml'
+            java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
+            aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
+            res.srcDirs = [qt5AndroidDir + '/res', 'res']
+            resources.srcDirs = ['src']
+            renderscript.srcDirs = ['src']
+            assets.srcDirs = ['assets']
+            jniLibs.srcDirs = ['libs']
+       }
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+}

BIN
src/common/modulecomm/android/gradle/wrapper/gradle-wrapper.jar


+ 5 - 0
src/common/modulecomm/android/gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists

+ 172 - 0
src/common/modulecomm/android/gradlew

@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"

+ 84 - 0
src/common/modulecomm/android/gradlew.bat

@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 25 - 0
src/common/modulecomm/android/res/values/libs.xml

@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='utf-8'?>
+<resources>
+    <array name="qt_sources">
+        <item>https://download.qt.io/ministro/android/qt5/qt-5.9</item>
+    </array>
+
+    <!-- The following is handled automatically by the deployment tool. It should
+         not be edited manually. -->
+
+    <array name="bundled_libs">
+        <!-- %%INSERT_EXTRA_LIBS%% -->
+    </array>
+
+     <array name="qt_libs">
+         <!-- %%INSERT_QT_LIBS%% -->
+     </array>
+
+    <array name="bundled_in_lib">
+        <!-- %%INSERT_BUNDLED_IN_LIB%% -->
+    </array>
+    <array name="bundled_in_assets">
+        <!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
+    </array>
+
+</resources>

+ 327 - 0
src/common/modulecomm/fastrtps/Topics.cxx

@@ -0,0 +1,327 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file Topics.cpp
+ * This source file contains the definition of the described types in the IDL file.
+ *
+ * This file was generated by the tool gen.
+ */
+
+#ifdef USE_FASTRTPS
+
+#ifdef _WIN32
+// Remove linker warning LNK4221 on Visual Studio
+namespace { char dummy; }
+#endif
+
+
+
+#include "Topics.h"
+#include <fastcdr/Cdr.h>
+
+#include <fastcdr/exceptions/BadParamException.h>
+using namespace eprosima::fastcdr::exception;
+
+#include <utility>
+
+
+TopicSample::Message::Message()
+{
+    // m_msgname com.eprosima.idl.parser.typecode.StringTypeCode@76329302
+    m_msgname ="";
+    // m_counter com.eprosima.idl.parser.typecode.PrimitiveTypeCode@5e25a92e
+    m_counter = 0;
+    // m_sendtime com.eprosima.idl.parser.typecode.PrimitiveTypeCode@4df828d7
+    m_sendtime = 0;
+    // m_xdata com.eprosima.idl.parser.typecode.AliasTypeCode@b59d31
+
+    m_xdata.push_back(1);
+    m_xdata.push_back(2);
+
+
+}
+
+TopicSample::Message::~Message()
+{
+
+
+
+
+}
+
+TopicSample::Message::Message(const Message &x)
+{
+    m_msgname = x.m_msgname;
+    m_counter = x.m_counter;
+    m_sendtime = x.m_sendtime;
+    m_xdata = x.m_xdata;
+}
+
+TopicSample::Message::Message(Message &&x)
+{
+    m_msgname = std::move(x.m_msgname);
+    m_counter = x.m_counter;
+    m_sendtime = x.m_sendtime;
+    m_xdata = std::move(x.m_xdata);
+}
+
+TopicSample::Message& TopicSample::Message::operator=(const Message &x)
+{
+
+    m_msgname = x.m_msgname;
+    m_counter = x.m_counter;
+    m_sendtime = x.m_sendtime;
+    m_xdata = x.m_xdata;
+
+    return *this;
+}
+
+TopicSample::Message& TopicSample::Message::operator=(Message &&x)
+{
+
+    m_msgname = std::move(x.m_msgname);
+    m_counter = x.m_counter;
+    m_sendtime = x.m_sendtime;
+    m_xdata = std::move(x.m_xdata);
+
+    return *this;
+}
+
+size_t TopicSample::Message::getMaxCdrSerializedSize(size_t current_alignment)
+{
+    size_t initial_alignment = current_alignment;
+
+
+    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1;
+
+    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
+
+
+    current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
+
+
+    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
+
+    current_alignment += (100 * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
+
+
+
+    return 10000000;
+//    return current_alignment - initial_alignment;
+}
+
+size_t TopicSample::Message::getCdrSerializedSize(const TopicSample::Message& data, size_t current_alignment)
+{
+    (void)data;
+    size_t initial_alignment = current_alignment;
+
+
+    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.msgname().size() + 1;
+
+    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
+
+
+    current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
+
+
+    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
+
+    if (data.xdata().size() > 0)
+    {
+        current_alignment += (data.xdata().size() * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
+    }
+
+
+
+
+    return current_alignment - initial_alignment;
+}
+
+void TopicSample::Message::serialize(eprosima::fastcdr::Cdr &scdr) const
+{
+
+    scdr << m_msgname;
+    scdr << m_counter;
+    scdr << m_sendtime;
+    scdr << m_xdata;
+
+//    std::cout<<"serialize."<<std::endl;
+}
+
+void TopicSample::Message::deserialize(eprosima::fastcdr::Cdr &dcdr)
+{
+
+    dcdr >> m_msgname;
+    dcdr >> m_counter;
+    dcdr >> m_sendtime;
+    dcdr >> m_xdata;
+}
+
+/*!
+ * @brief This function copies the value in member msgname
+ * @param _msgname New value to be copied in member msgname
+ */
+void TopicSample::Message::msgname(const std::string &_msgname)
+{
+m_msgname = _msgname;
+}
+
+/*!
+ * @brief This function moves the value in member msgname
+ * @param _msgname New value to be moved in member msgname
+ */
+void TopicSample::Message::msgname(std::string &&_msgname)
+{
+m_msgname = std::move(_msgname);
+}
+
+/*!
+ * @brief This function returns a constant reference to member msgname
+ * @return Constant reference to member msgname
+ */
+const std::string& TopicSample::Message::msgname() const
+{
+    return m_msgname;
+}
+
+/*!
+ * @brief This function returns a reference to member msgname
+ * @return Reference to member msgname
+ */
+std::string& TopicSample::Message::msgname()
+{
+    return m_msgname;
+}
+/*!
+ * @brief This function sets a value in member counter
+ * @param _counter New value for member counter
+ */
+void TopicSample::Message::counter(int32_t _counter)
+{
+m_counter = _counter;
+}
+
+/*!
+ * @brief This function returns the value of member counter
+ * @return Value of member counter
+ */
+int32_t TopicSample::Message::counter() const
+{
+    return m_counter;
+}
+
+/*!
+ * @brief This function returns a reference to member counter
+ * @return Reference to member counter
+ */
+int32_t& TopicSample::Message::counter()
+{
+    return m_counter;
+}
+
+/*!
+ * @brief This function sets a value in member sendtime
+ * @param _sendtime New value for member sendtime
+ */
+void TopicSample::Message::sendtime(int64_t _sendtime)
+{
+m_sendtime = _sendtime;
+}
+
+/*!
+ * @brief This function returns the value of member sendtime
+ * @return Value of member sendtime
+ */
+int64_t TopicSample::Message::sendtime() const
+{
+    return m_sendtime;
+}
+
+/*!
+ * @brief This function returns a reference to member sendtime
+ * @return Reference to member sendtime
+ */
+int64_t& TopicSample::Message::sendtime()
+{
+    return m_sendtime;
+}
+
+/*!
+ * @brief This function copies the value in member xdata
+ * @param _xdata New value to be copied in member xdata
+ */
+void TopicSample::Message::xdata(const TopicSample::SomeBytes &_xdata)
+{
+ //   return;
+  m_xdata = _xdata;
+//int i;
+//for(i=0;i<300;i++)
+//    m_xdata.push_back(_xdata.at(i));
+}
+
+/*!
+ * @brief This function moves the value in member xdata
+ * @param _xdata New value to be moved in member xdata
+ */
+void TopicSample::Message::xdata(TopicSample::SomeBytes &&_xdata)
+{
+m_xdata = std::move(_xdata);
+}
+
+/*!
+ * @brief This function returns a constant reference to member xdata
+ * @return Constant reference to member xdata
+ */
+const TopicSample::SomeBytes& TopicSample::Message::xdata() const
+{
+    return m_xdata;
+}
+
+/*!
+ * @brief This function returns a reference to member xdata
+ * @return Reference to member xdata
+ */
+TopicSample::SomeBytes& TopicSample::Message::xdata()
+{
+    return m_xdata;
+}
+
+size_t TopicSample::Message::getKeyMaxCdrSerializedSize(size_t current_alignment)
+{
+    size_t current_align = current_alignment;
+
+
+
+
+
+
+
+    return current_align;
+}
+
+bool TopicSample::Message::isKeyDefined()
+{
+   return false;
+}
+
+void TopicSample::Message::serializeKey(eprosima::fastcdr::Cdr &scdr) const
+{
+    (void) scdr;
+     
+     
+     
+     
+}
+#endif

+ 253 - 0
src/common/modulecomm/fastrtps/Topics.h

@@ -0,0 +1,253 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file Topics.h
+ * This header file contains the declaration of the described types in the IDL file.
+ *
+ * This file was generated by the tool gen.
+ */
+
+#ifndef _TOPICSAMPLE_TOPICS_H_
+#define _TOPICSAMPLE_TOPICS_H_
+
+// TODO Poner en el contexto.
+
+#include <stdint.h>
+#include <array>
+#include <string>
+#include <vector>
+#include <map>
+#include <bitset>
+
+#if defined(_WIN32)
+#if defined(EPROSIMA_USER_DLL_EXPORT)
+#define eProsima_user_DllExport __declspec( dllexport )
+#else
+#define eProsima_user_DllExport
+#endif
+#else
+#define eProsima_user_DllExport
+#endif
+
+#if defined(_WIN32)
+#if defined(EPROSIMA_USER_DLL_EXPORT)
+#if defined(Topics_SOURCE)
+#define Topics_DllAPI __declspec( dllexport )
+#else
+#define Topics_DllAPI __declspec( dllimport )
+#endif // Topics_SOURCE
+#else
+#define Topics_DllAPI
+#endif
+#else
+#define Topics_DllAPI
+#endif // _WIN32
+
+namespace eprosima
+{
+    namespace fastcdr
+    {
+        class Cdr;
+    }
+}
+
+
+namespace TopicSample
+{
+    typedef std::vector<uint8_t> SomeBytes;
+    /*!
+     * @brief This class represents the structure Message defined by the user in the IDL file.
+     * @ingroup TOPICS
+     */
+    class Message
+    {
+    public:
+
+        /*!
+         * @brief Default constructor.
+         */
+        eProsima_user_DllExport Message();
+
+        /*!
+         * @brief Default destructor.
+         */
+        eProsima_user_DllExport ~Message();
+
+        /*!
+         * @brief Copy constructor.
+         * @param x Reference to the object TopicSample::Message that will be copied.
+         */
+        eProsima_user_DllExport Message(const Message &x);
+
+        /*!
+         * @brief Move constructor.
+         * @param x Reference to the object TopicSample::Message that will be copied.
+         */
+        eProsima_user_DllExport Message(Message &&x);
+
+        /*!
+         * @brief Copy assignment.
+         * @param x Reference to the object TopicSample::Message that will be copied.
+         */
+        eProsima_user_DllExport Message& operator=(const Message &x);
+
+        /*!
+         * @brief Move assignment.
+         * @param x Reference to the object TopicSample::Message that will be copied.
+         */
+        eProsima_user_DllExport Message& operator=(Message &&x);
+
+        /*!
+         * @brief This function copies the value in member msgname
+         * @param _msgname New value to be copied in member msgname
+         */
+        eProsima_user_DllExport void msgname(const std::string &_msgname);
+
+        /*!
+         * @brief This function moves the value in member msgname
+         * @param _msgname New value to be moved in member msgname
+         */
+        eProsima_user_DllExport void msgname(std::string &&_msgname);
+
+        /*!
+         * @brief This function returns a constant reference to member msgname
+         * @return Constant reference to member msgname
+         */
+        eProsima_user_DllExport const std::string& msgname() const;
+
+        /*!
+         * @brief This function returns a reference to member msgname
+         * @return Reference to member msgname
+         */
+        eProsima_user_DllExport std::string& msgname();
+        /*!
+         * @brief This function sets a value in member counter
+         * @param _counter New value for member counter
+         */
+        eProsima_user_DllExport void counter(int32_t _counter);
+
+        /*!
+         * @brief This function returns the value of member counter
+         * @return Value of member counter
+         */
+        eProsima_user_DllExport int32_t counter() const;
+
+        /*!
+         * @brief This function returns a reference to member counter
+         * @return Reference to member counter
+         */
+        eProsima_user_DllExport int32_t& counter();
+
+        /*!
+         * @brief This function sets a value in member sendtime
+         * @param _sendtime New value for member sendtime
+         */
+        eProsima_user_DllExport void sendtime(int64_t _sendtime);
+
+        /*!
+         * @brief This function returns the value of member sendtime
+         * @return Value of member sendtime
+         */
+        eProsima_user_DllExport int64_t sendtime() const;
+
+        /*!
+         * @brief This function returns a reference to member sendtime
+         * @return Reference to member sendtime
+         */
+        eProsima_user_DllExport int64_t& sendtime();
+
+        /*!
+         * @brief This function copies the value in member xdata
+         * @param _xdata New value to be copied in member xdata
+         */
+        eProsima_user_DllExport void xdata(const TopicSample::SomeBytes &_xdata);
+
+        /*!
+         * @brief This function moves the value in member xdata
+         * @param _xdata New value to be moved in member xdata
+         */
+        eProsima_user_DllExport void xdata(TopicSample::SomeBytes &&_xdata);
+
+        /*!
+         * @brief This function returns a constant reference to member xdata
+         * @return Constant reference to member xdata
+         */
+        eProsima_user_DllExport const TopicSample::SomeBytes& xdata() const;
+
+        /*!
+         * @brief This function returns a reference to member xdata
+         * @return Reference to member xdata
+         */
+        eProsima_user_DllExport TopicSample::SomeBytes& xdata();
+
+        /*!
+         * @brief This function returns the maximum serialized size of an object
+         * depending on the buffer alignment.
+         * @param current_alignment Buffer alignment.
+         * @return Maximum serialized size.
+         */
+        eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
+
+        /*!
+         * @brief This function returns the serialized size of a data depending on the buffer alignment.
+         * @param data Data which is calculated its serialized size.
+         * @param current_alignment Buffer alignment.
+         * @return Serialized size.
+         */
+        eProsima_user_DllExport static size_t getCdrSerializedSize(const TopicSample::Message& data, size_t current_alignment = 0);
+
+
+        /*!
+         * @brief This function serializes an object using CDR serialization.
+         * @param cdr CDR serialization object.
+         */
+        eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const;
+
+        /*!
+         * @brief This function deserializes an object using CDR serialization.
+         * @param cdr CDR serialization object.
+         */
+        eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr);
+
+
+
+        /*!
+         * @brief This function returns the maximum serialized size of the Key of an object
+         * depending on the buffer alignment.
+         * @param current_alignment Buffer alignment.
+         * @return Maximum serialized size.
+         */
+        eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
+
+        /*!
+         * @brief This function tells you if the Key has been defined for this type
+         */
+        eProsima_user_DllExport static bool isKeyDefined();
+
+        /*!
+         * @brief This function serializes the key members of an object using CDR serialization.
+         * @param cdr CDR serialization object.
+         */
+        eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
+
+    private:
+        std::string m_msgname;
+        int32_t m_counter;
+        int64_t m_sendtime;
+        TopicSample::SomeBytes m_xdata;
+    };
+}
+
+#endif // _TOPICSAMPLE_TOPICS_H_

+ 13 - 0
src/common/modulecomm/fastrtps/Topics.idl

@@ -0,0 +1,13 @@
+module TopicSample {
+
+#pragma DCPS_DATA_TYPE "TopicSample::Message"
+
+typedef sequence<octet> SomeBytes;
+struct Message {
+  string msgname;
+  long counter;
+  long long sendtime;
+  SomeBytes   xdata;
+};
+
+};

+ 141 - 0
src/common/modulecomm/fastrtps/TopicsPubSubTypes.cxx

@@ -0,0 +1,141 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file TopicsPubSubTypes.cpp
+ * This header file contains the implementation of the serialization functions.
+ *
+ * This file was generated by the tool fastcdrgen.
+ */
+
+#ifdef USE_FASTRTPS
+
+#include <fastcdr/FastBuffer.h>
+#include <fastcdr/Cdr.h>
+
+#include "TopicsPubSubTypes.h"
+
+using namespace eprosima::fastrtps;
+using namespace eprosima::fastrtps::rtps;
+
+namespace TopicSample
+{
+
+    MessagePubSubType::MessagePubSubType()
+    {
+        setName("TopicSample::Message");
+        m_typeSize = static_cast<uint32_t>(Message::getMaxCdrSerializedSize()) + 4 /*encapsulation*/;
+        m_isGetKeyDefined = Message::isKeyDefined();
+        size_t keyLength = Message::getKeyMaxCdrSerializedSize()>16 ? Message::getKeyMaxCdrSerializedSize() : 16;
+        m_keyBuffer = reinterpret_cast<unsigned char*>(malloc(keyLength));
+        memset(m_keyBuffer, 0, keyLength);
+    }
+
+    MessagePubSubType::~MessagePubSubType()
+    {
+        if(m_keyBuffer!=nullptr)
+            free(m_keyBuffer);
+    }
+
+    bool MessagePubSubType::serialize(void *data, SerializedPayload_t *payload)
+    {
+        Message *p_type = static_cast<Message*>(data);
+        eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->max_size); // Object that manages the raw buffer.
+        eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
+                eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data.
+        payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
+        // Serialize encapsulation
+        ser.serialize_encapsulation();
+
+        try
+        {
+            p_type->serialize(ser); // Serialize the object:
+        }
+        catch(eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/)
+        {
+            return false;
+        }
+
+        payload->length = static_cast<uint32_t>(ser.getSerializedDataLength()); //Get the serialized length
+        return true;
+    }
+
+    bool MessagePubSubType::deserialize(SerializedPayload_t* payload, void* data)
+    {
+        Message* p_type = static_cast<Message*>(data); //Convert DATA to pointer of your type
+        eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length); // Object that manages the raw buffer.
+        eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
+                eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
+        // Deserialize encapsulation.
+        deser.read_encapsulation();
+        payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
+
+        try
+        {
+            p_type->deserialize(deser); //Deserialize the object:
+        }
+        catch(eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/)
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    std::function<uint32_t()> MessagePubSubType::getSerializedSizeProvider(void* data)
+    {
+        return [data]() -> uint32_t
+        {
+            return static_cast<uint32_t>(type::getCdrSerializedSize(*static_cast<Message*>(data))) + 4 /*encapsulation*/;
+        };
+    }
+
+    void* MessagePubSubType::createData()
+    {
+        return reinterpret_cast<void*>(new Message());
+    }
+
+    void MessagePubSubType::deleteData(void* data)
+    {
+        delete(reinterpret_cast<Message*>(data));
+    }
+
+    bool MessagePubSubType::getKey(void *data, InstanceHandle_t* handle, bool force_md5)
+    {
+        if(!m_isGetKeyDefined)
+            return false;
+        Message* p_type = static_cast<Message*>(data);
+        eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(m_keyBuffer),Message::getKeyMaxCdrSerializedSize());     // Object that manages the raw buffer.
+        eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS);     // Object that serializes the data.
+        p_type->serializeKey(ser);
+        if(force_md5 || Message::getKeyMaxCdrSerializedSize()>16)    {
+            m_md5.init();
+            m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.getSerializedDataLength()));
+            m_md5.finalize();
+            for(uint8_t i = 0;i<16;++i)        {
+                handle->value[i] = m_md5.digest[i];
+            }
+        }
+        else    {
+            for(uint8_t i = 0;i<16;++i)        {
+                handle->value[i] = m_keyBuffer[i];
+            }
+        }
+        return true;
+    }
+
+
+} //End of namespace TopicSample
+
+#endif

+ 61 - 0
src/common/modulecomm/fastrtps/TopicsPubSubTypes.h

@@ -0,0 +1,61 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file TopicsPubSubTypes.h
+ * This header file contains the declaration of the serialization functions.
+ *
+ * This file was generated by the tool fastcdrgen.
+ */
+
+
+#ifndef _TOPICSAMPLE_TOPICS_PUBSUBTYPES_H_
+#define _TOPICSAMPLE_TOPICS_PUBSUBTYPES_H_
+
+#include <fastrtps/config.h>
+#include <fastrtps/TopicDataType.h>
+
+#include "Topics.h"
+
+#if !defined(GEN_API_VER) || (GEN_API_VER != 1)
+#error Generated Topics is not compatible with current installed Fast-RTPS. Please, regenerate it with fastrtpsgen.
+#endif
+
+namespace TopicSample
+{
+    typedef std::vector<uint8_t> SomeBytes;
+    /*!
+     * @brief This class represents the TopicDataType of the type Message defined by the user in the IDL file.
+     * @ingroup TOPICS
+     */
+    class MessagePubSubType : public eprosima::fastrtps::TopicDataType {
+    public:
+        typedef Message type;
+
+        eProsima_user_DllExport MessagePubSubType();
+
+        eProsima_user_DllExport virtual ~MessagePubSubType();
+        eProsima_user_DllExport virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
+        eProsima_user_DllExport virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
+        eProsima_user_DllExport virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
+        eProsima_user_DllExport virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
+            bool force_md5 = false) override;
+        eProsima_user_DllExport virtual void* createData() override;
+        eProsima_user_DllExport virtual void deleteData(void * data) override;
+        MD5 m_md5;
+        unsigned char* m_keyBuffer;
+    };
+}
+
+#endif // _TOPICSAMPLE_TOPICS_PUBSUBTYPES_H_

+ 217 - 0
src/common/modulecomm/fastrtps/TopicsPublisher.cxx

@@ -0,0 +1,217 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file TopicsPublisher.cpp
+ * This file contains the implementation of the publisher functions.
+ *
+ * This file was generated by the tool fastcdrgen.
+ */
+
+#ifdef USE_FASTRTPS
+#include <fastrtps/participant/Participant.h>
+#include <fastrtps/attributes/ParticipantAttributes.h>
+#include <fastrtps/publisher/Publisher.h>
+#include <fastrtps/attributes/PublisherAttributes.h>
+
+#include <fastrtps/Domain.h>
+
+#include <fastrtps/participant/Participant.h>
+#include <fastrtps/attributes/ParticipantAttributes.h>
+#include <fastrtps/attributes/PublisherAttributes.h>
+#include <fastrtps/publisher/Publisher.h>
+#include <fastrtps/Domain.h>
+#include <fastdds/rtps/transport/shared_mem/SharedMemTransportDescriptor.h>
+#include <fastdds/rtps/transport/UDPv4TransportDescriptor.h>
+#include <fastdds/rtps/transport/TCPv4TransportDescriptor.h>
+
+#include <thread>
+#include <chrono>
+
+#include "TopicsPublisher.h"
+
+using namespace eprosima::fastrtps;
+using namespace eprosima::fastrtps::rtps;
+
+using namespace eprosima::fastdds::rtps;
+
+TopicsPublisher::TopicsPublisher() : mp_participant(nullptr), mp_publisher(nullptr) {}
+
+TopicsPublisher::~TopicsPublisher() {	Domain::removeParticipant(mp_participant);}
+
+bool TopicsPublisher::init(const char * strtopic,const unsigned short nListenPort,const int ntype )
+{
+    strncpy(mstrtopic,strtopic,255);
+    // Create RTPSParticipant
+
+    ParticipantAttributes PParam;
+    PParam.rtps.sendSocketBufferSize = 100000000;
+    PParam.rtps.setName("Participant_publisher");  //You can put here the name you want
+
+    PParam.rtps.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SIMPLE;
+    PParam.rtps.builtin.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = true;
+    PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true;
+    PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true;
+    PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
+
+    // SharedMem transport configuration
+    PParam.rtps.useBuiltinTransports = false;
+
+    if(ntype == 0)
+    {
+    auto shm_transport = std::make_shared<SharedMemTransportDescriptor>();
+    shm_transport->segment_size(100*1024*1024);
+    PParam.rtps.userTransports.push_back(shm_transport);
+
+    // UDP
+    auto udp_transport = std::make_shared<UDPv4TransportDescriptor>();
+    //udp_transport->interfaceWhiteList.push_back("127.0.0.1");
+    PParam.rtps.userTransports.push_back(udp_transport);
+
+
+    }
+    else
+    {
+        //Create a descriptor for the new transport.
+        auto tcp_transport = std::make_shared<TCPv4TransportDescriptor>();
+        tcp_transport->add_listener_port(nListenPort);
+        tcp_transport->set_WAN_address("0.0.0.0");
+
+        tcp_transport->wait_for_tcp_negotiation = false;
+        tcp_transport->sendBufferSize = 0;
+        tcp_transport->receiveBufferSize = 0;
+
+        PParam.rtps.userTransports.push_back(tcp_transport);
+    }
+    mp_participant = Domain::createParticipant(PParam);
+    if(mp_participant == nullptr)
+    {
+        return false;
+    }
+
+    //Register the type
+
+    Domain::registerType(mp_participant, static_cast<TopicDataType*>(&myType));
+
+    // Create Publisher
+
+    PublisherAttributes Wparam;
+    Wparam.topic.topicKind = NO_KEY;
+    Wparam.topic.topicDataType = myType.getName();  //This type MUST be registered
+    Wparam.topic.topicName = strtopic;//"TopicsPubSubTopic";
+
+    Wparam.topic.historyQos.depth = 30;
+    Wparam.topic.resourceLimitsQos.max_samples = 50;
+    Wparam.topic.resourceLimitsQos.allocated_samples = 20;
+    Wparam.times.heartbeatPeriod.seconds = 2;
+    Wparam.times.heartbeatPeriod.nanosec = 200 * 1000 * 1000;
+    Wparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
+    Wparam.qos.m_publishMode.kind = ASYNCHRONOUS_PUBLISH_MODE;
+
+    mp_publisher = Domain::createPublisher(mp_participant,Wparam,static_cast<PublisherListener*>(&m_listener));
+
+    if(mp_publisher == nullptr)
+    {
+        return false;
+    }
+
+    std::cout << "Publisher created, waiting for Subscribers." << std::endl;
+    return true;
+}
+
+void TopicsPublisher::PubListener::onPublicationMatched(Publisher* pub,MatchingInfo& info)
+{
+    (void)pub;
+
+    if (info.status == MATCHED_MATCHING)
+    {
+        n_matched++;
+        std::cout << "Publisher matched" << std::endl;
+    }
+    else
+    {
+        n_matched--;
+        std::cout << "Publisher unmatched" << std::endl;
+    }
+}
+
+void TopicsPublisher::run()
+{
+    while(m_listener.n_matched == 0)
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(250)); // Sleep 250 ms
+    }
+
+    // Publication code
+
+    TopicSample::Message st;
+
+    /* Initialize your structure here */
+
+    int msgsent = 0;
+    char ch = 'y';
+    do
+    {
+        if(ch == 'y')
+        {
+            mp_publisher->write(&st);  ++msgsent;
+            std::cout << "Sending sample, count=" << msgsent << ", send another sample?(y-yes,n-stop): ";
+        }
+        else if(ch == 'n')
+        {
+            std::cout << "Stopping execution " << std::endl;
+            break;
+        }
+        else
+        {
+            std::cout << "Command " << ch << " not recognized, please enter \"y/n\":";
+        }
+    } while(std::cin >> ch);
+}
+
+#include <QDateTime>
+
+void TopicsPublisher::senddata(const char *str, int nsize)
+{
+
+
+    static int ncount = 1;
+    std::cout<<"send data."<<std::endl;
+//    while(m_listener.n_matched == 0)
+    TopicSample::SomeBytes x;
+    x.resize(nsize);
+    memcpy(x.data(),str,nsize);
+
+    TopicSample::Message st;
+
+    st.msgname(mstrtopic);
+//    st.msgname("topictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopictopic");
+    st.counter(ncount);ncount++;
+    st.sendtime(QDateTime::currentMSecsSinceEpoch());
+    TopicSample::SomeBytes & px = x;
+    st.xdata(x);
+
+    int ndatasize = TopicSample::Message::getCdrSerializedSize(st);
+
+    std::cout<<"size is "<<ndatasize<<std::endl;
+
+
+    mp_publisher->write(&st);
+
+
+
+}
+
+#endif
+

+ 56 - 0
src/common/modulecomm/fastrtps/TopicsPublisher.h

@@ -0,0 +1,56 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file TopicsPublisher.h
+ * This header file contains the declaration of the publisher functions.
+ *
+ * This file was generated by the tool fastcdrgen.
+ */
+
+
+#ifndef _TOPICSAMPLE_TOPICS_PUBLISHER_H_
+#define _TOPICSAMPLE_TOPICS_PUBLISHER_H_
+
+#include <fastrtps/fastrtps_fwd.h>
+#include <fastrtps/publisher/PublisherListener.h>
+
+#include "TopicsPubSubTypes.h"
+
+class TopicsPublisher
+{
+public:
+	TopicsPublisher();
+	virtual ~TopicsPublisher();
+    bool init(const char * strtopic,const unsigned short nListenPort = 5100,const int ntype = 0);
+	void run();
+    void senddata(const char *str, int nsize);
+private:
+	eprosima::fastrtps::Participant *mp_participant;
+	eprosima::fastrtps::Publisher *mp_publisher;
+
+    char mstrtopic[256];
+
+	class PubListener : public eprosima::fastrtps::PublisherListener
+	{
+	public:
+		PubListener() : n_matched(0){};
+		~PubListener(){};
+		void onPublicationMatched(eprosima::fastrtps::Publisher* pub,eprosima::fastrtps::rtps::MatchingInfo& info);
+		int n_matched;
+	} m_listener;
+	TopicSample::MessagePubSubType myType;
+};
+
+#endif // _TOPICSAMPLE_TOPICS_PUBLISHER_H_

+ 232 - 0
src/common/modulecomm/fastrtps/TopicsSubscriber.cxx

@@ -0,0 +1,232 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file TopicsSubscriber.cpp
+ * This file contains the implementation of the subscriber functions.
+ *
+ * This file was generated by the tool fastcdrgen.
+ */
+
+#ifdef USE_FASTRTPS
+
+#include <fastrtps/participant/Participant.h>
+#include <fastrtps/attributes/ParticipantAttributes.h>
+#include <fastrtps/subscriber/Subscriber.h>
+#include <fastrtps/attributes/SubscriberAttributes.h>
+
+#include <fastrtps/Domain.h>
+
+#include <fastcdr/FastBuffer.h>
+#include <fastcdr/FastCdr.h>
+#include <fastcdr/Cdr.h>
+
+#include <fastrtps/participant/Participant.h>
+#include <fastrtps/attributes/ParticipantAttributes.h>
+#include <fastrtps/attributes/PublisherAttributes.h>
+#include <fastrtps/publisher/Publisher.h>
+#include <fastrtps/Domain.h>
+#include <fastdds/rtps/transport/shared_mem/SharedMemTransportDescriptor.h>
+#include <fastdds/rtps/transport/UDPv4TransportDescriptor.h>
+#include <fastdds/rtps/transport/TCPv4TransportDescriptor.h>
+
+#include "TopicsSubscriber.h"
+
+using namespace eprosima::fastrtps;
+using namespace eprosima::fastrtps::rtps;
+
+using namespace eprosima::fastdds::rtps;
+
+
+
+
+#include <QDateTime>
+
+TopicsSubscriber::TopicsSubscriber() : mp_participant(nullptr), mp_subscriber(nullptr) {}
+
+TopicsSubscriber::~TopicsSubscriber() {	Domain::removeParticipant(mp_participant);}
+
+bool TopicsSubscriber::init(const char * strtopic,const char * strpubip,const unsigned short nPort,int ntype)
+{
+
+    strncpy(mstrtopic,strtopic,255);
+    // Create RTPSParticipant
+
+    ParticipantAttributes PParam;
+    PParam.rtps.setName("Participant_subscriber"); //You can put the name you want
+
+    PParam.rtps.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SIMPLE;
+    PParam.rtps.builtin.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = true;
+    PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true;
+    PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true;
+    PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
+
+    // SharedMem transport configuration
+    PParam.rtps.useBuiltinTransports = false;
+
+    if(ntype == 0)
+    {
+    auto sm_transport = std::make_shared<SharedMemTransportDescriptor>();
+    sm_transport->segment_size(100*1024*1024);
+    PParam.rtps.userTransports.push_back(sm_transport);
+
+    // UDP
+    auto udp_transport = std::make_shared<UDPv4TransportDescriptor>();
+    //udp_transport->interfaceWhiteList.push_back("127.0.0.1");
+    PParam.rtps.userTransports.push_back(udp_transport);
+    }
+    else
+    {
+        auto tcp2_transport = std::make_shared<TCPv4TransportDescriptor>();
+
+        //Set initial peers.
+        Locator_t initial_peer_locator;
+        initial_peer_locator.kind = LOCATOR_KIND_TCPv4;
+        IPLocator::setIPv4(initial_peer_locator, strpubip);
+        initial_peer_locator.port = nPort;
+        PParam.rtps.builtin.initialPeersList.push_back(initial_peer_locator);
+
+    //    PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
+    //    PParam.rtps.builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(5, 0);
+    //    PParam.rtps.setName("Participant_sub");
+
+        tcp2_transport->wait_for_tcp_negotiation = false;
+        //Link the Transport Layer to the Participant.
+        PParam.rtps.userTransports.push_back(tcp2_transport);
+    }
+
+
+    mp_participant = Domain::createParticipant(PParam);
+    if(mp_participant == nullptr)
+    {
+        return false;
+    }
+
+    //Register the type
+
+    Domain::registerType(mp_participant, static_cast<TopicDataType*>(&myType));
+
+    // Create Subscriber
+
+    SubscriberAttributes Rparam;
+    Rparam.topic.topicKind = NO_KEY;
+    Rparam.topic.topicDataType = myType.getName(); //Must be registered before the creation of the subscriber
+    Rparam.topic.topicName = strtopic;//"TopicsPubSubTopic";
+
+    Rparam.topic.historyQos.depth = 30;
+    Rparam.topic.resourceLimitsQos.max_samples = 50;
+    Rparam.topic.resourceLimitsQos.allocated_samples = 20;
+
+    Rparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
+
+
+    mp_subscriber = Domain::createSubscriber(mp_participant,Rparam, static_cast<SubscriberListener*>(&m_listener));
+    if(mp_subscriber == nullptr)
+    {
+        return false;
+    }
+    return true;
+}
+
+void TopicsSubscriber::SubListener::onSubscriptionMatched(Subscriber* sub,MatchingInfo& info)
+{
+    (void)sub;
+
+    if (info.status == MATCHED_MATCHING)
+    {
+        n_matched++;
+        std::cout << "Subscriber matched" << std::endl;
+    }
+    else
+    {
+        n_matched--;
+        std::cout << "Subscriber unmatched" << std::endl;
+    }
+}
+
+
+void TopicsSubscriber::SubListener::setReceivedTopicFunction(ModuleFun xFun)
+{
+    mFun = xFun;
+    mbSetFun = true;
+}
+void TopicsSubscriber::SubListener::onNewDataMessage(Subscriber* sub)
+{
+    // Take data
+    TopicSample::Message st;
+    static int ncount = 0;
+
+    static int nmaxlatancy = 0;
+
+    std::cout<<"new msg"<<std::endl;
+
+
+//    char * strbuf = new char[1000000];
+//    eprosima::fastcdr::FastBuffer pbuf(strbuf,1000000);
+//    eprosima::fastcdr::Cdr * pxcdr;//
+//    pxcdr = new eprosima::fastcdr::Cdr(pbuf);
+
+//    if(sub->takeNextData(pxcdr, &m_info))
+//    {
+//        if(m_info.sampleKind == ALIVE)
+//        {
+//            // Print your structure data here.
+//            ++n_msg;
+//            std::cout << "Sample received, count=" << n_msg<<std::endl;
+//            st.deserialize(*pxcdr);
+
+//            std::cout<<" size is "<<TopicSample::Message::getCdrSerializedSize(st)<<std::endl;
+//        }
+//    }
+
+//    return;
+
+//    sub->get_first_untaken_info(&m_info);
+    std::cout<<"count is "<<sub->getUnreadCount()<<std::endl;
+
+    if(sub->takeNextData(&st, &m_info))
+    {
+        if(m_info.sampleKind == ALIVE)
+        {
+            // Print your structure data here.
+            ++n_msg;
+            ncount++;
+            std::cout << "Sample received, count=" << st.counter() <<" total: "<<ncount<<std::endl;
+            qint64 timex = QDateTime::currentMSecsSinceEpoch();
+            int nlatancy = (timex - st.sendtime());
+            if(nlatancy>nmaxlatancy)nmaxlatancy = nlatancy;
+            std::cout<<"  latency is "<<nlatancy<<" max: "<<nmaxlatancy<<std::endl;
+            std::cout<<" size is "<<st.xdata().size()<<std::endl;
+            QDateTime dt = QDateTime::fromMSecsSinceEpoch(st.sendtime());
+            if(mbSetFun) mFun((char *)(st.xdata().data()),st.xdata().size(),st.counter(),&dt,st.msgname().data());
+
+
+        }
+    }
+}
+
+void TopicsSubscriber::setReceivedTopicFunction(ModuleFun xFun)
+{
+    m_listener.setReceivedTopicFunction(xFun);
+}
+
+void TopicsSubscriber::run()
+{
+    std::cout << "Waiting for Data, press Enter to stop the Subscriber. "<<std::endl;
+    std::cin.ignore();
+    std::cout << "Shutting down the Subscriber." << std::endl;
+}
+
+#endif
+

+ 72 - 0
src/common/modulecomm/fastrtps/TopicsSubscriber.h

@@ -0,0 +1,72 @@
+// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*!
+ * @file TopicsSubscriber.h
+ * This header file contains the declaration of the subscriber functions.
+ *
+ * This file was generated by the tool fastcdrgen.
+ */
+
+
+#ifndef _TOPICSAMPLE_TOPICS_SUBSCRIBER_H_
+#define _TOPICSAMPLE_TOPICS_SUBSCRIBER_H_
+
+#include <fastrtps/fastrtps_fwd.h>
+#include <fastrtps/subscriber/SubscriberListener.h>
+#include <fastrtps/subscriber/SampleInfo.h>
+#include "TopicsPubSubTypes.h"
+
+
+#include <QDateTime>
+
+typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
+
+class TopicsSubscriber
+{
+public:
+	TopicsSubscriber();
+	virtual ~TopicsSubscriber();
+    bool init(const char * strtopic,const char * strpubip = 0,const unsigned short nPort = 5100,int ntype = 0);
+	void run();
+
+    void setReceivedTopicFunction(ModuleFun xFun);
+private:
+	eprosima::fastrtps::Participant *mp_participant;
+	eprosima::fastrtps::Subscriber *mp_subscriber;
+
+
+    char mstrtopic[256];
+
+	class SubListener : public eprosima::fastrtps::SubscriberListener
+	{
+	public:
+		SubListener() : n_matched(0),n_msg(0){};
+		~SubListener(){};
+		void onSubscriptionMatched(eprosima::fastrtps::Subscriber* sub,eprosima::fastrtps::rtps::MatchingInfo& info);
+		void onNewDataMessage(eprosima::fastrtps::Subscriber* sub);
+		eprosima::fastrtps::SampleInfo_t m_info;
+		int n_matched;
+		int n_msg;
+
+        void setReceivedTopicFunction(ModuleFun xFun);
+
+    private:
+        bool mbSetFun = false;
+        ModuleFun mFun;
+	} m_listener;
+	TopicSample::MessagePubSubType myType;
+};
+
+#endif // _TOPICSAMPLE_TOPICS_SUBSCRIBER_H_

+ 22 - 0
src/common/modulecomm/fastrtps/modulecomm_fastrtps.pri

@@ -0,0 +1,22 @@
+HEADERS += \
+    $$PWD/Topics.h \
+    $$PWD/TopicsPubSubTypes.h \
+    $$PWD/TopicsPublisher.h \
+    $$PWD/TopicsSubscriber.h \
+    $$PWD/modulecomm_fastrtps_shm.h \
+    $$PWD/modulecomm_fastrtps_tcp.h \
+    $$PWD/modulecomm_impl_shm.h \
+    $$PWD/modulecomm_impl_tcp.h
+
+SOURCES += \
+    $$PWD/Topics.cxx \
+    $$PWD/TopicsPubSubTypes.cxx \
+    $$PWD/TopicsPublisher.cxx \
+    $$PWD/TopicsSubscriber.cxx \
+    $$PWD/modulecomm_fastrtps_shm.cpp \
+    $$PWD/modulecomm_fastrtps_tcp.cpp \
+    $$PWD/modulecomm_impl_shm.cpp \
+    $$PWD/modulecomm_impl_tcp.cpp
+
+INCLUDEPATH += $$PWD/../../../../thirdpartylib/FastRTPS/include
+LIBS += -L$$PWD/../../../../thirdpartylib/FastRTPS/lib

+ 64 - 0
src/common/modulecomm/fastrtps/modulecomm_fastrtps_shm.cpp

@@ -0,0 +1,64 @@
+#ifdef USE_FASTRTPS
+#include "modulecomm_fastrtps_shm.h"
+
+#include "modulecomm_impl_shm.h"
+
+namespace  iv {
+
+
+modulecomm_fastrtps_shm::modulecomm_fastrtps_shm()
+{
+
+}
+
+void modulecomm_fastrtps_shm::RegisterSend(const char *strcommname, const unsigned int nBufSize, const unsigned int nMsgBufCount)
+{
+    modulecomm_impl_shm * pif = new modulecomm_impl_shm(strcommname,modulecomm_impl_shm::type_send);
+
+//    procsm_if * pif = new procsm_if(strcommname,nBufSize,nMsgBufCount,procsm::ModeWrite);
+    mpif = pif;
+}
+
+void modulecomm_fastrtps_shm::RegisterRecv(const char *strcommname, SMCallBack pCall)
+{
+    modulecomm_impl_shm * pif = new modulecomm_impl_shm(strcommname,modulecomm_impl_shm::type_recv);
+ //   procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(pCall);
+    mpif = pif;
+}
+
+void modulecomm_fastrtps_shm::RegisterRecvPlus(const char *strcommname, ModuleFun xFun)
+{
+    modulecomm_impl_shm * pif = new modulecomm_impl_shm(strcommname,modulecomm_impl_shm::type_recv);
+ //   procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(xFun);
+    mpif = pif;
+}
+
+void modulecomm_fastrtps_shm::ModuleSendMsg(const char *strdata, const unsigned int nDataLen)
+{
+    modulecomm_impl_shm * pif= (modulecomm_impl_shm *)mpif;
+ //   procsm_if * pif = (procsm_if *)pHandle;
+    pif->writemsg(strdata,nDataLen);
+}
+
+void modulecomm_fastrtps_shm::PauseComm()
+{
+
+}
+
+void modulecomm_fastrtps_shm::ContintuComm()
+{
+
+}
+
+void modulecomm_fastrtps_shm::Unregister()
+{
+    modulecomm_impl_shm * pif= (modulecomm_impl_shm *)mpif;
+//    procsm_if * pif = (procsm_if *)pHandle;
+    delete pif;
+}
+
+}
+
+#endif

+ 29 - 0
src/common/modulecomm/fastrtps/modulecomm_fastrtps_shm.h

@@ -0,0 +1,29 @@
+#ifndef MODULECOMM_FASTRTPS_SHM_H
+#define MODULECOMM_FASTRTPS_SHM_H
+
+#include "modulecomm_impl_shm.h"
+
+namespace iv {
+
+
+
+class modulecomm_fastrtps_shm
+{
+public:
+    modulecomm_fastrtps_shm();
+
+    void RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount);
+    void RegisterRecv(const char * strcommname,SMCallBack pCall);
+    void RegisterRecvPlus(const char * strcommname,ModuleFun xFun);
+    virtual void ModuleSendMsg(const char * strdata,const unsigned int nDataLen);
+    virtual void Unregister();
+    virtual void PauseComm();
+    virtual void ContintuComm();
+
+private:
+    void * mpif;
+};
+
+}
+
+#endif // MODULECOMM_FASTRTPS_SHM_H

+ 64 - 0
src/common/modulecomm/fastrtps/modulecomm_fastrtps_tcp.cpp

@@ -0,0 +1,64 @@
+#ifdef USE_FASTRTPS
+#include "modulecomm_fastrtps_tcp.h"
+
+#include "modulecomm_impl_tcp.h"
+
+namespace  iv {
+
+
+modulecomm_fastrtps_tcp::modulecomm_fastrtps_tcp()
+{
+
+}
+
+void modulecomm_fastrtps_tcp::RegisterSend(const char *strcommname, const unsigned int nBufSize, const unsigned int nMsgBufCount, unsigned int nListenPort)
+{
+    modulecomm_impl_tcp * pif = new modulecomm_impl_tcp(strcommname,modulecomm_impl_tcp::type_send,nListenPort);
+
+//    procsm_if * pif = new procsm_if(strcommname,nBufSize,nMsgBufCount,procsm::ModeWrite);
+    mpif = pif;
+}
+
+void modulecomm_fastrtps_tcp::RegisterRecv(const char *strcommname, SMCallBack pCall, const char *strpubip, unsigned int nListenPort)
+{
+    modulecomm_impl_tcp * pif = new modulecomm_impl_tcp(strcommname,modulecomm_impl_tcp::type_recv,nListenPort,strpubip);
+ //   procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(pCall);
+    mpif = pif;
+}
+
+void modulecomm_fastrtps_tcp::RegisterRecvPlus(const char *strcommname, ModuleFun xFun, const char *strpubip, unsigned int nListenPort)
+{
+    modulecomm_impl_tcp * pif = new modulecomm_impl_tcp(strcommname,modulecomm_impl_tcp::type_recv,nListenPort,strpubip);
+ //   procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(xFun);
+    mpif = pif;
+}
+
+void modulecomm_fastrtps_tcp::ContintuComm()
+{
+
+}
+
+void modulecomm_fastrtps_tcp::PauseComm()
+{
+
+}
+
+void modulecomm_fastrtps_tcp::ModuleSendMsg(const char *strdata, const unsigned int nDataLen)
+{
+    modulecomm_impl_tcp * pif= (modulecomm_impl_tcp *)mpif;
+ //   procsm_if * pif = (procsm_if *)pHandle;
+    pif->writemsg(strdata,nDataLen);
+}
+
+void modulecomm_fastrtps_tcp::Unregister()
+{
+    modulecomm_impl_tcp * pif= (modulecomm_impl_tcp *)mpif;
+//    procsm_if * pif = (procsm_if *)pHandle;
+    delete pif;
+
+}
+}
+
+#endif

+ 26 - 0
src/common/modulecomm/fastrtps/modulecomm_fastrtps_tcp.h

@@ -0,0 +1,26 @@
+#ifndef MODULECOMM_FASTRTPS_TCP_H
+#define MODULECOMM_FASTRTPS_TCP_H
+
+#include "modulecomm_impl_tcp.h"
+namespace  iv {
+
+
+class modulecomm_fastrtps_tcp
+{
+public:
+    modulecomm_fastrtps_tcp();
+    void RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount,unsigned int nListenPort);
+    void RegisterRecv(const char * strcommname,SMCallBack pCall,const char * strpubip,unsigned int nListenPort);
+    void RegisterRecvPlus(const char * strcommname,ModuleFun xFun,const char * strpubip,unsigned int nListenPort);
+    virtual void ModuleSendMsg(const char * strdata,const unsigned int nDataLen);
+    virtual void Unregister();
+    virtual void PauseComm();
+    virtual void ContintuComm();
+
+private:
+    void * mpif;
+};
+
+}
+
+#endif // MODULECOMM_FASTRTPS_TCP_H

+ 142 - 0
src/common/modulecomm/fastrtps/modulecomm_impl_shm.cpp

@@ -0,0 +1,142 @@
+#ifdef USE_FASTRTPS
+#include "modulecomm_impl_shm.h"
+
+#include <thread>
+#include <iostream>
+#include <QDateTime>
+
+#include <QMutex>
+#include <QFile>
+
+namespace iv {
+namespace modulecomm {
+static QMutex gmodulecomm_dds_Mutex;
+static int createcount = 0;
+}
+
+}
+
+
+void modulecomm_impl_shm::callbackTopic(const char * strdata,const unsigned int nSize,const unsigned int index, QDateTime * dt,const char * strmemname) {
+
+  if(mbFunPlus)
+  {
+      mFun(strdata,nSize,index,dt,strmemname);
+  }
+  else
+  {
+     (*mpCall)(strdata,nSize,index,dt,strmemname);
+  }
+}
+
+
+int modulecomm_impl_shm::GetTempConfPath(char *strpath)
+{
+    char strtmppath[256];
+    QDateTime dt = QDateTime::currentDateTime();
+    snprintf(strtmppath,256,"/tmp/adc_modulecomm_conf_%04d%02d%02d%02d%02d.ini",dt.date().year(),
+             dt.date().month(),dt.date().day(),dt.time().hour(),dt.time().minute());
+    QFile xFile;
+    xFile.setFileName(strtmppath);
+    char strtem[256];
+    char strdata[10000];
+    snprintf(strdata,10000,"");
+    if(!xFile.exists())
+    {
+        if(xFile.open(QIODevice::ReadWrite))
+        {
+            snprintf(strtem,256,"[common]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"DCPSDefaultDiscovery=TheRTPSConfig\n");strncat(strdata,strtem,10000);
+#ifdef dds_use_shm
+            snprintf(strtem,256,"DCPSGlobalTransportConfig=myconfig\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"[config/myconfig]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"transports=share\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"[transport/share]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"transport_type=shmem\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"pool_size=100000000\n");strncat(strdata,strtem,10000);
+#endif
+            snprintf(strtem,256,"[rtps_discovery/TheRTPSConfig]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"ResendPeriod=5\n");strncat(strdata,strtem,10000);
+            xFile.write(strdata,strnlen(strdata,10000));
+            xFile.close();
+        }
+    }
+    strncpy(strpath,strtmppath,255);
+    return 0;
+}
+
+modulecomm_impl_shm::modulecomm_impl_shm(const char * strcommname,int ntype )
+{
+
+    strncpy(mstrtopic,strcommname,255);
+
+    iv::modulecomm::gmodulecomm_dds_Mutex.lock();
+    if(ntype == type_recv)
+    {
+        mpSub = new TopicsSubscriber();
+        mpSub->init(strcommname);
+//        std::this_thread::sleep_for(std::chrono::milliseconds(10));
+
+        mnType = type_recv;
+    }
+    else
+    {
+        mpPub = new TopicsPublisher();
+        mpPub->init(strcommname);
+ //       std::this_thread::sleep_for(std::chrono::milliseconds(10));
+        mnType = type_send;
+    }
+    iv::modulecomm::createcount++;
+    std::cout<<"count is "<<iv::modulecomm::createcount<<std::endl;
+    iv::modulecomm::gmodulecomm_dds_Mutex.unlock();
+
+}
+
+int modulecomm_impl_shm::listenmsg(ModuleFun xFun)
+{
+    if(mnType == type_send)
+    {
+        std::cout<<"send not listen."<<std::endl;;
+        return -1;
+    }
+    mbFunPlus = true;
+    mFun = xFun;
+    ModuleFun topicFunction = std::bind(&modulecomm_impl_shm::callbackTopic,this,std::placeholders::_1,
+                                                                                std::placeholders::_2,
+                                                                                std::placeholders::_3,
+                                                                                std::placeholders::_4,
+                                                                                std::placeholders::_5);
+    mpSub->setReceivedTopicFunction(topicFunction);
+    return 0;
+}
+
+int modulecomm_impl_shm::listenmsg(SMCallBack pCall)
+{
+    if(mnType == type_send)
+    {
+        std::cout<<"send not listen."<<std::endl;
+        return -1;
+    }
+    mbFunPlus = false;
+    mpCall = pCall;
+    ModuleFun topicFunction = std::bind(&modulecomm_impl_shm::callbackTopic,this,std::placeholders::_1,
+                                                                                std::placeholders::_2,
+                                                                                std::placeholders::_3,
+                                                                                std::placeholders::_4,
+                                                                                std::placeholders::_5);
+    mpSub->setReceivedTopicFunction(topicFunction);
+    return 0;
+}
+
+void modulecomm_impl_shm::writemsg(const char *str, int nlen)
+{
+    if(mnType == type_recv)
+    {
+        std::cout<<"recv not send."<<std::endl;
+        return ;
+    }
+
+    mpPub->senddata(str,nlen);
+
+}
+#endif

+ 41 - 0
src/common/modulecomm/fastrtps/modulecomm_impl_shm.h

@@ -0,0 +1,41 @@
+#ifndef MODULECOMM_IMPL_SHM_H
+#define MODULECOMM_IMPL_SHM_H
+
+#include <QDateTime>
+
+#include "TopicsPublisher.h"
+#include "TopicsSubscriber.h"
+
+
+typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+
+
+class modulecomm_impl_shm
+{
+public:
+    const static int type_send = 1;
+    const static int type_recv = 2;
+public:
+    modulecomm_impl_shm(const char * strcommname,int ntype = 2);
+    int listenmsg(SMCallBack pCall);
+    int listenmsg(ModuleFun xFun);
+    void writemsg(const char * str,int nlen);
+
+private:
+    char mstrtopic[256];
+    int mnType = type_recv;
+    TopicsPublisher * mpPub;
+    TopicsSubscriber * mpSub;
+    SMCallBack  mpCall;
+    ModuleFun mFun;
+    void callbackTopic(const char * strdata,const unsigned int nSize,const unsigned int index,QDateTime * dt,const char * strmemname);
+
+    int GetTempConfPath(char * strpath);
+
+
+
+    bool mbFunPlus = false;
+
+};
+
+#endif // MODULECOMM_IMPL_H

+ 143 - 0
src/common/modulecomm/fastrtps/modulecomm_impl_tcp.cpp

@@ -0,0 +1,143 @@
+#ifdef USE_FASTRTPS
+#include "modulecomm_impl_tcp.h"
+
+#include <thread>
+#include <iostream>
+#include <QDateTime>
+
+#include <QMutex>
+#include <QFile>
+
+namespace iv {
+namespace modulecomm {
+static QMutex gmodulecomm_dds_Mutex;
+static int createcount = 0;
+}
+
+}
+
+
+void modulecomm_impl_tcp::callbackTopic(const char * strdata,const unsigned int nSize,const unsigned int index, QDateTime * dt,const char * strmemname) {
+
+  if(mbFunPlus)
+  {
+      mFun(strdata,nSize,index,dt,strmemname);
+  }
+  else
+  {
+     (*mpCall)(strdata,nSize,index,dt,strmemname);
+  }
+}
+
+
+int modulecomm_impl_tcp::GetTempConfPath(char *strpath)
+{
+    char strtmppath[256];
+    QDateTime dt = QDateTime::currentDateTime();
+    snprintf(strtmppath,256,"/tmp/adc_modulecomm_conf_%04d%02d%02d%02d%02d.ini",dt.date().year(),
+             dt.date().month(),dt.date().day(),dt.time().hour(),dt.time().minute());
+    QFile xFile;
+    xFile.setFileName(strtmppath);
+    char strtem[256];
+    char strdata[10000];
+    snprintf(strdata,10000,"");
+    if(!xFile.exists())
+    {
+        if(xFile.open(QIODevice::ReadWrite))
+        {
+            snprintf(strtem,256,"[common]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"DCPSDefaultDiscovery=TheRTPSConfig\n");strncat(strdata,strtem,10000);
+#ifdef dds_use_shm
+            snprintf(strtem,256,"DCPSGlobalTransportConfig=myconfig\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"[config/myconfig]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"transports=share\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"[transport/share]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"transport_type=shmem\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"pool_size=100000000\n");strncat(strdata,strtem,10000);
+#endif
+            snprintf(strtem,256,"[rtps_discovery/TheRTPSConfig]\n");strncat(strdata,strtem,10000);
+            snprintf(strtem,256,"ResendPeriod=5\n");strncat(strdata,strtem,10000);
+            xFile.write(strdata,strnlen(strdata,10000));
+            xFile.close();
+        }
+    }
+    strncpy(strpath,strtmppath,255);
+    return 0;
+}
+
+modulecomm_impl_tcp::modulecomm_impl_tcp(const char * strcommname,int ntype,const unsigned short nport ,const char * strip )
+{
+
+    strncpy(mstrtopic,strcommname,255);
+
+    iv::modulecomm::gmodulecomm_dds_Mutex.lock();
+    if(ntype == type_recv)
+    {
+        mpSub = new TopicsSubscriber();
+        mpSub->init(strcommname,strip,nport,1);
+//        std::this_thread::sleep_for(std::chrono::milliseconds(10));
+
+        mnType = type_recv;
+    }
+    else
+    {
+        mpPub = new TopicsPublisher();
+        mpPub->init(strcommname,nport,1);
+ //       std::this_thread::sleep_for(std::chrono::milliseconds(10));
+        mnType = type_send;
+    }
+    iv::modulecomm::createcount++;
+    std::cout<<"count is "<<iv::modulecomm::createcount<<std::endl;
+    iv::modulecomm::gmodulecomm_dds_Mutex.unlock();
+
+}
+
+int modulecomm_impl_tcp::listenmsg(ModuleFun xFun)
+{
+    if(mnType == type_send)
+    {
+        std::cout<<"send not listen."<<std::endl;;
+        return -1;
+    }
+    mbFunPlus = true;
+    mFun = xFun;
+    ModuleFun topicFunction = std::bind(&modulecomm_impl_tcp::callbackTopic,this,std::placeholders::_1,
+                                                                                std::placeholders::_2,
+                                                                                std::placeholders::_3,
+                                                                                std::placeholders::_4,
+                                                                                std::placeholders::_5);
+    mpSub->setReceivedTopicFunction(topicFunction);
+    return 0;
+}
+
+int modulecomm_impl_tcp::listenmsg(SMCallBack pCall)
+{
+    if(mnType == type_send)
+    {
+        std::cout<<"send not listen."<<std::endl;
+        return -1;
+    }
+    mbFunPlus = false;
+    mpCall = pCall;
+    ModuleFun topicFunction = std::bind(&modulecomm_impl_tcp::callbackTopic,this,std::placeholders::_1,
+                                                                                std::placeholders::_2,
+                                                                                std::placeholders::_3,
+                                                                                std::placeholders::_4,
+                                                                                std::placeholders::_5);
+    mpSub->setReceivedTopicFunction(topicFunction);
+    return 0;
+}
+
+void modulecomm_impl_tcp::writemsg(const char *str, int nlen)
+{
+    if(mnType == type_recv)
+    {
+        std::cout<<"recv not send."<<std::endl;
+        return ;
+    }
+
+    mpPub->senddata(str,nlen);
+
+}
+
+#endif

+ 41 - 0
src/common/modulecomm/fastrtps/modulecomm_impl_tcp.h

@@ -0,0 +1,41 @@
+#ifndef MODULECOMM_IMPL_TCP_H
+#define MODULECOMM_IMPL_TCP_H
+
+#include <QDateTime>
+
+#include "TopicsPublisher.h"
+#include "TopicsSubscriber.h"
+
+
+typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+
+
+class modulecomm_impl_tcp
+{
+public:
+    const static int type_send = 1;
+    const static int type_recv = 2;
+public:
+    modulecomm_impl_tcp(const char * strcommname,int ntype = 2,const unsigned short nport =1,const char * strip = 0);
+    int listenmsg(SMCallBack pCall);
+    int listenmsg(ModuleFun xFun);
+    void writemsg(const char * str,int nlen);
+
+private:
+    char mstrtopic[256];
+    int mnType = type_recv;
+    TopicsPublisher * mpPub;
+    TopicsSubscriber * mpSub;
+    SMCallBack  mpCall;
+    ModuleFun mFun;
+    void callbackTopic(const char * strdata,const unsigned int nSize,const unsigned int index,QDateTime * dt,const char * strmemname);
+
+    int GetTempConfPath(char * strpath);
+
+
+
+    bool mbFunPlus = false;
+
+};
+
+#endif // MODULECOMM_IMPL_H

+ 491 - 0
src/common/modulecomm/inter/intercomm.cpp

@@ -0,0 +1,491 @@
+#include "intercomm.h"
+
+#include <QMutex>
+#include <QWaitCondition>
+#include <iostream>
+
+namespace  iv {
+
+struct InterListenUnit
+{
+    QMutex mWaitMutex;
+    SMCallBack  mpCall;
+    ModuleFun mFun;
+    QWaitCondition * mpwc;
+    bool mbFunPlus = false;
+};
+
+struct interunit
+{
+    char strintername[256];
+    char * strdatabuf;
+    int nbufsize = 0;
+    int nPacCount;
+    QMutex mMutexUnit;
+    std::vector<InterListenUnit *> mvectorlisten;
+    QWaitCondition mwc;
+    bool mbHaveWriter = false;
+
+};
+
+std::vector<interunit *> gvectorinter;
+QMutex gMutexInter;
+
+
+static interunit * FindInterUnitByName(const char * strname)
+{
+    interunit * p = 0;
+    int i;
+    int nsize;
+    nsize = gvectorinter.size();
+    for(i=0;i<nsize;i++)
+    {
+        if(strncmp(strname,gvectorinter.at(i)->strintername,256) == 0)
+        {
+            return (gvectorinter.at(i));
+        }
+    }
+    return p;
+}
+
+
+intercomm::intercomm(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode)
+{
+    strncpy(mstrsmname,strsmname,256);
+
+    mnMode = nMode;
+    if(nMode == ModeWrite)
+    {
+        gMutexInter.lock();
+        interunit * p = FindInterUnitByName(strsmname);
+        if(p == 0)
+        {
+            interunit * pnewinter = new interunit;
+            strncpy(pnewinter->strintername,strsmname,256);
+            pnewinter->strdatabuf = new char[sizeof(procinter_info)+nMaxPacCount*sizeof(procinter_head) + nBufSize];
+            pnewinter->nPacCount = nMaxPacCount;
+            pnewinter->nbufsize = nBufSize;
+            gvectorinter.push_back(pnewinter);
+            mpa = pnewinter;
+
+
+        }
+        else
+        {
+            p->mMutexUnit.lock();
+            delete p->strdatabuf;
+            p->strdatabuf = new char[sizeof(procinter_info)+nMaxPacCount*sizeof(procinter_head) + nBufSize];
+            p->nPacCount = nMaxPacCount;
+            p->nbufsize = nBufSize;
+            p->mMutexUnit.unlock();
+            mpa = p;
+        }
+
+        interunit * pinter = (interunit * )mpa;
+        char * pdata = (char *)pinter->strdatabuf;
+        mpinfo = (procinter_info *)pdata;
+        mphead = (procinter_head *)(pdata+sizeof(procinter_info));
+        mpinfo->mCap = nMaxPacCount;
+        mpinfo->mnBufSize = nBufSize;
+        mpinfo->mFirst = 0;
+        mpinfo->mNext = 0;
+        mpinfo->mLock = 0;
+        pinter->mbHaveWriter = true;
+
+        gMutexInter.unlock();
+
+    }
+    else
+    {
+        gMutexInter.lock();
+        interunit * p = FindInterUnitByName(strsmname);
+        if(p == 0)
+        {
+            interunit * pnewinter = new interunit;
+            strncpy(pnewinter->strintername,strsmname,256);
+            gvectorinter.push_back(pnewinter);
+            mpa = pnewinter;
+        }
+        else
+        {
+            mpa = p;
+        }
+
+        interunit * pinter = (interunit * )mpa;
+        char * pdata = (char *)pinter->strdatabuf;
+        mpinfo = (procinter_info *)pdata;
+        mphead = (procinter_head *)(pdata+sizeof(procinter_info));
+
+        gMutexInter.unlock();
+    }
+}
+
+intercomm::~intercomm()
+{
+    if(mnMode == ModeRead)
+    {
+        stoplisten();
+        interunit * p = (interunit *)mpa;
+        p->mMutexUnit.lock();
+        InterListenUnit * plisten = (InterListenUnit *)mplistenunit;
+        int i;
+        for(i=0;i<p->mvectorlisten.size();i++)
+        {
+            if(plisten == p->mvectorlisten.at(i))
+            {
+                p->mvectorlisten.erase(p->mvectorlisten.begin() + i);
+                delete plisten;
+                break;
+            }
+        }
+        p->mMutexUnit.unlock();
+    }
+}
+
+int intercomm::listenmsg(ModuleFun xFun)
+{
+    if(mnMode == ModeWrite)
+    {
+        std::cout<<"intercomm::listenmsg this is Write. Can't Listen."<<std::endl;
+        return - 1;
+    }
+
+    interunit * p = (interunit *)mpa;
+    p->mMutexUnit.lock();
+    InterListenUnit * pnewlisten = new InterListenUnit;
+    pnewlisten->mbFunPlus = true;
+    pnewlisten->mFun = xFun;
+    pnewlisten->mpwc = &p->mwc;
+    p->mvectorlisten.push_back(pnewlisten);
+    p->mMutexUnit.unlock();
+
+    mplistenunit = (void *)pnewlisten;
+
+    mplistenthread = new std::thread(&intercomm::listernrun,this);
+    return 0;
+}
+
+int intercomm::listenmsg(SMCallBack pCall)
+{
+    if(mnMode == ModeWrite)
+    {
+        std::cout<<"intercomm::listenmsg this is Write. Can't Listen."<<std::endl;
+        return - 1;
+    }
+
+    interunit * p = (interunit *)mpa;
+    p->mMutexUnit.lock();
+    InterListenUnit * pnewlisten = new InterListenUnit;
+    pnewlisten->mbFunPlus = false;
+    pnewlisten->mpCall = pCall;
+    pnewlisten->mpwc = &p->mwc;
+    p->mvectorlisten.push_back(pnewlisten);
+    p->mMutexUnit.unlock();
+    mplistenunit = (void *)pnewlisten;
+    mplistenthread = new std::thread(&intercomm::listernrun,this);
+    return 0;
+}
+
+void intercomm::stoplisten()
+{
+    mblistenrun = false;
+    if(mplistenthread != 0)
+    {
+        mplistenthread->join();
+        mplistenthread = 0;
+    }
+}
+
+void intercomm::pausecomm()
+{
+    mbPause = true;
+}
+
+void intercomm::continuecomm()
+{
+    mbPause = false;
+}
+
+void intercomm::listernrun()
+{
+    InterListenUnit * pILU = (InterListenUnit * )mplistenunit;
+    QTime xTime;
+    xTime.start();
+    unsigned int nBufLen = 1;
+    unsigned int nRead;
+    char * str = new char[nBufLen];
+    unsigned int index =0;
+    QDateTime *pdt = new QDateTime();
+    interunit * pinter = (interunit *)mpa;
+    while(mblistenrun)
+    {
+        if(mbPause)
+        {
+            std::this_thread::sleep_for(std::chrono::milliseconds(100));
+            continue;
+        }
+        if(pinter->mbHaveWriter == false)
+        {
+            std::this_thread::sleep_for(std::chrono::milliseconds(100));
+            continue;
+        }
+        pILU->mWaitMutex.lock();
+        pILU->mpwc->wait(&pILU->mWaitMutex,100);
+        pILU->mWaitMutex.unlock();
+        int nRtn = readmsg(index,str,nBufLen,&nRead,pdt);
+        while ((nRtn != 0)&&(mblistenrun))
+        {
+            if(nRtn == -1)
+            {
+                nBufLen = nRead;
+                delete str;
+                if(nBufLen < 1)nBufLen = 1;
+                str = new char[nBufLen];
+            }
+            else
+            {
+                if(nRtn == -2)
+                {
+                   index = getcurrentnext();
+                }
+                else
+                {
+                   if(nRtn >0)
+                   {
+                       if(pILU->mbFunPlus)
+                       {
+                           pILU->mFun(str,nRtn,index,pdt,mstrsmname);
+                       }
+                       else
+                       {
+                          (*pILU->mpCall)(str,nRtn,index,pdt,mstrsmname);
+                       }
+                       index++;
+                   }
+                   else
+                   {
+                       std::this_thread::sleep_for(std::chrono::milliseconds(100));
+                   }
+                }
+            }
+            nRtn = readmsg(index,str,nBufLen,&nRead,pdt);
+        }
+
+    }
+
+    delete str;
+    delete pdt;
+}
+
+int intercomm::writemsg(const char *str, const unsigned int nSize)
+{
+    if(mbPause)return -2;
+    if(mnMode == ModeRead)
+    {
+        std::cout<<"Register read. can't write."<<std::endl;
+        return -1;
+    }
+    interunit * pinter = (interunit *)mpa;
+
+    pinter->mMutexUnit.lock();
+
+    if(nSize > pinter->nbufsize)
+    {
+ //       qDebug("procsm::writemsg message size is very big");
+
+        int nnewsize = std::max(nSize*11/10,nSize+100);
+        char * strdatabuf = new char[sizeof(procinter_info)+ pinter->nPacCount*sizeof(procinter_head) + nnewsize];
+
+        memcpy(strdatabuf,pinter->strdatabuf,sizeof(procinter_info)+ pinter->nPacCount*sizeof(procinter_head) + pinter->nbufsize);
+        pinter->nbufsize = nnewsize;
+        delete pinter->strdatabuf;
+        pinter->strdatabuf = strdatabuf;
+        qDebug("inter resize buf,new buffer size is %d",nnewsize);
+    }
+    char * pdata = (char *)pinter->strdatabuf;
+    mpinfo = (procinter_info *)pdata;
+    mphead = (procinter_head *)(pdata+sizeof(procinter_info));
+
+WRITEMSG:
+
+    char * pH,*pD;
+    QDateTime dt;
+    pH = (char *)pinter->strdatabuf;pH = pH + sizeof(procinter_info);
+    pD = (char *)pinter->strdatabuf;pD = pD + sizeof(procinter_info) + pinter->nPacCount * sizeof(procinter_head);
+    procinter_head * phh = (procinter_head *)pH;
+    unsigned int nPac = mpinfo->mNext - mpinfo->mFirst;
+    if(nPac>=pinter->nPacCount)
+    {
+        unsigned int nRemove = pinter->nPacCount/3;
+        if(nRemove == 0)nRemove = 1;
+        MoveMem(nRemove);
+        goto WRITEMSG;
+    }
+    if(nPac == 0)
+    {
+        memcpy(pD,str,nSize);
+        dt = QDateTime::currentDateTime();
+        phh->SetDate(dt);
+        phh->mindex = mpinfo->mNext;
+        phh->mnPos = 0;
+        phh->mnLen = nSize;
+        mpinfo->mNext = mpinfo->mNext+1;
+    }
+    else
+    {
+        if(((phh+nPac-1)->mnPos+(phh+nPac-1)->mnLen + nSize)>=pinter->nbufsize)
+        {
+            unsigned int nRemove = pinter->nPacCount/2;
+            if(nRemove == 0)nRemove = 1;
+            MoveMem(nRemove);
+            goto WRITEMSG;
+        }
+        else
+        {
+            unsigned int nPos = (phh+nPac-1)->mnPos + (phh+nPac-1)->mnLen;
+            memcpy(pD+nPos,str,nSize);
+            dt = QDateTime::currentDateTime();
+            (phh+nPac)->SetDate(dt);
+            (phh+nPac)->mindex = mpinfo->mNext;
+            (phh+nPac)->mnPos = nPos;
+            (phh+nPac)->mnLen = nSize;
+            mpinfo->mNext = mpinfo->mNext+1;
+        }
+    }
+
+    const unsigned int nTM = 0x6fffffff;
+    if((mpinfo->mNext >nTM)&&(mpinfo->mFirst>nTM))
+    {
+       nPac = mpinfo->mNext - mpinfo->mFirst;
+       unsigned int i;
+       for(i=0;i<nPac;i++)
+       {
+           (phh+i)->mindex = (phh+i)->mindex-nTM;
+       }
+       mpinfo->mFirst = mpinfo->mFirst-nTM;
+       mpinfo->mNext = mpinfo->mNext - nTM;
+    }
+
+    pinter->mMutexUnit.unlock();
+    pinter->mwc.wakeAll();
+    return 0;
+}
+
+int intercomm::MoveMem(const unsigned int nSize)
+{
+    unsigned int nRemove = nSize;
+    if(nRemove == 0)return -1;
+    interunit * pinter = (interunit *)mpa;
+    char * pH,*pD;
+    pH = (char *)pinter->strdatabuf;pH = pH + sizeof(procinter_info);
+    pD = (char *)pinter->strdatabuf;pD = pD + sizeof(procinter_info) + pinter->nPacCount * sizeof(procinter_head);
+    procinter_head * phh = (procinter_head *)pH;
+    unsigned int nPac = mpinfo->mNext - mpinfo->mFirst;
+
+    if(nRemove >nPac)
+    {
+        nRemove = nPac;
+    }
+
+    if(nRemove == nPac)
+    {
+        mpinfo->mFirst = mpinfo->mFirst + (unsigned int)nRemove;
+        return 0;
+    }
+
+    unsigned int i;
+    int nDataMove = 0;
+    for(i=0;i<nRemove;i++)
+    {
+        procinter_head * phd = phh+i;
+        nDataMove = nDataMove + phd->mnLen;
+    }
+    unsigned int nDataTotal;
+    for(i=0;i<(nPac - nRemove);i++)
+    {
+        memcpy(phh+i,phh+i+nRemove,sizeof(procinter_head));
+        (phh+i)->mnPos = (phh+i)->mnPos - nDataMove;
+    }
+    nDataTotal = (phh + nPac-nRemove-1)->mnPos + (phh+nPac-nRemove-1)->mnLen;
+    char * strtem = new char[pinter->nbufsize];
+    memcpy(strtem,pD+nDataMove,nDataTotal);
+    memcpy(pD,strtem,nDataTotal);
+    delete strtem;
+
+    mpinfo->mFirst = mpinfo->mFirst + (unsigned int)nRemove;
+    return 0;
+}
+
+int intercomm::readmsg(unsigned int index, char *str, unsigned int nMaxSize, unsigned int *nRead, QDateTime *pdt)
+{
+    int nRtn = 0;
+
+    interunit * pinter = (interunit *)mpa;
+
+    if(pinter->nbufsize == 0)return 0;
+    pinter->mMutexUnit.lock();
+    char * pdata = (char *)pinter->strdatabuf;
+    mpinfo = (procinter_info *)pdata;
+    mphead = (procinter_head *)(pdata+sizeof(procinter_info));
+
+    if((index< mpinfo->mFirst)||(index > mpinfo->mNext))
+    {
+        nRtn = -2;
+    }
+    if(nRtn != (-2))
+    {
+        if(index == mpinfo->mNext)
+        {
+            nRtn = 0;
+        }
+        else
+        {
+            char * pH,*pD;
+ //           pH = (char *)mpASM->data();pH = pH + 2*sizeof(unsigned int);
+
+ //           pD = (char *)mpASM->data();pD = pD + 2*sizeof(unsigned int) + mnMaxPacCount * sizeof(procsm_head);
+            pD = (char *)pinter->strdatabuf;pD = pD+ sizeof(procinter_info) + mpinfo->mCap*sizeof(procinter_head);
+            pH = (char *)pinter->strdatabuf;pH = pH+sizeof(procinter_info);
+            procinter_head * phh = (procinter_head *)pH;
+            unsigned int nPac = mpinfo->mNext - mpinfo->mFirst;
+            if(nPac == 0)
+            {
+                nRtn = 0;
+            }
+            else
+            {
+                unsigned int nPos = index - mpinfo->mFirst;
+                *nRead = (phh+nPos)->mnLen;
+                if((phh+nPos)->mnLen > nMaxSize)
+                {
+                    nRtn = -1;
+
+                }
+                else
+                {
+        //            qDebug("read pos = %d",(phh+nPos)->mnPos);
+                   memcpy(str,pD + (phh+nPos)->mnPos,(phh+nPos)->mnLen);
+          //         qDebug("read pos = %d",(phh+nPos)->mnPos);
+                   nRtn = (phh+nPos)->mnLen;
+                   (phh+nPos)->GetDate(pdt);
+           //        memcpy(pdt,&((phh+nPos)->mdt),sizeof(QDateTime));
+                }
+            }
+        }
+    }
+    pinter->mMutexUnit.unlock();
+    return nRtn;
+}
+
+unsigned int intercomm::getcurrentnext()
+{
+    unsigned int nNext;
+    interunit * pinter = (interunit *)mpa;
+    char * pdata = (char *)pinter->strdatabuf;
+    mpinfo = (procinter_info *)pdata;
+    mphead = (procinter_head *)(pdata+sizeof(procinter_info));
+    nNext = mpinfo->mNext;
+    return nNext;
+}
+
+}

+ 109 - 0
src/common/modulecomm/inter/intercomm.h

@@ -0,0 +1,109 @@
+#ifndef INTERCOMM_H
+#define INTERCOMM_H
+
+#include <QDateTime>
+#include "vector"
+#include <functional>
+#include <thread>
+
+typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+using namespace std::placeholders;
+typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
+
+
+class procinter_info
+{
+public:
+  unsigned int mFirst;
+  unsigned int mNext;
+  unsigned int mCap;
+  unsigned int mLock;
+  unsigned int mnBufSize;
+};
+
+class procinter_head
+{
+public:
+    unsigned short mYear;
+    unsigned char mMonth;
+    unsigned char mDay;
+    unsigned char mHour;
+    unsigned char mMinute;
+    unsigned char mSec;
+    unsigned short mMSec;
+    unsigned int mindex;
+    unsigned int mnPos;
+    unsigned int mnLen;
+public:
+    void SetDate(QDateTime dt)
+    {
+        mYear = dt.date().year();
+        mMonth = dt.date().month();
+        mDay = dt.date().day();
+        mHour = dt.time().hour();
+        mMinute = dt.time().minute();
+        mSec = dt.time().second();
+        mMSec = dt.time().msec();
+    }
+    void GetDate(QDateTime * pdt)
+    {
+        QDate dt;
+        dt.setDate(mYear,mMonth,mDay);
+        QTime time;
+        time.setHMS(mHour,mMinute,mSec,mMSec);
+        pdt->setDate(dt);
+        pdt->setTime(time);
+
+    }
+};
+
+
+namespace  iv {
+
+class intercomm
+{
+public:
+    intercomm(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode);
+    ~intercomm();
+
+    int listenmsg(SMCallBack pCall);
+    int listenmsg(ModuleFun xFun);
+    void stoplisten();
+
+    void pausecomm();
+    void continuecomm();
+
+    const static int ModeRead = 1;
+    const static int ModeWrite = 0;
+
+    int writemsg(const char * str,const unsigned int nSize);
+
+private:
+
+
+    char mstrsmname[256];
+    int mnMode;
+    void * mpa;
+    void * mplistenunit;
+
+private:
+    void listernrun();
+    bool mblistenrun = true;
+    bool mbPause = false;
+    std::thread * mplistenthread = 0;
+
+    procinter_info * mpinfo;
+    procinter_head * mphead;
+
+
+private:
+
+    int readmsg(unsigned int index,char * str,unsigned int nMaxSize,unsigned int * nRead,QDateTime * pdt);
+    int MoveMem(const unsigned int nSize);
+    unsigned int getcurrentnext();
+};
+}
+
+
+
+#endif // INTERCOMM_H

+ 60 - 0
src/common/modulecomm/inter/modulecomm_inter.cpp

@@ -0,0 +1,60 @@
+#include "modulecomm_inter.h"
+
+#include <iostream>
+
+#include "intercomm.h"
+
+namespace iv {
+
+
+
+modulecomm_inter::modulecomm_inter()
+{
+
+}
+
+void modulecomm_inter::RegisterSend(const char *strcommname, const unsigned int nBufSize, const unsigned int nMsgBufCount)
+{
+    iv::intercomm * pinter = new iv::intercomm(strcommname,nBufSize,nMsgBufCount,iv::intercomm::ModeWrite);
+    mpinter = (void *)pinter;
+}
+
+void modulecomm_inter::RegisterRecv(const char *strcommname, SMCallBack pCall)
+{
+    iv::intercomm * pif = new iv::intercomm(strcommname,0,0,iv::intercomm::ModeRead);
+    pif->listenmsg(pCall);
+    mpinter = (void *)pif;
+}
+
+void modulecomm_inter::RegisterRecvPlus(const char *strcommname, ModuleFun xFun)
+{
+    iv::intercomm * pif = new iv::intercomm(strcommname,0,0,iv::intercomm::ModeRead);
+    pif->listenmsg(xFun);
+    mpinter = (void *)pif;
+}
+
+void modulecomm_inter::ModuleSendMsg(const char *strdata, const unsigned int nDataLen)
+{
+    iv::intercomm * pif = (iv::intercomm *)mpinter;
+    pif->writemsg(strdata,nDataLen);
+}
+
+void modulecomm_inter::ContintuComm()
+{
+    iv::intercomm * pif = (iv::intercomm *)mpinter;
+    pif->continuecomm();
+}
+
+void modulecomm_inter::PauseComm()
+{
+    iv::intercomm * pif = (iv::intercomm *)mpinter;
+    pif->pausecomm();
+}
+
+void modulecomm_inter::Unregister()
+{
+    iv::intercomm * pif = (iv::intercomm *)mpinter;
+    delete pif;
+}
+
+}

+ 30 - 0
src/common/modulecomm/inter/modulecomm_inter.h

@@ -0,0 +1,30 @@
+#ifndef MODULECOMM_INTER_H
+#define MODULECOMM_INTER_H
+
+#include "modulecomm_base.h"
+
+namespace iv {
+
+
+class modulecomm_inter : public modulecomm_base
+{
+public:
+    modulecomm_inter();
+
+    void RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount);
+    void RegisterRecv(const char * strcommname,SMCallBack pCall);
+    void RegisterRecvPlus(const char * strcommname,ModuleFun xFun);
+    virtual void ModuleSendMsg(const char * strdata,const unsigned int nDataLen);
+    virtual void Unregister();
+    virtual void PauseComm();
+    virtual void ContintuComm();
+
+private:
+    void * mpinter;
+};
+
+}
+
+
+
+#endif // MODULECOMM_INTER_H

+ 7 - 0
src/common/modulecomm/inter/modulecomm_inter.pri

@@ -0,0 +1,7 @@
+HEADERS += \
+    $$PWD/intercomm.h \
+    $$PWD/modulecomm_inter.h
+
+SOURCES += \
+    $$PWD/intercomm.cpp \
+    $$PWD/modulecomm_inter.cpp

BIN
src/common/modulecomm/libfast.zip


+ 172 - 0
src/common/modulecomm/main.cpp

@@ -0,0 +1,172 @@
+#include <QCoreApplication>
+
+#include <thread>
+#include <chrono>
+#include <iostream>
+
+#include "modulecomm.h"
+
+#include "modulecommext.h"
+
+#include <QSharedMemory>
+
+#include "testmodulecommext.pb.h"
+
+
+void * gpa;
+
+std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<double,std::nano>> t1,t2;
+
+void testcall(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    qint64 sendtime;
+    t2 = std::chrono::steady_clock::now();
+    double dr_ns = std::chrono::duration<double,std::nano>(t2-t1).count();
+    memcpy(&sendtime,strdata,8);
+    qDebug("lat is %d ns is %f ",QDateTime::currentMSecsSinceEpoch() - sendtime,dr_ns);
+}
+
+void threadsend()
+{
+    char * strdata = new char[3000000];
+    while(1)
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+        qint64 ntime = QDateTime::currentMSecsSinceEpoch();
+        memcpy(strdata,&ntime,8);
+
+        iv::modulecomm::ModuleSendMsg(gpa,strdata,2000000);
+        t1 =  std::chrono::steady_clock::now();
+        qDebug("send msg.");
+    }
+}
+
+void testcall2(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    qint64 sendtime;
+    t2 = std::chrono::steady_clock::now();
+    double dr_ns = std::chrono::duration<double,std::nano>(t2-t1).count();
+    memcpy(&sendtime,strdata,8);
+    qDebug("lat is %d ns is %f ",QDateTime::currentMSecsSinceEpoch() - sendtime,dr_ns);
+}
+
+void threadsend2()
+{
+    char * strdata = new char[3000000];
+    int nsendlen = 10000;
+    while(1)
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        qint64 ntime = QDateTime::currentMSecsSinceEpoch();
+        memcpy(strdata,&ntime,8);
+        if(nsendlen<2000000)nsendlen = nsendlen*1001/1000;
+        iv::modulecomm::ModuleSendMsg(gpa,strdata,nsendlen);
+        t1 =  std::chrono::steady_clock::now();
+//        qDebug("send msg.");
+    }
+}
+
+#include <future>
+
+
+void testfunc(int a)
+{
+    a = a+1;
+    std::cout<<"a = "<<a<<std::endl;
+
+}
+
+void testfunc2(double a)
+{
+    a = a+1.1;
+    std::cout<<"a = "<<a<<std::endl;
+
+}
+
+
+iv::modulecommext::modulecommmsg<iv::testmodulecommext> * gmsgtestsend,* gmsgtestrecv;
+
+
+void ListenProto(google::protobuf::Message & xmsg)
+{
+    iv::testmodulecommext * pmsg = (iv::testmodulecommext *)&xmsg;
+    qDebug("time : %lld",pmsg->time());
+}
+
+void threadsendproto()
+{
+    while(1)
+    {
+        iv::testmodulecommext xmsg;
+        xmsg.set_a(1);
+        xmsg.set_b(2);
+        xmsg.set_time(QDateTime::currentMSecsSinceEpoch());
+        gmsgtestsend->ModuleSendMsg(xmsg);
+        std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication a(argc, argv);
+
+//    auto x1 =  std::chrono::system_clock::now();
+//    std::cout << "秒:"<<std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count() << std::endl;
+//        std::cout << "毫秒:" << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()<<std::endl;
+//        std::cout << "微秒:" << std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count() << std::endl;
+//        std::cout << "纳秒:" << std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count() << std::endl;
+//        qint64 naotime = std::chrono::system_clock::now().time_since_epoch().count();
+
+//    int j;
+//    for(j=0;j<10000000;j++)
+//    {
+
+//    }
+//    auto x2 = std::chrono::system_clock::now();
+//    double elapsed =
+//        std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now() - x1).count();
+
+//    qDebug("ela is %f ",elapsed);
+//    return 0;
+
+
+
+//    gpa = iv::modulecomm::RegisterSend("test1",3000000,1,iv::modulecomm::ModuleComm_INTERIOR);
+//    iv::modulecomm::RegisterRecv("test1",testcall,iv::modulecomm::ModuleComm_INTERIOR);
+//    std::thread * xthread = new std::thread(threadsend);
+
+
+//    QSharedMemory * pmem = new QSharedMemory("hello");
+//    pmem->create(1000);
+//    qDebug("create");
+//    pmem->lock();
+//    qDebug("lock");
+//    gpa = iv::modulecomm::RegisterSend("test1",1000,1);
+//    gpa = iv::modulecomm::RegisterSend("test1");
+//    iv::modulecomm::RegisterRecv("test1",testcall2);
+//    gpa = iv::modulecomm::RegisterSend("test1",1000,1,iv::modulecomm::ModuleComm_FASTRTPS);
+//    iv::modulecomm::RegisterRecv("test1",testcall2,iv::modulecomm::ModuleComm_FASTRTPS);
+//    iv::modulecomm::RegisterRecv("test1",testcall2);
+//    std::thread * xthread = new std::thread(threadsend2);
+
+
+      gmsgtestsend = new iv::modulecommext::modulecommmsg<iv::testmodulecommext>();
+
+      gmsgtestsend->RegisterSend("testsendproto");
+
+      gmsgtestrecv = new iv::modulecommext::modulecommmsg<iv::testmodulecommext>();
+
+      gmsgtestrecv->RegisterRecv("testsendproto",ListenProto);
+
+      std::thread * xthreadproto = new std::thread(threadsendproto);
+
+
+
+//    extfunc<int>::pfun x = &testfunc;
+//    extfunc<double>::pfun x2 = &testfunc2;
+//    (*x)(1);
+//    (*x2)(2.0);
+
+
+    return a.exec();
+}

+ 11 - 0
src/common/modulecomm/main1.cpp

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

+ 11 - 0
src/common/modulecomm/main2.cpp

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

+ 242 - 23
src/common/modulecomm/modulecomm.cpp

@@ -1,55 +1,274 @@
-#include "modulecomm.h"
-#include "procsm_if.h"
-#include "procsm.h"
-
+#include "modulecomm.h"
 #include <iostream>
 
+#include "modulecomm_shm.h"
+
+#include "modulecomm_inter.h"
+#ifdef USE_FASTRTPS
+#include "modulecomm_fastrtps_shm.h"
+#include "modulecomm_fastrtps_tcp.h"
+#endif
+
+#include <QtXml>
+#include <QFile>
+
 namespace iv {
 namespace modulecomm {
 
+struct ModeduleInfo
+{
+    modulecomm_base * mphandle;
+    ModuleComm_TYPE mmctype;
+};
 
-void *  RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount)
+static ModuleComm_TYPE getdefmodulecommtype()
 {
+#ifdef  ANDROID
+    return ModuleComm_INTERIOR;
+#endif
+    ModuleComm_TYPE xrtn = ModuleComm_SHAREMEM;
+    QDomDocument xdoc;
+    QFile file("./modulecomm.xml");
+    if (!file.open(QIODevice::ReadOnly))
+    {
+        return xrtn;
+    }
+    if (!xdoc.setContent(&file)) {
+        file.close();
+        return xrtn;
+    }
+    file.close();
+    QDomElement docElem = xdoc.documentElement();
+
+    QDomNode n = docElem.firstChild();
+    while(!n.isNull())
+    {
+    QDomElement e = n.toElement();
+    if(e.nodeName() == "commtype")
+    {
+        QString strvalue = e.attribute("value","0");
+        if(strvalue == "0")
+        {
+            xrtn = ModuleComm_SHAREMEM;
+        }
+        if(strvalue == "1")
+        {
+            xrtn = ModuleComm_INTERIOR;
+        }
+#ifdef USE_FASTRTPS
+        if(strvalue == "2")
+        {
+            xrtn = ModuleComm_FASTRTPS;
+        }
+#endif
+        break;
+    }
+        n = n.nextSibling();
+    }
 
-    procsm_if * pif = new procsm_if(strcommname,nBufSize,nMsgBufCount,procsm::ModeWrite);
-    return (void *)pif;
+    return xrtn;
 }
 
-void  *  RegisterRecv(const char * strcommname,SMCallBack pCall)
+
+void *  RegisterSend(const char * strcommname)
 {
-    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
-    pif->listenmsg(pCall);
-    return (void *)pif;
+    return RegisterSend(strcommname,1000,1);
 }
 
-void * MODULECOMMSHARED_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun)
+void *  RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount,
+                     ModuleComm_TYPE xmctype,const unsigned short nport)
 {
-    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
-    pif->listenmsg(xFun);
-    return (void *)pif;
+
+    iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
+    pmi->mmctype = xmctype;
+    pmi->mphandle = 0;
+    ModuleComm_TYPE mctype = xmctype;
+    if(mctype == ModuleComm_UNDEFINE)
+    {
+        mctype = getdefmodulecommtype();
+    }
+    switch (mctype) {
+    case ModuleComm_SHAREMEM:
+    {
+        iv::modulecomm_shm * p = new iv::modulecomm_shm();
+        p->RegisterSend(strcommname,nBufSize,nMsgBufCount);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+    case ModuleComm_INTERIOR:
+    {
+        iv::modulecomm_inter * p = new iv::modulecomm_inter();
+        p->RegisterSend(strcommname,nBufSize,nMsgBufCount);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+
+#ifdef USE_FASTRTPS
+    case ModuleComm_FASTRTPS:
+    {
+        iv::modulecomm_fastrtps_shm * p = new iv::modulecomm_fastrtps_shm();
+        p->RegisterSend(strcommname,nBufSize,nMsgBufCount);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+
+    case ModuleComm_FASTRTPS_TCP:
+    {
+        iv::modulecomm_fastrtps_tcp * p = new iv::modulecomm_fastrtps_tcp();
+        p->RegisterSend(strcommname,nBufSize,nMsgBufCount,nport);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+#endif
+    default:
+        break;
+    }
+    return pmi;
 }
+
+
+void  *  RegisterRecv(const char * strcommname,SMCallBack pCall,ModuleComm_TYPE xmctype,const char * strip,
+                      const unsigned short nPort)
+{
+    iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
+    pmi->mmctype = xmctype;
+    pmi->mphandle = 0;
+    ModuleComm_TYPE mctype = xmctype;
+    if(mctype == ModuleComm_UNDEFINE)
+    {
+        mctype = getdefmodulecommtype();
+    }
+    switch (mctype) {
+    case ModuleComm_SHAREMEM:
+    {
+        iv::modulecomm_shm * p = new iv::modulecomm_shm();
+        p->RegisterRecv(strcommname,pCall);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+    case ModuleComm_INTERIOR:
+    {
+        iv::modulecomm_inter * p = new iv::modulecomm_inter();
+        p->RegisterRecv(strcommname,pCall);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+
+#ifdef USE_FASTRTPS
+    case ModuleComm_FASTRTPS:
+    {
+        iv::modulecomm_fastrtps_shm * p = new iv::modulecomm_fastrtps_shm();
+        p->RegisterRecv(strcommname,pCall);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+
+    case ModuleComm_FASTRTPS_TCP:
+    {
+        iv::modulecomm_fastrtps_tcp * p = new iv::modulecomm_fastrtps_tcp();
+        p->RegisterRecv(strcommname,pCall,strip,nPort);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+#endif
+    default:
+        break;
+    }
+    return pmi;
+}
+
+void *  RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
+                                                ModuleComm_TYPE xmctype,const char * strip,
+                         const unsigned short nPort)
+{
+    iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
+    pmi->mmctype = xmctype;
+    pmi->mphandle = 0;
+    ModuleComm_TYPE mctype = xmctype;
+    if(mctype == ModuleComm_UNDEFINE)
+    {
+        mctype = getdefmodulecommtype();
+    }
+    switch (mctype) {
+    case ModuleComm_SHAREMEM:
+    {
+        iv::modulecomm_shm * p = new iv::modulecomm_shm();
+        p->RegisterRecvPlus(strcommname,xFun);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+    case ModuleComm_INTERIOR:
+    {
+        iv::modulecomm_inter * p = new iv::modulecomm_inter();
+        p->RegisterRecvPlus(strcommname,xFun);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+#ifdef USE_FASTRTPS
+    case ModuleComm_FASTRTPS:
+    {
+        iv::modulecomm_fastrtps_shm * p = new iv::modulecomm_fastrtps_shm();
+        p->RegisterRecvPlus(strcommname,xFun);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+
+    case ModuleComm_FASTRTPS_TCP:
+    {
+        iv::modulecomm_fastrtps_tcp * p = new iv::modulecomm_fastrtps_tcp();
+        p->RegisterRecvPlus(strcommname,xFun,strip,nPort);
+        pmi->mphandle = (iv::modulecomm_base *)p;
+    }
+        break;
+#endif
+    default:
+        break;
+    }
+    return pmi;
+}
+
 void  ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen)
 {
-    procsm_if * pif = (procsm_if *)pHandle;
-    pif->writemsg(strdata,nDataLen);
+    iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo  * )pHandle;
+    if(pmi->mphandle == 0)
+    {
+        qDebug("handler error. use fastrtps but not define.");
+        return;
+    }
+    pmi->mphandle->ModuleSendMsg(strdata,nDataLen);
 }
 
 void  Unregister(void * pHandle)
 {
-    procsm_if * pif = (procsm_if *)pHandle;
-    delete pif;
+    iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo  * )pHandle;
+    if(pmi->mphandle == 0)
+    {
+        qDebug("handler error. use fastrtps but not define.");
+        return;
+    }
+    pmi->mphandle->Unregister();
 }
 
 void PauseComm(void *pHandle)
 {
-    procsm_if * pif = (procsm_if *)pHandle;
-    pif->pausecomm();
+    iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo  * )pHandle;
+    if(pmi->mphandle == 0)
+    {
+        qDebug("handler error. use fastrtps but not define.");
+        return;
+    }
+    pmi->mphandle->PauseComm();
 }
 
 void ContintuComm(void *pHandle)
 {
-    procsm_if * pif = (procsm_if *)pHandle;
-    pif->continuecomm();
+    iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo  * )pHandle;
+    if(pmi->mphandle == 0)
+    {
+        qDebug("handler error. use fastrtps but not define.");
+        return;
+    }
+    pmi->mphandle->ContintuComm();
 }
 
 }

+ 35 - 7
src/common/modulecomm/modulecomm.h

@@ -1,11 +1,15 @@
-#ifndef MODULECOMM_H
+#ifndef MODULECOMM_H
 #define MODULECOMM_H
 
+
 #include <QtCore/qglobal.h>
 #include <QDateTime>
 
 #include <functional>
 
+
+
+
 #if defined(MODULECOMM_LIBRARY)
 #  define MODULECOMMSHARED_EXPORT Q_DECL_EXPORT
 #else
@@ -13,18 +17,44 @@
 #endif
 
 
+
+
+
+
 //#include <iostream>
 //#include <thread>
 
 //using namespace std::placeholders;
+
+#ifndef IV_MODULE_FUN
+
 typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
 typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+#define IV_MODULE_FUN
+#endif
 
 namespace iv {
 namespace modulecomm {
-void * MODULECOMMSHARED_EXPORT RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount);
-void * MODULECOMMSHARED_EXPORT RegisterRecv(const char * strcommname,SMCallBack pCall);
-void * MODULECOMMSHARED_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun);
+
+enum ModuleComm_TYPE
+{
+    ModuleComm_SHAREMEM = 0,
+    ModuleComm_INTERIOR = 1,
+    ModuleComm_FASTRTPS = 2,
+    ModuleComm_FASTRTPS_TCP = 3,
+    ModuleComm_UNDEFINE = 4
+};
+
+void * MODULECOMMSHARED_EXPORT RegisterSend(const char * strcommname);
+
+
+void * MODULECOMMSHARED_EXPORT RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount
+                                            ,ModuleComm_TYPE xmctype = ModuleComm_UNDEFINE,const unsigned short nport = 5100);
+void * MODULECOMMSHARED_EXPORT RegisterRecv(const char * strcommname,SMCallBack pCall,
+                                            ModuleComm_TYPE xmctype = ModuleComm_UNDEFINE,const char * strip = 0,const unsigned short = 5100);
+void * MODULECOMMSHARED_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
+                                                ModuleComm_TYPE xmctype = ModuleComm_UNDEFINE,const char * strip = 0,const unsigned short = 5100);
+
 void MODULECOMMSHARED_EXPORT ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen);
 void MODULECOMMSHARED_EXPORT Unregister(void * pHandle);
 void MODULECOMMSHARED_EXPORT PauseComm(void * pHandle);
@@ -34,6 +64,4 @@ void MODULECOMMSHARED_EXPORT ContintuComm(void * pHandle);
 
 }
 
-
-
-#endif 
+#endif // MODULECOMM_H

+ 49 - 25
src/common/modulecomm/modulecomm.pro

@@ -1,44 +1,68 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2018-07-10T05:46:48
-#
-#-------------------------------------------------
+QT -= gui
 
-QT       -= gui
+QT += dbus
+QT += xml
 
-QT       += dbus
+TEMPLATE = lib
+DEFINES += MODULECOMM_LIBRARY
 
+#unix:DEFINES += USE_FASTRTPS
+DEFINES += USEDBUS
 
-#DEFINES += USELCM
+CONFIG += c++11
 
+# 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
 
-DEFINES += USEDBUS
+# 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
 
-TARGET = modulecomm
-TEMPLATE = lib
+SOURCES += \
+    modulecomm.cpp \
+    modulecomm_base.cpp
 
-DEFINES += MODULECOMM_LIBRARY
+HEADERS += \
+    ivmodulemsg_type.h \
+    modulecomm.h \
+    modulecomm_base.h
 
-#VERSION = 1.0.1
 CONFIG += plugin
 
 
-SOURCES += modulecomm.cpp \
-    procsm.cpp \
-    procsm_if.cpp
-
-HEADERS += modulecomm.h \
-    procsm.h \
-    procsm_if.h \
-    ivmodulemsg_type.h
-
+# Default rules for deployment.
 unix {
     target.path = /usr/lib
-    INSTALLS += target
 }
+!isEmpty(target.path): INSTALLS += target
 
 
 
-#INCLUDEPATH += $$PWD/../../../include/
-LIBS += -L$$PWD
+!include(./shm/modulecomm_shm.pri ) {
+    error( "Couldn't find the modulecomm_shm.pri file!" )
+}
+
+!include(./inter/modulecomm_inter.pri ) {
+    error( "Couldn't find the modulecomm_inter.pri file!" )
+}
+
+if(contains(DEFINES,USE_FASTRTPS)){
+!include(./fastrtps/modulecomm_fastrtps.pri ) {
+    error( "Couldn't find the modulecomm_fastrtps.pri file!" )
+}
+}
+
+
+INCLUDEPATH += $$PWD/shm
+INCLUDEPATH += $$PWD/fastrtps
+INCLUDEPATH += $$PWD/inter
+
+
+if(contains(DEFINES,USE_FASTRTPS)){
+LIBS += -L$$PWD -lfastcdr -lfastrtps
+}
 

+ 4 - 0
src/common/modulecomm/modulecomm.xml

@@ -0,0 +1,4 @@
+<xml>	
+	<commtype value="0" />
+</xml>
+

+ 11 - 0
src/common/modulecomm/modulecomm_base.cpp

@@ -0,0 +1,11 @@
+#include "modulecomm_base.h"
+
+
+namespace  iv {
+
+modulecomm_base::modulecomm_base()
+{
+
+}
+
+}

+ 33 - 0
src/common/modulecomm/modulecomm_base.h

@@ -0,0 +1,33 @@
+#ifndef MODULECOMM_BASE_H
+#define MODULECOMM_BASE_H
+
+
+#include <QDateTime>
+
+#include <functional>
+
+#ifndef IV_MODULE_FUN
+
+typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
+typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+#define IV_MODULE_FUN
+#endif
+
+namespace  iv {
+
+
+class modulecomm_base
+{
+public:
+    modulecomm_base();
+
+public:
+    virtual void ModuleSendMsg(const char * strdata,const unsigned int nDataLen) = 0;
+    virtual void Unregister() = 0;
+    virtual void PauseComm() = 0;
+    virtual void ContintuComm() = 0;
+};
+
+}
+
+#endif // MODULECOMM_BASE_H

+ 9 - 0
src/common/modulecomm/modulecommext.cpp

@@ -0,0 +1,9 @@
+
+#include "modulecommext.h"
+
+namespace iv {
+namespace modulecommext {
+
+
+}
+}

+ 208 - 0
src/common/modulecomm/modulecommext.h

@@ -0,0 +1,208 @@
+#ifndef MODULECOMMEXT_H
+#define MODULECOMMEXT_H
+
+#include <QtCore/qglobal.h>
+#include <QDateTime>
+
+#include <functional>
+
+
+#include "modulecomm.h"
+
+#if defined(MODULECOMMEXT_LIBRARY)
+#  define MODULECOMMEXTSHARED_EXPORT Q_DECL_EXPORT
+#else
+#  define MODULECOMMEXTSHARED_EXPORT Q_DECL_IMPORT
+#endif
+
+
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/generated_message_reflection.h>
+#include <google/protobuf/reflection_ops.h>
+#include <google/protobuf/wire_format.h>
+
+
+
+#ifndef IV_MODULEEXT_FUN
+
+typedef std::function<void(google::protobuf::Message & xmsg)> ModuleExtFun;
+typedef void (* SMExtCallBack)(google::protobuf::Message & xmsg);
+#define IV_MODULEEXT_FUN
+#endif
+
+namespace iv {
+namespace modulecommext {
+
+
+template<class T>
+class modulecommmsg
+{
+private:
+    T mMessage;
+    void * mphandle = NULL;
+    ModuleExtFun mFun;
+    SMExtCallBack mpCall;
+    bool mbCallPlus = false;
+    int mnType = 0; //0:Not Init  1:Send   2:Recv
+    void UpdateMsg(const char *strdata,
+                                         const unsigned int nSize, const unsigned int index, const QDateTime *dt,
+                                         const char *strmemname);
+public:
+    modulecommmsg();
+    ~modulecommmsg();
+
+    void RegisterSend(const char * strcommname);
+
+    void RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount
+                                                ,iv::modulecomm::ModuleComm_TYPE xmctype = iv::modulecomm::ModuleComm_UNDEFINE,const unsigned short nport = 5100);
+    void RegisterRecv(const char * strcommname,SMExtCallBack pCall,
+                                                iv::modulecomm::ModuleComm_TYPE xmctype =iv::modulecomm:: ModuleComm_UNDEFINE,const char * strip = 0,const unsigned short = 5100);
+    void RegisterRecvPlus(const char * strcommname,ModuleExtFun xFun,
+                                                    iv::modulecomm::ModuleComm_TYPE xmctype = iv::modulecomm::ModuleComm_UNDEFINE,const char * strip = 0,const unsigned short = 5100);
+
+    void ModuleSendMsg(google::protobuf::Message & xmsg);
+    void Unregister();
+    void PauseComm();
+    void ContintuComm();
+};
+
+template<class T>
+modulecommmsg<T>::modulecommmsg()
+{
+
+}
+
+template<class T>
+modulecommmsg<T>::~modulecommmsg()
+{
+    if(mphandle != NULL)
+    {
+        Unregister();
+    }
+}
+
+template<class T>
+void modulecommmsg<T>::UpdateMsg(const char *strdata,
+                                 const unsigned int nSize, const unsigned int index, const QDateTime *dt,
+                                 const char *strmemname)
+{
+    (void)&index;
+    (void)dt;
+    (void)strmemname;
+    T xmsg;
+    google::protobuf::Message * pmsg = (google::protobuf::Message *)&xmsg;
+    bool bParse = pmsg->ParseFromArray(strdata,nSize);
+    if(bParse == false)
+    {
+        qDebug("modulecommext<T>::UpdateMsg Parse Fail.");
+        return;
+    }
+    if(mbCallPlus)
+        mFun(*pmsg);
+    else
+        (*mpCall)(*pmsg);
+
+}
+
+
+
+template<class T>
+void modulecommmsg<T>::RegisterSend(const char * strcommname)
+{
+    mphandle = iv::modulecomm::RegisterSend(strcommname);
+    mnType = 1;
+}
+
+template<class T>
+void modulecommmsg<T>::RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount
+                                            ,iv::modulecomm::ModuleComm_TYPE xmctype ,const unsigned short nport)
+{
+    mphandle = iv::modulecomm::RegisterSend(strcommname,nBufSize,nMsgBufCount,xmctype,nport);
+    mnType = 1;
+}
+
+template<class T>
+void modulecommmsg<T>::RegisterRecv(const char * strcommname,SMExtCallBack pCall,
+                                            iv::modulecomm::ModuleComm_TYPE xmctype,const char * strip,const unsigned short nport)
+{
+    mpCall = pCall;
+    mbCallPlus = false;
+    ModuleFun funext = std::bind(&modulecommmsg::UpdateMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mphandle = iv::modulecomm::RegisterRecvPlus(strcommname,funext,xmctype,strip,nport);
+    mnType = 2;
+}
+
+template<class T>
+void modulecommmsg<T>::RegisterRecvPlus(const char * strcommname,ModuleExtFun xFun,
+                                                iv::modulecomm::ModuleComm_TYPE xmctype ,const char * strip ,const unsigned short nport)
+{
+    mFun = xFun;
+    mbCallPlus = true;
+    ModuleFun funext = std::bind(&modulecommmsg::UpdateMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mphandle = iv::modulecomm::RegisterRecvPlus(strcommname,funext,xmctype,strip,nport);
+    mnType = 2;
+}
+
+template<class T>
+void modulecommmsg<T>::ModuleSendMsg(google::protobuf::Message & xmsg)
+{
+    if((mnType != 1)||(mphandle == NULL))
+    {
+        qDebug("This Handle is not send. type : %d ",mnType);
+        return;
+    }
+    int ndatasize = xmsg.ByteSize();
+    std::shared_ptr<char> str_ptr= std::shared_ptr<char>(new char[ndatasize]);
+    bool bSer = xmsg.SerializeToArray(str_ptr.get(),ndatasize);
+    if(bSer == false)
+    {
+        qDebug("modulecommext<T>::ModuleSendMsg serialize fail.");
+        return;
+    }
+    iv::modulecomm::ModuleSendMsg(mphandle,str_ptr.get(),ndatasize);
+
+}
+
+template<class T>
+void modulecommmsg<T>::Unregister()
+{
+    if((mnType == 0)||(mphandle == NULL))
+    {
+        return;
+    }
+    iv::modulecomm::Unregister(mphandle);
+    mphandle = NULL;
+}
+
+template<class T>
+void modulecommmsg<T>::PauseComm()
+{
+    if((mnType == 0)||(mphandle == NULL))
+    {
+        qDebug("modulecommext<T>::PauseComm handle not init.");
+        return;
+    }
+    iv::modulecomm::PauseComm(mphandle);
+}
+
+template<class T>
+void modulecommmsg<T>::ContintuComm()
+{
+    if((mnType == 0)||(mphandle == NULL))
+    {
+        qDebug("modulecommext<T>::PauseComm handle not init.");
+        return;
+    }
+    iv::modulecomm::ContintuComm(mphandle);
+}
+
+
+
+}
+}
+#endif // MODULECOMMEXT_H

+ 54 - 0
src/common/modulecomm/shm/b/modulecomm_shm.cpp

@@ -0,0 +1,54 @@
+#include "modulecomm_shm.h"
+#include "procsm_if.h"
+#include "procsm.h"
+#include <iostream>
+
+namespace iv {
+namespace modulecomm_shm {
+
+void *  RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount)
+{
+
+    procsm_if * pif = new procsm_if(strcommname,nBufSize,nMsgBufCount,procsm::ModeWrite);
+    return (void *)pif;
+}
+
+void  *  RegisterRecv(const char * strcommname,SMCallBack pCall)
+{
+    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(pCall);
+    return (void *)pif;
+}
+
+void * MODULECOMMSHARED_SHM_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun)
+{
+    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(xFun);
+    return (void *)pif;
+}
+void  ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    pif->writemsg(strdata,nDataLen);
+}
+
+void  Unregister(void * pHandle)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    delete pif;
+}
+
+void PauseComm(void *pHandle)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    pif->pausecomm();
+}
+
+void ContintuComm(void *pHandle)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    pif->continuecomm();
+}
+
+}
+}

+ 42 - 0
src/common/modulecomm/shm/b/modulecomm_shm.h

@@ -0,0 +1,42 @@
+#ifndef MODULECOMM_SHM_H
+#define MODULECOMM_SHM_H
+
+#include <QtCore/qglobal.h>
+#include <QDateTime>
+
+#include <functional>
+
+#if defined(MODULECOMM_SHM_LIBRARY)
+#  define MODULECOMMSHARED_SHM_EXPORT Q_DECL_EXPORT
+#else
+#  define MODULECOMMSHARED_SHM_EXPORT Q_DECL_IMPORT
+#endif
+
+
+
+//#include <iostream>
+//#include <thread>
+
+#ifndef IV_MODULE_FUN
+
+typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
+typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+#define IV_MODULE_FUN
+#endif
+namespace iv {
+namespace modulecomm_shm {
+void * MODULECOMMSHARED_SHM_EXPORT RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount);
+void * MODULECOMMSHARED_SHM_EXPORT RegisterRecv(const char * strcommname,SMCallBack pCall);
+void * MODULECOMMSHARED_SHM_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun);
+void MODULECOMMSHARED_SHM_EXPORT ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen);
+void MODULECOMMSHARED_SHM_EXPORT Unregister(void * pHandle);
+void MODULECOMMSHARED_SHM_EXPORT PauseComm(void * pHandle);
+void MODULECOMMSHARED_SHM_EXPORT ContintuComm(void * pHandle);
+
+}
+
+}
+
+
+
+#endif 

+ 61 - 0
src/common/modulecomm/shm/modulecomm_shm.cpp

@@ -0,0 +1,61 @@
+#include "modulecomm_shm.h"
+
+#include "procsm_if.h"
+#include "procsm.h"
+#include <iostream>
+
+namespace iv {
+
+
+modulecomm_shm::modulecomm_shm()
+{
+
+
+}
+
+void modulecomm_shm::RegisterSend(const char *strcommname, const unsigned int nBufSize, const unsigned int nMsgBufCount)
+{
+    procsm_if * pif = new procsm_if(strcommname,nBufSize,nMsgBufCount,procsm::ModeWrite);
+    mpif = pif;
+}
+
+void modulecomm_shm::RegisterRecv(const char *strcommname, SMCallBack pCall)
+{
+    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(pCall);
+    mpif = pif;
+}
+
+void modulecomm_shm::RegisterRecvPlus(const char *strcommname, ModuleFun xFun)
+{
+    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(xFun);
+    mpif = (void *)pif;
+}
+
+void modulecomm_shm::ModuleSendMsg(const char *strdata, const unsigned int nDataLen)
+{
+    procsm_if * pif = (procsm_if *)mpif;
+    pif->writemsg(strdata,nDataLen);
+}
+
+void modulecomm_shm::PauseComm()
+{
+    procsm_if * pif = (procsm_if *)mpif;
+    pif->pausecomm();
+}
+
+void modulecomm_shm::ContintuComm()
+{
+    procsm_if * pif = (procsm_if *)mpif;
+    pif->continuecomm();
+}
+
+void modulecomm_shm::Unregister()
+{
+    procsm_if * pif = (procsm_if *)mpif;
+    delete pif;
+    mpif =0;
+}
+
+}

+ 28 - 0
src/common/modulecomm/shm/modulecomm_shm.h

@@ -0,0 +1,28 @@
+#ifndef MODULECOMM_SHM_H
+#define MODULECOMM_SHM_H
+
+#include "modulecomm_base.h"
+
+namespace iv {
+
+
+class modulecomm_shm : public modulecomm_base
+{
+public:
+    modulecomm_shm();
+
+    void RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount);
+    void RegisterRecv(const char * strcommname,SMCallBack pCall);
+    void RegisterRecvPlus(const char * strcommname,ModuleFun xFun);
+    virtual void ModuleSendMsg(const char * strdata,const unsigned int nDataLen);
+    virtual void Unregister();
+    virtual void PauseComm();
+    virtual void ContintuComm();
+
+private :
+    void * mpif = 0;
+};
+
+}
+
+#endif // MODULECOMM_SHM_H

+ 9 - 0
src/common/modulecomm/shm/modulecomm_shm.pri

@@ -0,0 +1,9 @@
+HEADERS += \
+    $$PWD/modulecomm_shm.h \
+    $$PWD/procsm.h \
+    $$PWD/procsm_if.h
+
+SOURCES += \
+    $$PWD/modulecomm_shm.cpp \
+    $$PWD/procsm.cpp \
+    $$PWD/procsm_if.cpp

+ 572 - 0
src/common/modulecomm/shm/procsm.cpp

@@ -0,0 +1,572 @@
+#include <iostream>
+#include <thread>
+#include <QTime>
+#include <QThread>
+#include <algorithm>
+#include "procsm.h"
+
+
+class AttachThread : public QThread
+{
+  public:
+    AttachThread(QSharedMemory * pa,bool & bAttach)
+    {
+       mbAttach = bAttach;
+       mpa = pa;
+       mbrun = true;
+    }
+    QSharedMemory * mpa;
+    bool mbAttach = false;
+    bool mbrun = true;
+    void run()
+    {
+        mbAttach = mpa->attach();
+        mbrun = false;
+    }
+};
+
+procsm::procsm(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode)
+{
+//    mnBufSize = nBufSize;
+
+//    qDebug("create dbus");
+
+    strncpy(mstrsmname,strsmname,256);
+
+    mpASMPtr = new QSharedMemory(strsmname);
+
+
+    char strasmname[256];
+
+    if(nMode == ModeWrite)
+    {
+        bool bres = mpASMPtr->attach();
+        if(bres == false)
+        {
+            mpASMPtr->create(sizeof(ASM_PTR));
+            ASM_PTR * pasm = (ASM_PTR *)mpASMPtr->data();
+            snprintf(strasmname,256,"%s_%lld",strsmname,QDateTime::currentMSecsSinceEpoch());
+            pasm->mnshmsize = sizeof(procsm_info)+nMaxPacCount*sizeof(procsm_head) + nBufSize;
+            pasm->mnUpdateTime = QDateTime::currentMSecsSinceEpoch();
+            strncpy(pasm->mstrshmname,strasmname,256);
+            mASM_State = *pasm;
+        }
+        else
+        {
+            ASM_PTR * pasm = (ASM_PTR *)mpASMPtr->data();
+            mASM_State = *pasm;
+        }
+    }
+    else
+    {
+        return;
+    }
+
+//    mpASM = new QSharedMemory(strsmname);
+    mpASM = new QSharedMemory(strasmname);
+
+    if(nMode == ModeWrite)
+    {
+
+        mmodulemsg_type.mnBufSize = nBufSize;
+        mmodulemsg_type.mnMsgBufCount = nMaxPacCount;
+        strncpy(mmodulemsg_type.mstrmsgname,strasmname,255);
+#ifdef USEDBUS
+        mmsg = QDBusMessage::createSignal("/catarc/adc",  "adc.adciv.modulecomm", strsmname);
+        mmsg<<1;
+#endif
+
+        bool bAttach = false;
+        AttachThread AT(mpASM,bAttach);
+        AT.start();
+        QTime xTime;
+        xTime.start();
+        while(xTime.elapsed()<100)
+        {
+            if(AT.mbrun == false)
+            {
+                bAttach = AT.mbAttach;
+                break;
+            }
+        }
+ //       qDebug("time is %d",xTime.elapsed());
+        if(xTime.elapsed()>= 1000)
+        {
+            qDebug("in 1000ms Attach fail.terminate it .");
+            AT.terminate();
+            bAttach = false;
+        }
+
+ //       if(!mpASM->attach())
+        if(!bAttach)
+        {
+
+            mpASM->create(sizeof(procsm_info)+nMaxPacCount*sizeof(procsm_head) + nBufSize);
+            char * p = (char *)mpASM->data();
+            mpinfo = (procsm_info *)p;
+            mphead = (procsm_head *)(p+sizeof(procsm_info));
+            mpinfo->mCap = nMaxPacCount;
+            mpinfo->mnBufSize = nBufSize;
+            mpinfo->mFirst = 0;
+            mpinfo->mNext = 0;
+            mpinfo->mLock = 0;
+        }
+
+
+
+
+        if(mpASM->isAttached())
+        {
+
+            mbAttach = true;
+            char * p = (char *)mpASM->data();
+            mpinfo = (procsm_info *)p;
+            mphead = (procsm_head *)(p+sizeof(procsm_info));
+            mnMaxPacCount = mpinfo->mCap;
+            mnBufSize = mpinfo->mnBufSize;
+    //        qDebug("attach successful");
+            mstrtem = new char[mnBufSize];
+
+#ifdef USEDBUS
+            mmsgres = QDBusMessage::createSignal("/catarc/adc",  "adciv.interface", "modulemsgres");
+            mmsgres<<1;
+
+            bool bconnect = QDBusConnection::sessionBus().connect(QString(),"/catarc/adc",  "adciv.interface", "modulemsgquery",this,SLOT(onQuery()));
+            if(bconnect == false)
+            {
+                std::cout<<"procsm_if_readthread::procsm_if_readthread bconect is false"<<std::endl;
+            }
+#endif
+        }
+        else
+        {
+          mbAttach = false;
+            qDebug("Share Memory Error.");
+        }
+
+
+    }
+}
+
+void procsm::recreateasm(int nbufsize)
+{
+
+    mpASMPtr->lock();
+    qDebug("recreate asms");
+
+
+    mnBufSize = std::max(nbufsize*11/10,nbufsize+1000);
+ //   mnBufSize = nbufsize+100;
+    char strasmname[256];
+    ASM_PTR * pasm = (ASM_PTR *)mpASMPtr->data();
+    snprintf(strasmname,256,"%s_%lld",mstrsmname,QDateTime::currentMSecsSinceEpoch());
+    pasm->mnshmsize = sizeof(procsm_info)+mnMaxPacCount*sizeof(procsm_head) + mnBufSize;
+    pasm->mnUpdateTime = QDateTime::currentMSecsSinceEpoch();
+    strncpy(pasm->mstrshmname,strasmname,256);
+    mASM_State = *pasm;
+
+    mmodulemsg_type.mnBufSize = mnBufSize;
+    mmodulemsg_type.mnMsgBufCount = mnMaxPacCount;
+    strncpy(mmodulemsg_type.mstrmsgname,mASM_State.mstrshmname,255);
+
+    mpASM->lock();
+    int noldmemsize = mpASM->size();
+    char * px = new char[mpASM->size()];
+    memcpy(px,mpASM->data(),noldmemsize);
+    mpASM->unlock();
+    mpASM->detach();
+
+    qDebug("new asm name is %s,buffer size is %d ",mASM_State.mstrshmname,mnBufSize);
+    mpASM = new QSharedMemory(mASM_State.mstrshmname);
+
+    bool bAttach = false;
+    AttachThread AT(mpASM,bAttach);
+    AT.start();
+    QTime xTime;
+    xTime.start();
+    while(xTime.elapsed()<100)
+    {
+        if(AT.mbrun == false)
+        {
+            bAttach = AT.mbAttach;
+            break;
+        }
+    }
+    //       qDebug("time is %d",xTime.elapsed());
+    if(xTime.elapsed()>= 1000)
+    {
+        qDebug("in 1000ms Attach fail.terminate it .");
+        AT.terminate();
+        bAttach = false;
+    }
+
+    //       if(!mpASM->attach())
+    if(!bAttach)
+    {
+
+        mpASM->create(sizeof(procsm_info)+mnMaxPacCount*sizeof(procsm_head) + mnBufSize);
+        memcpy(mpASM->data(),px,noldmemsize);
+        char * p = (char *)mpASM->data();
+        mpinfo = (procsm_info *)p;
+        mphead = (procsm_head *)(p+sizeof(procsm_info));
+        mpinfo->mCap = mnMaxPacCount;
+        mpinfo->mnBufSize = mnBufSize;
+//        mpinfo->mFirst = nfirst;
+//        mpinfo->mNext = nnext;
+//        mpinfo->mLock = 0;
+    }
+
+
+
+
+    if(mpASM->isAttached())
+    {
+
+        mbAttach = true;
+        char * p = (char *)mpASM->data();
+        mpinfo = (procsm_info *)p;
+        mphead = (procsm_head *)(p+sizeof(procsm_info));
+        mnMaxPacCount = mpinfo->mCap;
+        mnBufSize = mpinfo->mnBufSize;
+        //        qDebug("attach successful");
+ //       mstrtem = new char[mnBufSize];
+    }
+    else
+    {
+        mbAttach = false;
+        qDebug("Share Memory Error.");
+    }
+
+    mpASMPtr->unlock();
+
+    delete px;
+
+
+
+
+}
+
+#ifdef USEDBUS
+    void procsm::onQuery()
+    {
+        QByteArray ba;
+        ba.append((char *)&mmodulemsg_type,sizeof(iv::modulemsg_type));
+
+        QList<QVariant> x;
+        x<<ba;
+        mmsgres.setArguments(x);
+        QDBusConnection::sessionBus().send(mmsgres);
+    }
+
+#endif
+
+bool procsm::AttachMem()
+{
+
+    if(!mpASMPtr->isAttached())mpASMPtr->attach();
+    if(mpASMPtr->isAttached())
+    {
+        ASM_PTR * pasmptr = (ASM_PTR *)(mpASMPtr->data());
+        mASM_State = * pasmptr;
+
+        if(mpASM != 0)
+        {
+            if(mpASM->isAttached())mpASM->detach();
+            delete mpASM;
+        }
+        mpASM = new QSharedMemory(mASM_State.mstrshmname);
+
+        mpASM->attach();
+        if(mpASM->isAttached())
+        {
+            mbAttach = true;
+            char * p = (char *)mpASM->data();
+            mpinfo = (procsm_info *)p;
+            mphead = (procsm_head *)(p+sizeof(procsm_info));
+            mnMaxPacCount = mpinfo->mCap;
+            mnBufSize = mpinfo->mnBufSize;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    else
+    {
+        return false;
+    }
+
+    return false;
+    mpASM->attach();
+    if(mpASM->isAttached())
+    {
+        mbAttach = true;
+        char * p = (char *)mpASM->data();
+        mpinfo = (procsm_info *)p;
+        mphead = (procsm_head *)(p+sizeof(procsm_info));
+        mnMaxPacCount = mpinfo->mCap;
+        mnBufSize = mpinfo->mnBufSize;
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+int procsm::MoveMem(const unsigned int nSize)
+{
+//    qDebug("move mem");
+     unsigned int nRemove = nSize;
+     if(nRemove == 0)return -1;
+
+//     unsigned int * pIndexFirst = (unsigned int *)mpASM->data();
+//     unsigned int * pIndexNext = pIndexFirst+1;
+//     qDebug("first = %d next = %d",*pIndexFirst,*pIndexNext);
+//    unsigned int * pIndexNext = pIndexFirst;
+    char * pH,*pD;
+    pH = (char *)mpASM->data();pH = pH + sizeof(procsm_info);
+    pD = (char *)mpASM->data();pD = pD + sizeof(procsm_info) + mnMaxPacCount * sizeof(procsm_head);
+    procsm_head * phh = (procsm_head *)pH;
+    unsigned int nPac = mpinfo->mNext - mpinfo->mFirst;
+
+    if(nRemove >nPac)
+    {
+  //      qDebug("procsm::MoveMem nRemove > nPac nRemove = %d",nRemove);
+        nRemove = nPac;
+    }
+
+    if(nRemove == nPac)
+    {
+        mpinfo->mFirst = mpinfo->mFirst + (unsigned int)nRemove;
+        return 0;
+    }
+
+    unsigned int i;
+    int nDataMove = 0;
+    for(i=0;i<nRemove;i++)
+    {
+        procsm_head * phd = phh+i;
+        nDataMove = nDataMove + phd->mnLen;
+    }
+    unsigned int nDataTotal;
+    for(i=0;i<(nPac - nRemove);i++)
+    {
+        memcpy(phh+i,phh+i+nRemove,sizeof(procsm_head));
+        (phh+i)->mnPos = (phh+i)->mnPos - nDataMove;
+    }
+    nDataTotal = (phh + nPac-nRemove-1)->mnPos + (phh+nPac-nRemove-1)->mnLen;
+    memcpy(mstrtem,pD+nDataMove,nDataTotal);
+    memcpy(pD,mstrtem,nDataTotal);
+
+//    for(i=0;i<nDataTotal;i++)
+//    {
+//        *(pD+i) = *(pD+i+nDataMove);
+//    }
+    mpinfo->mFirst = mpinfo->mFirst + (unsigned int)nRemove;
+    return 0;
+}
+
+
+void procsm::checkasm()
+{
+
+    mpASMPtr->lock();
+    ASM_PTR * pASM_PTR = (ASM_PTR * )mpASMPtr->data();
+    if(pASM_PTR->mnUpdateTime == mASM_State.mnUpdateTime)
+    {
+
+        mpASMPtr->unlock();
+        return;
+    }
+    qDebug("reattch mem.");
+    mbAttach = false;
+    AttachMem();
+    mpASMPtr->unlock();
+}
+
+int procsm::writemsg(const char *str, const unsigned int nSize)
+{
+    checkasm();
+    if(nSize > mnBufSize)
+    {
+        if(nSize<1000000000)
+        {
+            recreateasm(nSize);
+            checkasm();
+        }
+        else
+        {
+        qDebug("procsm::writemsg message size is very big");
+        return -1;
+        }
+    }
+    if(mbAttach == false)
+    {
+        std::cout<<"ShareMemory Attach fail."<<std::endl;
+        return -1;
+    }
+    mpASM->lock();
+
+
+
+//    unsigned int * pIndexFirst = (unsigned int *)mpASM->data();
+//    unsigned int * pIndexNext = pIndexFirst+1;
+    if(mpinfo->mLock == 1)
+    {
+        std::cout<<"ShareMemory have lock.Init."<<std::endl;
+        mpinfo->mLock = 0;
+        mpinfo->mFirst = 0;
+        mpinfo->mNext = 0;
+    }
+    mpinfo->mLock =1;
+WRITEMSG:
+    char * pH,*pD;
+    QDateTime dt;
+    pH = (char *)mpASM->data();pH = pH + sizeof(procsm_info);
+    pD = (char *)mpASM->data();pD = pD + sizeof(procsm_info) + mnMaxPacCount * sizeof(procsm_head);
+    procsm_head * phh = (procsm_head *)pH;
+    unsigned int nPac = mpinfo->mNext - mpinfo->mFirst;
+    if(nPac>=mnMaxPacCount)
+    {
+        unsigned int nRemove = mnMaxPacCount/3;
+        if(nRemove == 0)nRemove = 1;
+        MoveMem(nRemove);
+        goto WRITEMSG;
+    }
+    if(nPac == 0)
+    {
+        memcpy(pD,str,nSize);
+        dt = QDateTime::currentDateTime();
+    //    phh->mdt = dt;
+        phh->SetDate(dt);
+   //     memcpy(&phh->mdt,&dt,sizeof(QDateTime));
+   //     phh->mdt = QDateTime::currentDateTime();
+        phh->mindex = mpinfo->mNext;
+        phh->mnPos = 0;
+        phh->mnLen = nSize;
+        mpinfo->mNext = mpinfo->mNext+1;
+    }
+    else
+    {
+        if(((phh+nPac-1)->mnPos+(phh+nPac-1)->mnLen + nSize)>=mnBufSize)
+        {
+            unsigned int nRemove = mnMaxPacCount/2;
+            if(nRemove == 0)nRemove = 1;
+            MoveMem(nRemove);
+            goto WRITEMSG;
+        }
+        else
+        {
+            unsigned int nPos = (phh+nPac-1)->mnPos + (phh+nPac-1)->mnLen;
+     //       qDebug("write pos = %d",nPos);
+            memcpy(pD+nPos,str,nSize);
+            dt = QDateTime::currentDateTime();
+            (phh+nPac)->SetDate(dt);
+ //           memcpy(&(phh+nPac)->mdt,&dt,sizeof(QDateTime));
+ //           (phh+nPac)->mdt = QDateTime::currentDateTime();
+            (phh+nPac)->mindex = mpinfo->mNext;
+            (phh+nPac)->mnPos = nPos;
+            (phh+nPac)->mnLen = nSize;
+            mpinfo->mNext = mpinfo->mNext+1;
+        }
+    }
+
+    const unsigned int nTM = 0x6fffffff;
+    if((mpinfo->mNext >nTM)&&(mpinfo->mFirst>nTM))
+    {
+       nPac = mpinfo->mNext - mpinfo->mFirst;
+       unsigned int i;
+       for(i=0;i<nPac;i++)
+       {
+           (phh+i)->mindex = (phh+i)->mindex-nTM;
+       }
+       mpinfo->mFirst = mpinfo->mFirst-nTM;
+       mpinfo->mNext = mpinfo->mNext - nTM;
+    }
+
+    mpinfo->mLock = 0;
+    mpASM->unlock();
+#ifdef USEDBUS
+    QDBusConnection::sessionBus().send(mmsg);
+#endif
+    return 0;
+}
+
+unsigned int procsm::getcurrentnext()
+{
+
+    checkasm();
+    unsigned int nNext;
+    mpASM->lock();
+    nNext = mpinfo->mNext;
+    mpASM->unlock();
+    return nNext;
+}
+
+
+//if return 0 No Data.
+//if return -1 nMaxSize is small
+//if retrun -2 index is not in range,call getcurrentnext get position
+//if return > 0 readdata
+int procsm::readmsg(unsigned int index, char *str, unsigned int nMaxSize,unsigned int * nRead,QDateTime * pdt)
+{
+    checkasm();
+    if(mbAttach == false)
+    {
+        std::cout<<"ShareMemory Attach fail."<<std::endl;
+        return -1;
+    }    
+    int nRtn = 0;
+    mpASM->lock();
+
+    if((index< mpinfo->mFirst)||(index > mpinfo->mNext))
+    {
+        nRtn = -2;
+    }
+    if(nRtn != (-2))
+    {
+        if(index == mpinfo->mNext)
+        {
+            nRtn = 0;
+        }
+        else
+        {
+            char * pH,*pD;
+ //           pH = (char *)mpASM->data();pH = pH + 2*sizeof(unsigned int);
+
+ //           pD = (char *)mpASM->data();pD = pD + 2*sizeof(unsigned int) + mnMaxPacCount * sizeof(procsm_head);
+            pD = (char *)mpASM->data();pD = pD+ sizeof(procsm_info) + mpinfo->mCap*sizeof(procsm_head);
+            pH = (char *)mpASM->data();pH = pH+sizeof(procsm_info);
+            procsm_head * phh = (procsm_head *)pH;
+            unsigned int nPac = mpinfo->mNext - mpinfo->mFirst;
+            if(nPac == 0)
+            {
+                nRtn = 0;
+            }
+            else
+            {
+                unsigned int nPos = index - mpinfo->mFirst;
+                *nRead = (phh+nPos)->mnLen;
+                if((phh+nPos)->mnLen > nMaxSize)
+                {
+                    nRtn = -1;
+
+                }
+                else
+                {
+        //            qDebug("read pos = %d",(phh+nPos)->mnPos);
+                   memcpy(str,pD + (phh+nPos)->mnPos,(phh+nPos)->mnLen);
+          //         qDebug("read pos = %d",(phh+nPos)->mnPos);
+                   nRtn = (phh+nPos)->mnLen;
+                   (phh+nPos)->GetDate(pdt);
+           //        memcpy(pdt,&((phh+nPos)->mdt),sizeof(QDateTime));
+                }
+            }
+        }
+    }
+    mpASM->unlock();
+    return nRtn;
+}
+

+ 131 - 0
src/common/modulecomm/shm/procsm.h

@@ -0,0 +1,131 @@
+#ifndef PROCSM_H
+#define PROCSM_H
+
+#include <QThread>
+#include <QSharedMemory>
+#include <QDateTime>
+#include <QList>
+#include <QVariant>
+
+#ifdef USEDBUS
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusConnection>
+
+#endif
+
+#include "ivmodulemsg_type.h"
+
+
+class ASM_PTR
+{
+public:
+    qint64 mnUpdateTime;
+    char mstrshmname[256];
+    unsigned int mnshmsize;
+    char mstrreserve[1000];
+};
+
+class procsm_info
+{
+public:
+  unsigned int mFirst;
+  unsigned int mNext;
+  unsigned int mCap;
+  unsigned int mLock;
+  unsigned int mnBufSize;
+};
+
+class procsm_head
+{
+public:
+    unsigned short mYear;
+    unsigned char mMonth;
+    unsigned char mDay;
+    unsigned char mHour;
+    unsigned char mMinute;
+    unsigned char mSec;
+    unsigned short mMSec;
+    unsigned int mindex;
+    unsigned int mnPos;
+    unsigned int mnLen;
+public:
+    void SetDate(QDateTime dt)
+    {
+        mYear = dt.date().year();
+        mMonth = dt.date().month();
+        mDay = dt.date().day();
+        mHour = dt.time().hour();
+        mMinute = dt.time().minute();
+        mSec = dt.time().second();
+        mMSec = dt.time().msec();
+    }
+    void GetDate(QDateTime * pdt)
+    {
+        QDate dt;
+        dt.setDate(mYear,mMonth,mDay);
+        QTime time;
+        time.setHMS(mHour,mMinute,mSec,mMSec);
+        pdt->setDate(dt);
+        pdt->setTime(time);
+
+    }
+};
+
+class procsm : public QObject
+{
+#ifdef USEDBUS
+    Q_OBJECT
+
+#endif
+public:
+    procsm(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode);
+    int writemsg(const char * str,const unsigned int nSize);
+    unsigned int getcurrentnext();
+    int readmsg(unsigned int index,char * str,unsigned int nMaxSize,unsigned int * nRead,QDateTime * pdt);
+
+    bool AttachMem();
+
+private:
+    int MoveMem(const unsigned int nSize);
+    QSharedMemory * mpASM = 0;
+    QSharedMemory * mpASMPtr;
+    unsigned int mnBufSize;
+    unsigned int mnMaxPacCount;
+    procsm_info * mpinfo;
+    procsm_head * mphead;
+
+    ASM_PTR mASM_State;
+    bool mbAttach;
+
+    char * mstrtem;
+
+public:
+    const static int ModeRead = 1;
+    const static int ModeWrite = 0;
+
+    iv::modulemsg_type mmodulemsg_type;
+
+#ifdef USEDBUS
+private slots:
+    void onQuery();
+
+#endif
+private:
+#ifdef USEDBUS
+    QDBusMessage mmsg;
+    QDBusMessage mmsgres;  //Response Message Query;
+
+#endif
+
+private:
+    void checkasm();
+    void recreateasm(int nbufsize);
+
+private:
+    char mstrsmname[256];
+
+
+
+};
+
+#endif // PROCSM_H

+ 310 - 0
src/common/modulecomm/shm/procsm_if.cpp

@@ -0,0 +1,310 @@
+#include "procsm_if.h"
+#include <QTimer>
+
+#include <iostream>
+
+
+
+procsm_if_readthread::procsm_if_readthread(procsm *pPSM,SMCallBack pCall,const char * strsmname)
+{
+    mpPSM = pPSM;
+    mpCall = pCall;
+    strncpy(mstrsmname,strsmname,255);
+
+#ifdef USEDBUS
+    bool bconnect = QDBusConnection::sessionBus().connect(QString(),"/catarc/adc",  "adc.adciv.modulecomm", strsmname,this,SLOT(onNewMsg(int)));
+    if(bconnect == false)
+    {
+        std::cout<<"procsm_if_readthread::procsm_if_readthread bconect is false"<<std::endl;
+    }
+#endif
+}
+
+procsm_if_readthread::procsm_if_readthread(procsm *pPSM,ModuleFun xFun,const char * strsmname)
+{
+    mpPSM = pPSM;
+    mFun = xFun;
+    strncpy(mstrsmname,strsmname,255);
+    mbFunPlus = true;
+
+#ifdef USEDBUS
+    bool bconnect = QDBusConnection::sessionBus().connect(QString(),"/catarc/adc",  "adc.adciv.modulecomm", strsmname,this,SLOT(onNewMsg(int)));
+    if(bconnect == false)
+    {
+        std::cout<<"procsm_if_readthread::procsm_if_readthread bconect is false"<<std::endl;
+        mbDBUSOK = false;
+        QTimer * timer = new QTimer();
+        timer->setTimerType(Qt::PreciseTimer);
+        delete timer;
+    }
+#endif
+}
+
+
+#ifdef USELCM
+    void procsm_if_readthread::handlerMethod(const lcm::ReceiveBuffer *rbuf, const std::string &channel)
+    {
+        qDebug("lcm receiv data. ");
+        mxindex++;
+        QDateTime dt = QDateTime::currentDateTime();
+        if(mbFunPlus)
+        {
+            mFun((char *)rbuf->data,rbuf->data_size,mxindex,&dt,mstrsmname);
+        }
+        else
+        {
+           (*mpCall)((char *)rbuf->data,rbuf->data_size,mxindex,&dt,mstrsmname);
+        }
+    }
+#endif
+
+
+void procsm_if_readthread::puaseread()
+{
+    mbRun = false;
+}
+
+void procsm_if_readthread::continueread()
+{
+    mbRun = true;
+}
+
+void procsm_if_readthread::run()
+{
+#ifdef USELCM
+    mlcm.subscribe(mstrsmname,&procsm_if_readthread::handlerMethod,this);
+    while(!QThread::isInterruptionRequested())
+    {
+        mlcm.handle();
+    }
+    return;
+#endif
+    QTime xTime;
+    xTime.start();
+    unsigned int nBufLen = 1;
+    unsigned int nRead;
+    char * str = new char[nBufLen];
+    unsigned int index =0;
+
+
+    QDateTime *pdt = new QDateTime();
+
+    bool bAttach = false;
+    while(!QThread::isInterruptionRequested())
+    {
+        if(mbRun == false)
+        {
+            msleep(10);
+            continue;
+        }
+        if(bAttach == false)
+        {
+            bAttach = mpPSM->AttachMem();
+            if(bAttach == false)
+            {
+                msleep(100);
+                continue;
+            }
+            else
+            {
+                index = mpPSM->getcurrentnext();
+            }
+        }
+
+        int nRtn = mpPSM->readmsg(index,str,nBufLen,&nRead,pdt);
+        if(nRtn == 0)
+        {
+#ifdef USEDBUS
+            if(mbDBUSOK == true)
+            {
+                mWaitMutex.lock();
+                mwc.wait(&mWaitMutex,10);
+                mWaitMutex.unlock();
+            }
+            else
+            {
+                msleep(1);
+            }
+#else
+            msleep(1);
+#endif
+        }
+        else
+        {
+            if(nRtn == -1)
+            {
+                nBufLen = nRead;
+                delete str;
+                if(nBufLen < 1)nBufLen = 1;
+                str = new char[nBufLen];
+            }
+            else
+            {
+                if(nRtn == -2)
+                {
+                   index = mpPSM->getcurrentnext();
+                }
+                else
+                {
+                   if(nRtn >0)
+                   {
+                       if(mbFunPlus)
+                       {
+                           mFun(str,nRtn,index,pdt,mstrsmname);
+                       }
+                       else
+                       {
+                          (*mpCall)(str,nRtn,index,pdt,mstrsmname);
+                       }
+                       index++;
+                   }
+                   else
+                   {
+                       usleep(100);
+                   }
+                }
+            }
+        }
+
+    }
+    delete str;
+    delete pdt;
+//    qDebug("Thread finish.");
+}
+
+#ifdef USEDBUS
+
+void procsm_if_readthread::onNewMsg(int x)
+{
+    if(x == 100)std::cout<<x<<std::endl;
+    mwc.wakeAll();
+//    qDebug("wake");
+}
+
+#endif
+
+procsm_if::procsm_if(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode)
+{
+    strncpy(mstrsmname,strsmname,255);
+#ifdef USELCM
+    if(nMode == procsm::ModeWrite)
+    {
+
+    }
+    else
+    {
+
+    }
+    return;
+#endif
+    mpPSM = new procsm(strsmname,nBufSize,nMaxPacCount,nMode);
+    mnType = nMode;
+
+    mTimer.setTimerType(Qt::PreciseTimer);
+
+}
+
+procsm_if::~procsm_if()
+{
+    if(mnType == procsm::ModeRead)
+    {
+
+        mpReadThread->requestInterruption();
+        while(!mpReadThread->isFinished())
+        {
+
+        }
+        delete mpReadThread;
+    }
+    delete mpPSM;
+}
+
+
+
+int procsm_if::writemsg(const char *str, const unsigned int nSize)
+{
+    if(mbRun == false)return -2;
+#ifdef USELCM
+    int nres = mlcm.publish(mstrsmname,str,nSize);
+    qDebug("publish message. res = %d",nres);
+    return 0;
+#endif
+    if(mnType == procsm::ModeRead)return -1; //this is listen.
+    return mpPSM->writemsg(str,nSize);
+}
+
+#ifdef USELCM
+    void procsm_if::handlerMethod(const lcm::ReceiveBuffer *rbuf, const std::string &channel)
+    {
+        qDebug("receiv data. ");
+    }
+#endif
+int procsm_if::listenmsg(SMCallBack pCall)
+{
+//#ifdef USELCM
+////     mlcm.subscribe(mstrsmname,&handlerMethod2);
+//    mlcm.subscribe(mstrsmname,&procsm_if::handlerMethod,this);
+//    while(true)
+//    {
+//        mlcm.handle();
+//    }
+//    return 0;
+//#endif
+    if(mnType == procsm::ModeWrite)return -1; //listening.
+    mpReadThread = new procsm_if_readthread(mpPSM,pCall,mstrsmname);
+//    mpReadThread->setPriority(QThread::TimeCriticalPriority);
+//    mpReadThread->start();
+    mpReadThread->start(QThread::HighestPriority);
+//    mnType = 1;
+    return 0;
+}
+
+int procsm_if::listenmsg(ModuleFun xFun)
+{
+//#ifdef USELCM
+//    mlcm.subscribe(mstrsmname,&procsm_if::handlerMethod,this);
+//    while(true)
+//    {
+//        mlcm.handle();
+//    }
+//    return 0;
+//#endif
+    if(mnType == procsm::ModeWrite)return -1; //listening.
+    mpReadThread = new procsm_if_readthread(mpPSM,xFun,mstrsmname);
+//    mpReadThread->setPriority(QThread::TimeCriticalPriority);
+//    mpReadThread->start();
+    mpReadThread->start(QThread::HighestPriority);
+//    mnType = 1;
+    return 0;
+}
+
+void procsm_if::stoplisten()
+{
+    if(mnType != 1)return;
+    mpReadThread->requestInterruption();
+    while(!mpReadThread->isFinished());
+    mnType = 0;
+//    mpReadThread->deleteLater();
+    qDebug("stop listen ok");
+}
+
+void procsm_if::pausecomm()
+{
+    mbRun = false;
+    if(mnType == procsm::ModeRead)
+    {
+        mpReadThread->puaseread();
+    }
+}
+
+void procsm_if::continuecomm()
+{
+    mbRun = true;
+    if(mnType == procsm::ModeRead)
+    {
+        mpReadThread->continueread();
+    }
+}
+
+
+

+ 0 - 0
src/common/modulecomm/procsm_if.h → src/common/modulecomm/shm/procsm_if.h


+ 66 - 0
src/common/modulecomm/testmodulecomm.pro

@@ -0,0 +1,66 @@
+QT -= gui
+
+QT += dbus
+QT       += xml
+
+
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+#DEFINES += ANDROID
+DEFINES += USE_FASTRTPS
+DEFINES += USEDBUS
+
+# 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 += \
+        main.cpp \
+        modulecomm.cpp \
+        modulecomm_base.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(./shm/modulecomm_shm.pri ) {
+    error( "Couldn't find the modulecomm_shm.pri file!" )
+}
+
+!include(./inter/modulecomm_inter.pri ) {
+    error( "Couldn't find the modulecomm_inter.pri file!" )
+}
+
+if(contains(DEFINES,USE_FASTRTPS)){
+!include(./fastrtps/modulecomm_fastrtps.pri ) {
+    error( "Couldn't find the modulecomm_fastrtps.pri file!" )
+}
+}
+
+
+INCLUDEPATH += $$PWD/shm
+INCLUDEPATH += $$PWD/fastrtps
+INCLUDEPATH += $$PWD/inter
+
+
+if(contains(DEFINES,USE_FASTRTPS)){
+LIBS += -L$$PWD -lfastcdr -lfastrtps
+}
+
+HEADERS += \
+    modulecomm.h \
+    modulecomm_base.h
+
+
+

+ 83 - 0
src/common/modulecomm/testmodulecomm_android.pro

@@ -0,0 +1,83 @@
+QT       += core gui
+
+#QT += dbus
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# 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
+
+DEFINES += USE_FASTRTPS
+#DEFINES += USEDBUS
+
+DEFINES += Module1
+
+# 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 += \
+    main1.cpp \
+    andmainwindow.cpp \
+        modulecomm.cpp \
+        modulecomm_base.cpp
+
+HEADERS += \
+    andmainwindow.h
+
+FORMS += \
+    andmainwindow.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(./shm/modulecomm_shm.pri ) {
+    error( "Couldn't find the modulecomm_shm.pri file!" )
+}
+
+!include(./inter/modulecomm_inter.pri ) {
+    error( "Couldn't find the modulecomm_inter.pri file!" )
+}
+
+if(contains(DEFINES,USE_FASTRTPS)){
+!include(./fastrtps/modulecomm_fastrtps.pri ) {
+    error( "Couldn't find the modulecomm_fastrtps.pri file!" )
+}
+}
+
+
+INCLUDEPATH += $$PWD/shm
+INCLUDEPATH += $$PWD/fastrtps
+INCLUDEPATH += $$PWD/inter
+
+
+if(contains(DEFINES,USE_FASTRTPS)){
+LIBS += -L$$PWD/androidlib -lfastcdr -lfastrtps
+}
+
+DISTFILES += \
+    android/AndroidManifest.xml \
+    android/build.gradle \
+    android/gradle/wrapper/gradle-wrapper.jar \
+    android/gradle/wrapper/gradle-wrapper.properties \
+    android/gradlew \
+    android/gradlew.bat \
+    android/res/values/libs.xml
+
+contains(ANDROID_TARGET_ARCH,arm64-v8a) {
+    ANDROID_PACKAGE_SOURCE_DIR = \
+        $$PWD/android
+
+    ANDROID_EXTRA_LIBS = \
+        $$PWD/androidlib/libfastcdr.so \
+        $$PWD/androidlib/libfastrtps.so
+}

+ 31 - 0
src/common/modulecomm/testmodulecomm_android2.pro

@@ -0,0 +1,31 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# 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 += \
+    main2.cpp \
+    andmainwindow.cpp
+
+HEADERS += \
+    andmainwindow.h
+
+FORMS += \
+    andmainwindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target

+ 73 - 0
src/common/modulecomm/testmodulecommext.pro

@@ -0,0 +1,73 @@
+QT -= gui
+
+QT += dbus
+QT       += xml
+
+
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+#DEFINES += ANDROID
+DEFINES += USE_FASTRTPS
+DEFINES += USEDBUS
+
+# 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 += \
+        ../../../src/include/msgtype/testmodulecommext.pb.cc \
+        main.cpp \
+        modulecomm.cpp \
+        modulecomm_base.cpp \
+        modulecommext.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(./shm/modulecomm_shm.pri ) {
+    error( "Couldn't find the modulecomm_shm.pri file!" )
+}
+
+!include(./inter/modulecomm_inter.pri ) {
+    error( "Couldn't find the modulecomm_inter.pri file!" )
+}
+
+if(contains(DEFINES,USE_FASTRTPS)){
+!include(./fastrtps/modulecomm_fastrtps.pri ) {
+    error( "Couldn't find the modulecomm_fastrtps.pri file!" )
+}
+}
+
+
+INCLUDEPATH += $$PWD/shm
+INCLUDEPATH += $$PWD/fastrtps
+INCLUDEPATH += $$PWD/inter
+
+
+if(contains(DEFINES,USE_FASTRTPS)){
+LIBS += -L$$PWD -lfastcdr -lfastrtps
+}
+
+LIBS += -lprotobuf
+INCLUDEPATH += $$PWD/../../../src/include/msgtype
+
+HEADERS += \
+    ../../../src/include/msgtype/testmodulecommext.pb.h \
+    modulecomm.h \
+    modulecomm_base.h \
+    modulecommext.h
+
+
+

+ 0 - 0
src/common/modulecomm/ReadMe.md → src/common/modulecomm_classic/ReadMe.md


+ 13 - 0
src/common/modulecomm_classic/ivmodulemsg_type.h

@@ -0,0 +1,13 @@
+#ifndef IVMODULEMSG_TYPE_H
+#define IVMODULEMSG_TYPE_H
+
+namespace iv {
+struct modulemsg_type
+{
+    char mstrmsgname[256];
+    int mnBufSize;
+    int mnMsgBufCount;
+};
+
+}
+#endif // IVMODULEMSG_TYPE_H

+ 56 - 0
src/common/modulecomm_classic/modulecomm.cpp

@@ -0,0 +1,56 @@
+#include "modulecomm.h"
+#include "procsm_if.h"
+#include "procsm.h"
+
+#include <iostream>
+
+namespace iv {
+namespace modulecomm {
+
+
+void *  RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount)
+{
+
+    procsm_if * pif = new procsm_if(strcommname,nBufSize,nMsgBufCount,procsm::ModeWrite);
+    return (void *)pif;
+}
+
+void  *  RegisterRecv(const char * strcommname,SMCallBack pCall)
+{
+    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(pCall);
+    return (void *)pif;
+}
+
+void * MODULECOMMSHARED_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun)
+{
+    procsm_if * pif = new procsm_if(strcommname,0,0,procsm::ModeRead);
+    pif->listenmsg(xFun);
+    return (void *)pif;
+}
+void  ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    pif->writemsg(strdata,nDataLen);
+}
+
+void  Unregister(void * pHandle)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    delete pif;
+}
+
+void PauseComm(void *pHandle)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    pif->pausecomm();
+}
+
+void ContintuComm(void *pHandle)
+{
+    procsm_if * pif = (procsm_if *)pHandle;
+    pif->continuecomm();
+}
+
+}
+}

+ 39 - 0
src/common/modulecomm_classic/modulecomm.h

@@ -0,0 +1,39 @@
+#ifndef MODULECOMM_H
+#define MODULECOMM_H
+
+#include <QtCore/qglobal.h>
+#include <QDateTime>
+
+#include <functional>
+
+#if defined(MODULECOMM_LIBRARY)
+#  define MODULECOMMSHARED_EXPORT Q_DECL_EXPORT
+#else
+#  define MODULECOMMSHARED_EXPORT Q_DECL_IMPORT
+#endif
+
+
+//#include <iostream>
+//#include <thread>
+
+//using namespace std::placeholders;
+typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
+typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+
+namespace iv {
+namespace modulecomm {
+void * MODULECOMMSHARED_EXPORT RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount);
+void * MODULECOMMSHARED_EXPORT RegisterRecv(const char * strcommname,SMCallBack pCall);
+void * MODULECOMMSHARED_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun);
+void MODULECOMMSHARED_EXPORT ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen);
+void MODULECOMMSHARED_EXPORT Unregister(void * pHandle);
+void MODULECOMMSHARED_EXPORT PauseComm(void * pHandle);
+void MODULECOMMSHARED_EXPORT ContintuComm(void * pHandle);
+
+}
+
+}
+
+
+
+#endif 

+ 44 - 0
src/common/modulecomm_classic/modulecomm.pro

@@ -0,0 +1,44 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2018-07-10T05:46:48
+#
+#-------------------------------------------------
+
+QT       -= gui
+
+QT       += dbus
+
+
+#DEFINES += USELCM
+
+
+DEFINES += USEDBUS
+
+TARGET = modulecomm
+TEMPLATE = lib
+
+DEFINES += MODULECOMM_LIBRARY
+
+#VERSION = 1.0.1
+CONFIG += plugin
+
+
+SOURCES += modulecomm.cpp \
+    procsm.cpp \
+    procsm_if.cpp
+
+HEADERS += modulecomm.h \
+    procsm.h \
+    procsm_if.h \
+    ivmodulemsg_type.h
+
+unix {
+    target.path = /usr/lib
+    INSTALLS += target
+}
+
+
+
+#INCLUDEPATH += $$PWD/../../../include/
+LIBS += -L$$PWD
+

+ 41 - 0
src/common/modulecomm_classic/modulecomm_android.pro

@@ -0,0 +1,41 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2018-07-10T05:46:48
+#
+#-------------------------------------------------
+
+QT       -= gui
+
+#QT       += dbus
+
+
+#DEFINES += USELCM
+
+#DEFINES += USEDBUS
+
+TARGET = modulecomm
+TEMPLATE = lib
+
+DEFINES += MODULECOMM_LIBRARY
+
+#VERSION = 1.0.1
+CONFIG += plugin
+
+
+SOURCES += modulecomm.cpp \
+    procsm.cpp \
+    procsm_if.cpp
+
+HEADERS += modulecomm.h \
+    procsm.h \
+    procsm_if.h \
+    ivmodulemsg_type.h
+
+unix {
+    target.path = /usr/lib
+    INSTALLS += target
+}
+
+#INCLUDEPATH += $$PWD/../../../include/
+LIBS += -L$$PWD
+

+ 0 - 0
src/common/modulecomm/procsm.cpp → src/common/modulecomm_classic/procsm.cpp


+ 0 - 0
src/common/modulecomm/procsm.h → src/common/modulecomm_classic/procsm.h


+ 0 - 0
src/common/modulecomm/procsm_if.cpp → src/common/modulecomm_classic/procsm_if.cpp


+ 99 - 0
src/common/modulecomm_classic/procsm_if.h

@@ -0,0 +1,99 @@
+#ifndef PROCSM_IF_H
+#define PROCSM_IF_H
+
+#include <QThread>
+#include <QTimer>
+#include <QWaitCondition>
+#include <QMutex>
+#include <functional>
+
+#ifdef USEDBUS
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusConnection>
+
+#endif
+
+#include "procsm.h"
+
+typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+using namespace std::placeholders;
+typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
+
+class procsm_if_readthread:public QThread
+{
+    Q_OBJECT
+public:
+#ifdef USELCM
+
+#endif
+    procsm_if_readthread(procsm * pPSM,SMCallBack pCall,const char * strsmname);
+    procsm_if_readthread(procsm * pPSM,ModuleFun xFun,const char * strsmname);
+
+    void puaseread();
+    void continueread();
+private slots:
+#ifdef USEDBUS
+    void onNewMsg(int x);
+#endif
+private:
+
+#ifdef USELCM
+    lcm::LCM mlcm;
+    void handlerMethod(const lcm::ReceiveBuffer *rbuf,const std::string &channel);
+    int mxindex = 0;
+#endif
+    void run();
+    procsm * mpPSM;
+    SMCallBack  mpCall;
+    ModuleFun mFun;
+    char mstrsmname[256];
+
+    QWaitCondition mwc;
+
+    QMutex mWaitMutex;
+    bool mbFunPlus = false;
+    bool mbRun = true;
+    bool mbDBUSOK = true;
+};
+
+class procsm_if
+{
+
+
+public:
+    procsm_if(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode);
+    ~procsm_if();
+
+    int writemsg(const char * str,const unsigned int nSize);
+    int listenmsg(SMCallBack pCall);
+    int listenmsg(ModuleFun xFun);
+    void stoplisten();
+
+    void pausecomm();
+    void continuecomm();
+
+
+private:
+    procsm * mpPSM;
+    int mnType;
+    procsm_if_readthread * mpReadThread;
+    QTimer mTimer;
+    char mstrsmname[256];
+
+    bool mbRun = true;
+
+
+
+#ifdef USELCM
+    lcm::LCM mlcm;
+    void handlerMethod(const lcm::ReceiveBuffer *rbuf,const std::string &channel);
+#endif
+
+
+
+
+
+
+};
+
+#endif // PROCSM_IF_H