SlideShare a Scribd company logo
1 of 12
Download to read offline
Recipe to Build Open Splice DDS Ver 6.3.xxx Hello World Example Over Qt 5.2
1. This recipe is developed to help those who could face problem in deploying Open Splice
DDS Ver 6.3.xxx over Qt 5.2. This recipe would help them to develop GUI based applications over
LINUX.
2. Following are steps wise details :-
Pre-requisite: According to my station following is the configuration:-.
a. Ubuntu 13.10
b. Qt 5.2.0 based on (GCC 4.6.1, 32 bit)
c. GCC 4.8.1
d. autoconf
e. automake
f. build-essential
g. OpenSpliceDDSV6.3.130716OSS-HDE-x86.linux-gcc4.6-glibc2.15 for LINUX
kernel 3.0 and above. (Download from following link)
http://www.prismtech.com/opensplice/opensplice-dds-community/software-downloads )
Step No 1: Configure Environmental Settings
3. Create a folder opensplice in /home/xxxxx.xxx copy the above downloaded open splice api
folder and unzip. Or you can unzip anywhere else but for easy reference use /home folder.
4. Open a Terminal in Ubuntu and go inside the folder as mentioned below:-
>cd /home/xxxxx.xxxx/opensplice/HDE/x86.linux2.6
>ls -all {This command is use to check the directory. Check availability of file
release.com.}
>chmod 777 release.com Note: This command make release.com an executable
5. release.com contains environmental settings which are mandatory to build any application
based on open splice DDS. Open release.com in any text editor analyze it. As mentioned below:-
6. At line OSPL_HOME=”/home/..../opensplice/HDE/.... ” you can add your own address
where you had un-ziped the folder. Moreover, edit CPATH variable and replace with following
paths:-
CPATH=$OSPL_HOME/include/dcps/C++/CCPP:$OSPL_HOME/include/dcps/C++/isocpp:
$OSPL_HOME/include/dcps/C++/SACPP:$OSPL_HOME/include:
$OSPL_HOME/include/sys:${CPATH:=}
7. There are three ways to load these environmental setting:-
Option 1: Just write following line on the command prompt.
>. ./release.com
8. This suppose to work but if due to some reasons setting are not loaded then we have to load
each setting manually mentioned in option 2. but to check setting are loaded, write following lines
and check the response.
> echo $OSPL_HOME
> echo $OSPL_TARGET
> echo $PATH
> echo $LD_LIBRARY_PATH
> echo $CPATH
> echo $OSPL_URI
> echo $OSPL_TMPL_PATH
Option 2: Load each line over command prompt one by one and check
SPLICE_JDK=jdk
export SPLICE_JDK
export OSPL_HOME="/home/....../opensplice/HDE/x86.linux2.6"
echo $OSPL_HOME
export OSPL_TARGET=x86.linux2.6
echo $OSPL_TARGET
export PATH=$OSPL_HOME/bin:$PATH
echo $PATH
export LD_LIBRARY_PATH=$OSPL_HOME/lib${LD_LIBRARY_PATH:+:
$LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
export CPATH=$OSPL_HOME/include:$OSPL_HOME/include/sys:${CPATH:=}
echo $CPATH
export OSPL_URI=file://$OSPL_HOME/etc/config/ospl.xml
echo $OSPL_URI
export OSPL_TMPL_PATH=$OSPL_HOME/etc/idlpp
echo $OSPL_TMPL_PATH
$OSPL_HOME/etc/java/defs.$SPLICE_JDK
Option 3: Open the file /etc/environment as root and update. Add lines mentioned in
option # 2 (Note: load each setting manually on terminal and copy output of echo $xxxx command;
for reference setting are mentioned below):-
>sudo nano /etc/environment
9. nano is a text editor if it is not install use following command and connect to INTERNET.
>sudo apt-get update
>sudo apt-get install nano
10. update the environment file .
11. Add following lines as mentioned in above picture (../adilkhan/ would be replace with your
system folder address).
PATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/etc/idlpp:/home/xxx.xxxx/opensplice/HDE/x86.linux2
.6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
OSPL_HOME=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6
OSPL_TARGET=x86.linux2.6
LD_LIBRARY_PATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/lib
CPATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include:/home/xxx.xxxx/opensplice/HDE/x86.linux
2.6/include/sys:/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include/dcps/C+
+/SACPP:/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include/dcps/C+
+/CCPP:/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include/dcps/C++/isocpp
OSPL_URI=file:///home/xxx.xxxx/opensplice/HDE/x86.linux2.6/etc/config/ospl.xml
OSPL_TMPL_PATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/etc/idlpp
QTDIR=/home/xxx.xxxx/Qt5.2.0/5.2.0/gcc
CLASSPATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/jar/dcpssaj.jar:/home/xxx.xxxx/opensplice/HD
E/x86.linux2.6/jar/dcpscj.jar:$CLASSPATH
12. Now, execute following line on terminal.
>source /etc/environment
10. Important Note : Always load these setting using any of the above options.
Step No 2: Starting Qt 5.2 Creator
11. Open terminal and load environmental setting as mentioned in Step No 1.
12. Using same terminal instance, navigate to Qt 5.2 folder. Note: If other terminal is use to
load Qt Creator, then environmental setting shall not be valid.
>cd /home/.../opensplice/HDE/x86.linux2.6
>. ./release.com
>cd /home/..../Qt5.2/Tools/QtCreator/bin
>./qtcreator
Step No 3: Hello World Publisher
13. This recipe takes you step by step to convert Hello World example into QT based GUI
application. However, this is not a tutorial to Qt but, I shall be using Qt terminologies directly:-
(a) Create two new projects using Qt Widget Application:-
(b) Add project name HelloWorldDDS_Publisher for first and
HelloWorldDDS_Subscriber for second.
(c) Copy Checkstatus.cpp & .h / DDSEntityManager.cpp & .h / HelloWorldData.idl
from opensplice HelloWorld (C++) example folder into project folder separately (copying
separately is just to keep it isolated). Open another terminal load environmental settings,
then go into project folder where HelloWorldData.idl file is copied and execute following
command. It would generate requisite file to configure topic and its type support:-
> idlpp -S -l cpp HelloWorldData.idl
(d) Add above generated files as existing files along with Checkstatus.cpp & .h /
DDSEntityManager.cpp & .h into the project.
(e) Go inside project build setting and edit build environment. Add all the Paths and
setting mentioned in Step # 1 : option # 3.
(f) Add library. Select external library then select LINUX as platform and browse. Go in
to a folder /home/..../opensplice/HDE/x86.linux2.6/lib and add each library one by one.
This will update HelloWorldDDS_Publisher.pro and HelloWorldDDS_Subscriber.pro as
shown in picture.
(g) Create user interface as shown below:-
-
(h) Edit mainwindow.cpp & .h files of both the projects as per attached Appendix A &
B. However, complete project folder is also available with this document.
(j) Build the application, If there is some error try to find out over INTERNET or
consult me over INTERNET for any query (adil53@pnec.nust.edu.pk)
14. Execute both projects on same or different computers and connect these computers over
LAN or WiFi and enjoy DDS communication . It is better to launch from terminal after loading
environmental settings.
16. Use this recipe and play with different idl files and multiple QoS (quality of service).
You are allowed to share this recipe with any body.
Regards
Adil Khan
Appendix “A”
Publisher mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QString"
#include <string>
#include <sstream>
#include <iostream>
#include "DDSEntityManager.h"
#include "ccpp_HelloWorldData.h"
#include "os.h"
#include "ccpp_dds_dcps.h"
//#include "subscriberthread.h"
#include <unistd.h>
#include "CheckStatus.h"
using namespace DDS;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//QObject::connect(subscriberthread, SIGNAL(receivedtext(QString)),
ui->plainTextEdit_Subscribe, SLOT(setPlainText(QString)));
DDSEntityManager mgr;
// create domain participant
mgr.createParticipant("HelloWorld example");
//create type
mt = new MsgTypeSupport();
mgr.registerType(mt.in());
//create Topic
char topic_name[] = "HelloWorldData_Msg";
mgr.createTopic(topic_name);
//create Publisher
mgr.createPublisher();
// create DataWriter :
// If autodispose_unregistered_instances is set to true (default value),
// you will have to start the subscriber before the publisher
bool autodispose_unregistered_instances = false;
mgr.createWriter(autodispose_unregistered_instances);
// Publish Events
DataWriter_var dwriter = mgr.getWriter();
MsgDataWriter_var HelloWorldWriter = MsgDataWriter::_narrow(dwriter.in());
Msg msgInstance; /* Example on Stack */
msgInstance.userID = 1;
msgInstance.message = DDS::string_dup("Hello World");
ui->plainTextEdit_Publish->setPlainText("Start Message:-");
ui->plainTextEdit_Publish->setPlainText( "userID : " +
QString(msgInstance.userID));
ui->plainTextEdit_Publish->setPlainText("Message : " +
QString( msgInstance.message));
ReturnCode_t status = HelloWorldWriter->write(msgInstance, DDS::HANDLE_NIL);
checkStatus(status, "MsgDataWriter::write");
//os_nanoSleep(delay_1s);
/* Remove the DataWriters */
mgr.deleteWriter();
/* Remove the Publisher. */
mgr.deletePublisher();
/* Remove the Topics. */
mgr.deleteTopic();
/* Remove Participant. */
mgr.deleteParticipant();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_Create_Participants_clicked()
{
DDSEntityManager mgr;
// create domain participant
mgr.createParticipant("HelloWorld example");
//create type
mt = new MsgTypeSupport();
mgr.registerType(mt.in());
//create Topic
char topic_name[] = "HelloWorldData_Msg";
mgr.createTopic(topic_name);
//create Publisher
mgr.createPublisher();
// create DataWriter :
// If autodispose_unregistered_instances is set to true (default value),
// you will have to start the subscriber before the publisher
bool autodispose_unregistered_instances = false;
mgr.createWriter(autodispose_unregistered_instances);
// Publish Events
DataWriter_var dwriter = mgr.getWriter();
MsgDataWriter_var HelloWorldWriter = MsgDataWriter::_narrow(dwriter.in());
Msg msgInstance; /* Example on Stack */
QString message;
message = ui->transmit_text->toPlainText();
msgInstance.userID = 1;
msgInstance.message = message.toUtf8().constData();
ui->plainTextEdit_Publish->setPlainText("Start Message:-");
ui->plainTextEdit_Publish->setPlainText( "userID : " +
QString(msgInstance.userID));
ui->plainTextEdit_Publish->setPlainText("Message : " +
QString( msgInstance.message));
ReturnCode_t status = HelloWorldWriter->write(msgInstance, DDS::HANDLE_NIL);
checkStatus(status, "MsgDataWriter::write");
//os_nanoSleep(delay_1s);
/* Remove the DataWriters */
mgr.deleteWriter();
/* Remove the Publisher. */
mgr.deletePublisher();
/* Remove the Topics. */
mgr.deleteTopic();
/* Remove Participant. */
mgr.deleteParticipant();
}
void MainWindow::on_Quit_clicked()
{
QCoreApplication::exit();
}
/**************************************************************************/
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "ccpp_HelloWorldData.h"
#include "ccpp_dds_dcps.h"
//#include "subscriberthread.h"
using namespace HelloWorldData; // Very important to declare this namespace
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
//subscriberthread* subs=new subscriberthread;
MsgTypeSupport_var mt;
Ui::MainWindow *ui;
private slots:
void on_Create_Participants_clicked();
void on_Quit_clicked();
private:
//MsgTypeSupport_var mt;
};
#endif // MAINWINDOW_H
Appendix “B” : Subscriber mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QString"
#include <string>
#include <sstream>
#include <iostream>
#include "DDSEntityManager.h"
#include "ccpp_HelloWorldData.h"
#include "os.h"
#include "ccpp_dds_dcps.h"
//#include "subscriberthread.h"
#include <unistd.h>
#include "CheckStatus.h"
#include <qthread.h>
using namespace DDS;
DDSEntityManager subs;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_Subscribe_clicked()
{
MsgSeq msgList;
SampleInfoSeq infoSeq;
// create domain participants
subs.createParticipant("HelloWorld example");
//create type
MsgTypeSupport_var mt = new MsgTypeSupport();
subs.registerType(mt.in());
//create Topic
char topic_name[] = "HelloWorldData_Msg";
subs.createTopic(topic_name);
//create Subscriber
subs.createSubscriber();
// create DataReader
subs.createReader();
DataReader_var dreader = subs.getReader();
MsgDataReader_var HelloWorldReader = MsgDataReader::_narrow(dreader.in());
checkHandle(HelloWorldReader.in(), "MsgDataReader::_narrow");
ui->plainTextEdit_Subscribe->setPlainText("=== [Subscriber] Ready ...");
// Q_EMIT receivedtext("=== [Subscriber] Ready ...");
bool closed = false;
ReturnCode_t status = - 1;
int count = 0;
while (!closed && count < 1500) // We dont want the example to run
indefinitely
{
status = HelloWorldReader->take(msgList, infoSeq, LENGTH_UNLIMITED,
ANY_SAMPLE_STATE, ANY_VIEW_STATE, ANY_INSTANCE_STATE);
checkStatus(status, "msgDataReader::take");
for (DDS::ULong j = 0; j < msgList.length(); j++)
{
ui->plainTextEdit_Subscribe->setPlainText("=== [Subscriber] message
received :");
// cout << " userID : " << msgList[j].userID << endl;
// cout << " Message : "" << msgList[j].message << """ << endl;
ui->plainTextEdit_Subscribe->setPlainText(QString::number(msgList[j].userID));
ui->plainTextEdit_Subscribe->setPlainText(QString(msgList[j].message));
closed = true;
}
status = HelloWorldReader->return_loan(msgList, infoSeq);
checkStatus(status, "MsgDataReader::return_loan");
//QThread::msleep(8);
++count;
}
//cleanup
subs.deleteReader();
subs.deleteSubscriber();
subs.deleteTopic();
subs.deleteParticipant();
}
void MainWindow::on_Quit_clicked()
{
QCoreApplication::exit();
}
/**************************************************************************/
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "ccpp_HelloWorldData.h"
#include "ccpp_dds_dcps.h"
//#include "subscriberthread.h"
using namespace HelloWorldData; // very important to declare this namespace
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
MsgTypeSupport_var mt;
Ui::MainWindow *ui;
private slots:
void on_Subscribe_clicked();
void on_Quit_clicked();
private:
};
#endif // MAINWINDOW_H

