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 :
>
> &#10;&gt;     RTT::ReadDataPort&lt;double&gt;  m_in_foo_port;&#10;&gt;     RTT::WriteDataPort&lt;double&gt; m_out_foo_port;&#10;&gt; &#10;&gt;     RTT::Property&lt;bool&gt;        m_strap_property;&#10;&gt;
>
> So when both ports are connected i have this :
>
>  remote_foo_writer  &lt;----connection_object----&gt; in_foo    out_foo&#10;&gt;  &lt;----connection_object----&gt; 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 :
>
> &#10;&gt; remote_foo_writer  &lt;----connection_object----&gt; remote_foo_reader&#10;&gt;

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 :
>
> &#10;&gt; if(m_in_foo_port.connected() &amp;&amp;&#10;&gt;    m_out_foo_port.connected())&#10;&gt;   {&#10;&gt;     // FIXME get RTT::ReadDataPort&lt;double&gt; remote_foo_writer&#10;&gt;     // FIXME get RTT::ReadDataPort&lt;double&gt; remote_foo_reader&#10;&gt; &#10;&gt;     remote_foo_reader-&gt;connectTo(remote_foo_writer);&#10;&gt; &#10;&gt;     ConnectionInterface::shared_ptr in_con  = m_in_foo_port.connection();&#10;&gt;     if (out_con)&#10;&gt;       {&#10;&gt;         out_con-&gt;disconnect();&#10;&gt;       }&#10;&gt;     ConnectionInterface::shared_ptr out_con = m_out_foo_port.connection();&#10;&gt;     if (out_con)&#10;&gt;       {&#10;&gt;         out_con-&gt;disconnect();&#10;&gt;       }&#10;&gt;   }&#10;&gt;
>
> 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 :

&#10;&#10;remote_foo_writer ( connection object ) in_foo    out_foo (  connection_object  ) remote_foo_reader&#10;&#10;

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 :

&#10;    RTT::ReadDataPort&lt;double&gt;  m_in_foo_port;&#10;    RTT::WriteDataPort&lt;double&gt; m_out_foo_port;&#10;&#10;    RTT::Property&lt;bool&gt;        m_strap_property;&#10;

So when both ports are connected i have this :

 in_foo    out_foo &lt;----connection_object----&gt; remote_foo_reader&#10;

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

&#10;remote_foo_writer  &lt;----connection_object----&gt; remote_foo_reader&#10;

So i try to do :

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

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

Thanks for your help.

Paul.