Modifying properties from program scripts

Hi,

The component builders manual mentions how to call/fire elements from
the public API of a taskcontext:
- Methods (section 3.2.7)
- Functions (3.2.8)
- Events (3.2.9)

Extrapolating this, I was expecting section 3.2.10 to deal with
getting/setting attributes/properties from program scripts?
Is the latter possible, and
- if yes: how?
- if no: is there a particular reason for this?

TIA,

Klaas

Modifying properties from program scripts

On Feb 10, 2010, at 10:36 , Klaas Gadeyne wrote:

> Hi,
>
> The component builders manual mentions how to call/fire elements from
> the public API of a taskcontext:
> - Methods (section 3.2.7)
> - Functions (3.2.8)
> - Events (3.2.9)
>
> Extrapolating this, I was expecting section 3.2.10 to deal with
> getting/setting attributes/properties from program scripts?
> Is the latter possible, and
> - if yes: how?
> - if no: is there a particular reason for this?

You can do this, IIRC. Don't have the code in front of me, but ...

	var int x;
	set x = MyAttribute
	// or
	set x = Peer.OtherAttribute
	...
	do MyPort.Set(MyConstant)
	...

I think they all work the same way ...

HTH
Stephen

Modifying properties from program scripts

On Wed, Feb 10, 2010 at 4:41 PM, S Roderick <kiwi [dot] net [..] ...> wrote:
> On Feb 10, 2010, at 10:36 , Klaas Gadeyne wrote:
>
>> Hi,
>>
>> The component builders manual mentions how to call/fire elements from
>> the public API of a taskcontext:
>> - Methods (section 3.2.7)
>> - Functions (3.2.8)
>> - Events (3.2.9)
>>
>> Extrapolating this, I was expecting section 3.2.10 to deal with
>> getting/setting attributes/properties from program scripts?
>> Is the latter possible, and
>> - if yes: how?
>> - if no: is there a particular reason for this?
>
> You can do this, IIRC. Don't have the code in front of me, but ...
>
>

>        var int x;
>        set x = MyAttribute
>        // or
>        set x = Peer.OtherAttribute
>        ...
>        do MyPort.Set(MyConstant)
>        ...
> 

>
> I think they all work the same way ...

You're right. I tried that before I sent the mail, I'll have to check
why it didn't work on my project, probably a typo :-(. I've created a
basic test and everything works fine there.

set MyProp = 10.0

Thx!

Klaas

Modifying properties from program scripts

On Wed, Feb 10, 2010 at 8:32 PM, Klaas Gadeyne <klaas [dot] gadeyne [..] ...> wrote:
[...]
> You're right.  I tried that before I sent the mail, I'll have to check
> why it didn't work on my project, probably a typo :-(.  I've created a
> basic test and everything works fine there.

And ofcourse also on the real project now. Shame on me :-(

Index: orocos-program-parser.xml
===================================================================
--- orocos-program-parser.xml (revision 31138)
+++ orocos-program-parser.xml (working copy)
@@ -816,6 +816,17 @@
<para>
<section>
<section>
+ <title>Setting Task Attributes/Properties<title>
+ <para>
+ Task attributes/Properties are set in the same way as ordinary
script variables.
+ <para>
+ <programlisting> // Setting a property named MyProp of type double
+ var double d
+ set TC.MyProp = d <programlisting>
+ <para>
+ <para>
+ <section>
+ <section>
<title><symbol>function<symbol><title>
<para>Statements
can be grouped in functions. A function can only call a function

Modifying properties from program scripts

On Thursday 11 February 2010 11:27:31 Klaas Gadeyne wrote:
> On Wed, Feb 10, 2010 at 8:32 PM, Klaas Gadeyne <klaas [dot] gadeyne [..] ...>
> wrote: [...]
>
> > You're right. I tried that before I sent the mail, I'll have to check
> > why it didn't work on my project, probably a typo :-(. I've created a
> > basic test and everything works fine there.
>
> And ofcourse also on the real project now. Shame on me :-(
>
> Index: orocos-program-parser.xml
> ===================================================================
> --- orocos-program-parser.xml (revision 31138)
> +++ orocos-program-parser.xml (working copy)
> @@ -816,6 +816,17 @@
> <para>
> <section>
> <section>
> + <title>Setting Task Attributes/Properties<title>
> + <para>
> + Task attributes/Properties are set in the same way as ordinary
> script variables.
> + <para>
> + <programlisting> // Setting a property named MyProp of type double
> + var double d
> + set TC.MyProp = d <programlisting>
> + <para>
> + <para>
> + <section>
> + <section>
> <title><symbol>function<symbol><title>
> <para>Statements
> can be grouped in functions. A function can only call a function
>

Applied, thanks.

Peter