More Related Content

What's hot

Expo diagramme cas d'utilisation
Expo diagramme cas d'utilisationExpo diagramme cas d'utilisation
Expo diagramme cas d'utilisation
aminooovich
 
Business Intelligence : introduction to datawarehouse
Business Intelligence : introduction to datawarehouseBusiness Intelligence : introduction to datawarehouse
Business Intelligence : introduction to datawarehouse
Alexandre Equoy
 
Realtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and HadoopRealtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and Hadoop
DataWorks Summit
 
Library management system
Library management systemLibrary management system
Library management system
siddiqui241993
 
cisco icon
cisco iconcisco icon
cisco icon
yusi2001
 
Mpls foudhaili oussama
Mpls foudhaili oussamaMpls foudhaili oussama
Mpls foudhaili oussama
Gilles Samba
 

What's hot (20)

Expo diagramme cas d'utilisation
Expo diagramme cas d'utilisationExpo diagramme cas d'utilisation
Expo diagramme cas d'utilisation
 
Business Intelligence : introduction to datawarehouse
Business Intelligence : introduction to datawarehouseBusiness Intelligence : introduction to datawarehouse
Business Intelligence : introduction to datawarehouse
 
Grocery Station- Database Management System Project
Grocery Station- Database Management System ProjectGrocery Station- Database Management System Project
Grocery Station- Database Management System Project
 
