Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing ECA signature #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/ATC/.DS_Store
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RamziKaroui the macos .DS_Store files should not be checked into git, may you can remove this file?

Binary file not shown.
42 changes: 42 additions & 0 deletions examples/ATC/ATCDataModel.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @addtogroup examplesdcpsatcisocpp
*/
/** @{*/
/** @file */

/* CycloneDDS isoC++ example
*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*
*/

module ATCDataModule
{

struct Position {
short x; // latitude
short y; // longitude
short z; // altitude

};


struct Flight
{
/** Flight Call ID */
long ID; //@Key

Position pos;
// float Speed;
/** Current Region we are flying into*/
string CurrentRegion;
};
#pragma keylist Flight ID
};

/** @}*/
38 changes: 38 additions & 0 deletions examples/ATC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
cmake_minimum_required(VERSION 3.5)
find_package(Idlpp-cxx REQUIRED)
find_package(CycloneDDS REQUIRED)

if (NOT TARGET CycloneDDS_CXX_API::ddscxx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RamziKaroui may you can update the cmake file, the target is not called ..._API anymore. May you can update the code with the current master?

# Find the CycloneDDS_CXX_API package. If it is not in a default location, try
# finding it relative to the example where it most likely resides.
find_package(CycloneDDS_CXX_API REQUIRED PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../../..")
endif()

# This is a convenience function, provided by the CycloneDDS_CXX_API package,
# that will supply a library target related the the given idl file.
# In short, it takes the idl file, generates the source files with
# the proper data types and compiles them into a library.
idl_ddscxx_generate(ddscxxATCDataModel_lib "ATCDataModel.idl")

# Both executables have only one related source file.
add_executable(pubATC publisher.cpp)
add_executable(subATC subscriber.cpp)

# Both executables need to be linked to the idl data type library and
# the ddsc API library.
target_link_libraries(pubATC ddscxxATCDataModel_lib CycloneDDS_CXX_API::ddscxx)
target_link_libraries(subATC ddscxxATCDataModel_lib CycloneDDS_CXX_API::ddscxx)

set_property(TARGET pubATC PROPERTY CXX_STANDARD 11)
set_property(TARGET subATC PROPERTY CXX_STANDARD 11)
85 changes: 85 additions & 0 deletions examples/ATC/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/***************************************************************************************/

Copyright(c) 2006 to 2018 ADLINK Technology Limited and others

This program and the accompanying materials are made available under the

terms of the Eclipse Public License v. 2.0 which is available at

http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License

v. 1.0 which is available at

http://www.eclipse.org/org/documents/edl-v10.php.

SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

/***************************************************************************************/

# Description

This example mimics, in its most simplistic form, an Air Traffic Controller System , made of two subsystems:

A **Radar System** that, detects and publishes Flights in different region in Europe, within a dedicated Global data space, and an Air **Flight Visualiser system** that can build *different views* of that space, either Per country, Per Region or Per the Entire continent.



![](C:\Users\User\Documents\GitHub\cdds-cxx\src\examples\ATC\clip_image002.jpg)





# Design

The Radar system is modelled by the Publishing program ( **pubATC** ). This program

· Get involved in the European Global Data Space DDS domain (domainId=0),

· Creates 6 DDS partitions that corresponds to the 6 regions shown on the Map (see Fig below), then it

· Publishes 5 Flights with different Call signs ( CIDs) as well as their respective positions .

The European Global Data Space is organized hierarchically following this pattern: /<Continent>/<Country>/<Region>.

The Air Flight Visualizer is modelled by the Subscribing program (**subATC**) . This program allows you to Subscribe to a specific region, for example, to the region /Europe/Sweden/Norrland or at the scale of the country ( /Europe/Italy/*) or the scale of the entire continent ( /*), Regular expressions can be used to specify the scopes .

The subATC program will create one subscriber to get all the data corresponding to the view you are building using the DDS concept of Partition.

The subATC program takes at most one argument. This argument specifies the absolute name of the region i.e “/<Continent>/<Country>/<Region>”

Both programs use the default DDS QoS but the PartitionQoS.

The example helps you understand the concept of partition in DDS and how it can be used to creates different views on the data or split the dds domain in smaller logical groups .

# Building the examples

cmake <CycloneDDS_Cpp_Dir>/examples/ATC

cmake --build .

# Running the examples

It is recommended to run one Publishing program ( pubATC) and several Subscribing programs in different terminals .

**Scenario1** : Subscribing to all the flights to have a global view on all the flights

\> ./pubATC

\>./subATC “*”

**Scenario2** : Gross grain Subscription, subscribe to an entire country view

\> ./pubATC

\>./subATC /Europe/Netherlands/*

**Scenario3** : Fine grain Subscription, subscribe to a give region

\> ./pubATC

\>./subATC /Europe/Netherlands/Zeeland




Binary file added examples/ATC/ReadMe.pdf
Binary file not shown.
Binary file added examples/ATC/clip_image002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
149 changes: 149 additions & 0 deletions examples/ATC/publisher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/* CycloneDDS isoC++ example
*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*
*/

#include <iostream>
#include "dds/dds.hpp"
#include "dds/core/ddscore.hpp"
#include "ATCDataModel_DCPS.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RamziKaroui may you can update the source code too for the current master. There is no _DCPS anymore.
And no need to include dds/core/ddscore, its already included in dds/dds.hpp


int main(int argc, char *argv[]) {

std::cout << "Cyclone- ATC Pub" << std::endl;

/** A dds::domain::DomainParticipant is created for the default domain. */
dds::domain::DomainParticipant dp(0);
dds::topic::qos::TopicQos topicQos= dp.default_topic_qos();

/** A dds::topic::Topic is created for our sample type on the domain participant. */
dds::topic::Topic<ATCDataModule::Flight> topic(dp, "FlightData", topicQos);

/** 5 dds Publishers are associated to 5 different partitions. */
dds::pub::qos::PublisherQos PubGotalandQoS = dp.default_publisher_qos();
dds::pub::qos::PublisherQos PubSardegnaQoS = dp.default_publisher_qos();
dds::pub::qos::PublisherQos PubNorrlandQoS = dp.default_publisher_qos();
dds::pub::qos::PublisherQos PubLombardiaQoS = dp.default_publisher_qos();
dds::pub::qos::PublisherQos pubSiciliaQoS = dp.default_publisher_qos();

dds::pub::qos::PublisherQos pubZeelandQoS = dp.default_publisher_qos();
dds::pub::qos::PublisherQos pubDrentheQoS = dp.default_publisher_qos();

PubGotalandQoS << dds::core::policy::Partition("/Europe/Sweden/Gotaland");
PubNorrlandQoS << dds::core::policy::Partition("/Europe/Sweden/Norrland");
PubSardegnaQoS << dds::core::policy::Partition("/Europe/Italy/Sardegna");
PubLombardiaQoS << dds::core::policy::Partition("/Europe/Italy/Lombardia");
pubSiciliaQoS << dds::core::policy::Partition("/Europe/Italy/Sicilia");
pubZeelandQoS << dds::core::policy::Partition("/Europe/Netherlands/Zeeland");
pubDrentheQoS << dds::core::policy::Partition("/Europe/Netherlands/Drenthe");

dds::pub::Publisher pubGotaland(dp, PubGotalandQoS);
dds::pub::Publisher pubNorrland(dp, PubNorrlandQoS);
dds::pub::Publisher pubSardegna(dp, PubSardegnaQoS);
dds::pub::Publisher pubLombardia(dp, PubLombardiaQoS);
dds::pub::Publisher pubSicilia(dp, pubSiciliaQoS);
dds::pub::Publisher pubZeeland(dp, pubZeelandQoS);
dds::pub::Publisher pubDrenthe(dp, pubDrentheQoS);

/** A dds::pub::DataWriter is created on the Publisher & Topic with the associated Partition Qos. */
dds::pub::qos::DataWriterQos dwqos = topic.qos();

dds::pub::DataWriter<ATCDataModule::Flight> dwGotaland(pubGotaland, topic, dwqos);
dds::pub::DataWriter<ATCDataModule::Flight> dwNorrland(pubNorrland, topic, dwqos);
dds::pub::DataWriter<ATCDataModule::Flight> dwSardegna(pubSardegna, topic, dwqos);
dds::pub::DataWriter<ATCDataModule::Flight> dwLombardia(pubLombardia, topic, dwqos);
dds::pub::DataWriter<ATCDataModule::Flight> dwsicilia(pubSicilia, topic, dwqos);
dds::pub::DataWriter<ATCDataModule::Flight> dwzeeland(pubZeeland, topic, dwqos);
dds::pub::DataWriter<ATCDataModule::Flight> dwdrenthe(pubDrenthe, topic, dwqos);

// std::cout << "@ With ddsi, Let the Apps discover each other a bit ZZZzzz:" << std::endl;
//dds_sleepfor (DDS_MSECS (5000));

std::cout << "===> Waiting for a subscriber. " << std::endl;
while (dwdrenthe.publication_matched_status().current_count() == 0 &&
dwzeeland.publication_matched_status().current_count() == 0 &&
dwsicilia.publication_matched_status().current_count() == 0 &&
dwLombardia.publication_matched_status().current_count() == 0 &&
dwSardegna.publication_matched_status().current_count() == 0 &&
dwNorrland.publication_matched_status().current_count() == 0 &&
dwGotaland.publication_matched_status().current_count() == 0
)
{
dds_sleepfor (DDS_MSECS (20));
}
std::cout << "===> Found a matching one ... " << std::endl;

for (int i = 0; i < 5; i++) {
ATCDataModule::Position p1(i+800, i+20, i+93 );
ATCDataModule::Flight FlightInstance(i, p1,"** /Europe/Sweden/Gotaland partition ** ");
dwGotaland << FlightInstance;
std::cout << "=> [Radar Simulator] detecting FlightID: "<< FlightInstance.ID() << " in the /Europe/Sweden/Gotaland Region " << std::endl;

dds_sleepfor (DDS_MSECS (500));
}

for (int i = 5; i < 10; i++) {
ATCDataModule::Position p2(i+7900, i+20, i+93 );
ATCDataModule::Flight FlightInstance(i, p2, "** /Europe/Sweden/Norrland partition ++");
dwNorrland << FlightInstance;
std::cout << "=> [Radar Simulator] detecting FlightID: "<< FlightInstance.ID() << " in the /Europe/Sweden/Norrland Region " << std::endl;

dds_sleepfor (DDS_MSECS (500));
}

for (int i = 10; i < 15; i++) {
ATCDataModule::Position p3(i+800, i+20, i+93 );
ATCDataModule::Flight FlightInstance(i, p3, "** /Europe/Italy/Sardegna partition &&");
dwSardegna << FlightInstance;
std::cout << "=> [Radar Simulator] detecting FlightID: "<< FlightInstance.ID() << " in the /Europe/Italy/Sardegna Region " << std::endl;

dds_sleepfor (DDS_MSECS (500));
}

for (int i = 15; i < 20; i++) {
ATCDataModule::Position p4(i+99, i+97, i+93 );
ATCDataModule::Flight FlightInstance(i, p4, "** /Europe/Italy/Lombardia partition %%");
dwLombardia << FlightInstance;
std::cout << "=> [Radar Simulator] detecting FlightID: "<< FlightInstance.ID() << " in the /Europe/Italy/Lombardia Region " << std::endl;

dds_sleepfor (DDS_MSECS (500));
}

for (int i = 20; i < 25; i++) {
ATCDataModule::Position p5(i+242, i+240, i+930 );
ATCDataModule::Flight FlightInstance(i,p5, "** /Europe/Italy/Sicilia partition $$");
dwsicilia << FlightInstance;
std::cout << "=> [Radar Simulator] detecting FlightID: "<< FlightInstance.ID() << " in the /Europe/Italy/Sicilia Region " << std::endl;

dds_sleepfor (DDS_MSECS (500));
}

for (int i = 25; i < 30; i++) {
ATCDataModule::Position p6(i+22, i+20, i+930 );
ATCDataModule::Flight FlightInstance(i,p6, "** /Europe/Netherlands/Zeeland partition &&");
dwzeeland << FlightInstance;
std::cout << "=> [Radar Simulator] detecting FlightID: "<< FlightInstance.ID() << " in the /Europe/Netherlands/Zeeland Region " << std::endl;

dds_sleepfor (DDS_MSECS (500));
}

for (int i = 30; i < 35; i++) {
ATCDataModule::Position p7(i+22, i+20, i+930 );
ATCDataModule::Flight FlightInstance(i,p7, "** /Europe/Netherlands/Drenthe partition &&");
dwdrenthe << FlightInstance;
std::cout << "=> [Radar Simulator] detecting FlightID: "<< FlightInstance.ID() << " in the /Europe/Netherlands/Drenthe Region " << std::endl;

dds_sleepfor (DDS_MSECS (500));
}


dds_sleepfor (DDS_MSECS (5000));
return 0;
}

Loading