1

I am currently using RTI DDS on a system where we will have one main topic for multiple items, such as a car topic with multiple vin numbers. Since this is the design I am trying to then make a "keyed" topic which is basically a topic that has a member acting as a key (kind of like the primary key in the database) which in this example would be the vin of each car. To implement the keyed topics I am using an IDL file which is as follows,

const string CAR_TOPIC = "CAR";
enum ALARMSTATUS {
    ON,
    OFF
};

struct keys {

    long vin; //@key

    string make;

    ALARMSTATUS alarm;

};

When I run the IDL file through the rtigen tool for making C,Java, etc kind of files from the IDL, the only thing I can do is run the program and see

Writing keys, count 0
Writing keys, count 1 ...

and

keys subscriber sleeping for 4 sec...
Received:
    vin: 38
    make: 
    alarm : ON

keys subscriber sleeping for 4 sec...
Received:
    vin: 38
    make: 
    alarm : ON ...

Thus making it hard to see how the keyed topics work and if they are really working at all. Does anyone have any input what to do with the files generated from the IDL files to make the program more functional? Also I never see the topic CAR so I am not sure I am using the right syntax to set the topic for the DDS.

jgr208
  • 2,896
  • 9
  • 36
  • 64

1 Answers1

1

When you say "the only thing I can do is run the program", it is not clear what "the" program is. I do not recognize the exact output that you give, so did you adjust the code of the generated example?

Anyway, responding to some of your remarks:

Thus making it hard to see how the keyed topics work and if they are really working at all.

The concept of keys is most clearly visible when you have values for multiple instances (that is, different key-values) present simultaneously in your DataReader. This is comparable to having a database table containing multiple rows at the same time. So in order to demonstrate the key concept, you will have to assign different values to the key-fields on the DataWriter side and write() the resulting samples. This does not happen by default in the generated examples, so you have to do adjust the code to achieve that.

On the DataReader side, you will have to make sure that multiple values remain stored to demonstrate the effect. This means that you should not do a take() (which is similar to a "destructive read"), but a read(). This way, the number of values in your DataReader will grow in line with the number of distinct key values that you wrote.

Note that in real life, you should not have a growing number of key-values for ever, just like you do not want a database table to contain an ever growing number of rows.

Also I never see the topic CAR so I am not sure I am using the right syntax to set the topic for the DDS.

Check out the piece of code that creates the Topic. The method name depends on the language you use, but should have something like create_topic() in it. The second parameter to that call is the name of the Topic. In general, the IDL constant CAR_TOPIC that you defined will not be automatically used as the name of the Topic, you have to indicate that in the code.

Depending on the example you are running, you could try -h to get some extra flags to use. You might be able to increase verbosity to see the name of the Topic being created, or set the topic name off the command line.

If you want to verify the name of the Topic in your system, you could use rtiddsspy to watch the data flowing. Its output includes the names of the Topics it discovers.

Reinier Torenbeek
  • 16,669
  • 7
  • 46
  • 69
  • sorry I meant there is a `**classname**Publisher.java` and all I can really do with the files by default is run that publisher class. So basically I have to hook into these classes and use them it sound like. Its kind of a class generator like jaxb per say where they are not meant to run the program but supplement what you want to do? – jgr208 Jan 21 '15 at 18:01
  • OK - note that this `**classname**Publisher.java` is purely intended as an example for you. It is not supposed to be used in your application. If you want to understand the different chunks of code in that example, I suggest you check out the "Programming How-To's" section in the "Modules" section in the reference manual. See http://community.rti.com/rti-doc/500/ndds/doc/html/api_java/ – Reinier Torenbeek Jan 21 '15 at 18:02
  • ahh ok, thanks. I knew i was doing in right but wasnt sure what to do after the classes are generated this helped a lot. So I can overwrite what is in there and the reader if I like correct? – jgr208 Jan 21 '15 at 18:04
  • Yes, you can overwrite what is in there. Be careful not to lose your modifications when you run `make` again. For example when you change the IDL, all its dependencies will be re-generated, including the example classes. Although I think by default, it will refuse to overwrite existing files. – Reinier Torenbeek Jan 21 '15 at 18:06
  • yes it does. do you also know a good resource for the idl syntax that rti uses? – jgr208 Jan 21 '15 at 18:06
  • The link to the documentation of the current version should be http://community.rti.com/rti-doc/510/ndds/doc/html/api_java/ by the way. – Reinier Torenbeek Jan 21 '15 at 18:08
  • The IDL that RTI uses is actually a language standardized as part of the CORBA spec. For example here: http://www.omg.org/spec/CORBA/2.5/ is an older version of the spec, IDL is defined in chapter 3. DDS only uses structures and unions as top-level type elements, and everything that can be legally contained by those. Additionally, modules, consts and typedefs are supported. Interfaces, exceptions etc do not apply to DDS. – Reinier Torenbeek Jan 21 '15 at 21:55
  • Hi. The current version of the OMG IDL spec (IDL version 3.5) is a stand-alone document so you do not need to refer to a chapter in the CORBA spec. You can access it here: http://www.omg.org/spec/IDL35 – Gerardo Pardo Feb 01 '15 at 15:15
  • As far as the specific subset RTI uses it is described in Section 3.3 (Creating User Data Types with IDL) of the RTI Connext DDS User's manual which you can access from here: https://community.rti.com/rti-doc/510/ndds.5.1.0/doc/pdf/RTI_CoreLibrariesAndUtilities_UsersManual.pdf – Gerardo Pardo Feb 01 '15 at 15:18