Interface to start/stop and query a Activity. More...
#include <ActivityInterface.hpp>
Public Types | |
typedef boost::shared_ptr< ActivityInterface > | shared_ptr |
Public Member Functions | |
ActivityInterface () | |
ActivityInterface (RunnableInterface *run) | |
virtual bool | execute ()=0 |
virtual unsigned | getCpuAffinity () const =0 |
virtual Seconds | getPeriod () const =0 |
virtual RunnableInterface * | getRunner () const |
virtual bool | isActive () const =0 |
virtual bool | isPeriodic () const =0 |
virtual bool | isRunning () const =0 |
virtual bool | run (RunnableInterface *r) |
virtual bool | setCpuAffinity (unsigned cpu)=0 |
virtual bool | setPeriod (Seconds s)=0 |
virtual bool | start ()=0 |
virtual bool | stop ()=0 |
virtual os::ThreadInterface * | thread ()=0 |
virtual bool | timeout ()=0 |
virtual bool | trigger ()=0 |
virtual | ~ActivityInterface () |
Protected Member Functions | |
void | disableRun (RunnableInterface *caller) |
Protected Attributes | |
RunnableInterface * | runner |
Friends | |
class | RunnableInterface |
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.
Definition at line 62 of file ActivityInterface.hpp.
typedef boost::shared_ptr<ActivityInterface> RTT::base::ActivityInterface::shared_ptr |
Definition at line 77 of file ActivityInterface.hpp.
|
inline |
Definition at line 79 of file ActivityInterface.hpp.
ActivityInterface::ActivityInterface | ( | RunnableInterface * | run | ) |
Definition at line 45 of file ActivityInterface.cpp.
|
virtual |
Definition at line 50 of file ActivityInterface.cpp.
|
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.
|
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().
true | When this->isActive() and the implementation allows external executes. |
false | When !this->isActive() or the implementation does not allow external updating. |
Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, RTT::extras::SequentialActivity, and RTT::extras::SimulationActivity.
|
pure virtual |
Get the cpu affinity of this activity
Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.
|
pure virtual |
Get the periodicity of this activity in Seconds
Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.
|
virtual |
Returns a pointer to the RunnableInterface instance
Definition at line 70 of file ActivityInterface.cpp.
|
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.
Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.
|
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().
Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.
|
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.
Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.
|
virtual |
Run exclusively this RunnableInterface.
r | The RunnableInterface to run exclusively. |
Definition at line 57 of file ActivityInterface.cpp.
|
pure virtual |
Set the cpu affinity of this activity.
Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.
|
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.
Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.
|
pure virtual |
Start the activity. This will call RunnableInterface::initialize() and upon success, effectively start the activity, by running the RunnableInterface::step() or RunnableInterface::loop() in a thread.
Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::IRQActivity, RTT::extras::SequentialActivity, and RTT::extras::SimulationActivity.
|
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.
Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::SlaveActivity, RTT::extras::FileDescriptorSimulationActivity, and RTT::extras::SequentialActivity.
|
pure virtual |
Returns a pointer to the thread which will run this activity. Will not be null.
Implemented in RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, RTT::extras::SimulationActivity, and RTT::extras::SequentialActivity.
|
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::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.
|
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.
true | When this->isActive() and the implementation allows external triggers. |
false | When !this->isActive() or the implementation does not allow external triggering. |
Implemented in RTT::extras::FileDescriptorActivity, RTT::extras::PeriodicActivity, RTT::Activity, RTT::extras::FileDescriptorSimulationActivity, RTT::extras::SlaveActivity, and RTT::extras::SequentialActivity.
|
friend |
Definition at line 75 of file ActivityInterface.hpp.
|
protected |
Definition at line 65 of file ActivityInterface.hpp.