An example showing how to compose independently developed services into arbitrary deployment components.
The example uses the data types and topics used by the RTI Shapes Demo.
The example defines three services, each comprising of two interfaces.
- 
Squareservice: comprising of an interface for publication of squares, and an interface for subscription of squares- if/Square.xml: the service interfaces
 
- 
Circleservice: comprising of an interface for publication of circles, and an interface for subscription of circles- if/Circle.xml: the service interfaces
 
- 
Triangleservice: comprising of an interface for publication of triangles, and an interface for subscription of triangles- if/Triangle.xml: the service interfaces
 
Services can be composed to define new components. In this example, several
components are defined by composing the above services, located in the
directory run/.
- square_pub.sh: a component that implements the- Squarepublication service
- triangle_sub.sh: a component that implements the- Trianglesubscription service
- circle_pub_triangle_pub.sh: a component that implements the- Circlepublication service and the- Trianglepublication service
- square_sub_circle_sub.sh: a component that implements the- Squaresubscription service and the- Circlesubscription service
- square_pub_sub.sh: a component that implements the- Squarepublication service and the- Squaresubscription service
A component definition can be implemented in the programming language of choice. The example shows component implementations in C++11 and Lua.
- src/c++11/shapes: component implementations in C++11
- src/lua/shapes: component implementations in Lua
The RTI Shapes Demo can be used to visualize the data produced by the services, and to feed data into the services.
The directory structure and organization of the artifacts is described in the section Organization.
- 
Define the data types used by the service 1.1 Add the data types to the directory: res/types/For an example, look at res/types/ShapeType.idl.1.2 For data types defined in IDL, use rtiddsgen -convertToXmlto generate the equivalent XML representation.cd res/types/ make
- 
Define a new service interface: MyService2.1 Add a file res/qos/services/MyService_qos.xmlby cloning the templateres/template/TEMPLATE_MyService_qos.xml.2.2 Define all the service end-point qos policies. Use a topic_filter to specify per topic DataWriter and DataReader Qos. Reuse the common qos policy libraries defined in res/qos/common/, and expand those common libraries if appropriate. For an example, look atres/qos/services/Square_qos.xml.2.2 Add a file if/MyService.xmlby cloning the template res/template/TEMPLATE_MyService.xml.2.3 Define all the service interface(s). For an example, look at if/Square.xml 2.4 Ensure that the service interfaces are using the service qos profile for all DataWriter, DataReader, Publisher, and Subscriber entities. 
- 
Implement the service MyService
Implement the service in the programming language of choice. This example illustrates implementations in C++11 and Lua.
- 
src/c+11/shapes/: C++11 implementation- Service_publisher[.hpp|cxx]implements the publication interface
- Service_subscriber[.hpp|cxx]implements the subscription interface
 
- 
src/c+lua/shapes/: Lua implementation (using rtiddsprototyper)- ServicePublisher.luaimplements the publication interface
- ServiceSubscriber.luaimplements the subscription interface
 
- 
Define a new component: MyComponent4.1 Add a file run/MyComponent.shby cloning the template res/template/TEMPLATE_MyComponent.sh.4.2 Name the component: NAME_Component4.3 Define the service composition: - BASE_NAME_Component
- Continue defining BASE_NAME_<Service>, until you reachDeploymentIfLib::Component_Root
 For an example, look at: run/square_pub_sub.sh 4.4 Add a file res/qos/components/MyComponent_qos.xmlby cloning the templateres/template/TEMPLATE_MyComponent_qos.xml.4.5 Define the component deployment qos policies. For an example look at res/qos/components/deployment.xmlNOTE: Since the composition is by inheritance, the publisher and subscriber entities are not shared between the service interfaces. 
- 
Implement the component MyComponent
Implement the component in the programming language of choice. This example illustrates implementations in C++11 and Lua.
- 
src/c+11/shapes/: C++11 implementation- Component_square_pub.cxxcomposed of the square publication service
- Component_triangle_sub.cxxcomposed of the triangle publication service
- Component_circle_pub_triangle_pub.cxxcomposed of the circle publication service and the triangle publication service
- Component_square_sub_circle_sub.cxxcomposed of the square subscription service and the triangle subscription service
- Component_square_pub_sub.cxxcomposed of the square publication service and the square subscription service
 
- 
src/lua/: Lua implementation (using rtiddsprototyper)- Endpoints.luageneric component thats simply enumerates the endpoints of a components and exits; it is the default component that runs if an executable or lua script is not specified in the component launcher command line
 
Generate the platform specific makefile (per platform)
cd src/c++11/shapes/
make makefile/x64Darwin17clang9.0  # look at $NDDSHOME/lib for choices
Build components:
cd src/c++11/shapes/
make
Clean components:
cd src/c++11/shapes/
make clean                        # as needed
To run a component, use its launcher script MyComponent.sh:
./bin/MyComponent.sh [<domain_id> [<path_to_executable_or_lua_script>] [project_dir]]
The component's launcher script sets up the correct environment for running the component.
The [project_dir] is only needed if the launcher script is
not located in the standard location under the run/ directory. The
[project_dir] should contain the hierarchy with the relevant files:
[project_dir]/
	if/
	res/
		types/
		qos/
The [<path_to_executable_or_lua_script>] specifies the component implementation.
- A value ending in .luais launched as a lua script within thertiddsprototyper.
- Otherwise, it is launched as the component executable. E.g. MyComponent[.exe],rtiroutingservice[.exe],bash
Thus,
- 
To run rtiroutingservicewith the component's environment:./bin/MyComponent.sh <domain_id> <rtiroutingservice> [project_dir]
- 
To launch a shell with the component's environment: ./bin/MyComponent.sh <domain_id> bash [project_dir]
- 
See Demo for examples 
Author: Rajive Joshi, Real-Time Innovations Inc. Copyright (C) 2017.