Making DDS more generic

6 posts / 0 new
Last post
Offline
Last seen: 11 years 1 month ago
Joined: 02/25/2013
Posts: 4
Making DDS more generic

Hey all,

 

I'm looking for a way to make my DDS implementation more generic. I know this will be tough because the IDL generates very specific classes per topic. So i guess the idea would be to have a generic publisher, and a generic subscriber. This way i could just pass in an instance of the Topic and it's reader/writer, and then just publish/subscribe to Topics. Does anyone have any design patterns for this, or suggestions for breaking up the functionality?

 

Thanks!

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 2 days ago
Joined: 06/02/2010
Posts: 601

Hi,

Can you be more specific as to what kind of generic actions you would like to perform? Also what programming language are you using? Short of that information I can only offer "generic" answers :)

Doing something with the data itself in a generic fashion requires some kind of introspection because most things you would want to do require some knowledge of the data-type. This is possible using the TypeCode API and the DynamicData API. These APIs allow an application to discover at run-time a new data/type and topic and create dynamically DataReaders and DataWriters that can read and write that data.  This is what applications such as the rtiddsspy utility do when you pass the -printData option and they are able to subscribe and print data of any type. You can read more about this in Section 3.8 (Interacting Dynamically with User Data Types) and 3.9 (Working with Data Samples) of the RTI Connext DDS User's Manual. There are also code Examples in the RTI Connext DDS distribution. You can find them under ndds.5.0.0/examples/C++/Hello_dynamic. There is also Java Example on using DynamicData here.

The the TypeCode API and the DynamicData API manipulate data-types without linking in any code generated by rtiddsgen. If on the other hand you are using the rtiddsgen code but just want to write code that is generic with respect to the types you could use C++ Templates or Java generics to do some of this.  An example of a generic C++ Listener using templates was posted to the forums a couple of days ago: See http://community.rti.com/sites/default/files/DPS_DDSListener.h

Gerardo

 

 

 

Offline
Last seen: 11 years 1 month ago
Joined: 02/25/2013
Posts: 4

I believe i have found the answer i was looking for.

 

Thanks Gerardo!

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 2 days ago
Joined: 06/02/2010
Posts: 601

Great to hear!  Would you mind sharing your insights?  I am thinking that it may be useful for others...

Thanks,

Gerardo

Offline
Last seen: 11 years 1 month ago
Joined: 02/25/2013
Posts: 4

Sure, i can share. Sorry for not being too specific in the first post. What i am trying to accomplish is to create a generic publisher / subscriber that accept objects of DDS types and uses them to publish any IDL DDS generated topic. So say i have some IDL that generates the HelloWorld code. I want to be able to generate that IDL code during the build process and use it as is. So what i did to accomplish this is to create a layer of abstraction above all of that topic specific code. This way i can work with my implementation code to use the IDL generated code as i like. There are several levels of abstraction that you can put over the code, and it really depends on how much you'd like to abstract the DDS from the process of sending data. Essentially the coder could have no notion that DDS is the underlying communication platform. The level of abstraction is really up to the developer. In my case i'd prefer to have some notion of DDS, so i can define the objects that i send into my generic publisher / subscriber. This way i can define the Topic + relevant datawriter/reader, Data Sample, and attributes like QOS. Then i just send an abstracted version of IDL specific objects into my publisher / subscriber. I would be curious to hear more about TypeSupport though. I don't need to create dynamic topics at runtime, but would th TypeSupport be useful to me base upon what i just described?

 

Thanks

Offline
Last seen: 2 years 6 months ago
Joined: 10/18/2013
Posts: 42

can you do this in C# using TypeSupport?