User defined types - problem reading from XML

I'm currently trying to use the deployment-component for creating fully configurable machine. Therefore I have introduced some new user defined types as described in http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-toolkit-plugin.html and some configuration files for each component. These files are read and the properties are initialized - at least they can be viewed within the TaskBrowser.

When I try to access these properties of my user defined types I get properties of the type Property instead of Property. Did I forget something or is this the desired behaviour?

User defined types - problem reading from XML

On Monday 23 March 2009 09:53:32 walter [dot] hargassner [..] ... wrote:
> I'm currently trying to use the deployment-component for creating fully
> configurable machine. Therefore I have introduced some new user defined
> types as described in
> http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-toolki
>t-plugin.html and some configuration files for each component. These files
> are read and the properties are initialized - at least they can be viewed
> within the TaskBrowser.
>
> When I try to access these properties of my user defined types I get
> properties of the type Property<PropertyBag> instead of Property<MyType>.
> Did I forget something or is this the desired behaviour?

Did you use loadProperties() ? In that case it's 'normal' because there is no
'reference' the property loading mechanism has (this is in fact a bug in the
type system, it shouldn't need a reference).

The current system requires that the property hierarchy you have in your
XML file matches what the component has predefined, in case you use
custom types. You can test this by adding a Property<MyType> to the
interface of your component and then writeProperties()/readProperties()
on the same file. That must work with correct composition/decomposition
functions.

Peter

User defined types - problem reading from XML

It works as you have described it, if I define a Property<MyType> directly in my component. But in my case I need to configure a component with an undefined number of properties of on userdefined type. Therefore I used the following structure:

<struct name="mytypes" type="PropertyBag">
   <struct name="mytype_1" type="MyType">
       <simple name="..." ...
   </struct>
   <struct name="mytype_2" type="MyType">
       <simple name=" ..." ...
   </struct>
</struct>

When I try to load this structure by calling readProperties(), the properties are not initialized at all but configureComponents() does not return an error. Is there another possibility how to get this configured automatically?

User defined types - problem reading from XML

On Tuesday 24 March 2009 09:08:23 walter [dot] hargassner [..] ... wrote:
> It works as you have described it, if I define a Property<MyType> directly
> in my component. But in my case I need to configure a component with an
> undefined number of properties of on userdefined type. Therefore I used the
> following structure:
>
>

> <struct name="mytypes" type="PropertyBag">
>    <struct name="mytype_1" type="MyType">
>        <simple name="..." ...
>    </struct>
>    <struct name="mytype_2" type="MyType">
>        <simple name=" ..." ...
>    </struct>
> </struct>
> 

>
> When I try to load this structure by calling readProperties(), the
> properties are not initialized at all but configureComponents() does not
> return an error. Is there another possibility how to get this configured
> automatically?

readProperties allows that more properties than necessary are in the file. They
are just ignored.

You need loadProperties() instead. However, as I pointed out, the property
loading mechanism does not automatically construct the user defined type,
so it will just replicate your XML file. This is a bug. The only work-around
you have is to do the composition step yourself (so create a Property<MyType>
and compose the loaded properties into that property).

Peter

Ruben Smits's picture

User defined types - problem reading from XML

On Tuesday 24 March 2009 09:22:37 Peter Soetens wrote:
> On Tuesday 24 March 2009 09:08:23 walter [dot] hargassner [..] ... wrote:
> > It works as you have described it, if I define a Property<MyType>
> > directly in my component. But in my case I need to configure a component
> > with an undefined number of properties of on userdefined type. Therefore
> > I used the following structure:
> >
> >

> > <struct name="mytypes" type="PropertyBag">
> >    <struct name="mytype_1" type="MyType">
> >        <simple name="..." ...
> >    </struct>
> >    <struct name="mytype_2" type="MyType">
> >        <simple name=" ..." ...
> >    </struct>
> > </struct>
> > 

> >
> > When I try to load this structure by calling readProperties(), the
> > properties are not initialized at all but configureComponents() does not
> > return an error. Is there another possibility how to get this configured
> > automatically?
>
> readProperties allows that more properties than necessary are in the file.
> They are just ignored.
>
> You need loadProperties() instead. However, as I pointed out, the property
> loading mechanism does not automatically construct the user defined type,
> so it will just replicate your XML file. This is a bug. The only
> work-around you have is to do the composition step yourself (so create a
> Property<MyType> and compose the loaded properties into that property).

If a std::vector<MyType> is also usefull for you, you could also use
Property<std::vector properties and scripting for std::vector<AnyType>.

Ruben