Orocos Real-Time Toolkit
2.9.0
|
Simulate a FileDescriptorActivity (FDA) Primarily this is designed for unit tests that are testing components that require a FDA. More...
#include <rtt/extras/FileDescriptorSimulationActivity.hpp>
Public Types | |
typedef boost::shared_ptr< ActivityInterface > | shared_ptr |
Public Member Functions | |
FileDescriptorSimulationActivity (int priority, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity") | |
FileDescriptorSimulationActivity (int scheduler, int priority, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity") | |
FileDescriptorSimulationActivity (int scheduler, int priority, Seconds period, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity") | |
FileDescriptorSimulationActivity (int scheduler, int priority, Seconds period, unsigned cpu_affinity, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity") | |
virtual | ~FileDescriptorSimulationActivity () |
Cleanup and notify the base::RunnableInterface that we are gone. More... | |
void | watch (int fd) |
Does nothing. More... | |
void | unwatch (int fd) |
Does nothing. More... | |
void | clearAllWatches () |
Does nothing. More... | |
bool | isWatched (int fd) const |
Returns false always. More... | |
bool | isUpdated (int fd) const |
Return (IOReady == lastReason) More... | |
bool | hasTimeout () const |
Return (Timeout == lastReason) More... | |
bool | hasError () const |
True if one of the file descriptors has a problem (for instance it has been closed) More... | |
void | setTimeout (int timeout) |
Does nothing. More... | |
void | setTimeout_us (int timeout_us) |
Does nothing. More... | |
int | getTimeout () const |
Return 0. More... | |
int | getTimeout_us () const |
Returns 0. More... | |
virtual bool | start () |
Returns true. More... | |
virtual bool | stop () |
Returns true. More... | |
virtual bool | isRunning () const |
Returns true. More... | |
virtual bool | isActive () const |
Returns true. More... | |
virtual Seconds | getPeriod () const |
Returns period. More... | |
virtual bool | isPeriodic () const |
Returns true iff (0 != period) More... | |
virtual bool | setPeriod (Seconds s) |
If s>0 then returns true and period == s, otherwise returns false. More... | |
virtual unsigned | getCpuAffinity () const |
Returns 0. More... | |
virtual bool | setCpuAffinity (unsigned cpu) |
Returns true. More... | |
virtual bool | execute () |
Returns true. More... | |
virtual bool | trigger () |
Returns true. More... | |
virtual bool | timeout () |
Returns true. More... | |
virtual os::ThreadInterface * | thread () |
Returns os::MainThread::Instance() More... | |
virtual void | work (base::RunnableInterface::WorkReason reason) |
If have a runner then pass the reason to the runner and store in lastReason. More... | |
virtual bool | run (RunnableInterface *r) |
Run exclusively this RunnableInterface. More... | |
virtual RunnableInterface * | getRunner () 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 | |
Seconds | period |
Fake period - some classes require period!=0. More... | |
bool | running |
base::RunnableInterface::WorkReason | lastReason |
Value passed to last work() call Used to determine the return from isUpdated() and hasTimeout() More... | |
RunnableInterface * | runner |
Simulate a FileDescriptorActivity (FDA) Primarily this is designed for unit tests that are testing components that require a FDA.
This implementation allows deterministic cycling of such a component.
The intended use case is a component that is woken up by its FDA and then the component determines why it was woken up by calling isUpdated(), hasTimeout(), and hasError(). The unit test code should call work() with an appropriate reason, which will end up being returned to the component through the above calls. So a unit test call of work(IOReady) will result in isUpdated() returning true to the component, and similarly for work(TimeOut) and hasTimeout(). Currently hasError() always returns false - there is no way to simulate this with the current implementation.
Definition at line 58 of file FileDescriptorSimulationActivity.hpp.
|
inherited |
Definition at line 77 of file ActivityInterface.hpp.
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity | ( | int | priority, |
base::RunnableInterface * | _r = 0 , |
||
const std::string & | name = "FileDescriptorSimulationActivity" |
||
) |
Definition at line 37 of file FileDescriptorSimulationActivity.cpp.
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity | ( | int | scheduler, |
int | priority, | ||
base::RunnableInterface * | _r = 0 , |
||
const std::string & | name = "FileDescriptorSimulationActivity" |
||
) |
Definition at line 50 of file FileDescriptorSimulationActivity.cpp.
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity | ( | int | scheduler, |
int | priority, | ||
Seconds | period, | ||
base::RunnableInterface * | _r = 0 , |
||
const std::string & | name = "FileDescriptorSimulationActivity" |
||
) |
Definition at line 64 of file FileDescriptorSimulationActivity.cpp.
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity | ( | int | scheduler, |
int | priority, | ||
Seconds | period, | ||
unsigned | cpu_affinity, | ||
base::RunnableInterface * | _r = 0 , |
||
const std::string & | name = "FileDescriptorSimulationActivity" |
||
) |
Definition at line 80 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Cleanup and notify the base::RunnableInterface that we are gone.
Definition at line 98 of file FileDescriptorSimulationActivity.cpp.
References stop().
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 117 of file FileDescriptorSimulationActivity.cpp.
|
inlineprotectedinherited |
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 |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 225 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns 0.
Implements RTT::base::ActivityInterface.
Definition at line 214 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns period.
Implements RTT::base::ActivityInterface.
Definition at line 195 of file FileDescriptorSimulationActivity.cpp.
References period.
|
virtualinherited |
Returns a pointer to the RunnableInterface instance.
Definition at line 70 of file ActivityInterface.cpp.
References RTT::base::ActivityInterface::runner.
Referenced by RTT::ExecutionEngine::setActivity().
|
virtual |
Return 0.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 152 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns 0.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 157 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
True if one of the file descriptors has a problem (for instance it has been closed)
This should only be used from within the base::RunnableInterface this activity is driving, i.e. in TaskContext::updateHook() or TaskContext::errorHook().
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 137 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Return (Timeout == lastReason)
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 132 of file FileDescriptorSimulationActivity.cpp.
References lastReason, and RTT::base::RunnableInterface::TimeOut.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 190 of file FileDescriptorSimulationActivity.cpp.
References running.
|
virtual |
Returns true iff (0 != period)
Implements RTT::base::ActivityInterface.
Definition at line 200 of file FileDescriptorSimulationActivity.cpp.
References period.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 185 of file FileDescriptorSimulationActivity.cpp.
References running.
|
virtual |
Return (IOReady == lastReason)
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 127 of file FileDescriptorSimulationActivity.cpp.
References RTT::base::RunnableInterface::IOReady, and lastReason.
|
virtual |
Returns false always.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 121 of file FileDescriptorSimulationActivity.cpp.
|
virtualinherited |
Run exclusively this RunnableInterface.
r | The RunnableInterface to run exclusively. |
Definition at line 57 of file ActivityInterface.cpp.
References RTT::base::ActivityInterface::isActive(), RTT::base::ActivityInterface::runner, and RTT::base::RunnableInterface::setActivity().
Referenced by RTT::TaskContext::setActivity().
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 219 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
If s>0 then returns true and period == s, otherwise returns false.
Implements RTT::base::ActivityInterface.
Definition at line 205 of file FileDescriptorSimulationActivity.cpp.
References period.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 142 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 147 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 167 of file FileDescriptorSimulationActivity.cpp.
References running.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 176 of file FileDescriptorSimulationActivity.cpp.
References running.
Referenced by ~FileDescriptorSimulationActivity().
|
virtual |
Returns os::MainThread::Instance()
Implements RTT::base::ActivityInterface.
Definition at line 240 of file FileDescriptorSimulationActivity.cpp.
References RTT::os::MainThread::Instance().
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 235 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 230 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 112 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 107 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
If have a runner then pass the reason to the runner and store in lastReason.
Definition at line 245 of file FileDescriptorSimulationActivity.cpp.
References lastReason, RTT::base::ActivityInterface::runner, and RTT::base::RunnableInterface::work().
|
protected |
Value passed to last work() call Used to determine the return from isUpdated() and hasTimeout()
Definition at line 172 of file FileDescriptorSimulationActivity.hpp.
Referenced by hasTimeout(), isUpdated(), and work().
|
protected |
Fake period - some classes require period!=0.
Is initialized to 0
Definition at line 167 of file FileDescriptorSimulationActivity.hpp.
Referenced by getPeriod(), isPeriodic(), and setPeriod().
|
protectedinherited |
Definition at line 65 of file ActivityInterface.hpp.
Referenced by RTT::base::ActivityInterface::ActivityInterface(), RTT::Activity::breakLoop(), RTT::extras::SlaveActivity::execute(), RTT::extras::PeriodicActivity::finalize(), RTT::Activity::finalize(), RTT::base::ActivityInterface::getRunner(), RTT::Activity::initialize(), RTT::extras::PeriodicActivity::initialize(), RTT::Activity::loop(), RTT::base::ActivityInterface::run(), RTT::extras::SequentialActivity::start(), RTT::extras::SlaveActivity::start(), RTT::Activity::step(), RTT::extras::PeriodicActivity::step(), RTT::extras::FileDescriptorActivity::step(), RTT::extras::SequentialActivity::stop(), RTT::extras::SlaveActivity::stop(), RTT::extras::SequentialActivity::trigger(), work(), RTT::extras::PeriodicActivity::work(), RTT::Activity::work(), RTT::extras::FileDescriptorActivity::work(), and RTT::base::ActivityInterface::~ActivityInterface().
|
protected |
Definition at line 169 of file FileDescriptorSimulationActivity.hpp.
Referenced by isActive(), isRunning(), start(), and stop().