Public Member Functions | Protected Attributes | List of all members
RTT::extras::FileDescriptorSimulationActivity Class Reference

#include <FileDescriptorSimulationActivity.hpp>

Inheritance diagram for RTT::extras::FileDescriptorSimulationActivity:
Inheritance graph
[legend]

Public Member Functions

void clearAllWatches ()
 Does nothing. More...
 
virtual bool execute ()
 Returns true. More...
 
 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 unsigned getCpuAffinity () const
 Returns 0. More...
 
virtual Seconds getPeriod () const
 Returns period. More...
 
int getTimeout () const
 Return 0. More...
 
int getTimeout_us () const
 Returns 0. More...
 
bool hasError () const
 
bool hasTimeout () const
 
virtual bool isActive () const
 Returns true. More...
 
virtual bool isPeriodic () const
 Returns true iff (0 != period) More...
 
virtual bool isRunning () const
 Returns true. More...
 
bool isUpdated (int fd) const
 
bool isWatched (int fd) const
 Returns false always. More...
 
virtual bool setCpuAffinity (unsigned cpu)
 Returns true. More...
 
virtual bool setPeriod (Seconds s)
 If s>0 then returns true and period == s, otherwise returns false. More...
 
void setTimeout (int timeout)
 Does nothing. More...
 
void setTimeout_us (int timeout_us)
 Does nothing. More...
 
virtual bool start ()
 Returns true. More...
 
virtual bool stop ()
 Returns true. More...
 
virtual os::ThreadInterfacethread ()
 Returns os::MainThread::Instance() More...
 
virtual bool timeout ()
 Returns true. More...
 
virtual bool trigger ()
 Returns true. More...
 
void unwatch (int fd)
 Does nothing. More...
 
void watch (int fd)
 Does nothing. 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 ~FileDescriptorSimulationActivity ()
 
- Public Member Functions inherited from RTT::extras::FileDescriptorActivityInterface
virtual ~FileDescriptorActivityInterface ()
 
- Public Member Functions inherited from RTT::base::ActivityInterface
 ActivityInterface ()
 
 ActivityInterface (RunnableInterface *run)
 
virtual RunnableInterfacegetRunner () const
 
virtual bool run (RunnableInterface *r)
 
virtual ~ActivityInterface ()
 

Protected Attributes

base::RunnableInterface::WorkReason lastReason
 
Seconds period
 
bool running
 
- Protected Attributes inherited from RTT::base::ActivityInterface
RunnableInterfacerunner
 

Additional Inherited Members

- Public Types inherited from RTT::base::ActivityInterface
typedef boost::shared_ptr< ActivityInterfaceshared_ptr
 
- Protected Member Functions inherited from RTT::base::ActivityInterface
void disableRun (RunnableInterface *caller)
 

Detailed Description

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.

Note
Component OwnThread operations are executed by the MainThread, which is correct for a unit test case that is directly executing.

Definition at line 58 of file FileDescriptorSimulationActivity.hpp.

Constructor & Destructor Documentation

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.

FileDescriptorSimulationActivity::~FileDescriptorSimulationActivity ( )
virtual

Cleanup and notify the base::RunnableInterface that we are gone.

Definition at line 98 of file FileDescriptorSimulationActivity.cpp.

Member Function Documentation

void FileDescriptorSimulationActivity::clearAllWatches ( )
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 117 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::execute ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 225 of file FileDescriptorSimulationActivity.cpp.

unsigned FileDescriptorSimulationActivity::getCpuAffinity ( ) const
virtual

Returns 0.

Implements RTT::base::ActivityInterface.

Definition at line 214 of file FileDescriptorSimulationActivity.cpp.

Seconds FileDescriptorSimulationActivity::getPeriod ( ) const
virtual

Returns period.

Implements RTT::base::ActivityInterface.

Definition at line 195 of file FileDescriptorSimulationActivity.cpp.

int FileDescriptorSimulationActivity::getTimeout ( ) const
virtual
int FileDescriptorSimulationActivity::getTimeout_us ( ) const
virtual
bool FileDescriptorSimulationActivity::hasError ( ) const
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.

bool FileDescriptorSimulationActivity::hasTimeout ( ) const
virtual

Return (Timeout == lastReason)

See also
work()

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 132 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::isActive ( ) const
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 190 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::isPeriodic ( ) const
virtual

Returns true iff (0 != period)

Implements RTT::base::ActivityInterface.

Definition at line 200 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::isRunning ( ) const
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 185 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::isUpdated ( int  fd) const
virtual

Return (IOReady == lastReason)

See also
work()

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 127 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::isWatched ( int  fd) const
virtual

Returns false always.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 121 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::setCpuAffinity ( unsigned  cpu)
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 219 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::setPeriod ( Seconds  s)
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.

void FileDescriptorSimulationActivity::setTimeout ( int  timeout)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 142 of file FileDescriptorSimulationActivity.cpp.

void FileDescriptorSimulationActivity::setTimeout_us ( int  timeout_us)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 147 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::start ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 167 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::stop ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 176 of file FileDescriptorSimulationActivity.cpp.

os::ThreadInterface * FileDescriptorSimulationActivity::thread ( )
virtual
bool FileDescriptorSimulationActivity::timeout ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 235 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::trigger ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 230 of file FileDescriptorSimulationActivity.cpp.

void FileDescriptorSimulationActivity::unwatch ( int  fd)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 112 of file FileDescriptorSimulationActivity.cpp.

void FileDescriptorSimulationActivity::watch ( int  fd)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 107 of file FileDescriptorSimulationActivity.cpp.

void FileDescriptorSimulationActivity::work ( base::RunnableInterface::WorkReason  reason)
virtual

If have a runner then pass the reason to the runner and store in lastReason.

Definition at line 245 of file FileDescriptorSimulationActivity.cpp.

Member Data Documentation

base::RunnableInterface::WorkReason RTT::extras::FileDescriptorSimulationActivity::lastReason
protected

Value passed to last work() call Used to determine the return from isUpdated() and hasTimeout()

Definition at line 172 of file FileDescriptorSimulationActivity.hpp.

Seconds RTT::extras::FileDescriptorSimulationActivity::period
protected

Fake period - some classes require period!=0. Is initialized to 0

Definition at line 167 of file FileDescriptorSimulationActivity.hpp.

bool RTT::extras::FileDescriptorSimulationActivity::running
protected

Definition at line 169 of file FileDescriptorSimulationActivity.hpp.


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


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:43