Passing arguments to script programs

Hi all,

I am writing some program scripts to configure and monitor my components directly through the Deployer.

Is it possible to give arguments to a script program ? When writing
program my_script(int i) {
}
The deployer parser raises an error!

Any help ? Any idea ?

Thanks.

Charles

Passing arguments to script programs

On Fri, Jul 17, 2009 at 13:49, <charles [dot] lesire [..] ...> wrote:
> Hi all,
>
> I am writing some program scripts to configure and monitor my components directly through the Deployer.
>
> Is it possible to give arguments to a script program ? When writing
> program my_script(int i) {
> }
> The deployer parser raises an error!
>
> Any help ? Any idea ?

You can only pass arguments to functions, not to programs. The
function then becomes a command in your interface, if it's exported.
Another way people communicate with scripts is to declare the
'parameters' as attributes in their TaskContext in which they load the
script. The program script will then lookup the used variables in the
TaskContext's attributes interface.

So:

program my_script {
   var int i;
   for( i=0; i < count; ++i) {
      // ...
   }
}
 
'count' is an RTT::Attribute<int> of your TaskContext, 'i' is a local
variable in your script.
 
Peter

Passing arguments to script programs

Then is it possible to add attributes to the Deployer (where my program
script is executed) through the property file (the xml file declaring
loaded components) ?

Charles.

Peter Soetens a écrit :
> On Fri, Jul 17, 2009 at 13:49, <charles [dot] lesire [..] ...> wrote:
>
>> Hi all,
>>
>> I am writing some program scripts to configure and monitor my components directly through the Deployer.
>>
>> Is it possible to give arguments to a script program ? When writing
>> program my_script(int i) {
>> }
>> The deployer parser raises an error!
>>
>> Any help ? Any idea ?
>>
>
> You can only pass arguments to functions, not to programs. The
> function then becomes a command in your interface, if it's exported.
> Another way people communicate with scripts is to declare the
> 'parameters' as attributes in their TaskContext in which they load the
> script. The program script will then lookup the used variables in the
> TaskContext's attributes interface.
>
> So:
>

> program my_script {
>    var int i;
>    for( i=0; i < count; ++i) {
>       // ...
>    }
> }
>
> 'count' is an RTT::Attribute<int> of your TaskContext, 'i' is a local
> variable in your script.
>
> Peter
>   

Passing arguments to script programs

On Fri, Jul 17, 2009 at 16:26, Charles
Lesire-Cabaniols<Charles [dot] Lesire [..] ...> wrote:
> Then is it possible to add attributes to the Deployer (where my program
> script is executed) through the property file (the xml file declaring
> loaded components) ?

You can't add attributes, but you can add properties, which are
equally accepted in your scripts. You need to use the 'LoadProperties'
XML tag to point to a file. However, maybe it's worth more to create
a dedicated component where you add the attributes, load&run the
scripts instead of trying to run everything from the deployer ?

Peter

Re: Passing arguments to script programs

I have exported a function map_zone(zone z) from script, where zone is a type I defined to represent 2D rectangular regions.

When I put the line
var zone z = zone(25,0,250,250)
in the function instead of the argument, all is fine (my mapping algorithm goes well).

But when I launch map_zone from deployer using
map_zone(zone(25,0,250,250))
nothing works... my algorithm works like if the zone was initialized to 0.

Have I missed something passing variables to exported functions? Maybe a default constructor I must define...

---
Charles.