enumeration values in orocos state machine scripts

Hi,
I would like to use enumeration values like
enum EnumType
{
ENABLE,
DISABLE
}
in orocos state machine scripts:
var EnumType enum = DISABLE;

I already managed to pass the enum type to the orocos script with the help of
RTT::types::Types()->addType(new EnumTypeInfo<EnumType>("EnumType")

For using the values of EnumType I tried the AssignableDataSource which I found in the rtt/tests/enum_type_test.cpp:

RTT::internal::AssignableDataSource<EnumType>::shared_ptr enable;
RTT::internal::AssignableDataSource<EnumType>::shared_ptr disable;
TypeKit ()
{
enable = new RTT::internal::ValueDataSource<EnumType>(ENABLE);
disable = new RTT::internal::ValueDataSource<EnumType>(DISABLE);
}

But the script loader still fails to interpret the enum values. Using the second example in rtt/tests/enum_string_type_test.cpp doesn't help too.

Is there a way to pass the values to scripts or do I have to find another way?

Thanks a lot.
Sandra

enumeration values in orocos state machine scripts

Hi Sandra,

The way to 'load' enum values like ENABLE/DISABLE in the type system is to
add them to the globals as an Attribute or Constant. Several RTT functions
do it like this, for example rtt/typekit/RealTimeTypekitGlobals.cpp :

GlobalsRepository::shared_ptr globals = GlobalsRepository::Instance();

// Data Flow enums:
globals->setValue( new Constant<FlowStatus>("NoData",NoData) );
globals->setValue( new Constant<FlowStatus>("OldData",OldData) );
globals->setValue( new Constant<FlowStatus>("NewData",NewData) );

Cheers,
Peter

On Thu, Mar 13, 2014 at 3:43 PM, Sandra Beyer <sandra [dot] beyer [..] ...>wrote:

> Hi,
>
> I would like to use enumeration values like
>
> enum EnumType
>
> {
>
> ENABLE,
>
> DISABLE
>
> }
>
> in orocos state machine scripts:
>
> var EnumType enum = DISABLE;
>
>
>
> I already managed to pass the enum type to the orocos script with the help
> of
>
> RTT::types::Types()->addType(new EnumTypeInfo<EnumType>(“EnumType”)
>
>
>
> For using the values of EnumType I tried the AssignableDataSource which I
> found in the rtt/tests/enum_type_test.cpp:
>
>
>
> RTT::internal::AssignableDataSource<EnumType>::shared_ptr enable;
>
> RTT::internal::AssignableDataSource<EnumType>::shared_ptr disable;
>
> TypeKit ()
>
> {
>
> enable = new RTT::internal::ValueDataSource<EnumType>(ENABLE);
>
> disable = new RTT::internal::ValueDataSource<EnumType>(DISABLE);
>
> }
>
>
>
> But the script loader still fails to interpret the enum values. Using the
> second example in rtt/tests/enum_string_type_test.cpp doesn’t help too.
>
>
>
> Is there a way to pass the values to scripts or do I have to find another
> way?
>
>
>
> Thanks a lot.
>
> Sandra
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>