[2] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 4 | // %flair:license}
|
---|
| 5 | /*!
|
---|
| 6 | * \file FrameworkManager.h
|
---|
| 7 | * \brief Main class of the Framework library
|
---|
| 8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 9 | * \date 2011/08/31
|
---|
| 10 | * \version 4.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef FRAMEWORKMANAGER_H
|
---|
| 14 | #define FRAMEWORKMANAGER_H
|
---|
| 15 |
|
---|
| 16 | #include <Object.h>
|
---|
| 17 |
|
---|
| 18 | class FrameworkManager_impl;
|
---|
| 19 |
|
---|
[15] | 20 | namespace flair {
|
---|
| 21 | namespace gui {
|
---|
| 22 | class TabWidget;
|
---|
| 23 | class SendData;
|
---|
[2] | 24 | }
|
---|
[15] | 25 | }
|
---|
| 26 | namespace flair {
|
---|
| 27 | namespace core {
|
---|
| 28 | class IODevice;
|
---|
[2] | 29 |
|
---|
[15] | 30 | /*! \class FrameworkManager
|
---|
| 31 | *
|
---|
| 32 | * \brief Main class of the Framework library
|
---|
| 33 | *
|
---|
| 34 | * This is the main class of the library. Only one instance of this class is
|
---|
| 35 | *allowed
|
---|
| 36 | * by program. Morevoer, its name must be unique if more than one program using
|
---|
| 37 | *this class
|
---|
| 38 | * is running on the same system (a control and a simlator for example). \n
|
---|
| 39 | * This class allows: \n
|
---|
| 40 | * -connexion with ground station, \n
|
---|
| 41 | * -creation of a QTabWidget on ground station, \n
|
---|
| 42 | * -handling of xml files, used for default values of Widgets, \n
|
---|
| 43 | * -logging of datas.
|
---|
| 44 | */
|
---|
| 45 | class FrameworkManager : public Object {
|
---|
| 46 | public:
|
---|
| 47 | /*!
|
---|
| 48 | * \brief Constructor
|
---|
| 49 | *
|
---|
| 50 | * Construct a FrameworkManager. \n
|
---|
| 51 | * Call SetupConnection method just after this constructor to setup the
|
---|
| 52 | *conection with a ground station.
|
---|
| 53 | *
|
---|
| 54 | * \param name name, must be unique
|
---|
| 55 | */
|
---|
| 56 | FrameworkManager(std::string name);
|
---|
[2] | 57 |
|
---|
[15] | 58 | /*!
|
---|
| 59 | * \brief Destructor
|
---|
| 60 | *
|
---|
| 61 | * Calling it will automatically destruct all childs. \n
|
---|
| 62 | * Destruction implies destruction of the QTabWidget on ground station.
|
---|
| 63 | *
|
---|
| 64 | */
|
---|
| 65 | ~FrameworkManager();
|
---|
[2] | 66 |
|
---|
[15] | 67 | /*!
|
---|
| 68 | * \brief Setup the connection with ground station
|
---|
| 69 | *
|
---|
| 70 | * Call this method just after the constructor of this class. If this method is
|
---|
| 71 | *not called, the program will run headless.
|
---|
| 72 | *
|
---|
| 73 | * \param address address of ground station
|
---|
| 74 | * \param port port of ground station
|
---|
| 75 | * \param rcv_buf_size receive buffer size
|
---|
| 76 | */
|
---|
| 77 | void SetupConnection(std::string address, uint16_t port,
|
---|
| 78 | size_t rcv_buf_size = 10000);
|
---|
[2] | 79 |
|
---|
[15] | 80 | /*!
|
---|
| 81 | * \brief Setup the user interface
|
---|
| 82 | *
|
---|
| 83 | * If this method is called after SetupConnection, Widgets will be displayed in
|
---|
| 84 | *the ground station.
|
---|
| 85 | * Otherwise, it will run headless, but default values of Widgets will be taken
|
---|
| 86 | *from the xml file.
|
---|
| 87 | *
|
---|
| 88 | * \param xml_file xml file for default values of Widgets
|
---|
| 89 | */
|
---|
| 90 | void SetupUserInterface(std::string xml_file);
|
---|
[2] | 91 |
|
---|
[15] | 92 | /*!
|
---|
| 93 | * \brief Get TabWidget
|
---|
| 94 | *
|
---|
| 95 | * \return TabWidget
|
---|
| 96 | */
|
---|
| 97 | gui::TabWidget *GetTabWidget(void) const;
|
---|
[2] | 98 |
|
---|
[15] | 99 | /*!
|
---|
| 100 | * \brief Logger setup
|
---|
| 101 | *
|
---|
| 102 | * Setup path of log files. \n
|
---|
| 103 | * No logging will be performed if this method is not called. \n
|
---|
| 104 | *
|
---|
| 105 | * \param log_path path to store logs
|
---|
| 106 | */
|
---|
| 107 | void SetupLogger(std::string log_path);
|
---|
[2] | 108 |
|
---|
[15] | 109 | /*!
|
---|
| 110 | * \brief Add log element
|
---|
| 111 | *
|
---|
| 112 | * The added element will be automatically logged once
|
---|
| 113 | * logging started (see StartLog()). \n
|
---|
| 114 | * This element must define on its side the io_data
|
---|
| 115 | * to log, trough IODevice::SetDataToLog method.
|
---|
| 116 | *
|
---|
| 117 | * \param device IODevice to add
|
---|
| 118 | */
|
---|
| 119 | void AddDeviceToLog(IODevice *device);
|
---|
[2] | 120 |
|
---|
[15] | 121 | /*!
|
---|
| 122 | * \brief Start logging
|
---|
| 123 | *
|
---|
| 124 | * All IODevice added through AddDeviceToLog() method
|
---|
| 125 | * will automatically be logged. \n
|
---|
| 126 | * SetupLogger() must have been called before.
|
---|
| 127 | */
|
---|
| 128 | void StartLog(void);
|
---|
[2] | 129 |
|
---|
[15] | 130 | /*!
|
---|
| 131 | * \brief Stop logging
|
---|
| 132 | *
|
---|
| 133 | * Logs will automatically be sent to ground station.
|
---|
| 134 | */
|
---|
| 135 | void StopLog(void);
|
---|
[2] | 136 |
|
---|
[15] | 137 | /*!
|
---|
| 138 | * \brief Is logging?
|
---|
| 139 | *
|
---|
| 140 | * \return true if is logging
|
---|
| 141 | */
|
---|
| 142 | bool IsLogging(void) const;
|
---|
[2] | 143 |
|
---|
[15] | 144 | /*!
|
---|
| 145 | * \brief Notify that SendData's period has changed
|
---|
| 146 | *
|
---|
| 147 | * This funtion must be called when the period has changed. \n
|
---|
| 148 | * Normally, it occurs in the Widget::XmlEvent method. \n
|
---|
| 149 | * This method must be called with communication blocked (see BlockCom()).
|
---|
| 150 | *
|
---|
| 151 | * \param obj SendData which changed
|
---|
| 152 | */
|
---|
| 153 | void UpdateSendData(const gui::SendData *obj);
|
---|
[2] | 154 |
|
---|
[15] | 155 | /*!
|
---|
| 156 | * \brief Block communication
|
---|
| 157 | *
|
---|
| 158 | * This funtion blocks the communication beetween the program and ground
|
---|
| 159 | *station. \n
|
---|
| 160 | * It must be called before changing datas or parameters exchanged between the
|
---|
| 161 | *program
|
---|
| 162 | * and the ground station.
|
---|
| 163 | *
|
---|
| 164 | */
|
---|
| 165 | void BlockCom(void);
|
---|
[2] | 166 |
|
---|
[15] | 167 | /*!
|
---|
| 168 | * \brief Unblock communication
|
---|
| 169 | *
|
---|
| 170 | * This funtion unblocks the communication beetween the program and ground
|
---|
| 171 | *station. \n
|
---|
| 172 | * It must be called after changing datas or parameters exchanged between the
|
---|
| 173 | *program
|
---|
| 174 | * and the ground station.
|
---|
| 175 | *
|
---|
| 176 | */
|
---|
| 177 | void UnBlockCom(void);
|
---|
[2] | 178 |
|
---|
[15] | 179 | /*!
|
---|
| 180 | * \brief Is connection lost?
|
---|
| 181 | *
|
---|
| 182 | * Once this method returns true, it will never return false back. \n
|
---|
| 183 | * Note that this method return false if no connection is defined (see
|
---|
| 184 | *SetupConnection).
|
---|
| 185 | *
|
---|
| 186 | * \return true if connection with ground station is lost
|
---|
| 187 | */
|
---|
| 188 | bool ConnectionLost(void) const;
|
---|
[2] | 189 |
|
---|
[15] | 190 | /*!
|
---|
| 191 | * \brief Disable errors display
|
---|
| 192 | *
|
---|
| 193 | * Disable errors display, if you do not want to saturate console for exemple.
|
---|
| 194 | * By defaults errors disply is enabled.
|
---|
| 195 | *
|
---|
| 196 | * \param value true to disable errors display
|
---|
| 197 | */
|
---|
| 198 | void DisableErrorsDisplay(bool value);
|
---|
[2] | 199 |
|
---|
[15] | 200 | /*!
|
---|
| 201 | * \brief Is displaying errors?
|
---|
| 202 | *
|
---|
| 203 | *
|
---|
| 204 | * \return true if errors display is enabled
|
---|
| 205 | */
|
---|
| 206 | bool IsDisplayingErrors(void) const;
|
---|
[2] | 207 |
|
---|
[15] | 208 | private:
|
---|
| 209 | class FrameworkManager_impl *pimpl_;
|
---|
| 210 | };
|
---|
[2] | 211 |
|
---|
[15] | 212 | /*!
|
---|
| 213 | * \brief get FrameworkManager
|
---|
| 214 | *
|
---|
| 215 | * \return the FrameworkManager
|
---|
| 216 | */
|
---|
| 217 | FrameworkManager *getFrameworkManager(void);
|
---|
[2] | 218 |
|
---|
[15] | 219 | /*!
|
---|
| 220 | * \brief is big endian?
|
---|
| 221 | *
|
---|
| 222 | * \return true if big endian, false if little endian
|
---|
| 223 | */
|
---|
| 224 | bool IsBigEndian(void);
|
---|
[2] | 225 |
|
---|
| 226 | } // end namespace core
|
---|
| 227 | } // end namespace flair
|
---|
| 228 |
|
---|
| 229 | #endif // FRAMEWORKMANAGER_H
|
---|