Prototyper configuration

5 posts / 0 new
Last post
Offline
Last seen: 6 years 1 month ago
Joined: 07/12/2012
Posts: 51
Prototyper configuration

Hi,

Can one specify values in a Prototyper configuration file for a union ? Take for example these type definitions

union jParValue switch (jParValueTypes)
{
case J_REAL_VAL:
   float realValue;
case J_LONG_VAL:
   long longValue;
case J_BOOL_VAL:
   boolean boolValue;
};//@top-level false

 struct jParChangeInfo

{
   unsigned long idx;
   jParValue value;
};//@top-level false

The idx field can be published like this:

<element>
   <name>rti.prototyper.member:idx</name>
   <value>linear?begin=2222,end=2222</value>
</element>

Is there a way to do the same for the "value" field ?

Thanks

 

Organization:
asanchez's picture
Offline
Last seen: 3 years 10 months ago
Joined: 11/16/2011
Posts: 50

Hello Nico,

RTI Prototyper supports union members as well. Indeed, there is no difference from a Prototyper point of view whether the member is an union or any other kind of complex member (i.e. Struct). Let me show you how we would do it:

Assuming we have defined our type as follows:

 <types>
        <enum name="jParValueTypes">
            <enumerator name="J_REAL_VAL"/>
            <enumerator name="J_LONG_VAL"/>
            <enumerator name="J_BOOL_VAL"/>
        </enum>
        <union name="jParValue">
            <discriminator type="nonBasic" nonBasicTypeName="jParValueTypes"/>
            <case>
                <caseDiscriminator value="J_REAL_VAL"/>
                <member name="realValue" type="float"/>
            </case>
            <case>
                <caseDiscriminator value="J_LONG_VAL"/>
                <member name="longValue" type="long"/>
            </case>
            <case>
                <caseDiscriminator value="J_BOOL_VAL"/>
                <member name="boolValue" type="boolean"/>
            </case>
        </union>
        <struct name="jParChangeInfo">
            <member name="idx" type="long"/>
            <member name="value" type="nonBasic" nonBasicTypeName="jParValue"/>
        </struct> 
 </types> 

Then we just need to refer to the union member as any other simple member, that is:

 <property>
	<value>	
		<element>
			<name>rti.prototyper.member:value.longValue</name>
			<value>linear?begin=0,end=10</value>
		</element>
	</value>
</property>

Hence RTI Prototyper will set the specified union member along with the corresponding discriminator.

Attached is a configuration file that creates a DW and DR in the same participant, publsihing and subscribing to the type shown above. Let me know  any other question or if you find something confusing in the configuration.


Best,

Antonio

File Attachments: 
Offline
Last seen: 6 years 1 month ago
Joined: 07/12/2012
Posts: 51

Antonio,

That was what I needed.

Thanks

Nico.

Offline
Last seen: 8 years 7 months ago
Joined: 06/16/2013
Posts: 8

Hi all, sorry for digging up an old thread but it seemed relevant.

Just getting started with the prototyper and I would like to do something similar to the OP, but rather than including a Union in the struct, I'd like to nest another struct.

My question is: Can this be done without strongly typing the member? I am approaching this from a OOP inheritance subclass point of view and would like the member to contain one of several possible structs at run-time, perhaps this doesn't map well to this application or maybe I am being short-sighted and it is easy...help or suggestions would be very welcome.

Thanks,

Ryan

asanchez's picture
Offline
Last seen: 3 years 10 months ago
Joined: 11/16/2011
Posts: 50

Hello Ryan,

I understand the use case here is to use Prototyper with the same syntax for derferencing members of an inherited type when using a programming language. Prototyper as an experimental feature does not support yet inherited types so unfortunately the use case you mention cannot be covered with this utility. The good news is that Prototyper is built on DynamiData, which does support inheritance, hence future versions might support it as well with no compatiblity issues.

In any case, let me go through the issue and see how we would approach it with DynamiData and with Prototyper (the latter hypothetically supporting it)). Let's consider our inheritance type tree:

BaseType {
	int x;
}

DerivedType : BaseType {
	int y;
}


In a programming language such as C++ we would dereference 'x' as follows:

DerivedType myDerived;
myDerived.x = 0;

In RTI Connext DynamicData:

DynamicData myDerived; //assume that myDerived has the type code of DerivedType
myDerived->set_long("x", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED, 0);

And in Prototyper, when supported, should be as follows:

rti.prototyper.member:x

 

Hope this clarifies your question. Let me know any other concern.

Antonio