Ports and Tasks

2011/10/10 jocamo5 [..] ... <jocamo5 [..] ...>:
>> If you're using the EventPort, you're updateHook gets executed each
>> time new data arrives on the port. So in that case, you don't even
>> need the if condition.
>
> Perfect.
>
>> You're data on both ports will never arrive simultaneously, and there
>> is no default way to have one trigger from those two ports. You'll
>> first have to decide on which activity to connect to your Controller
>> component. When do you want it to wake up? Every time one of both
>> ports has new Data? Or do you want one of both components to act as
>> the master? In both cases you can check for NewData on the other port
>> by putting all updateHook code inside an
>>
>> if(vectorPosition.read() == RTT::NewData && vectorForce.read() == RTT::NewData){
>>
>> }
>
> Then, if the Position and Force component have a period of 10 ms, and the Control component has an even port, when data position and data force arrive (both NewData), the condition: if(vectorPosition.read() == RTT::NewData && vectorForce.read() == RTT::NewData)  will be True, and the code inside will be executed. Right?

Hmm, I have to correct myself here slightly. As the read() effectively
reads out the port, it changes the data status from NewData to
OldData. so thereby you're code will never execute. What you can do is
attach to both event ports a custom method:

e.g. positionUpdate() and forceUpdate(). In those methods you read out
the ports _and_ set a flag indicating new data arrived.

You can then check that flag in the updateHook().

FYI: you can attach event ports to any custom method using the syntax:

&#10;this-&gt;addEventPort(&quot;portName&quot;,port,boost::bind(&amp;ComponentName::methodName,this,_1));&#10;

Regards,

Steven

>
> Thanks,
>
> Jose
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>