[Orocos] Component Interface

Quoting Vandenbroucke Sander <Sander [dot] Vandenbroucke [..] ...>:

> Hi,
>
> Lets say we have a common interface for multiple components.
>
> class IDummyComponent
> {
> protected:
> RTT::WriteDataPort m_DummyLoad;
>
> RTT::Property m_MaxLoad
>
> RTT::Command m_IncLoad;
>
> RTT::Event m_Emergency;
>
> IDummyComponent(TaskContext* Owner) :
> m_DummyLoad("DummyLoad"),
> m_MaxLoad("MaxLoad", "The maximum load", 1024),
> m_IncLoad("IncLoad"),
> m_Emergency("Emergency")
> {
> Owner->ports()->addPort(&m_DummyLoad);
> Owner->properties()->addProperty(&m_MaxLoad);
> Owner->commands()->addCommand(&m_IncLoad);
> Owner->events()->addEvent(&m_Emergency);
> }
> }
>
> The addPort and addProperty are no problem, if I want to change
> m_DummyLoad's implementation later on I can do so.
>
> The addCommand and addEvent won't work because neither will be ready().
> To make them ready means either connecting functions or choose an
> alternate implementation.
>
> Here is my question:
> How can I add a Command or Event to the interface without choosing an
> implementation?
> Or is there a way to change the implementation later on?

As you've probably figured out by looking at the code, it is the
implementation object that is stored in the 'interface'. Thus from the
moment an implementation is available, you can add the event. In
Orocos 1.2, you can do this for example in the configureHook() instead
of the constructor. It's not much use to change the implementation
half-way as the previous users of the event will continue to use the
old implementation, i.e. it is not possible to change the
implementation of the existing command/event/method/... users by
setting a new implementation in the component's interface. I believe a
'configuration' stage is what you require ?

Peter

RE: [Orocos] Component Interface

>
>As you've probably figured out by looking at the code, it is the
>implementation object that is stored in the 'interface'. Thus from the
>moment an implementation is available, you can add the event. In
>Orocos 1.2, you can do this for example in the configureHook() instead
>of the constructor. It's not much use to change the implementation
>half-way as the previous users of the event will continue to use the
>old implementation, i.e. it is not possible to change the
>implementation of the existing command/event/method/... users by
>setting a new implementation in the component's interface. I believe a
>'configuration' stage is what you require ?
>
I need a code-effective way of 'generating' a Proxy of a component.
Until now we used to code the proxy ourselves using an common interface
for the component and its proxy. This means copy-paste-ing code from the
component code to the proxy code. Due to naming convention this is error
prone. We would like a more robust manner.

I'm thinking about something like this:
template
Proxy : public RTT::TaskContext, public ComponentInterface
{
Proxy(....) : RTT::TaskContext(....), ComponentInterface(this)
{
//Set implementation of commands(), events(), ports() to
a proxy implementation.
}
}

I'm not sure about the template construct, I haven't got time to test it
yet.

Sander.

RE: [Orocos] Component Interface

Quoting Vandenbroucke Sander <Sander [dot] Vandenbroucke [..] ...>:

>
>>
>> As you've probably figured out by looking at the code, it is the
>> implementation object that is stored in the 'interface'. Thus from the
>> moment an implementation is available, you can add the event. In
>> Orocos 1.2, you can do this for example in the configureHook() instead
>> of the constructor. It's not much use to change the implementation
>> half-way as the previous users of the event will continue to use the
>> old implementation, i.e. it is not possible to change the
>> implementation of the existing command/event/method/... users by
>> setting a new implementation in the component's interface. I believe a
>> 'configuration' stage is what you require ?
>>
> I need a code-effective way of 'generating' a Proxy of a component.
> Until now we used to code the proxy ourselves using an common interface
> for the component and its proxy. This means copy-paste-ing code from the
> component code to the proxy code. Due to naming convention this is error
> prone. We would like a more robust manner.
>
> I'm thinking about something like this:
> template
> Proxy : public RTT::TaskContext, public ComponentInterface
> {
> Proxy(....) : RTT::TaskContext(....), ComponentInterface(this)
> {
> //Set implementation of commands(), events(), ports() to
> a proxy implementation.

So inhere, you want to iterate over the interface and change the
implementations ? This means you can only use one signature for all
primitives since you need
to know the signature type in the 'generic' Proxy class...

Peter

RE: [Orocos] Component Interface

>> I'm thinking about something like this:
>> template
>> Proxy : public RTT::TaskContext, public ComponentInterface
>> {
>> Proxy(....) : RTT::TaskContext(....), ComponentInterface(this)
>> {
>> //Set implementation of commands(), events(), ports() to
>> a proxy implementation.
>
>So inhere, you want to iterate over the interface and change the
>implementations ?

Yes. I do a similar scheme for assessing a component over Ethernet.
Off course changing the implementation in the interface won't be
straight forward, right?

>This means you can only use one signature for all
>primitives since you need
>to know the signature type in the 'generic' Proxy class...
>
One or a few supported signatures. That's ok for me since my protocol
can only handle a few signatures.

Sander.