source: flair-dev/trunk/include/FlairCore/FrameworkManager.h @ 44

Last change on this file since 44 was 44, checked in by Sanahuja Guillaume, 4 years ago

m

File size: 6.0 KB
Line 
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
18class FrameworkManager_impl;
19
20namespace flair {
21  namespace gui {
22    class TabWidget;
23    class SendData;
24  }
25}
26namespace flair {
27namespace core {
28class IODevice;
29
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*/
45class FrameworkManager : public Object {
46public:
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);
57
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();
66
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  * If this method is called, SetupUserInterface must also be called after this.
73  *
74  * \param address address of ground station
75  * \param port port of ground station
76  * \param watchdogTimeout watchdog timeout for the connection, passing TIME_INFINITE will disable the watchdog
77  * \param rcv_buf_size receive buffer size
78  */
79  void SetupConnection(std::string address, uint16_t port,Time watchdogTimeout=(Time)1000000000,
80                       size_t rcv_buf_size = 10000);
81
82  /*!
83  * \brief Setup the user interface
84  *
85  * If this method is called after SetupConnection, Widgets will be displayed in
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.
90  *
91  * \param xml_file xml file for default values of Widgets
92  */
93  void SetupUserInterface(std::string xml_file);
94
95  /*!
96  * \brief Get TabWidget
97  *
98  * \return TabWidget
99  */
100  gui::TabWidget *GetTabWidget(void) const;
101
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);
111
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);
123       
124        /*!
125  * \brief Is device logged
126  *
127  * Check if AddDeviceToLog was called for an IODevice
128  *
129  * \param device IODevice to check
130  * \return true if AddDeviceToLog was called for this IODevice
131  */
132  bool IsDeviceLogged(const IODevice *device) const;
133
134  /*!
135  * \brief Start logging
136  *
137  * All IODevice added through AddDeviceToLog() method
138  * will automatically be logged. \n
139  * SetupLogger() must have been called before.
140  */
141  void StartLog(void);
142
143  /*!
144  * \brief Stop logging
145  *
146  * Logs will automatically be sent to ground station.
147  */
148  void StopLog(void);
149
150  /*!
151  * \brief Is logging?
152  *
153  * \return true if is logging
154  */
155  bool IsLogging(void) const;
156
157  /*!
158  * \brief Notify that SendData's period has changed
159  *
160  * This funtion must be called when the period has changed. \n
161  * Normally, it occurs in the Widget::XmlEvent method. \n
162  * This method must be called with communication blocked (see BlockCom()).
163  *
164  * \param obj SendData which changed
165  */
166  void UpdateSendData(const gui::SendData *obj);
167
168  /*!
169  * \brief Block communication
170  *
171  * This funtion blocks the communication beetween the program and ground
172  *station. \n
173  * It must be called before changing datas or parameters exchanged between the
174  *program
175  * and the ground station.
176  *
177  */
178  void BlockCom(void);
179
180  /*!
181 * \brief Unblock communication
182 *
183 * This funtion unblocks the communication beetween the program and ground
184 *station. \n
185 * It must be called after changing datas or parameters exchanged between the
186 *program
187 * and the ground station.
188 *
189 */
190  void UnBlockCom(void);
191
192  /*!
193  * \brief Is connection lost?
194  *
195  * Once this method returns true, it will never return false back. \n
196  * Note that this method return false if no connection is defined (see
197  *SetupConnection).
198  *
199  * \return true if connection with ground station is lost
200  */
201  bool ConnectionLost(void) const;
202
203  /*!
204  * \brief Disable errors display
205  *
206  * Disable errors display, if you do not want to saturate console for exemple.
207  * By defaults errors disply is enabled.
208  *
209  * \param value true to disable errors display
210  */
211  void DisableErrorsDisplay(bool value);
212
213  /*!
214  * \brief Is displaying errors?
215  *
216  *
217  * \return true if errors display is enabled
218  */
219  bool IsDisplayingErrors(void) const;
220
221private:
222  class FrameworkManager_impl *pimpl_;
223};
224
225/*!
226* \brief get FrameworkManager
227*
228* \return the FrameworkManager
229*/
230FrameworkManager *getFrameworkManager(void);
231
232/*!
233* \brief is big endian?
234*
235* \return true if big endian, false if little endian
236*/
237bool IsBigEndian(void);
238
239} // end namespace core
240} // end namespace flair
241
242#endif // FRAMEWORKMANAGER_H
Note: See TracBrowser for help on using the repository browser.