Framework Libre Air
flair::core::IODevice Class Referenceabstract

Abstract class for input/ouput system. More...

#include <IODevice.h>

+ Inheritance diagram for flair::core::IODevice:

Public Member Functions

 IODevice (const Object *parent, std::string name)
 Constructor. More...
virtual ~IODevice ()
 Destructor. More...
void AddDeviceToLog (const IODevice *device)
 Add an IODevice to the logs. More...
void AddDataToLog (const io_data *data)
 Add an io_data to the log. More...
void OutputToShMem (bool enabled)
 Send the output to a shared memory. More...
virtual DataType const & GetInputDataType () const
virtual DataType const & GetOutputDataType () const
- Public Member Functions inherited from flair::core::Object
 Object (const Object *parent=NULL, std::string name="", std::string type="")
 Constructor. More...
virtual ~Object ()
 Destructor. More...
std::string ObjectName (void) const
 Name. More...
std::string ObjectType (void) const
 Type. More...
const ObjectParent (void) const
 Parent. More...
std::vector< const Object * > * TypeChilds (void) const
 Childs of the same type. More...
std::vector< const Object * > * Childs (void) const
 Childs. More...
void Information (const char *function, int line, const char *format,...) const
 Formatted information. More...
void Warning (const char *function, const char *format,...) const
 Formatted warning. More...
void Error (const char *function, const char *format,...) const
 Formatted error. More...
bool ErrorOccured (bool recursive=true) const
 Has an errror occured? More...

Public Attributes

Time lastUpdate

Protected Member Functions

void ProcessUpdate (io_data *data)
 Process the childs of type IODevice, and log if needed. More...

Additional Inherited Members

- Public Types inherited from flair::core::Object
enum  color_t { Auto = 0, Red = 31, Green = 32, Orange = 33 }

Detailed Description

Abstract class for input/ouput system.

An input/output system is generally used to describe a sensor, an actuator or a filter.
These systems can be linked (for exemple a sensor with a filter), when an IODevice is created with a parent of type IODevice. In this case, an update of the parent's data will call an update of the child's data (for exemple when a sensor gets new datas, a filter is automatically called).
Output of this object can also be sent to a shared memory using the OutputToShMem method; in order to use it with an external program.

Constructor & Destructor Documentation

flair::core::IODevice::IODevice ( const Object parent,
std::string  name 


Construct an IODevice of Object's type "IODevice" (see Object::ObjectType).
If parent's Object::ObjectType is also "IODevice", this IODevice will be linked to its parent (see ProcessUpdate()).

virtual flair::core::IODevice::~IODevice ( )


Member Function Documentation

void flair::core::IODevice::AddDeviceToLog ( const IODevice device)

Add an IODevice to the logs.

The IODevice will be automatically logged among this IODevice logs, if logging is enabled (see SetDataToLog(), FrameworkManager::StartLog and FrameworkManager::AddDeviceToLog).
Logging happens when ProcessUpdate() is called.
Note that when an IODevice is just added for logs (ie. no parent/child link between the two IODevice), UpdateFrom() is not automatically called.

deviceIODevice to log
void flair::core::IODevice::AddDataToLog ( const io_data data)

Add an io_data to the log.

The io_data will be automatically logged if enabled (see FrameworkManager::StartLog and FrameworkManager::AddDeviceToLog), during call to ProcessUpdate().

datadata to log
void flair::core::IODevice::OutputToShMem ( bool  enabled)

Send the output to a shared memory.

Use this method to output log datas to a shared memory. This can be usefull to get datas from an external progam.
Output happens when ProcessUpdate() is called.
The name and the structure of the shared memory will be displayed when this method is called with true as argument.
By default it is not enabled.

enabledtrue to enable the output, false otherwise
void flair::core::IODevice::ProcessUpdate ( io_data data)

Process the childs of type IODevice, and log if needed.

This method must be called after computing datas; generally at the end of the reimplemented UpdateFrom or after acquiring datas in case of a sensor.
It will call UpdateFrom methods of each child of type IODevice, and log all datas (this IODevice and its childs) if logging is enabled (see SetDataToLog(), AddDeviceToLog(), FrameworkManager::StartLog and FrameworkManager::AddDeviceToLog).
If a thread is waiting on this IODevice (see Thread::WaitUpdate), it will be resumed.

datadata to process