Orocos Real-Time Toolkit  2.9.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
RTT::base::ActivityInterface Class Referenceabstract

Interface to start/stop and query a Activity. More...

#include <rtt/base/ActivityInterface.hpp>

Inheritance diagram for RTT::base::ActivityInterface:
RTT::Activity RTT::extras::FileDescriptorSimulationActivity RTT::extras::PeriodicActivity RTT::extras::SequentialActivity RTT::extras::SlaveActivity RTT::corba::CorbaDispatcher RTT::corba::OrbRunner RTT::extras::FileDescriptorActivity RTT::extras::IRQActivity RTT::mqueue::Dispatcher RTT::extras::SimulationActivity

Public Types

typedef boost::shared_ptr< ActivityInterfaceshared_ptr
 

Public Member Functions

 ActivityInterface ()
 
 ActivityInterface (RunnableInterface *run)
 
virtual ~ActivityInterface ()
 
virtual bool run (RunnableInterface *r)
 Run exclusively this RunnableInterface. More...
 
virtual bool start ()=0
 Start the activity. More...
 
virtual bool stop ()=0
 Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call RunnableInterface::breakLoop(). More...
 
virtual bool isRunning () const =0
 Query if the activity is initialized and executing. More...
 
virtual bool isActive () const =0
 Query if the activity is started. More...
 
virtual Seconds getPeriod () const =0
 Get the periodicity of this activity in Seconds. More...
 
virtual bool isPeriodic () const =0
 Inspect if this activity is periodic. More...
 
virtual bool setPeriod (Seconds s)=0
 Set the periodicity of this activity in Seconds. More...
 
virtual unsigned getCpuAffinity () const =0
 Get the cpu affinity of this activity. More...
 
virtual bool setCpuAffinity (unsigned cpu)=0
 Set the cpu affinity of this activity. More...
 
virtual bool execute ()=0
 Execute this activity such that it executes a step or loop of the RunnableInterface. More...
 
virtual bool trigger ()=0
 Trigger that work has to be done. More...
 
virtual bool timeout ()=0
 Requests this Activity to wakeup and call step() + work(Timeout). More...
 
virtual os::ThreadInterfacethread ()=0
 Returns a pointer to the thread which will run this activity. More...
 
virtual RunnableInterfacegetRunner () const
 Returns a pointer to the RunnableInterface instance. More...
 

Protected Member Functions

void disableRun (RunnableInterface *caller)
 This method is only meant for RunnableInterface (ie runner) in order to inform the ActivityInterface it should no longer be used. More...
 

Protected Attributes

RunnableInterfacerunner
 

Friends

class RunnableInterface
 

Detailed Description

Interface to start/stop and query a Activity.

A ActivityInterface provides the control methods for activities. An activity can be periodic, non periodic, event driven or any activity object which can be started, stopped and be queried for their state and (optional) period.

It is complementary to the RunnableInterface, which defines the methods for the functionality that is executed.

See also
RunnableInterface

Definition at line 62 of file ActivityInterface.hpp.

Member Typedef Documentation

Constructor & Destructor Documentation

RTT::base::ActivityInterface::ActivityInterface ( )
inline

Definition at line 79 of file ActivityInterface.hpp.

ActivityInterface::ActivityInterface ( RunnableInterface run)

Definition at line 45 of file ActivityInterface.cpp.

References runner, and RTT::base::RunnableInterface::setActivity().

ActivityInterface::~ActivityInterface ( )
virtual

Definition at line 50 of file ActivityInterface.cpp.

References runner, and RTT::base::RunnableInterface::setActivity().

Member Function Documentation

void RTT::base::ActivityInterface::disableRun ( RunnableInterface caller)
inlineprotected

This method is only meant for RunnableInterface (ie runner) in order to inform the ActivityInterface it should no longer be used.

run(0) can not be used in this case because it would recurse.

Definition at line 73 of file ActivityInterface.hpp.

Referenced by RTT::base::RunnableInterface::setActivity(), and RTT::base::RunnableInterface::~RunnableInterface().

