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

Last change on this file since 247 was 234, checked in by Sanahuja Guillaume, 6 years ago

create file oscket only when necessary

File size: 3.3 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);
47 void SetupUserInterface(std::string xml_file);
48 void SetupLogger(std::string log_path,uint32_t stackSize);
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 com_sock;
85 UDTSOCKET GetSocket(void);
86 void Run();
87 void SendFile(UDTSOCKET socket,std::string path, std::string name);
88 void FinishSending(UDTSOCKET socket);
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 std::string address;
95 uint16_t port;
96#ifdef __XENO__
97 int CreatePipe(RT_PIPE *fd, std::string name);
98 int DeletePipe(RT_PIPE *fd);
99 RT_PIPE cmd_pipe;
100 RT_PIPE data_pipe;
101 RT_HEAP log_heap;
102#else
103 int CreatePipe(int (*fd)[2], std::string name);
104 int DeletePipe(int (*fd)[2]);
105 int cmd_pipe[2];
106 int data_pipe[2];
107#endif
108 // logger
109 bool continuer; // a enlever, avoir un seul bool pour toutes les taches
110 static void *write_log_user(void *arg);
111 pthread_t log_th;
112 std::string xml_file;
113 bool logger_defined;
114 bool ui_defined;
115 flair::gui::Layout *top_layout;
116
117 typedef struct {
118 flair::core::IODevice *device;
119 size_t size;
120 hdfile_t *dbtFile;
121 bool running;
122 } log_desc_t;
123
124 std::vector<log_desc_t> logs;
125 std::vector<std::string> xml_changes;
126 flair::core::Watchdog *gcs_watchdog;
127 void ConnectionLost(void);
128};
129
130namespace {
131inline ui_com *getUiCom(void) { return FrameworkManager_impl::com; }
132
133inline FrameworkManager_impl *getFrameworkManagerImpl(void) {
134 return FrameworkManager_impl::_this;
135}
136}
137
138#endif // FRAMEWORKMANAGER_IMPL_H
Note: See TracBrowser for help on using the repository browser.