Flair
Framework Libre Air
flair::core::FrameworkManager Class Reference

Main class of the Framework library. More...

#include <FrameworkManager.h>

+ Inheritance diagram for flair::core::FrameworkManager:

Public Member Functions

 FrameworkManager (std::string name)
 Constructor. More...
 
 ~FrameworkManager ()
 Destructor. More...
 
void SetupConnection (std::string address, uint16_t port, Time watchdogTimeout=(Time) 1000000000, size_t rcv_buf_size=10000)
 Setup the connection with ground station. More...
 
void SetupUserInterface (std::string xml_file)
 Setup the user interface. More...
 
gui::TabWidgetGetTabWidget (void) const
 Get TabWidget. More...
 
void SetupLogger (std::string log_path)
 Logger setup. More...
 
void AddDeviceToLog (IODevice *device)
 Add log element. More...
 
void StartLog (void)
 Start logging. More...
 
void StopLog (void)
 Stop logging. More...
 
bool IsLogging (void) const
 Is logging? More...
 
void UpdateSendData (const gui::SendData *obj)
 Notify that SendData's period has changed. More...
 
void BlockCom (void)
 Block communication. More...
 
void UnBlockCom (void)
 Unblock communication. More...
 
bool ConnectionLost (void) const
 Is connection lost? More...
 
void DisableErrorsDisplay (bool value)
 Disable errors display. More...
 
bool IsDisplayingErrors (void) const
 Is displaying errors? More...
 
- 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...
 

Additional Inherited Members

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

Detailed Description

Main class of the Framework library.

This is the main class of the library. Only one instance of this class is allowed by program. Morevoer, its name must be unique if more than one program using this class is running on the same system (a control and a simlator for example).
This class allows:
-connexion with ground station,
-creation of a QTabWidget on ground station,
-handling of xml files, used for default values of Widgets,
-logging of datas.

Constructor & Destructor Documentation

flair::core::FrameworkManager::FrameworkManager ( std::string  name)

Constructor.

Construct a FrameworkManager.
Call SetupConnection method just after this constructor to setup the conection with a ground station.

Parameters
namename, must be unique
flair::core::FrameworkManager::~FrameworkManager ( )

Destructor.

Calling it will automatically destruct all childs.
Destruction implies destruction of the QTabWidget on ground station.

Member Function Documentation

void flair::core::FrameworkManager::SetupConnection ( std::string  address,
uint16_t  port,
Time  watchdogTimeout = (Time) 1000000000,
size_t  rcv_buf_size = 10000 
)

Setup the connection with ground station.

Call this method just after the constructor of this class. If this method is not called, the program will run headless. If this method is called, SetupUserInterface must also be called after this.

Parameters
addressaddress of ground station
portport of ground station
watchdogTimeoutwatchdog timeout for the connection, passing TIME_INFINITE will disable the watchdog
rcv_buf_sizereceive buffer size
void flair::core::FrameworkManager::SetupUserInterface ( std::string  xml_file)

Setup the user interface.

If this method is called after SetupConnection, Widgets will be displayed in the ground station. If this method is called and SetupConnection was not called, it will run headless but default values of Widgets will be taken from the xml file. If this method is not called, Widgets will not be available. Constructing an object based on Widget class will fail.

Parameters
xml_filexml file for default values of Widgets
gui::TabWidget* flair::core::FrameworkManager::GetTabWidget ( void  ) const

Get TabWidget.

Returns
TabWidget
void flair::core::FrameworkManager::SetupLogger ( std::string  log_path)

Logger setup.

Setup path of log files.
No logging will be performed if this method is not called.

Parameters
log_pathpath to store logs
void flair::core::FrameworkManager::AddDeviceToLog ( IODevice device)

Add log element.

The added element will be automatically logged once logging started (see StartLog()).
This element must define on its side the io_data to log, trough IODevice::SetDataToLog method.

Parameters
deviceIODevice to add
void flair::core::FrameworkManager::StartLog ( void  )

Start logging.

All IODevice added through AddDeviceToLog() method will automatically be logged.
SetupLogger() must have been called before.

void flair::core::FrameworkManager::StopLog ( void  )

Stop logging.

Logs will automatically be sent to ground station.

bool flair::core::FrameworkManager::IsLogging ( void  ) const

Is logging?

Returns
true if is logging
void flair::core::FrameworkManager::UpdateSendData ( const gui::SendData obj)

Notify that SendData's period has changed.

This funtion must be called when the period has changed.
Normally, it occurs in the Widget::XmlEvent method.
This method must be called with communication blocked (see BlockCom()).

Parameters
objSendData which changed
void flair::core::FrameworkManager::BlockCom ( void  )

Block communication.

This funtion blocks the communication beetween the program and ground station.
It must be called before changing datas or parameters exchanged between the program and the ground station.

void flair::core::FrameworkManager::UnBlockCom ( void  )

Unblock communication.

This funtion unblocks the communication beetween the program and ground station.
It must be called after changing datas or parameters exchanged between the program and the ground station.

bool flair::core::FrameworkManager::ConnectionLost ( void  ) const

Is connection lost?

Once this method returns true, it will never return false back.
Note that this method return false if no connection is defined (see SetupConnection).

Returns
true if connection with ground station is lost
void flair::core::FrameworkManager::DisableErrorsDisplay ( bool  value)

Disable errors display.

Disable errors display, if you do not want to saturate console for exemple. By defaults errors disply is enabled.

Parameters
valuetrue to disable errors display
bool flair::core::FrameworkManager::IsDisplayingErrors ( void  ) const

Is displaying errors?

Returns
true if errors display is enabled