Straping a component.

Hi.

I have a component that would have, for instance, two ports, like this :

    RTT::ReadDataPort<double>  m_in_foo_port;
    RTT::WriteDataPort<double> m_out_foo_port;
 
    RTT::Property<bool>        m_strap_property;

So when both ports are connected i have this :

 in_foo    out_foo <----connection_object----> remote_foo_reader

If the strap property is enable, i would like to transform this scheme to an other like this :

remote_foo_writer  <----connection_object----> remote_foo_reader

So i try to do :

if(m_in_foo_port.connected() &&
   m_out_foo_port.connected())
  {
    // FIXME get RTT::ReadDataPort<double> remote_foo_writer 
    // FIXME get RTT::ReadDataPort<double> remote_foo_reader
 
    remote_foo_reader->connectTo(remote_foo_writer);
 
    ConnectionInterface::shared_ptr in_con  = m_in_foo_port.connection();
    if (out_con)
      {
        out_con->disconnect();
      }
    ConnectionInterface::shared_ptr out_con = m_out_foo_port.connection();
    if (out_con)
      {
        out_con->disconnect();
      }
  }

But i don't know how to get remote ports ?

Thanks for your help.

Paul.

Straping a component.

On Friday 19 February 2010 10:56:37 paul [dot] chavent [..] ... wrote:
> Hi.
>
> I have a component that would have, for instance, two ports, like this :
>
>

>     RTT::ReadDataPort<double>  m_in_foo_port;
>     RTT::WriteDataPort<double> m_out_foo_port;
> 
>     RTT::Property<bool>        m_strap_property;
> 

>
> So when both ports are connected i have this :
>
>
 remote_foo_writer  <----connection_object----> in_foo    out_foo
>  <----connection_object----> remote_foo_reader 

With remote, do you mean CORBA remote, or an in process component ?

>
> If the strap property is enable, i would like to transform this scheme to
> an other like this :
>
>

> remote_foo_writer  <----connection_object----> remote_foo_reader
> 

You could also solve this as a system level thing, and not a thing the
component solves. Routing data flow is (if possible) best done on system level.

>
> So i try to do :
>
>

> if(m_in_foo_port.connected() &&
>    m_out_foo_port.connected())
>   {
>     // FIXME get RTT::ReadDataPort<double> remote_foo_writer
>     // FIXME get RTT::ReadDataPort<double> remote_foo_reader
> 
>     remote_foo_reader->connectTo(remote_foo_writer);
> 
>     ConnectionInterface::shared_ptr in_con  = m_in_foo_port.connection();
>     if (out_con)
>       {
>         out_con->disconnect();
>       }
>     ConnectionInterface::shared_ptr out_con = m_out_foo_port.connection();
>     if (out_con)
>       {
>         out_con->disconnect();
>       }
>   }
> 

>
> But i don't know how to get remote ports ?

That's because you can't know that from within a component, not in 1.x, not in
2.x. The best thing you can do from 'within' the component is that when
'straping' is on, you just repeat on your output what's on your input,
possibly using 'addEventPort' to make the input/read port event driven and
make the activity non periodic, such that each sample on the input port will
lead to a write on the output port.

Otherwise, use a deployment that connects all ports and a state machine which
starts/stops the components that may or may not participate in the dataflow (so
a system level solution).

Peter

Typo error :So when both

Typo error :

So when both ports are connected i have this :

remote_foo_writer ( connection object ) in_foo    out_foo (  connection_object  ) remote_foo_reader

Typo error :So when both

Typo error :

So when both ports are connected i have this :

remote_foo_writer ( connection object ) in_foo    out_foo (  connection_object  ) remote_foo_reader

Straping a component.

Hi.

I have a component that would have, for instance, two ports, like this :

    RTT::ReadDataPort<double>  m_in_foo_port;
    RTT::WriteDataPort<double> m_out_foo_port;
 
    RTT::Property<bool>        m_strap_property;

So when both ports are connected i have this :

 in_foo    out_foo <----connection_object----> remote_foo_reader

If the strap property is enable, i would like to transform this scheme to an other like this :

remote_foo_writer  <----connection_object----> remote_foo_reader

So i try to do :

if(m_in_foo_port.connected() &&
   m_out_foo_port.connected())
  {
    // FIXME get RTT::ReadDataPort<double> remote_foo_writer 
    // FIXME get RTT::ReadDataPort<double> remote_foo_reader
 
    remote_foo_reader->connectTo(remote_foo_writer);
 
    ConnectionInterface::shared_ptr in_con  = m_in_foo_port.connection();
    if (out_con)
      {
        out_con->disconnect();
      }
    ConnectionInterface::shared_ptr out_con = m_out_foo_port.connection();
    if (out_con)
      {
        out_con->disconnect();
      }
  }

But i don't know how to get remote ports ?

Thanks for your help.

Paul.