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

Last change on this file was 414, checked in by Sanahuja Guillaume, 8 months ago

added possibility to autodetect gcs ip when using autodetect as address parameter, see demos. This only works when ssh connected to a target (not in simulation)

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