[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 {
|
---|
[55] | 21 | namespace gui {
|
---|
| 22 | class TabWidget;
|
---|
| 23 | class SendData;
|
---|
| 24 | }
|
---|
[2] | 25 | }
|
---|
[15] | 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
|
---|
[55] | 71 | * not called, the program will run headless.
|
---|
| 72 | * If this method is called, SetupUserInterface must also be called after this.
|
---|
[15] | 73 | *
|
---|
| 74 | * \param address address of ground station
|
---|
| 75 | * \param port port of ground station
|
---|
[55] | 76 | * \param watchdogTimeout watchdog timeout for the connection, passing TIME_INFINITE will disable the watchdog
|
---|
[15] | 77 | * \param rcv_buf_size receive buffer size
|
---|
| 78 | */
|
---|
[55] | 79 | void SetupConnection(std::string address, uint16_t port,Time watchdogTimeout=(Time)1000000000,
|
---|
[15] | 80 | size_t rcv_buf_size = 10000);
|
---|
[2] | 81 |
|
---|
[15] | 82 | /*!
|
---|
| 83 | * \brief Setup the user interface
|
---|
| 84 | *
|
---|
| 85 | * If this method is called after SetupConnection, Widgets will be displayed in
|
---|
[55] | 86 | * the ground station.
|
---|
| 87 | * If this method is called and SetupConnection was not called, it will run headless but default values of Widgets will be taken
|
---|
| 88 | * from the xml file.
|
---|
| 89 | * If this method is not called, Widgets will not be available. Constructing an object based on Widget class will fail.
|
---|
[15] | 90 | *
|
---|
| 91 | * \param xml_file xml file for default values of Widgets
|
---|
| 92 | */
|
---|
| 93 | void SetupUserInterface(std::string xml_file);
|
---|
[2] | 94 |
|
---|
[15] | 95 | /*!
|
---|
| 96 | * \brief Get TabWidget
|
---|
| 97 | *
|
---|
| 98 | * \return TabWidget
|
---|
| 99 | */
|
---|
| 100 | gui::TabWidget *GetTabWidget(void) const;
|
---|
[2] | 101 |
|
---|
[15] | 102 | /*!
|
---|
| 103 | * \brief Logger setup
|
---|
| 104 | *
|
---|
| 105 | * Setup path of log files. \n
|
---|
| 106 | * No logging will be performed if this method is not called. \n
|
---|
| 107 | *
|
---|
| 108 | * \param log_path path to store logs
|
---|
| 109 | */
|
---|
| 110 | void SetupLogger(std::string log_path);
|
---|
[2] | 111 |
|
---|
[15] | 112 | /*!
|
---|
| 113 | * \brief Add log element
|
---|
| 114 | *
|
---|
| 115 | * The added element will be automatically logged once
|
---|
| 116 | * logging started (see StartLog()). \n
|
---|
| 117 | * This element must define on its side the io_data
|
---|
| 118 | * to log, trough IODevice::SetDataToLog method.
|
---|
| 119 | *
|
---|
| 120 | * \param device IODevice to add
|
---|
| 121 | */
|
---|
| 122 | void AddDeviceToLog(IODevice *device);
|
---|
[2] | 123 |
|
---|
[15] | 124 | /*!
|
---|
| 125 | * \brief Start logging
|
---|
| 126 | *
|
---|
| 127 | * All IODevice added through AddDeviceToLog() method
|
---|
| 128 | * will automatically be logged. \n
|
---|
| 129 | * SetupLogger() must have been called before.
|
---|
| 130 | */
|
---|
| 131 | void StartLog(void);
|
---|
[2] | 132 |
|
---|
[15] | 133 | /*!
|
---|
| 134 | * \brief Stop logging
|
---|
| 135 | *
|
---|
| 136 | * Logs will automatically be sent to ground station.
|
---|
| 137 | */
|
---|
| 138 | void StopLog(void);
|
---|
[2] | 139 |
|
---|
[15] | 140 | /*!
|
---|
| 141 | * \brief Is logging?
|
---|
| 142 | *
|
---|
| 143 | * \return true if is logging
|
---|
| 144 | */
|
---|
| 145 | bool IsLogging(void) const;
|
---|
[2] | 146 |
|
---|
[15] | 147 | /*!
|
---|
| 148 | * \brief Notify that SendData's period has changed
|
---|
| 149 | *
|
---|
| 150 | * This funtion must be called when the period has changed. \n
|
---|
| 151 | * Normally, it occurs in the Widget::XmlEvent method. \n
|
---|
| 152 | * This method must be called with communication blocked (see BlockCom()).
|
---|
| 153 | *
|
---|
| 154 | * \param obj SendData which changed
|
---|
| 155 | */
|
---|
| 156 | void UpdateSendData(const gui::SendData *obj);
|
---|
[2] | 157 |
|
---|
[15] | 158 | /*!
|
---|
| 159 | * \brief Block communication
|
---|
| 160 | *
|
---|
| 161 | * This funtion blocks the communication beetween the program and ground
|
---|
| 162 | *station. \n
|
---|
| 163 | * It must be called before changing datas or parameters exchanged between the
|
---|
| 164 | *program
|
---|
| 165 | * and the ground station.
|
---|
| 166 | *
|
---|
| 167 | */
|
---|
| 168 | void BlockCom(void);
|
---|
[2] | 169 |
|
---|
[15] | 170 | /*!
|
---|
| 171 | * \brief Unblock communication
|
---|
| 172 | *
|
---|
| 173 | * This funtion unblocks the communication beetween the program and ground
|
---|
| 174 | *station. \n
|
---|
| 175 | * It must be called after changing datas or parameters exchanged between the
|
---|
| 176 | *program
|
---|
| 177 | * and the ground station.
|
---|
| 178 | *
|
---|
| 179 | */
|
---|
| 180 | void UnBlockCom(void);
|
---|
[2] | 181 |
|
---|
[15] | 182 | /*!
|
---|
| 183 | * \brief Is connection lost?
|
---|
| 184 | *
|
---|
| 185 | * Once this method returns true, it will never return false back. \n
|
---|
| 186 | * Note that this method return false if no connection is defined (see
|
---|
| 187 | *SetupConnection).
|
---|
| 188 | *
|
---|
| 189 | * \return true if connection with ground station is lost
|
---|
| 190 | */
|
---|
| 191 | bool ConnectionLost(void) const;
|
---|
[2] | 192 |
|
---|
[15] | 193 | /*!
|
---|
| 194 | * \brief Disable errors display
|
---|
| 195 | *
|
---|
| 196 | * Disable errors display, if you do not want to saturate console for exemple.
|
---|
| 197 | * By defaults errors disply is enabled.
|
---|
| 198 | *
|
---|
| 199 | * \param value true to disable errors display
|
---|
| 200 | */
|
---|
| 201 | void DisableErrorsDisplay(bool value);
|
---|
[2] | 202 |
|
---|
[15] | 203 | /*!
|
---|
| 204 | * \brief Is displaying errors?
|
---|
| 205 | *
|
---|
| 206 | *
|
---|
| 207 | * \return true if errors display is enabled
|
---|
| 208 | */
|
---|
| 209 | bool IsDisplayingErrors(void) const;
|
---|
[2] | 210 |
|
---|
[15] | 211 | private:
|
---|
| 212 | class FrameworkManager_impl *pimpl_;
|
---|
| 213 | };
|
---|
[2] | 214 |
|
---|
[15] | 215 | /*!
|
---|
| 216 | * \brief get FrameworkManager
|
---|
| 217 | *
|
---|
| 218 | * \return the FrameworkManager
|
---|
| 219 | */
|
---|
| 220 | FrameworkManager *getFrameworkManager(void);
|
---|
[2] | 221 |
|
---|
[15] | 222 | /*!
|
---|
| 223 | * \brief is big endian?
|
---|
| 224 | *
|
---|
| 225 | * \return true if big endian, false if little endian
|
---|
| 226 | */
|
---|
| 227 | bool IsBigEndian(void);
|
---|
[2] | 228 |
|
---|
| 229 | } // end namespace core
|
---|
| 230 | } // end namespace flair
|
---|
| 231 |
|
---|
| 232 | #endif // FRAMEWORKMANAGER_H
|
---|