ProgramProcessor Class Reference
[Execution Engine]

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

Inheritance diagram for ProgramProcessor:

RunnableInterface RunnableInterface List of all members.

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().


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 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)
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 void loop ()
 The method that will be executed once when this class is run in a non periodic thread.
virtual bool breakLoop ()
 This method is called by the framework to break out of the loop() method.
ThreadInterface * getThread () const
 Get the thread this object is run in.
virtual void setThread (ThreadInterface *t)
 Set the thread this object will be run in.

Protected Types

typedef ListLockFree< ProgramInterfacePtr > ProgMap

Protected Attributes

ProgMapprograms
std::vector< ProgramInterface * > funcs
AtomicQueue< ProgramInterface *,
NonBlockingPolicy, NonBlockingPolicy > * 
f_queue


Constructor & Destructor Documentation

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

bool 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.

bool 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

bool 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.

virtual bool 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 bool 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.

ActivityInterface * 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.

virtual void 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 ExecutionEngine.

virtual void loop (  )  [virtual, inherited]

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

The default implementation calls step() once.

virtual bool 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 EventProcessor, and ExecutionEngine.

ThreadInterface* getThread (  )  const [inherited]

Get the thread this object is run in.

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


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