Orocos Real-Time Toolkit
2.8.3
|
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 false. More... | |
bool | hasTimeout () const |
Return false. 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 os::ThreadInterface * | thread () |
Returns os::MainThread::Instance() 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 |
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 49 of file FileDescriptorSimulationActivity.cpp.
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity | ( | int | scheduler, |
int | priority, | ||
Seconds | period, | ||
base::RunnableInterface * | _r = 0 , |
||
const std::string & | name = "FileDescriptorSimulationActivity" |
||
) |
Definition at line 62 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 77 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Cleanup and notify the base::RunnableInterface that we are gone.
Definition at line 94 of file FileDescriptorSimulationActivity.cpp.
References stop().
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 113 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 221 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns 0.
Implements RTT::base::ActivityInterface.
Definition at line 210 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns period.
Implements RTT::base::ActivityInterface.
Definition at line 191 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 148 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns 0.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 153 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 133 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Return false.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 128 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 186 of file FileDescriptorSimulationActivity.cpp.
References running.
|
virtual |
Returns true iff (0 != period)
Implements RTT::base::ActivityInterface.
Definition at line 196 of file FileDescriptorSimulationActivity.cpp.
References period.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 181 of file FileDescriptorSimulationActivity.cpp.
References running.
|
virtual |
Return false.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 123 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns false always.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 117 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 215 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
If s>0 then returns true and period == s, otherwise returns false.
Implements RTT::base::ActivityInterface.
Definition at line 201 of file FileDescriptorSimulationActivity.cpp.
References period.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 138 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 143 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 163 of file FileDescriptorSimulationActivity.cpp.
References running.
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 172 of file FileDescriptorSimulationActivity.cpp.
References running.
Referenced by ~FileDescriptorSimulationActivity().
|
virtual |
Returns os::MainThread::Instance()
Implements RTT::base::ActivityInterface.
Definition at line 231 of file FileDescriptorSimulationActivity.cpp.
References RTT::os::MainThread::Instance().
|
virtual |
Returns true.
Implements RTT::base::ActivityInterface.
Definition at line 226 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 108 of file FileDescriptorSimulationActivity.cpp.
|
virtual |
Does nothing.
Implements RTT::extras::FileDescriptorActivityInterface.
Definition at line 103 of file FileDescriptorSimulationActivity.cpp.
|
protected |
Fake period - some classes require period!=0.
Is initialized to 0
Definition at line 163 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::Activity::finalize(), RTT::extras::PeriodicActivity::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(), and RTT::base::ActivityInterface::~ActivityInterface().
|
protected |
Definition at line 165 of file FileDescriptorSimulationActivity.hpp.
Referenced by isActive(), isRunning(), start(), and stop().