À quoi servent les langages M et DAX
À quoi servent les langages M et DAXÀ quoi servent les langages M et DAX
À quoi servent les langages M et DAX
 
Realtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and HadoopRealtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and Hadoop
 
Gestion des données d'entreprise à l'ère de MongoDB et du Data Lake
Gestion des données d'entreprise à l'ère de MongoDB et du Data LakeGestion des données d'entreprise à l'ère de MongoDB et du Data Lake
Gestion des données d'entreprise à l'ère de MongoDB et du Data Lake
 
Protocole d’authetification PPP
Protocole d’authetification PPPProtocole d’authetification PPP
Protocole d’authetification PPP
 
Architectures n-tiers
Architectures n-tiersArchitectures n-tiers
Architectures n-tiers
 
Library management system
Library management systemLibrary management system
Library management system
 
Merise
MeriseMerise
Merise
 
cisco icon
cisco iconcisco icon
cisco icon
 
Voice over MPLS
Voice over MPLSVoice over MPLS
Voice over MPLS
 
Analysis of Database Issues using AHF and Machine Learning v2 - AOUG2022
Analysis of Database Issues using AHF and Machine Learning v2 -  AOUG2022Analysis of Database Issues using AHF and Machine Learning v2 -  AOUG2022
Analysis of Database Issues using AHF and Machine Learning v2 - AOUG2022
 
