I am using java to write a dynamic data program with RTI DDS that needs to use string arrays. I however don't see any API to set a string array. What is the way you got about making a string array to be used with dynamic data?
I am using java to write a dynamic data program with RTI DDS that needs to use string arrays. I however don't see any API to set a string array. What is the way you got about making a string array to be used with dynamic data?
Hi there,
I think you will have to 'bind complex member" first and then set the strings for each position in the array. Here you can find an example in C++ but the logic is the same!
Does this help?
Best,
Gianpiero
I was trying that example but was having trouble converting some of the C++ code to an exact java match, is there any example of this exact code in java that you know of?
Hello,
Here how the code looks like in java:
The type i used in the above example is a modified version of $NDDSHOME/example/java/HelloWorld_xml_dynamic/USER_QOS_PROFILES.xml:
I put my modifed example here: https://community.rti.com/filedepot?cid=1&fid=31
Best,
Gianpiero
That you very much, now with my stuff I am trying to get work, I get the following error.
Exception in thread "main" com.rti.dds.infrastructure.RETCODE_BAD_PARAMETER
at com.rti.dds.util.Utilities.rethrow(Unknown Source)
at com.rti.dds.infrastructure.RETCODE_ERROR.check_return_codeI(Unknown Source)
at com.rti.dds.dynamicdata.DynamicData.bind_complex_member(Unknown Source)
DDS_DynamicData_bind_typeI:type not supported (primitive or string not allowed as a top-level type)
Not too sure why it is complaining about my top level type?
Do you have a reproducer you can share?
Reproducer?
Sorry, can you share your code so I can 'reproduce' the error you are getting?
This will be kinda abstract but heres the part I am using when I get the error, using an idl that creates a string called data
DynamicData data = new DynamicData(typeCode,DynamicData.PROPERTY_DEFAULT);
DynamicData a = new DynamicData(null,DynamicData.PROPERTY_DEFAULT);
try
{
data.bind_complex_member(a,"data", DynamicData.MEMBER_ID_UNSPECIFIED);
}
catch(RETCODE_BAD_PARAMETER e)
{
e.printStackTrace();
}
"data.bind_complex_member(a,"data", DynamicData.MEMBER_ID_UNSPECIFIED);" is where the error gets thrown.
In the idl is "data" a string or an array of strings?
It is a string and not an array of strings, which i suspect could be causing an issue then.
However the array of strings is variable, so how would that be expressed in the idl?
Hello,
Reguarding:
If it is just a string you can simple call
If you look at the example i shared here, in the HelloPublisher.java we do that on lines 84-87.
Also, when you say:
what do you mean? Do you mean that the size of the array can be variable? If you use array all of them will be allocated. If you have need for 'dynamic' allocation I would suggest you use a sequence. Start here and then look at the user manual to learn more about them.
Best,
Gianpiero
I am also facing the same problem..instead of array i have sequence..can u write code for sequence?