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