SlaveActivity Class Reference
[Activity (thread) classes.]

#include </home/sspr/src/www/orocos-1.0/export/build/orocos-rtt-1.2.2/build/rtt/SlaveActivity.hpp>

Inheritance diagram for SlaveActivity:

ActivityInterface List of all members.

Detailed Description

An ActivityInterface implementation which executes 'step' upon the invocation of 'trigger()', which is called by another Activity.

The SlaveActivity can only be started if the master is active or if no master is present. If a master is used, this activity takes periodicity over from the master. If no master is present, use one of the alternative constructors to make a periodic slave or a non periodic slave.

Reactions to trigger():

In the non periodic case, RunnableInterface::loop() is called, in the periodic case, RunnableInterface::step() is called. In case the RunnableInterface did not implement loop(), step() is invoked by default. If no RunnableInterface is given, said functions are called upon SlaveActivity itself.


Public Member Functions

 SlaveActivity (ActivityInterface *master, RunnableInterface *run=0)
 Create an activity which is the slave of master.
 SlaveActivity (double period, RunnableInterface *run=0)
 Create an activity which is periodic.
 SlaveActivity (RunnableInterface *run=0)
 Create an activity for which trigger() will not be periodically called.
 ~SlaveActivity ()
 Cleanup and notify the RunnableInterface that we are gone.
Seconds getPeriod () const
 Get the periodicity of this activity in Seconds.
OS::ThreadInterfacethread ()
 Returns a pointer to the thread which will run this activity.
bool initialize ()
void step ()
void loop ()
bool breakLoop ()
void finalize ()
bool start ()
 Start this slave.
bool stop ()
 Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call RunnableInterface::breakLoop().
bool isRunning () const
 Query if the activity is initialized and executing.
bool run (RunnableInterface *_r)
 Run exclusively this RunnableInterface.
bool isPeriodic () const
 Inspect if this activity is periodic.
bool isActive () const
 Query if the activity is started.
bool execute ()
 Execute this activity such that it executes a step or loop of the RunnableInterface.
bool trigger ()
 Trigger that work has to be done.


Constructor & Destructor Documentation

SlaveActivity ( ActivityInterface master,
RunnableInterface run = 0 
)

Create an activity which is the slave of master.

Parameters:
master The activity which will execute this activity.
run Run this instance.

SlaveActivity ( double  period,
RunnableInterface run = 0 
)

Create an activity which is periodic.

If period == 0.0, this constructor is equivalent to the one below for non periodic activities.

Parameters:
period The periodicity at which you will trigger() this activity.
run Run this instance.

SlaveActivity ( RunnableInterface run = 0  ) 

Create an activity for which trigger() will not be periodically called.

The period of this activity will be 0.0.

Parameters:
run Run this instance.


Member Function Documentation

Seconds getPeriod (  )  const [virtual]

Get the periodicity of this activity in Seconds.

Returns:
The execution period of this activity (zero if !this->isPeriodic() ).

Implements ActivityInterface.

OS::ThreadInterface* thread (  )  [virtual]

Returns a pointer to the thread which will run this activity.

Will not be null.

Implements ActivityInterface.

bool start (  )  [virtual]

Start this slave.

Only allowed if the master activity is already running.

Return values:
false if !master->isRunning() || this->isRunning() || initialize() returns false
true othwerise.

Implements ActivityInterface.

bool stop (  )  [virtual]

Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call RunnableInterface::breakLoop().

If no errors occured, RunnableInterface::finalize() is called.

See also:
isPeriodic()
Returns:
true if the activity is stopped, false otherwise

Implements ActivityInterface.

bool isRunning (  )  const [virtual]

Query if the activity is initialized and executing.

This is more strict than isActive(), it is only true after initialize() is executed and before finalize() is executed. More-over, an Activity may decide to be temporarily not running (not executing code), waiting for a signal to proceed. If this->isActive() and !this->isRunning() then the Activity is in a waiting state.

Returns:
true if it is running, false otherwise

Implements ActivityInterface.

bool run ( RunnableInterface _r  )  [virtual]

Run exclusively this RunnableInterface.

Precondition:
this->isRunning() == false
Parameters:
r The RunnableInterface to run exclusively.
Returns:
true if succeeded, false otherwise

Implements ActivityInterface.

bool isPeriodic (  )  const [virtual]

Inspect if this activity is periodic.

If so, it will call RunnableInterface::step(). If the activity is not periodic, it will call RunnableInterface::loop().

Returns:
true if periodic.

Implements ActivityInterface.

bool isActive (  )  const [virtual]

Query if the activity is started.

This is less strict than isRunning(), it is true during initialize(), step() or loop() and finalize(). Use this method to check if an activity was start()ed.

Returns:
true if it is active, false otherwise

Implements ActivityInterface.

bool execute (  )  [virtual]

Execute this activity such that it executes a step or loop of the RunnableInterface.

When you invoke execute() you intend to call the step() or loop() methods. Some activity implementations allow a user controlled execute, others ignore it.

Return values:
true When this->isActive() and the implementation allows external executes.
false When !this->isActive() or the implementation does not allow external updating.
See also:
trigger() for use in callbacks which want execute() to be executed.

Implements ActivityInterface.

bool trigger (  )  [virtual]

Trigger that work has to be done.

When you invoke trigger(), you intend to notify the instance that calls execute(), that execute() should be called. This allows a separation between actually executing code (execute()) and notifying that code must be executed (trigger()). A trigger may be ignored by the implementation.

Return values:
true When this->isActive() and the implementation allows external triggers.
false When !this->isActive() or the implementation does not allow external triggering.

Implements ActivityInterface.


The documentation for this class was generated from the following file:
Generated on Fri Oct 19 16:27:25 2007 for Orocos by  doxygen 1.5.1