source: flair-src/branches/mavlink/lib/FlairCore/src/unexported/FrameworkManager_impl.h @ 98

Last change on this file since 98 was 15, checked in by Bayard Gildas, 6 years ago

sources reformatted with flair-format-dir script

File size: 3.1 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 Classe de base de la librairie
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2011/08/31
10 * \version 4.0
11 */
12
13#ifndef FRAMEWORKMANAGER_IMPL_H
14#define FRAMEWORKMANAGER_IMPL_H
15
16#include "Thread.h"
17#include "ui_com.h"
18#include <io_hdfile.h>
19#include <libxml/xpath.h>
20
21#ifdef __XENO__
22#include <native/pipe.h>
23#include <native/heap.h>
24#endif
25
26namespace flair {
27namespace core {
28class FrameworkManager;
29class IODevice;
30class Watchdog;
31}
32namespace gui {
33class TabWidget;
34class PushButton;
35class Layout;
36}
37}
38
39class ui_com;
40
41class FrameworkManager_impl : public flair::core::Thread {
42public:
43  FrameworkManager_impl(flair::core::FrameworkManager *self, std::string name);
44  ~FrameworkManager_impl();
45  void SetupConnection(std::string address, uint16_t port,
46                       size_t rcv_buf_size = 10000);
47  void SetupUserInterface(std::string xml_file);
48  void SetupLogger(std::string log_path);
49  void AddDeviceToLog(flair::core::IODevice *device);
50  void StartLog();
51  void StopLog();
52  char *GetBuffer(size_t sz);
53  void ReleaseBuffer(char *buf);
54  void WriteLog(const char *buf, size_t size);
55
56  /*!
57  * \brief Affiche le xml
58  *
59  * Pour debug.
60  */
61  void PrintXml(void) const;
62
63  bool is_logging;
64  bool disable_errors;
65  bool connection_lost;
66  static ui_com *com;
67  static FrameworkManager_impl *_this;
68  std::string log_path;
69
70  flair::gui::TabWidget *tabwidget;
71  flair::gui::PushButton *save_button; //,*load_button;
72
73  xmlDocPtr file_doc;
74
75  typedef struct {
76    const flair::core::IODevice *device;
77    size_t size;
78    flair::core::Time time;
79  } log_header_t;
80
81private:
82  flair::core::FrameworkManager *self;
83  UDTSOCKET file_sock, com_sock;
84  UDTSOCKET GetSocket(std::string address, uint16_t port);
85  void Run();
86  void SendFile(std::string path, std::string name);
87  void FinishSending(void);
88  std::string FileName(flair::core::IODevice *device);
89  void SaveXmlChange(char *buf);
90  void SaveXml(void);
91  size_t rcv_buf_size;
92  char *rcv_buf;
93#ifdef __XENO__
94  int CreatePipe(RT_PIPE *fd, std::string name);
95  int DeletePipe(RT_PIPE *fd);
96  RT_PIPE cmd_pipe;
97  RT_PIPE data_pipe;
98  RT_HEAP log_heap;
99#else
100  int CreatePipe(int (*fd)[2], std::string name);
101  int DeletePipe(int (*fd)[2]);
102  int cmd_pipe[2];
103  int data_pipe[2];
104#endif
105  // logger
106  bool continuer; // a enlever, avoir un seul bool pour toutes les taches
107  static void *write_log_user(void *arg);
108  pthread_t log_th;
109  std::string xml_file;
110  bool logger_defined;
111  bool ui_defined;
112  flair::gui::Layout *top_layout;
113
114  typedef struct {
115    flair::core::IODevice *device;
116    size_t size;
117    hdfile_t *dbtFile;
118    bool running;
119  } log_desc_t;
120
121  std::vector<log_desc_t> logs;
122  std::vector<std::string> xml_changes;
123  flair::core::Watchdog *gcs_watchdog;
124  void ConnectionLost(void);
125};
126
127namespace {
128inline ui_com *getUiCom(void) { return FrameworkManager_impl::com; }
129
130inline FrameworkManager_impl *getFrameworkManagerImpl(void) {
131  return FrameworkManager_impl::_this;
132}
133}
134
135#endif // FRAMEWORKMANAGER_IMPL_H
Note: See TracBrowser for help on using the repository browser.