[2] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 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 |
|
---|
[15] | 26 | namespace flair {
|
---|
| 27 | namespace core {
|
---|
| 28 | class FrameworkManager;
|
---|
| 29 | class IODevice;
|
---|
| 30 | class Watchdog;
|
---|
[2] | 31 | }
|
---|
[15] | 32 | namespace gui {
|
---|
| 33 | class TabWidget;
|
---|
| 34 | class PushButton;
|
---|
| 35 | class Layout;
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
[2] | 38 |
|
---|
| 39 | class ui_com;
|
---|
| 40 |
|
---|
[15] | 41 | class FrameworkManager_impl : public flair::core::Thread {
|
---|
| 42 | public:
|
---|
| 43 | FrameworkManager_impl(flair::core::FrameworkManager *self, std::string name);
|
---|
| 44 | ~FrameworkManager_impl();
|
---|
[55] | 45 | void SetupConnection(std::string address, uint16_t port,flair::core::Time watchdogTimeout,
|
---|
[186] | 46 | size_t rcv_buf_size);
|
---|
[15] | 47 | void SetupUserInterface(std::string xml_file);
|
---|
[213] | 48 | void SetupLogger(std::string log_path,uint32_t stackSize);
|
---|
[15] | 49 | void AddDeviceToLog(flair::core::IODevice *device);
|
---|
[122] | 50 | bool IsDeviceLogged(const flair::core::IODevice *device) const;
|
---|
[15] | 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);
|
---|
[2] | 56 |
|
---|
[15] | 57 | /*!
|
---|
| 58 | * \brief Affiche le xml
|
---|
| 59 | *
|
---|
| 60 | * Pour debug.
|
---|
| 61 | */
|
---|
| 62 | void PrintXml(void) const;
|
---|
[2] | 63 |
|
---|
[15] | 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;
|
---|
[2] | 70 |
|
---|
[15] | 71 | flair::gui::TabWidget *tabwidget;
|
---|
| 72 | flair::gui::PushButton *save_button; //,*load_button;
|
---|
[2] | 73 |
|
---|
[15] | 74 | xmlDocPtr file_doc;
|
---|
[2] | 75 |
|
---|
[15] | 76 | typedef struct {
|
---|
| 77 | const flair::core::IODevice *device;
|
---|
| 78 | size_t size;
|
---|
| 79 | flair::core::Time time;
|
---|
| 80 | } log_header_t;
|
---|
[2] | 81 |
|
---|
[15] | 82 | private:
|
---|
| 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;
|
---|
[2] | 94 | #ifdef __XENO__
|
---|
[15] | 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;
|
---|
[2] | 100 | #else
|
---|
[15] | 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];
|
---|
[2] | 105 | #endif
|
---|
[15] | 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;
|
---|
[2] | 114 |
|
---|
[15] | 115 | typedef struct {
|
---|
| 116 | flair::core::IODevice *device;
|
---|
| 117 | size_t size;
|
---|
| 118 | hdfile_t *dbtFile;
|
---|
| 119 | bool running;
|
---|
| 120 | } log_desc_t;
|
---|
[2] | 121 |
|
---|
[15] | 122 | std::vector<log_desc_t> logs;
|
---|
| 123 | std::vector<std::string> xml_changes;
|
---|
| 124 | flair::core::Watchdog *gcs_watchdog;
|
---|
| 125 | void ConnectionLost(void);
|
---|
[2] | 126 | };
|
---|
| 127 |
|
---|
[15] | 128 | namespace {
|
---|
| 129 | inline ui_com *getUiCom(void) { return FrameworkManager_impl::com; }
|
---|
[2] | 130 |
|
---|
[15] | 131 | inline FrameworkManager_impl *getFrameworkManagerImpl(void) {
|
---|
| 132 | return FrameworkManager_impl::_this;
|
---|
[2] | 133 | }
|
---|
[15] | 134 | }
|
---|
[2] | 135 |
|
---|
| 136 | #endif // FRAMEWORKMANAGER_IMPL_H
|
---|