3. Tutorials
This chapter describes several examples, all of which require a Project. You can create your own Project by following Section 2.2.
3.1. Defining Your Data Type
This example shows how to define your own data type using System Designer. In this example, we are going to create the ShapeTypeExtended data type used by the Shapes Demo:
enum ShapeFillKind {
SOLID_FILL,
TRANSPARENT_FILL,
HORIZONTAL_HATCH_FILL,
VERTICAL_HATCH_FILL
};
@appendable
struct ShapeType
{
string<128> color; //@key
int32 x;
int32 y;
int32 shapesize;
};
@appendable
struct ShapeTypeExtended : ShapeType {
ShapeFillKind fillKind;
float angle;
};
Create a new project (see Section 2.2), name it ShapesDemo, and click OK.
Go to the Types View. By default it should be the first view shown by System Designer.
Add an enumeration by right-clicking on Types and selecting Add Enumeration… Name your enumeration ShapeFillKind and click OK.
Right-click on the recently created enum and select Add Member… to start adding each one of the following four enumerator value names: SOLID_FILL, TRANSPARENT_FILL, HORIZONTAL_HATCH_FILL, and VERTICAL_HATCH_FILL. You can leave the Value blank and @default_literal unchecked.
Create a struct and name it ShapeType by right-clicking on Types and selecting Add Struct… Select APPENDABLE as its @extensibility value and click OK. Fill the struct, adding each member by right-clicking on the struct and selecting Add Member…:
Add a bounded (128) string named color. This element will be the key of our type, so select the @key checkbox. (You can accept the other defaults in this window.)
Add three int32 named x, y and shapesize. See Working with Types.
Create a second struct and name it ShapeTypeExtended. Choose ShapeType as its base type. Add its elements by right-clicking on the struct and selecting Add Member…:
Add a ShapeFillKind enumerator named fillKind.
Add a float32 named angle.
When the type definition is complete, you can download the IDL by clicking on the Download IDL button in the IDL view.
![Downloading idl](_images/download_idl.png)
Now you have an IDL file to use to create your own Shapes Demo application.
3.2. Defining an XML Application Creation Configuration File
This example shows how to define an XML configuration file using System Designer. In this example, we are going to create the same configuration file used by the hello_world_xml_dynamic example.
For more information about XML-Based Application Creation, see the RTI Connext DDS Core Libraries XML-Based Application Creation Getting Started Guide.
Create a new XML file inside the open Project by clicking the Files icon at the top and selecting New… You can use the same project as you used in the previous tutorial, or a new project. Name the file USER_QOS_PROFILES.xml. Click OK.
Note
If you see a default XML file already associated with the project, that’s because you kept the default selection, “Automatically create an empty XML file” when you created the project. You can still create USER_QOS_PROFILES.xml, it will not replace the default one.
Go to the Types View. By default it should be the first view shown by System Designer.
Add two constants (right-click Types > Add Constant…) as follows:
Name ‘MAX_NAME_LEN’, Type ‘int32’, value 64, File USER_QOS_PROFILES.xml
Name ‘MAX_MSG_LEN’, Type ‘int32’, value 128, File USER_QOS_PROFILES.xml
Create a struct (right-click Types > Add Struct…) and name it HelloWorld. Fill the struct by adding each of the following members (right-click on the struct and select Add Member…):
Add a bounded string named sender with a maximum length of MAX_NAME_LEN. (For this and the following members, you can accept the defaults in the window.)
Add a second bounded string named message with a maximum length of MAX_MSG_LEN.
Add an int32 named count.
Click the XML view to view how your data type definition looks in XML:
Define the QoS that the application is going to use by clicking on the QoS view. Since we are creating the same XML file as the hello_world_xml_dynamic example has, to match the content of that file you only need to add a new QoS Library named qosLibrary and a QoS Profile named DefaultProfile inside the created libray. (You do not have to select any of the checkboxes.)
In the XML view, your QoS Profile should look like this:
Now that the QoS has been defined, define the system’s Topic and its corresponding data types, first by defining the Domain:
In the Domain view, right-click on Domain Libraries and select Add Library. Name your domain MyDomainLibrary and click OK.
Note
If your project contains more than one XML file, select the USER_QOS_PROFILES.xml file.
Add a domain to your library by right-clicking MyDomainLibrary and selecting Add Domain. Name it HelloWorldDomain, entering 0 as its Domain Id.
Select HelloWorldDomain and click the Add button to add a registered type. Name the type HelloWorldType, selecting the ‘HelloWorld’ struct that we created previously as its type reference.
In the Topics panel, click the Add button to add a topic named HelloWorldTopic, selecting the ‘HelloWorldType’ registered type as its registered type reference.
In the XML view, your domain configuration should look like this:
Define the elements that are going to be part of our system by clicking on the Participant view. In this example, we are going to create a simple application containing one DomainParticipant, one Publisher, one Subscriber, one DataReader, and one DataWriter.
Add a new Participant Library, naming it MyParticipantLibrary. Add a Participant inside that library named PublicationParticipant, selecting the previously created ‘MyDomainLibrary::HelloWorldDomain’ as its domain reference.
Note
If your project contains more than one XML file, select the USER_QOS_PROFILES.xml file.
Click the Add button to add a publisher named MyPublisher.
Click the Add button to add a DataWriter named HelloWorldWriter selecting ‘HelloWorldTopic’ as its topic reference.
Add a second Participant inside that library named SubscriptionParticipant, selecting the previously created ‘MyDomainLibrary::HelloWorldDomain’ as its domain reference.
Click Subscriptions and add a subscriber named MySubscriber.
Add a DataReader named HelloWorldReader, selecting ‘HelloWorldTopic’ as its topic reference. Unlike for the DataWriter, for the DataReader we are going to select the QoS profile that we created earlier, named ‘DefaultProfile’ (in the Default QoS): click on View/Edit inside the DataReader dialog and name the QoS Profile HelloWorld_reader_qos. Select ‘qosLibrary::DefaultProfile’ as its Base QoS.
Your XML view should look like this:
You can use this XML file to define your Connext DDS system using XML-Based Application Creation.
3.3. Defining a Routing Service Configuration File
This example shows how to define a Routing Service configuration file using System Designer. In this example, we are going to create the same configuration file used by the first example in the Routing Service Tutorial, see Routing a single specific Topic in the RTI Routing Service User’s Manual.
For more information about the Routing Service configuration file, see the Configuration Section of the RTI Routing Service User’s Manual.
Create a new XML file inside the open project by clicking the Files icon at the top and selecting New… You can use the same project as you used in the previous Tutorials, or a new project. Name the file rti_rs_example_square_topic.xml. Click OK.
Note
If you see a default XML file already associated with the project, that’s because you kept the default selection, “Automatically create an empty XML file” when you created the project. You can still create rti_rs_example_square_topic.xml, it will not replace the default one.
Go to the Routing Services View.
Right-click on Routing Services and select Add Routing Service. Name your service SquareRouter and click OK. System Designer will automatically select and open the newly created service.
Add a Domain Route (right-click on the ‘SquareRouter’ service or click on the
in the Domain Routes table) and name it DomainRoute.
Add two Participants to the newly created Domain Route (right-click on the ‘DomainRoute’ Domain Route and select Add Participant or click on the
in the Connections, Participants & Session table and select Participant).
Name the first Participant domain0 and set the Domain id to 0.
Name the second Participant domain1 and set the Domain id to 1.
Add a Session to the ‘DomainRoute’ Domain Route (right-click on the ‘DomainRoute’ Domain Route and select Add Session or click on the
in the Connections, Participants & Session table and select Session) and name it Session.
Add a Topic Route to the ‘Session’ Session (right-click on the ‘Session’ Session and select Add Topic Route or click on the
in the Routes & AutoRoutes table and select Topic Route) and name it RouteSquare.
Add an Input to the ‘RouteSquare’ Topic Route (right-click on the ‘RouteSquare’ Topic Route and select Add Input or click on the
in the Input & Output table and select Input).
Set the Participant to domain0.
Set the Topic name to Square.
Set the Registered type name to ShapeType.
Add an Output to the ‘RouteSquare’ Topic Route (right-click on the ‘RouteSquare’ Topic Route and select Add Output or click on the
in the Input & Output table and select Output).
Set the Participant to domain1.
Set the Topic name to Square.
Set the Registered type name to ShapeType.
Your XML view should look like this:
You can use this XML file to route the samples for the Topic Square from domain 0 to 1 following the Routing a single specific Topic in the RTI Routing Service User’s Manual example in the Routing Service Tutorial.