Flair
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...
 
bool IsReady (void) const
 is device ready 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...
 

Protected Member Functions

void ProcessUpdate (io_data *data)
 Process the childs of type IODevice, and log if needed. More...
 
void SetIsReady (bool status)
 set is ready 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 
)

Constructor.

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()).

Parameters
parentparent
namename
virtual flair::core::IODevice::~IODevice ( )
virtual

Destructor.

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.

Parameters
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().

Parameters
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.

Parameters
enabledtrue to enable the output, false otherwise
bool flair::core::IODevice::IsReady ( void  ) const

is device ready

Use it check if a device is ready or not. See also setIsReady.

Returns
true if device is ready
void flair::core::IODevice::ProcessUpdate ( io_data data)
protected

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.

Parameters
datadata to process
void flair::core::IODevice::SetIsReady ( bool  status)
protected

set is ready

Sets if the device is ready or not. By default the IODevice is not ready.
See also isReady.

Parameters
statusstatus