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 |
|
---|
26 | namespace flair
|
---|
27 | {
|
---|
28 | namespace core
|
---|
29 | {
|
---|
30 | class FrameworkManager;
|
---|
31 | class IODevice;
|
---|
32 | class Watchdog;
|
---|
33 | }
|
---|
34 | namespace gui
|
---|
35 | {
|
---|
36 | class TabWidget;
|
---|
37 | class PushButton;
|
---|
38 | class Layout;
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | class ui_com;
|
---|
43 |
|
---|
44 | class FrameworkManager_impl: public flair::core::Thread
|
---|
45 | {
|
---|
46 | public:
|
---|
47 | FrameworkManager_impl(flair::core::FrameworkManager *self,std::string name);
|
---|
48 | ~FrameworkManager_impl();
|
---|
49 | void SetupConnection(std::string address,uint16_t port,size_t rcv_buf_size=10000);
|
---|
50 | void SetupUserInterface(std::string xml_file);
|
---|
51 | void SetupLogger(std::string log_path);
|
---|
52 | void AddDeviceToLog(flair::core::IODevice *device);
|
---|
53 | void StartLog();
|
---|
54 | void StopLog();
|
---|
55 | char* GetBuffer(size_t sz);
|
---|
56 | void ReleaseBuffer(char* buf);
|
---|
57 | void WriteLog(const char* buf,size_t size);
|
---|
58 |
|
---|
59 | /*!
|
---|
60 | * \brief Affiche le xml
|
---|
61 | *
|
---|
62 | * Pour debug.
|
---|
63 | */
|
---|
64 | void PrintXml(void) const;
|
---|
65 |
|
---|
66 | bool is_logging;
|
---|
67 | bool disable_errors;
|
---|
68 | bool connection_lost;
|
---|
69 | static ui_com *com;
|
---|
70 | static FrameworkManager_impl *_this;
|
---|
71 | std::string log_path;
|
---|
72 |
|
---|
73 | flair::gui::TabWidget* tabwidget;
|
---|
74 | flair::gui::PushButton *save_button;//,*load_button;
|
---|
75 |
|
---|
76 | xmlDocPtr file_doc;
|
---|
77 |
|
---|
78 | typedef struct {
|
---|
79 | const flair::core::IODevice* device;
|
---|
80 | size_t size;
|
---|
81 | flair::core::Time time;
|
---|
82 | } log_header_t;
|
---|
83 |
|
---|
84 | private:
|
---|
85 | flair::core::FrameworkManager *self;
|
---|
86 | UDTSOCKET file_sock,com_sock;
|
---|
87 | UDTSOCKET GetSocket(std::string address,uint16_t port);
|
---|
88 | void Run();
|
---|
89 | void SendFile(std::string path,std::string name);
|
---|
90 | void FinishSending(void);
|
---|
91 | std::string FileName(flair::core::IODevice* device);
|
---|
92 | void SaveXmlChange(char* buf);
|
---|
93 | void SaveXml(void);
|
---|
94 | size_t rcv_buf_size;
|
---|
95 | char *rcv_buf;
|
---|
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 |
|
---|
130 | namespace
|
---|
131 | {
|
---|
132 | inline ui_com* getUiCom(void) {
|
---|
133 | return FrameworkManager_impl::com;
|
---|
134 | }
|
---|
135 |
|
---|
136 | inline FrameworkManager_impl* getFrameworkManagerImpl(void) {
|
---|
137 | return FrameworkManager_impl::_this;
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | #endif // FRAMEWORKMANAGER_IMPL_H
|
---|