[prev in list] [next in list] [prev in thread] [next in thread] 

List:       orocos-users
Subject:    [Orocos-users] [Orocos-Dev]  How to use Command::reset()
From:       ruben.smits () mech ! kuleuven ! be (Ruben Smits)
Date:       2009-01-29 9:50:34
Message-ID: 200901291050.34612.ruben.smits () mech ! kuleuven ! be
[Download RAW message or body]

On Thursday 29 January 2009 10:37:03 Peter Soetens wrote:
> On Monday 26 January 2009 12:27:18 gde at basystemes.fr wrote:
> > Hie,
> > I try to use the reset on commmands. I thought I could reuse a command
> > which would not be finished. You can see on the following exactly what I
> > tried (on C++ code):
> >
> >
> >  //In the component calling the command :
> >  cmdMyCommand = ...->getCommand("cmdMyCommand");
> >  cmdMyCommand(2);
> >  cmdMyCommand.reset();
> >  cmdMyCommand(3);
>
> Say that after cmdMyCommand(2), another command ('Cx()' ) is called. Would
> you expect cmdMyCommand(3) to be run A. instead of cmdMyCommand(2) or B.
> after 'Cx()' ?
>
> To orocos-dev:
> Sander proposed to check the state of the command when it's pulled from the
> queue. A reset() would then leave it in the queue, but with such a state
> that it would be discarded when dequeued. In addition, if a command ends up
> twice in the queue, the first one is executed and the second one is
> discarded (again by checking state).

This does not look like desired behaviour to me :s, since the execution of the 
commands would depend on the scheduling of the activities of the caller and 
the callee. If the first command is dequeued by the callee before the caller 
queues the second command the execution is different than in the case were the 
caller is not interrupted by the callee in between the two calls of the 
caller.

Ruben

>
> The net result of this minimal change is that the first command in queue is
> executed with the data of the first and the second command is discarded,
> hence my question.

> <code type="patch">
> diff --git a/src/LocalCommand.hpp b/src/LocalCommand.hpp
> index b4e3edf..750843b 100644
> --- a/src/LocalCommand.hpp
> +++ b/src/LocalCommand.hpp
> @@ -226,6 +226,9 @@ namespace RTT
>              }
>
>              virtual bool execute() {
> +                // do not allow to execute twice or if not queued.
> +                if (!this->maccept || this->mexec)
> +                    return false;
>                  this->mvalid = this->exec();
>                  this->mexec = true;
>                  return this->mvalid;
> </code>
>
> Peter
> --
> Peter Soetens -- FMTC -- <http://www.fmtc.be>


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic