tc and peertable in lua

Hi,

'small' question
What gives tc back actually?

example code
---------
tc=rtt.getTC()
function configureHook()
peertableEF = rttlib.mappeers(function (tc) return tc end, tc)
print("[eventFirer.lua] eventFirer has following peers:")
for K,V in pairs(peertableEF) do print( K) end
print(" end of eventFirer peers")
end

output
-------
[eventFirer.lua] eventFirer has following peers:
CartesianTrajectoryGenerator
KukaLWR
FixedObject
CartesianMotion
Solver
EventFirer
GlobalSuperVisor
Reporter
Robot
ITASCSuperVisor
Scene
end of eventFirer peers

=> much more 'peers' (I expected only the supervisors, wich I made explicitly peers at deployment
it seems to me that tc is actually the interface of the deployer?!
can I get the peers of my component alone?

nick

tc and peertable in lua

On Tue, Jul 12, 2011 at 11:36:17AM +0200, Dominick Vanthienen wrote:
> Hi,
>
> 'small' question
> What gives tc back actually?
> example code
> ---------
> tc=rtt.getTC()
> function configureHook()
> peertableEF = rttlib.mappeers(function (tc) return tc end, tc)

This line calls the function given as a first argument on *all* peers
reachable from the second argument and returns the results of all
calls in a table, your peertable.

> print("[eventFirer.lua] eventFirer has following peers:")
> for K,V in pairs(peertableEF) do print( K) end
> print(" end of eventFirer peers")
> end
>
> output
> -------
> [eventFirer.lua] eventFirer has following peers:
> CartesianTrajectoryGenerator
> KukaLWR
> FixedObject
> CartesianMotion
> Solver
> EventFirer
> GlobalSuperVisor
> Reporter
> Robot
> ITASCSuperVisor
> Scene
> end of eventFirer peers
>
> => much more 'peers' (I expected only the supervisors, wich I made explicitly peers at deployment
> it seems to me that tc is actually the interface of the deployer?!
> can I get the peers of my component alone?

mappeers performs a deep search. To get only the peers of a single
component you could do (untested):

peertab={}
for i,p in ipairs(tc:getPeers()) do peertab[p]=tc:getPeer(p) end

Markus

tc and peertable in lua

On 07/13/2011 08:43 AM, Markus Klotzbuecher wrote:
> On Tue, Jul 12, 2011 at 11:36:17AM +0200, Dominick Vanthienen wrote:
>> Hi,
>>
>> 'small' question
>> What gives tc back actually?
>> example code
>> ---------
>> tc=rtt.getTC()
>> function configureHook()
>> peertableEF = rttlib.mappeers(function (tc) return tc end, tc)
> This line calls the function given as a first argument on *all* peers
> reachable from the second argument and returns the results of all
> calls in a table, your peertable.
>
>> print("[eventFirer.lua] eventFirer has following peers:")
>> for K,V in pairs(peertableEF) do print( K) end
>> print(" end of eventFirer peers")
>> end
>>
>> output
>> -------
>> [eventFirer.lua] eventFirer has following peers:
>> CartesianTrajectoryGenerator
>> KukaLWR
>> FixedObject
>> CartesianMotion
>> Solver
>> EventFirer
>> GlobalSuperVisor
>> Reporter
>> Robot
>> ITASCSuperVisor
>> Scene
>> end of eventFirer peers
>>
>> => much more 'peers' (I expected only the supervisors, wich I made explicitly peers at deployment
>> it seems to me that tc is actually the interface of the deployer?!
>> can I get the peers of my component alone?
> mappeers performs a deep search. To get only the peers of a single
> component you could do (untested):
>
> peertab={}
> for i,p in ipairs(tc:getPeers()) do peertab[p]=tc:getPeer(p) end

this works! thanks!
> Markus
nick