RTT::ProgramProcessor Class Reference
[Execution Engine]

This class implements a real-time program processor. More...

#include <rtt/ProgramProcessor.hpp>

Inheritance diagram for RTT::ProgramProcessor:
RTT::RunnableInterface RTT::OS::RunnableInterface

List of all members.

Public Types

typedef ProgramInterface::Status Status

Public Member Functions

 ProgramProcessor (int f_queue_size=ORONUM_EXECUTION_PROC_QUEUE_SIZE)
 Constructs a new ProgramProcessor.
bool loadProgram (ProgramInterfacePtr pi)
 Load a new Program.
bool deleteProgram (const std::string &name)
 Completely discard a loaded Program.
bool unloadProgram (const std::string &name)
 Unload a program from this processor.
void clear ()
 Stop and unload all programs from the ProgramProcessor.
Status::ProgramStatus getProgramStatus (const std::string &name) const
 Return the status of a Program.
std::string getProgramStatusStr (const std::string &name) const
 Return the status of a Program as a human readable string.
virtual bool initialize ()
 The method that will be called before the first periodical execution of step() ( or non periodical execution of loop() ), when the thread is started.
virtual void step ()
 The method that will be periodically executed when this class RTT_API is run in a periodic thread.
virtual void finalize ()
 The method that will be called after the last periodical execution of step() ( or non periodical execution of loop() ), when the RunnableInterface is stopped.
virtual bool runFunction (ProgramInterface *f)
 Run a given function in step() or loop().
virtual bool removeFunction (ProgramInterface *f)
 Remove a running function added with runFunction.
std::vector< std::string > getProgramList () const
 Get a list of all loaded Programs.
const ProgramInterfacePtr getProgram (const std::string &name) const
 Get a pointer to a loaded Program.
ProgramInterfacePtr getProgram (const std::string &name)
virtual bool hasWork ()
 This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).
ActivityInterfacegetActivity () const
 Query for the task this interface is run in.
virtual void setActivity (ActivityInterface *task)
 Set the task this interface is run in.
virtual OS::ThreadInterfacegetThread () const
 Get the thread this object is run in.
virtual void loop ()
 The method that will be executed once when this class RTT_API is run in a non periodic thread.
virtual bool breakLoop ()
 This method is called by the framework to break out of the loop() method.
virtual void setThread (ThreadInterface *t)
 Set the thread this object will be run in.

Protected Types

typedef List< ProgramInterfacePtr > ProgMap

Protected Attributes

ProgMapprograms
std::vector< ProgramInterface * > funcs
Queue< ProgramInterface
*, NonBlockingPolicy,
NonBlockingPolicy > * 
f_queue
OS::Mutex syncer

Detailed Description

This class implements a real-time program processor.

It executes Realtime Programs when running.

Changing the Program Processing Policy

The default policy of the ProgramProcessor is to call ProgramInterface::execute() of all loaded programs in each step(). Within the same step(), after all programs are executed, any loaded function is executed. The functions are automatically unloaded when they are in error or finished.

If you want to change this policy, subclass the ProgramProcessor and override the virtual functions, such as step().

Definition at line 77 of file ProgramProcessor.hpp.


Constructor & Destructor Documentation

RTT::ProgramProcessor::ProgramProcessor ( int  f_queue_size = ORONUM_EXECUTION_PROC_QUEUE_SIZE  ) 

Constructs a new ProgramProcessor.

Parameters:
f_queue_size The maximum number of 'functions' this processor can execute

Member Function Documentation

virtual bool RTT::OS::RunnableInterface::breakLoop (  )  [virtual, inherited]

This method is called by the framework to break out of the loop() method.

Reimplement this method to signal loop() to return and return true on success. When this method is not reimplemented by you, it will always return false, denoting that the loop can not be broken. If breakLoop() returns true, the caller will wait until loop() returns.

Returns:
true if the loop could be notified to return.

Reimplemented in RTT::EventProcessor, RTT::ExecutionEngine, and RTT::Timer.

bool RTT::ProgramProcessor::deleteProgram ( const std::string &  name  ) 

Completely discard a loaded Program.

Exceptions:
program_unload_exception if the program is not stopped or does not exist.
Deprecated:
by unloadProgram
ActivityInterface * RTT::RunnableInterface::getActivity (  )  const [inline, inherited]

Query for the task this interface is run in.

Zero denotes that no task is present to run it, and hence no detailed information is available.

Returns:
The Activity which runs this RunnableInterface.

Definition at line 106 of file RunnableInterface.hpp.

virtual OS::ThreadInterface* RTT::RunnableInterface::getThread (  )  const [virtual, inherited]

Get the thread this object is run in.

Returns:
a pointer to the thread or 0 if not run by a thread.

Reimplemented from RTT::OS::RunnableInterface.

virtual bool RTT::RunnableInterface::hasWork (  )  [virtual, inherited]

This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).

By default, false is returned. You should only return true in case there is a temporary reason to (re-)run step.

Returns:
true if this object should be run.
See also:
SequentialActivity implementation to see how this can be of use.

Reimplemented in RTT::CommandProcessor, RTT::EventProcessor, and RTT::ExecutionEngine.

bool RTT::ProgramProcessor::loadProgram ( ProgramInterfacePtr  pi  ) 

Load a new Program.

The Processor takes full ownership and will delete it upon destruction.

Exceptions:
program_load_exception if a program with the same name already exists.
virtual void RTT::OS::RunnableInterface::loop (  )  [virtual, inherited]

The method that will be executed once when this class RTT_API is run in a non periodic thread.

The default implementation calls step() once.

Reimplemented in RTT::Timer.

virtual bool RTT::ProgramProcessor::removeFunction ( ProgramInterface f  )  [virtual]

Remove a running function added with runFunction.

This method is only required if the function is to be destroyed and is still present in the ProgramProcessor. This also stops the given function and f becomes in the ProgramInterface::Status::Unloaded state.

virtual bool RTT::ProgramProcessor::runFunction ( ProgramInterface f  )  [virtual]

Run a given function in step() or loop().

The function may only be destroyed after isFunctionFinished() returns true,the Processor is stopped or removeFunction() was invoked. The number of functions the Processor can run in parallel is set in its constructor argument queue_size. In addition to that number, a queue of the same size is allocated for pending functions to execute.

Returns:
false if the Processor is not running or the 'pending' queue is full.
See also:
isFunctionFinished, acceptCommands, removeFunction
virtual void RTT::RunnableInterface::setActivity ( ActivityInterface task  )  [virtual, inherited]

Set the task this interface is run in.

A Zero means no task is running it.

Parameters:
task The ActivityInterface running this interface.

Reimplemented in RTT::ExecutionEngine.

bool RTT::ProgramProcessor::unloadProgram ( const std::string &  name  ) 

Unload a program from this processor.

Exceptions:
program_unload_exception if the program is not stopped or does not exist.

The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:22:44 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3