Library management (use case diagram Software engineering)
Library management (use case  diagram Software engineering)Library management (use case  diagram Software engineering)
Library management (use case diagram Software engineering)
 
CBSE VS SOA Presentation
CBSE VS SOA PresentationCBSE VS SOA Presentation
CBSE VS SOA Presentation
 
APACHE TOMCAT
APACHE TOMCATAPACHE TOMCAT
APACHE TOMCAT
 
Stockage de données dans Android : Fichiers
Stockage de données dans Android : FichiersStockage de données dans Android : Fichiers
Stockage de données dans Android : Fichiers
 
Mpls foudhaili oussama
Mpls foudhaili oussamaMpls foudhaili oussama
Mpls foudhaili oussama
 
Mapping Hierarchical Sources into RDF using the RML Mapping Language
Mapping Hierarchical Sources into RDF using the RML Mapping LanguageMapping Hierarchical Sources into RDF using the RML Mapping Language
Mapping Hierarchical Sources into RDF using the RML Mapping Language
 
Introduction to EventStoreDB.pptx.pdf
Introduction to EventStoreDB.pptx.pdfIntroduction to EventStoreDB.pptx.pdf
Introduction to EventStoreDB.pptx.pdf
 

Similar to Recipe to build open splice dds 6.3.xxx Hello World example over Qt 5.2

IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
RahulRoy130127
 

Similar to Recipe to build open splice dds 6.3.xxx Hello World example over Qt 5.2 (20)

Native Hadoop with prebuilt spark
Native Hadoop with prebuilt sparkNative Hadoop with prebuilt spark
Native Hadoop with prebuilt spark
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
DPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabDPDK in Containers Hands-on Lab
DPDK in Containers Hands-on Lab
 
Readme
ReadmeReadme
Readme
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training
 
Os dev tool box
Os dev tool boxOs dev tool box
Os dev tool box
 
Install guide
Install guideInstall guide
Install guide
 
Install guide
Install guideInstall guide
Install guide
 
Ddev workshop t3dd18
Ddev workshop t3dd18Ddev workshop t3dd18
Ddev workshop t3dd18
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
 
Open Dayligth usando SDN-NFV
Open Dayligth usando SDN-NFVOpen Dayligth usando SDN-NFV
Open Dayligth usando SDN-NFV
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
 
Red Teaming macOS Environments with Hermes the Swift Messenger
Red Teaming macOS Environments with Hermes the Swift MessengerRed Teaming macOS Environments with Hermes the Swift Messenger
Red Teaming macOS Environments with Hermes the Swift Messenger
 
R server and spark
R server and sparkR server and spark
R server and spark
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
 
7 hands on
7 hands on7 hands on
7 hands on
 
Howto Pxeboot
Howto PxebootHowto Pxeboot
Howto Pxeboot
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linux
 

Recently uploaded

Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
Health
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Recently uploaded (20)

Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 

