source: flair-src/trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h@ 122

Last change on this file since 122 was 122, checked in by Sanahuja Guillaume, 5 years ago

modifs uav vrpn i686

File size: 3.2 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,flair::core::Time watchdogTimeout,
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 bool IsDeviceLogged(const flair::core::IODevice *device) const;
51 void StartLog();
52 void StopLog();
53 char *GetBuffer(size_t sz);
54 void ReleaseBuffer(char *buf);
55 void WriteLog(const char *buf, size_t size);
56
57 /*!
58 * \brief Affiche le xml
59 *
60 * Pour debug.
61 */
62 void PrintXml(void) const;
63
64 bool is_logging;
65 bool disable_errors;
66 bool connection_lost;
67 static ui_com *com;
68 static FrameworkManager_impl *_this;
69 std::string log_path;
70
71 flair::gui::TabWidget *tabwidget;
72 flair::gui::PushButton *save_button; //,*load_button;
73
74 xmlDocPtr file_doc;
75
76 typedef struct {
77 const flair::core::IODevice *device;
78 size_t size;
79 flair::core::Time time;
80 } log_header_t;
81
82private:
83 flair::core::FrameworkManager *self;
84 UDTSOCKET file_sock, com_sock;
85 UDTSOCKET GetSocket(std::string address, uint16_t port);
86 void Run();
87 void SendFile(std::string path, std::string name);
88 void FinishSending(void);
89 std::string FileName(flair::core::IODevice *device);
90 void SaveXmlChange(char *buf);
91 void SaveXml(void);
92 size_t rcv_buf_size;
93 char *rcv_buf;
94#ifdef __XENO__
95 int CreatePipe(RT_PIPE *fd, std::string name);
96 int DeletePipe(RT_PIPE *fd);
97 RT_PIPE cmd_pipe;
98 RT_PIPE data_pipe;
99 RT_HEAP log_heap;
100#else
101 int CreatePipe(int (*fd)[2], std::string name);
102 int DeletePipe(int (*fd)[2]);
103 int cmd_pipe[2];
104 int data_pipe[2];
105#endif
106 // logger
107 bool continuer; // a enlever, avoir un seul bool pour toutes les taches
108 static void *write_log_user(void *arg);
109 pthread_t log_th;
110 std::string xml_file;
111 bool logger_defined;
112 bool ui_defined;
113 flair::gui::Layout *top_layout;
114
115 typedef struct {
116 flair::core::IODevice *device;
117 size_t size;
118 hdfile_t *dbtFile;
119 bool running;
120 } log_desc_t;
121
122 std::vector<log_desc_t> logs;
123 std::vector<std::string> xml_changes;
124 flair::core::Watchdog *gcs_watchdog;
125 void ConnectionLost(void);
126};
127
128namespace {
129inline ui_com *getUiCom(void) { return FrameworkManager_impl::com; }
130
131inline FrameworkManager_impl *getFrameworkManagerImpl(void) {
132 return FrameworkManager_impl::_this;
133}
134}
135
136#endif // FRAMEWORKMANAGER_IMPL_H
Note: See TracBrowser for help on using the repository browser.