Flair
Framework Libre Air
|
Abstract class for input/ouput system. More...
#include <IODevice.h>
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 Object * | Parent (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... | |
virtual void | UpdateFrom (const io_data *data)=0 |
Update using provided datas. More... | |
Additional Inherited Members | |
Public Types inherited from flair::core::Object | |
enum | color_t { Auto = 0, Red = 31, Green = 32, Orange = 33 } |
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.
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()).
parent | parent |
name | name |
|
virtual |
Destructor.
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.
device | IODevice 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().
data | data 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.
enabled | true 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.
|
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.
data | data to process |
|
protected |
set is ready
Sets if the device is ready or not. By default the IODevice is not ready.
See also isReady.
status | status |
|
protectedpure virtual |
Update using provided datas.
This method is automatically called by ProcessUpdate() of the Object::Parent's if its Object::ObjectType is "IODevice".
This method must be reimplemented, in order to process the data from the parent.
data | data from the parent to process |
Implemented in flair::filter::ButterworthLowPass, and flair::sensor::TargetController.