50 #include <boost/bind.hpp> 53 #define ORONUM_EE_MQUEUE_SIZE 100 65 using namespace detail;
66 using namespace boost;
82 while (
f_queue->dequeue( foo ) )
86 while (
mqueue->dequeue( dis ) )
104 while (
f_queue->dequeue(foo) ) {
106 if ( foo->
execute() == false ){
124 bool result =
f_queue->enqueue( f );
135 : mf(f),mee(ee), found(false) {}
141 virtual bool isError()
const {
return false; }
196 return !
mqueue->isEmpty();
208 while (
mqueue->dequeue(com) ) {
254 bool result =
mqueue->enqueue( c );
303 if (slave_activity && slave_activity->
getMaster()) {
322 return (thread && thread->
isSelf());
402 )
CATCH(std::exception
const& e,
403 log(
Error) <<
"in updateHook(): switching to exception state because of unhandled exception" << endlog();
404 log(
Error) <<
" " << e.what() << endlog();
407 log(
Error) <<
"in updateHook(): switching to exception state because of unhandled exception" << endlog();
415 )
CATCH(std::exception
const& e,
416 log(
Error) <<
"in errorHook(): switching to exception state because of unhandled exception" << endlog();
417 log(
Error) <<
" " << e.what() << endlog();
420 log(
Error) <<
"in errorHook(): switching to exception state because of unhandled exception" << endlog();
453 name =
"GlobalEngine";
454 log(
Error) <<
"in "<<name<<
": unhandled exception in sent operation." << endlog();
ActivityInterface * getActivity() const
Query for the task this interface is run in.
virtual void setActivity(ActivityInterface *task)
Set the task this interface is run in.
virtual bool trigger()=0
Trigger that work has to be done.
#define TRY(C)
Contains static global configuration variables and cached entries.
virtual void step()
Executes (in that order) Messages, Functions and updateHook() functions of this TaskContext and its c...
void loaded(ExecutionEngine *ee)
Called by the ExecutionEngine ee or before synchronous execution to tell this object it is being load...
virtual bool removeFunction(base::ExecutableInterface *f)
Remove a running function added with runFunction.
bool isSelf() const
Check if the thread that processes messages send to this engine is the same as the calling thread...
void processPortCallbacks()
virtual bool hasWork()
This method is for 'intelligent' activity implementations that wish to see if it is required to call ...
void setMaster(ExecutionEngine *master)
Set the master ExecutionEngine.
virtual void dispose()
Just free this object without executing it.
bool isLoaded()
Returns true if this object is loaded in an ExecutionEngine.
ExecutionEngine * mmaster
A master ExecutionEngine which should process our messages.
virtual void updateHook()
Function where the user must insert his 'application' code.
void waitForMessages(const boost::function< bool(void)> &pred)
Call this if you wish to block on a message arriving in the Execution Engine.
virtual bool isActive() const =0
Query if the activity is started.
RemoveMsg(ExecutableInterface *f, ExecutionEngine *ee)
internal::MWSRQueue< base::PortInterface * > * port_queue
The port callback queue.
The state indicating that a run-time error has occured [red] and needs attention. ...
virtual bool removeSelfFunction(base::ExecutableInterface *f)
Self-removal for a running function added with runFunction.
virtual void finalize()
The method that will be called after the last periodical execution of step() ( or non periodical exec...
internal::MWSRQueue< base::ExecutableInterface * > * f_queue
Stores all functions we're executing.
virtual os::ThreadInterface * getThread() const
Get the thread this object is run in.
unsigned int mCycleCounter
For each update cycle, this counter increments by one.
void waitForMessagesInternal(boost::function< bool(void)> const &pred)
Call this if you wish to block on a message arriving in the Execution Engine.
unsigned int mIOCounter
Number of cycles that were caused by IOReady triggers.
An execution engine serialises (executes one after the other) the execution of all commands...
A thread which is being run.
internal::MWSRQueue< base::DisposableInterface * > * mqueue
Our Message queue.
virtual void executeAndDispose()=0
Execute functionality and free this object.
unsigned int mTimeOutCounter
Number of cycles that were caused by TimeOut triggers.
virtual bool isError() const
virtual void errorHook()
Implement this method to contain code that must be executed in the RunTimeError state, instead of updateHook().
Interface to start/stop and query a Activity.
bool stopTask(base::TaskCore *task)
Stops executing the updateHook of task.
virtual bool initialize()
The method that will be called before the first periodical execution of step() ( or non periodical ex...
The state indicating the component encountered a fatal error and is unable to execute.
virtual os::ThreadInterface * getThread() const
Get the thread that processes messages send to this engine.
virtual bool execute()=0
Executes a piece of functionality.
virtual void exception()
Call this method to indicate a run-time exception happend.
void unloaded()
Called by the ExecutionEngine ee or after synchronous execution to tell this object it is being unloa...
base::TaskCore * getParent()
The base::TaskCore which created this ExecutionEngine.
virtual bool breakUpdateHook()
Implement this function if your code might block for long times inside the updateHook() function...
An object that is executable and is freed after execution.
void waitAndProcessMessages(boost::function< bool(void)> const &pred)
Call this if you wish to block on a message arriving in the Execution Engine and execute it...
This object represents the default Multi-Writer, Single-Reader queue implementation used by Orocos ob...
void setExceptionTask()
Set the 'owner' task in the exception state.
The state indicating the component is running [green].
virtual void work(RunnableInterface::WorkReason reason)
Identical to step() but gives a reason why the function was called.
Notify the Logger in which 'module' the message occured.
The TaskContext is the C++ representation of an Orocos component.
virtual bool start()=0
Start the activity.
base::TaskCore * taskc
The parent or 'owner' of this ExecutionEngine, may be null.
virtual void setActivity(base::ActivityInterface *task)
Overridden version of RTT::base::RunnableInterface::setActivity().
Objects that implement this interface are to be executed in the ExecutionEngine.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
#define ORONUM_EE_MQUEUE_SIZE
virtual void dataOnPortCallback(base::PortInterface *port)
This method implements port callbacks.
The base class of every data flow port.
virtual bool process(base::DisposableInterface *c)
Queue and execute (process) a given message.
virtual bool runFunction(base::ExecutableInterface *f)
Run a given function in step() or loop().
virtual void executeAndDispose()
Execute functionality and free this object.
ExecutionEngine(base::TaskCore *owner=0)
Create an execution engine with a internal::CommandProcessor, scripting::ProgramProcessor and StateMa...
unsigned int mTriggerCounter
Number of cycles that were caused by Trigger triggers.
virtual const std::string & getName() const
Returns the name of this TaskContext.
virtual RunnableInterface * getRunner() const
Returns a pointer to the RunnableInterface instance.
void broadcast()
Wake all threads that are blocking in wait() or wait_until().
virtual bool breakLoop()
This method is called by the framework to break out of the loop() method.
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...
bool wait(Mutex &m)
Wait forever until a condition occurs.
virtual void dispose()=0
Just free this object without executing it.