Recipe to build open splice dds 6.3.xxx Hello World example over Qt 5.2

  • 1. Recipe to Build Open Splice DDS Ver 6.3.xxx Hello World Example Over Qt 5.2 1. This recipe is developed to help those who could face problem in deploying Open Splice DDS Ver 6.3.xxx over Qt 5.2. This recipe would help them to develop GUI based applications over LINUX. 2. Following are steps wise details :- Pre-requisite: According to my station following is the configuration:-. a. Ubuntu 13.10 b. Qt 5.2.0 based on (GCC 4.6.1, 32 bit) c. GCC 4.8.1 d. autoconf e. automake f. build-essential g. OpenSpliceDDSV6.3.130716OSS-HDE-x86.linux-gcc4.6-glibc2.15 for LINUX kernel 3.0 and above. (Download from following link) http://www.prismtech.com/opensplice/opensplice-dds-community/software-downloads ) Step No 1: Configure Environmental Settings 3. Create a folder opensplice in /home/xxxxx.xxx copy the above downloaded open splice api folder and unzip. Or you can unzip anywhere else but for easy reference use /home folder. 4. Open a Terminal in Ubuntu and go inside the folder as mentioned below:- >cd /home/xxxxx.xxxx/opensplice/HDE/x86.linux2.6 >ls -all {This command is use to check the directory. Check availability of file release.com.} >chmod 777 release.com Note: This command make release.com an executable 5. release.com contains environmental settings which are mandatory to build any application based on open splice DDS. Open release.com in any text editor analyze it. As mentioned below:-
  • 2. 6. At line OSPL_HOME=”/home/..../opensplice/HDE/.... ” you can add your own address where you had un-ziped the folder. Moreover, edit CPATH variable and replace with following paths:- CPATH=$OSPL_HOME/include/dcps/C++/CCPP:$OSPL_HOME/include/dcps/C++/isocpp: $OSPL_HOME/include/dcps/C++/SACPP:$OSPL_HOME/include: $OSPL_HOME/include/sys:${CPATH:=} 7. There are three ways to load these environmental setting:- Option 1: Just write following line on the command prompt. >. ./release.com 8. This suppose to work but if due to some reasons setting are not loaded then we have to load each setting manually mentioned in option 2. but to check setting are loaded, write following lines and check the response. > echo $OSPL_HOME > echo $OSPL_TARGET > echo $PATH > echo $LD_LIBRARY_PATH > echo $CPATH > echo $OSPL_URI > echo $OSPL_TMPL_PATH Option 2: Load each line over command prompt one by one and check SPLICE_JDK=jdk export SPLICE_JDK export OSPL_HOME="/home/....../opensplice/HDE/x86.linux2.6" echo $OSPL_HOME export OSPL_TARGET=x86.linux2.6 echo $OSPL_TARGET export PATH=$OSPL_HOME/bin:$PATH
  • 3. echo $PATH export LD_LIBRARY_PATH=$OSPL_HOME/lib${LD_LIBRARY_PATH:+: $LD_LIBRARY_PATH echo $LD_LIBRARY_PATH export CPATH=$OSPL_HOME/include:$OSPL_HOME/include/sys:${CPATH:=} echo $CPATH export OSPL_URI=file://$OSPL_HOME/etc/config/ospl.xml echo $OSPL_URI export OSPL_TMPL_PATH=$OSPL_HOME/etc/idlpp echo $OSPL_TMPL_PATH $OSPL_HOME/etc/java/defs.$SPLICE_JDK Option 3: Open the file /etc/environment as root and update. Add lines mentioned in option # 2 (Note: load each setting manually on terminal and copy output of echo $xxxx command; for reference setting are mentioned below):- >sudo nano /etc/environment 9. nano is a text editor if it is not install use following command and connect to INTERNET. >sudo apt-get update >sudo apt-get install nano 10. update the environment file . 11. Add following lines as mentioned in above picture (../adilkhan/ would be replace with your system folder address). PATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/etc/idlpp:/home/xxx.xxxx/opensplice/HDE/x86.linux2 .6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games OSPL_HOME=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6 OSPL_TARGET=x86.linux2.6 LD_LIBRARY_PATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/lib CPATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include:/home/xxx.xxxx/opensplice/HDE/x86.linux 2.6/include/sys:/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include/dcps/C+ +/SACPP:/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include/dcps/C+ +/CCPP:/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/include/dcps/C++/isocpp OSPL_URI=file:///home/xxx.xxxx/opensplice/HDE/x86.linux2.6/etc/config/ospl.xml
  • 4. OSPL_TMPL_PATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/etc/idlpp QTDIR=/home/xxx.xxxx/Qt5.2.0/5.2.0/gcc CLASSPATH=/home/xxx.xxxx/opensplice/HDE/x86.linux2.6/jar/dcpssaj.jar:/home/xxx.xxxx/opensplice/HD E/x86.linux2.6/jar/dcpscj.jar:$CLASSPATH 12. Now, execute following line on terminal. >source /etc/environment 10. Important Note : Always load these setting using any of the above options. Step No 2: Starting Qt 5.2 Creator 11. Open terminal and load environmental setting as mentioned in Step No 1. 12. Using same terminal instance, navigate to Qt 5.2 folder. Note: If other terminal is use to load Qt Creator, then environmental setting shall not be valid. >cd /home/.../opensplice/HDE/x86.linux2.6 >. ./release.com >cd /home/..../Qt5.2/Tools/QtCreator/bin >./qtcreator Step No 3: Hello World Publisher 13. This recipe takes you step by step to convert Hello World example into QT based GUI application. However, this is not a tutorial to Qt but, I shall be using Qt terminologies directly:- (a) Create two new projects using Qt Widget Application:-
  • 5. (b) Add project name HelloWorldDDS_Publisher for first and HelloWorldDDS_Subscriber for second. (c) Copy Checkstatus.cpp & .h / DDSEntityManager.cpp & .h / HelloWorldData.idl from opensplice HelloWorld (C++) example folder into project folder separately (copying separately is just to keep it isolated). Open another terminal load environmental settings, then go into project folder where HelloWorldData.idl file is copied and execute following command. It would generate requisite file to configure topic and its type support:- > idlpp -S -l cpp HelloWorldData.idl (d) Add above generated files as existing files along with Checkstatus.cpp & .h / DDSEntityManager.cpp & .h into the project. (e) Go inside project build setting and edit build environment. Add all the Paths and setting mentioned in Step # 1 : option # 3.
  • 6. (f) Add library. Select external library then select LINUX as platform and browse. Go in to a folder /home/..../opensplice/HDE/x86.linux2.6/lib and add each library one by one. This will update HelloWorldDDS_Publisher.pro and HelloWorldDDS_Subscriber.pro as shown in picture. (g) Create user interface as shown below:- - (h) Edit mainwindow.cpp & .h files of both the projects as per attached Appendix A & B. However, complete project folder is also available with this document. (j) Build the application, If there is some error try to find out over INTERNET or consult me over INTERNET for any query (adil53@pnec.nust.edu.pk) 14. Execute both projects on same or different computers and connect these computers over LAN or WiFi and enjoy DDS communication . It is better to launch from terminal after loading environmental settings. 16. Use this recipe and play with different idl files and multiple QoS (quality of service). You are allowed to share this recipe with any body. Regards Adil Khan
  • 7. Appendix “A” Publisher mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include "QString" #include <string> #include <sstream> #include <iostream> #include "DDSEntityManager.h" #include "ccpp_HelloWorldData.h" #include "os.h" #include "ccpp_dds_dcps.h" //#include "subscriberthread.h" #include <unistd.h> #include "CheckStatus.h" using namespace DDS; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //QObject::connect(subscriberthread, SIGNAL(receivedtext(QString)), ui->plainTextEdit_Subscribe, SLOT(setPlainText(QString))); DDSEntityManager mgr; // create domain participant mgr.createParticipant("HelloWorld example"); //create type mt = new MsgTypeSupport(); mgr.registerType(mt.in()); //create Topic char topic_name[] = "HelloWorldData_Msg"; mgr.createTopic(topic_name); //create Publisher mgr.createPublisher(); // create DataWriter : // If autodispose_unregistered_instances is set to true (default value), // you will have to start the subscriber before the publisher bool autodispose_unregistered_instances = false; mgr.createWriter(autodispose_unregistered_instances); // Publish Events DataWriter_var dwriter = mgr.getWriter(); MsgDataWriter_var HelloWorldWriter = MsgDataWriter::_narrow(dwriter.in()); Msg msgInstance; /* Example on Stack */ msgInstance.userID = 1; msgInstance.message = DDS::string_dup("Hello World");
  • 8. ui->plainTextEdit_Publish->setPlainText("Start Message:-"); ui->plainTextEdit_Publish->setPlainText( "userID : " + QString(msgInstance.userID)); ui->plainTextEdit_Publish->setPlainText("Message : " + QString( msgInstance.message)); ReturnCode_t status = HelloWorldWriter->write(msgInstance, DDS::HANDLE_NIL); checkStatus(status, "MsgDataWriter::write"); //os_nanoSleep(delay_1s); /* Remove the DataWriters */ mgr.deleteWriter(); /* Remove the Publisher. */ mgr.deletePublisher(); /* Remove the Topics. */ mgr.deleteTopic(); /* Remove Participant. */ mgr.deleteParticipant(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_Create_Participants_clicked() { DDSEntityManager mgr; // create domain participant mgr.createParticipant("HelloWorld example"); //create type mt = new MsgTypeSupport(); mgr.registerType(mt.in()); //create Topic char topic_name[] = "HelloWorldData_Msg"; mgr.createTopic(topic_name); //create Publisher mgr.createPublisher(); // create DataWriter : // If autodispose_unregistered_instances is set to true (default value), // you will have to start the subscriber before the publisher bool autodispose_unregistered_instances = false; mgr.createWriter(autodispose_unregistered_instances); // Publish Events DataWriter_var dwriter = mgr.getWriter(); MsgDataWriter_var HelloWorldWriter = MsgDataWriter::_narrow(dwriter.in()); Msg msgInstance; /* Example on Stack */ QString message; message = ui->transmit_text->toPlainText(); msgInstance.userID = 1; msgInstance.message = message.toUtf8().constData(); ui->plainTextEdit_Publish->setPlainText("Start Message:-"); ui->plainTextEdit_Publish->setPlainText( "userID : " + QString(msgInstance.userID));
  • 9. ui->plainTextEdit_Publish->setPlainText("Message : " + QString( msgInstance.message)); ReturnCode_t status = HelloWorldWriter->write(msgInstance, DDS::HANDLE_NIL); checkStatus(status, "MsgDataWriter::write"); //os_nanoSleep(delay_1s); /* Remove the DataWriters */ mgr.deleteWriter(); /* Remove the Publisher. */ mgr.deletePublisher(); /* Remove the Topics. */ mgr.deleteTopic(); /* Remove Participant. */ mgr.deleteParticipant(); } void MainWindow::on_Quit_clicked() { QCoreApplication::exit(); } /**************************************************************************/ mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include "ccpp_HelloWorldData.h" #include "ccpp_dds_dcps.h" //#include "subscriberthread.h" using namespace HelloWorldData; // Very important to declare this namespace namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); //subscriberthread* subs=new subscriberthread; MsgTypeSupport_var mt; Ui::MainWindow *ui; private slots: void on_Create_Participants_clicked(); void on_Quit_clicked(); private: //MsgTypeSupport_var mt; }; #endif // MAINWINDOW_H
  • 10. Appendix “B” : Subscriber mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include "QString" #include <string> #include <sstream> #include <iostream> #include "DDSEntityManager.h" #include "ccpp_HelloWorldData.h" #include "os.h" #include "ccpp_dds_dcps.h" //#include "subscriberthread.h" #include <unistd.h> #include "CheckStatus.h" #include <qthread.h> using namespace DDS; DDSEntityManager subs; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_Subscribe_clicked() { MsgSeq msgList; SampleInfoSeq infoSeq; // create domain participants subs.createParticipant("HelloWorld example"); //create type MsgTypeSupport_var mt = new MsgTypeSupport(); subs.registerType(mt.in()); //create Topic char topic_name[] = "HelloWorldData_Msg"; subs.createTopic(topic_name); //create Subscriber subs.createSubscriber(); // create DataReader subs.createReader(); DataReader_var dreader = subs.getReader(); MsgDataReader_var HelloWorldReader = MsgDataReader::_narrow(dreader.in()); checkHandle(HelloWorldReader.in(), "MsgDataReader::_narrow");
  • 11. ui->plainTextEdit_Subscribe->setPlainText("=== [Subscriber] Ready ..."); // Q_EMIT receivedtext("=== [Subscriber] Ready ..."); bool closed = false; ReturnCode_t status = - 1; int count = 0; while (!closed && count < 1500) // We dont want the example to run indefinitely { status = HelloWorldReader->take(msgList, infoSeq, LENGTH_UNLIMITED, ANY_SAMPLE_STATE, ANY_VIEW_STATE, ANY_INSTANCE_STATE); checkStatus(status, "msgDataReader::take"); for (DDS::ULong j = 0; j < msgList.length(); j++) { ui->plainTextEdit_Subscribe->setPlainText("=== [Subscriber] message received :"); // cout << " userID : " << msgList[j].userID << endl; // cout << " Message : "" << msgList[j].message << """ << endl; ui->plainTextEdit_Subscribe->setPlainText(QString::number(msgList[j].userID)); ui->plainTextEdit_Subscribe->setPlainText(QString(msgList[j].message)); closed = true; } status = HelloWorldReader->return_loan(msgList, infoSeq); checkStatus(status, "MsgDataReader::return_loan"); //QThread::msleep(8); ++count; } //cleanup subs.deleteReader(); subs.deleteSubscriber(); subs.deleteTopic(); subs.deleteParticipant(); } void MainWindow::on_Quit_clicked() { QCoreApplication::exit(); } /**************************************************************************/ mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include "ccpp_HelloWorldData.h" #include "ccpp_dds_dcps.h" //#include "subscriberthread.h" using namespace HelloWorldData; // very important to declare this namespace
  • 12. namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); MsgTypeSupport_var mt; Ui::MainWindow *ui; private slots: void on_Subscribe_clicked(); void on_Quit_clicked(); private: }; #endif // MAINWINDOW_H