Skip to content

Commit 8bd4791

Browse files
authored
Merge pull request #649 from rticommunity/master
Merge master into develop
2 parents 9c17623 + 6af11b1 commit 8bd4791

File tree

13 files changed

+629
-14
lines changed

13 files changed

+629
-14
lines changed

examples/connext_dds/distributed_logger/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ For example, you may find RTI Spy in your RTI Connext DDS installation
2323
and run it from a terminal as follows:
2424

2525
```sh
26-
cd rti_connext_dds-7.2.0/bin
27-
./rtiddsspy -printSample
26+
<install dir>/bin/rtiddsspy -printSample
2827
```
2928

3029
Once the Distributed Logger example is running in a different terminal,

examples/connext_dds/distributed_logger/c++11/DistLoggerExample.cxx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ void distlogger_example_main(
4141
// Instantiate Distributed Logger
4242
DistLogger dist_logger = DistLogger::get_instance();
4343

44-
// RTI Distributed Logger provides the ability to interact with its
45-
// topics directly. However, for the sake of simplicity in this example,
46-
// you may use RTI Tools such as RTI Spy or RTI Admin Console to visualize
47-
// the logging.
44+
45+
// The log messages are published as DDS topics, which allows your DDS
46+
// applications to subscribe to them. You can also run rtiddsspy or
47+
// RTI Admin Console to visualize the logs.
4848
for (uint i = 1; i <= iterations; ++i) {
4949
cout << "\nIteration #" << i << endl;
5050

51-
// Log messages using the appropiate log levels for your messages.
5251
dist_logger.debug("This is a debug message");
5352
dist_logger.warning("This is a warning message");
5453
dist_logger.error("This is an error message");

examples/connext_dds/distributed_logger/c++11/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@ on the terminal.
114114
### Visualizing the log messages
115115

116116
Once the example application is running, open RTI Spy or
117-
RTI Admin Console.
118-
You should be able to visualize the logging messages being sent
119-
by the application.
120-
121-
To learn more about RTI Tools, refer to their section in the
122-
[Connext DDS documentation](https://community.rti.com/documentation).
117+
RTI Admin Console as described in the top-level [README](../README.md) file.
123118

124119
## Customizing the Build
125120

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Example Code: Python Distributed Logger Application
2+
3+
See the example description in the top-level [README](../README.md) file.
4+
5+
## Running the Example
6+
7+
### Example Application
8+
9+
Run the application in a terminal as follows:
10+
11+
```sh
12+
python dist_logger_example.py [options]
13+
```
14+
15+
Run with ``--help`` to see the available options.
16+
17+
You should see the messages that are being logged on each iteration printed
18+
on the terminal.
19+
20+
### Visualizing the log messages
21+
22+
Once the example application is running, open RTI Spy or
23+
RTI Admin Console as described in the top-level [README](../README.md) file.
24+
25+
You should be able to visualize the logging messages being sent
26+
by the application.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# (c) 2024 Copyright, Real-Time Innovations, Inc. All rights reserved.
3+
#
4+
# RTI grants Licensee a license to use, modify, compile, and create derivative
5+
# works of the Software solely for use with RTI products. The Software is
6+
# provided "as is", with no warranty of any type, including any warranty for
7+
# fitness for any purpose. RTI is under no obligation to maintain or support
8+
# the Software. RTI shall not be liable for any incidental or consequential
9+
# damages arising out of the use or inability to use the software.
10+
#
11+
12+
import time
13+
import argparse
14+
import rti.connextdds as dds
15+
import rti.logging.distlog as distlog
16+
17+
18+
def distlogger_example(application_kind, domain_id, sleep, iterations):
19+
# First, create the options to personalize Distributed Logger.
20+
# If no options are provided, default ones will be created.
21+
options = distlog.LoggerOptions()
22+
options.domain_id = domain_id
23+
options.application_kind = application_kind
24+
25+
# Then, set the created options. The method init must be called before
26+
# using the Logger instance.
27+
distlog.Logger.init(options)
28+
29+
# The log messages are published as DDS topics, which allows your DDS
30+
# applications to subscribe to them. You can also run rtiddsspy or
31+
# RTI Admin Console to visualize the logs.
32+
for i in range(1, iterations + 1):
33+
print(f"\nIteration #{i}")
34+
35+
distlog.Logger.debug("This is a debug message")
36+
distlog.Logger.warning("This is a warning message")
37+
distlog.Logger.error("This is an error message")
38+
39+
time.sleep(sleep)
40+
41+
distlog.Logger.finalize()
42+
43+
44+
def main():
45+
# Parse command line arguments
46+
parser = argparse.ArgumentParser()
47+
parser.add_argument(
48+
"-d", "--domain_id", type=int, default=0, help="Domain ID (default: 0)"
49+
)
50+
parser.add_argument(
51+
"-s",
52+
"--sleep",
53+
type=int,
54+
default=1,
55+
help="Seconds between iterations (default: 1)",
56+
)
57+
parser.add_argument(
58+
"-i",
59+
"--iterations",
60+
type=int,
61+
default=50,
62+
help="Number of iterations (default: 50)",
63+
)
64+
args = parser.parse_args()
65+
66+
try:
67+
distlogger_example(
68+
"Python Distributed Logger Example",
69+
args.domain_id,
70+
args.sleep,
71+
args.iterations,
72+
)
73+
except Exception as ex:
74+
print(f"Exception in distlogger_example: {ex}")
75+
76+
dds.DomainParticipant.finalize_participant_factory()
77+
78+
79+
if __name__ == "__main__":
80+
main()

examples/connext_dds/keyed_data_advanced/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This is a second example that shows some advanced concepts related to keyed
66
data. As this example builds on [*Keyed
7-
Data*](https://github.com/rticommunity/rticonnextdds-examples/tree/master/examples/keyed_data)
7+
Data*](https://github.com/rticommunity/rticonnextdds-examples/tree/master/examples/connext_dds/keyed_data)
88
example, it is advisable to understand that example before investigating this
99
one.
1010

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0"?>
2+
3+
<!-- (c) Copyright, Real-Time Innovations, 2024. All rights reserved.
4+
RTI grants Licensee a license to use, modify, compile, and create derivative
5+
works of the software solely for use with RTI Connext DDS. Licensee may
6+
redistribute copies of the software provided that all such copies are subject
7+
to this license. The software is provided "as is", with no warranty of any
8+
type, including any warranty for fitness for any purpose. RTI is under no
9+
obligation to maintain or support the software. RTI shall not be liable for
10+
any incidental or consequential damages arising out of the use or inability
11+
to use the software. -->
12+
13+
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://community.rti.com/schema/7.2.0/rti_cloud_discovery_service.xsd">
14+
15+
<cloud_discovery_service name="cds_all_domains_udpv4">
16+
<annotation>
17+
<documentation><![CDATA[
18+
Forwards all domains using built-in UDPv4 transport.
19+
]]>
20+
</documentation>
21+
</annotation>
22+
23+
<transport>
24+
<element>
25+
<alias>udpv4</alias>
26+
<receive_port>$(CDS_PORT)</receive_port>
27+
</element>
28+
</transport>
29+
30+
</cloud_discovery_service>
31+
</dds>
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Shared Memory / UDP Gateway
2+
3+
This example contains the necessary files to run the RTI Routing Service
4+
example from the "Breaking through Hospital IT Silos: The Top 3 Challenges
5+
to Overcome" blogpost. Routing Service (RS) will help us interfacing
6+
between the shared memory domain and the UDP domain. Applications local to a
7+
host will communicate with each other over SHMEM. RS will be the gateway for
8+
communication between local and remote applications. For this, RS will create
9+
a SHMEM DP (no UDP ports) and a UDP DP (with the 3 default UDP ports). If
10+
multicast is disabled, it will only open 2 UDP ports.
11+
12+
In this example, you will use RTI DDS Ping as a pub/sub example application.
13+
Along with, Routing Service you will be able to create a gateway between a
14+
Shared Memory domain and a UDP domain that uses only 3 ports. There is also a
15+
second configuration option using RTI Cloud Discovery Service to use Unicast.
16+
17+
## Environment variables
18+
19+
For your convenience, there are 2 scripts to set up environment variables:
20+
21+
- Linux: *variables.sh*
22+
- Windows: *variables.bat*
23+
24+
These are the variables they contain, which you should modify according to your
25+
system:
26+
27+
- **NDDSHOME**: path to the installation of RTI Connext Professional.
28+
- **NDDS_QOS_PROFILES**: path to the *qos.xml* file containing QoS profiles.
29+
- **SHMEM_DOMAIN**: the domain for the applications using SHMEM.
30+
- **UDP_DOMAIN**: the domain for the applications using UDP (mainly the
31+
DomainParticipant of RTI Routing Service).
32+
- **APPS**: total number of DomainParticipants on the localhost. By default,
33+
Connext will try to reach out to the first 5 created applications on SHMEM,
34+
therefore, we need to increase that number if there are more than 5
35+
applications.
36+
- **CDS_IP_ADDRESS**: the IP address of the host that contains RTI Cloud
37+
Discovery Service.
38+
- **CDS_PORT**: the UDP port that CDS will use.
39+
40+
On Linux, you can use the environment variables by sourcing the file:
41+
42+
```bash
43+
source variables.sh
44+
```
45+
46+
On Windows, simply run it:
47+
48+
```bash
49+
> variables.bat
50+
```
51+
52+
For convenience, the rest of the README will use the Linux variable sign ($)
53+
instead of the Windows variable signs (%%).
54+
55+
## Multicast example
56+
57+
You will need 3 terminals to run this example.
58+
59+
1. On terminal 1, source the variables script and run an RTI DDS Ping
60+
publisher on SHMEM acting as a local publisher:
61+
62+
```bash
63+
source variables.sh
64+
$NDDSHOME/bin/rtiddsping -pub -domain $SHMEM_DOMAIN -qosProfile "example_library::shmem_profile"
65+
```
66+
67+
2. On terminal 2, source the variables script and run an RTI DDS Ping
68+
subscriber on UDP acting as a remote subscriber:
69+
70+
```bash
71+
source variables.sh
72+
$NDDSHOME/bin/rtiddsping -sub -domain $UDP_DOMAIN -qosProfile "example_library::multicast"
73+
```
74+
75+
3. At this point, there should be no communication between both applications.
76+
They are on different domains and they're using different transports.
77+
On terminal 3, on the same host as the SHMEM application,
78+
source the variables script and start Routing Service:
79+
80+
```bash
81+
source variables.sh
82+
$NDDSHOME/bin/rtiroutingservice -cfgFile RS_config_multicast.xml -cfgName gateway_SHMEM_and_UDP
83+
```
84+
85+
4. The subscriber should now be receiving data. For instance:
86+
87+
```bash
88+
...
89+
Current alive publisher tally is: 1
90+
rtiddsping, issue received: 0000002
91+
rtiddsping, issue received: 0000003
92+
rtiddsping, issue received: 0000004
93+
rtiddsping, issue received: 0000005
94+
...
95+
```
96+
97+
5. (Optional) Feel free to explore the QoS and RS config files. The relevant
98+
QoS profiles for this example are *shmem_profile* and *multicast*. The RS file
99+
contains a *domain_route* with 2 DPs. 1 for UDP and another one for SHMEM
100+
(configured through the DP QoS). It also contains 2 *auto_topic_route* tags
101+
that allow the traffic to flow in the SHMEM --> UDP and SHMEM <-- UDP
102+
directions. In a real scenario, there would most likely be more topic routes,
103+
because different topics will require different DW / DR QoS policies.
104+
105+
6. (Optional) You can run Wireshark and capture data to verify that the
106+
traffic only goes to the 3 different ports that Routing Service opens:
107+
Multicast discovery, Unicast discovery and Unicast user-data. Which ports are
108+
actually in use will depend on the domain ID you use for UDP and whether you
109+
started the RTI DDS Ping application on the same machine as Routing Service or
110+
not. Remember you can check the ports in use on this [spreadsheet](https://d2vkrkwbbxbylk.cloudfront.net/sites/default/files/knowledge_base/Port%20Assign4.2e.xls).
111+
112+
6. You can now shutdown the 3 applications with Ctrl+C.
113+
114+
## Multicast-less example (CDS)
115+
116+
You will need 3 terminals to run this example.
117+
118+
1. On terminal 1, source the variables script and run an RTI DDS Ping
119+
publisher on SHMEM acting as a local publisher:
120+
121+
```bash
122+
source variables.sh
123+
$NDDSHOME/bin/rtiddsping -pub -domain $SHMEM_DOMAIN -qosProfile "example_library::shmem_profile"
124+
```
125+
126+
2. Install the CDS package. For instance: *rti_cloud_discovery_service-7.2.0-host-x64Linux.rtipkg*
127+
128+
3. On terminal 2, source the variables script and start CDS:
129+
130+
```bash
131+
$NDDSHOME/bin/rticlouddiscoveryservice -cfgFile CDS_config.xml -cfgName cds_all_domains_udpv4
132+
```
133+
134+
4. On terminal 3, source the variables script and run an RTI DDS Ping
135+
subscriber on UDP acting as a remote subscriber:
136+
137+
```bash
138+
source variables.sh
139+
$NDDSHOME/bin/rtiddsping -sub -domain $UDP_DOMAIN -qosProfile "example_library::no_multicast"
140+
```
141+
142+
5. At this point, there should be no communication between both applications.
143+
They are on different domains and they're using different transports. On
144+
terminal 4, on the same host as the SHMEM application, source the variables
145+
script and start Routing Service:
146+
147+
```bash
148+
source variables.sh
149+
$NDDSHOME/bin/rtiroutingservice -cfgFile RS_config_with_CDS.xml -cfgName gateway_SHMEM_and_UDP
150+
```
151+
152+
6. The subscriber should now be receiving data. For instance:
153+
154+
```bash
155+
...
156+
Current alive publisher tally is: 1
157+
rtiddsping, issue received: 0000002
158+
rtiddsping, issue received: 0000003
159+
rtiddsping, issue received: 0000004
160+
rtiddsping, issue received: 0000005
161+
...
162+
```
163+
164+
7. (Optional) Feel free to explore the QoS and RS config files. The relevant
165+
QoS profiles for this example are *shmem_profile* and *no_multicast*. The RS
166+
file contains a *domain_route* with 2 DPs. 1 for UDP and another one for SHMEM
167+
(configured through the DP QoS). It also contains 2 *auto_topic_route* tags
168+
that allow the traffic to flow in the SHMEM --> UDP and SHMEM <-- UDP
169+
directions. In a real scenario, there would most likely be more topic routes,
170+
because different topics will require different DW / DR QoS policies.
171+
172+
8. (Optional) You can run Wireshark and capture data to verify that the
173+
traffic only goes to the 2 different ports that Routing Service opens: Unicast
174+
discovery and Unicast user-data. Which ports are actually in use will depend
175+
on the domain ID you use for UDP and whether you started the RTI DDS Ping
176+
application on the same machine as Routing Service or not. Remember you can
177+
check the ports in use on this [spreadsheet](https://d2vkrkwbbxbylk.cloudfront.net/sites/default/files/knowledge_base/Port%20Assign4.2e.xls).
178+
179+
8. You can now shutdown the 4 applications with Ctrl+C.

0 commit comments

Comments
 (0)