RE: Two way communication

 

Hello,

 

 

I have a question regarding the following implementation:

 

 

Suppose I have a node, which I want it to be able to receive and send data. Do I need two separate .cs files (I am programming in C#) where in one .cs file, I type the code required for sending data (data writer / publisher etc) and in another .cs file, I type the code required for receiving data (data reader / subscriber etc) or can I include the code required for publishing / subscribing for that node in just one .cs file ?

RE: Two way communication

 

Hi,

the answer is yes. You can have datareader and datawriter in the same file.Not only in C# but also in all the other supported languages.

You don't have to duplicate all the code, you can share some entities (eg. the domain participant doesn't have to be created twice). You can actually have a look at the example shipped with RTI DDS: example/CSHARP/Hello_simple. 

In that example the publisher and the subscriber are used depending on a cmd line parameter. But you can have them "alive" in the same process. Just as an example: you can create a subscriber and install a listener and then you can have your datawriter that writes sample: everything in the same process. 

The only things you should be careful is when you call restricted operation in listeners callback. From the RTI_DDS_UsersManual:

 

By default, each Publisher and Subscriber creates and uses its own EA, and shares it with

its children DataWriters and DataReaders, respectively. In that case: Within a DataWriter/DataReader’s Listener callback, do not:

create any entities delete any entities enable any entities set QoS’s on any entities

Within a Subscriber/DataReader’s Listener callback, do not call any operations on:

Other Subscribers

DataReaders that belong to other Subscribers

Publishers/DataWriters that have been configured to use the ParticipantEA (see below)

Within a Publisher/DataWriter Listener callback, do not call any operations on:

Other Publishers DataWriters that belong to other Publishers Any Subscribers Any DataReaders

 

You can have more information by looking at the RTI_DDS_UsersManual sections 4.5 and 4.5.1

 

-

Gianpiero

Re: Two Way Communication

Excellent, thank you very much for your help.