virtual bool RTT::base::ActivityInterface::execute ( )
pure 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, in which case execute() returns false.

Semantics: If execute() returns true, the activity has been executed exactly once during execute().

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

Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SequentialActivity, and RTT::extras::SimulationActivity.

Referenced by RTT::base::TaskCore::update().

virtual unsigned RTT::base::ActivityInterface::getCpuAffinity ( ) const
pure virtual
virtual Seconds RTT::base::ActivityInterface::getPeriod ( ) const
pure virtual
RunnableInterface * ActivityInterface::getRunner ( ) const
virtual

Returns a pointer to the RunnableInterface instance.

Definition at line 70 of file ActivityInterface.cpp.

References runner.

Referenced by RTT::ExecutionEngine::setActivity().

virtual bool RTT::base::ActivityInterface::isActive ( ) const
pure 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

Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.

Referenced by RTT::base::TaskCore::isActive(), RTT::ExecutionEngine::removeFunction(), run(), and RTT::extras::SlaveActivity::start().

virtual bool RTT::base::ActivityInterface::isPeriodic ( ) const
pure 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.

Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.

virtual bool RTT::base::ActivityInterface::isRunning ( ) const
pure 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

Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.

Referenced by RTT::base::RunnableInterface::~RunnableInterface().

bool ActivityInterface::run ( RunnableInterface r)
virtual

Run exclusively this RunnableInterface.

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

Definition at line 57 of file ActivityInterface.cpp.

References isActive(), runner, and RTT::base::RunnableInterface::setActivity().

Referenced by RTT::TaskContext::setActivity().

virtual bool RTT::base::ActivityInterface::setCpuAffinity ( unsigned  cpu)
pure virtual

Set the cpu affinity of this activity.

Returns
true if it could be updated, false otherwise.

Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.

Referenced by RTT::base::TaskCore::setCpuAffinity().

virtual bool RTT::base::ActivityInterface::setPeriod ( Seconds  s)
pure virtual

Set the periodicity of this activity in Seconds.

Note that not all activity implementation support periods. A period of s == 0 indicates non periodic. A non supported setting returns false.

Returns
true if it could be updated, false otherwise.

Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.

Referenced by RTT::base::TaskCore::setPeriod().

virtual bool RTT::base::ActivityInterface::start ( )
pure virtual
virtual bool RTT::base::ActivityInterface::stop ( )
pure 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

Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.

Referenced by RTT::corba::TaskContextServer::DestroyOrb(), RTT::base::TaskCore::fatal(), RTT::TaskContext::forceActivity(), and RTT::TaskContext::setActivity().

virtual os::ThreadInterface* RTT::base::ActivityInterface::thread ( )
pure virtual
virtual bool RTT::base::ActivityInterface::timeout ( )
pure virtual

Requests this Activity to wakeup and call step() + work(Timeout).

Will be ignored for periodic activities, since they use an internal timing mechanism, but can be used for non-periodic activities which want to emulate a timeout happening towards the base::RunnableInterface.

Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.

Referenced by RTT::scripting::StateMachine::createEventTransition(), RTT::extras::SlaveActivity::timeout(), and RTT::base::TaskCore::trigger().

virtual bool RTT::base::ActivityInterface::trigger ( )
pure virtual

Trigger that work has to be done.

When you invoke trigger(), you intend to notify the mechanism 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, in which case trigger returns false.

Semantics: If trigger() returns true, the activity will be executed at least once from the moment trigger() is called.

Requests this Activity to wakeup and call step() + work(Trigger). If the thread is periodic, it will continue sleeping for the remainder of the time after the work() has finished.

Return values
trueWhen this->isActive() and the implementation allows external triggers.
falseWhen !this->isActive() or the implementation does not allow external triggering.

Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.

Referenced by RTT::ExecutionEngine::process(), and RTT::extras::SlaveActivity::trigger().

Friends And Related Function Documentation

friend class RunnableInterface
friend

Definition at line 75 of file ActivityInterface.hpp.

Member Data Documentation

RunnableInterface* RTT::base::ActivityInterface::runner
protected

The documentation for this class was generated from the following files: