ControllerServer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2020 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
9 
11 #include <mc_rtc/log/Logger.h>
12 
13 #include <string>
14 #include <vector>
15 
16 namespace mc_control
17 {
18 
26 {
27 
40  ControllerServer(double dt,
41  double server_dt,
42  const std::vector<std::string> & pub_bind_uri,
43  const std::vector<std::string> & pull_bind_uri);
44 
51  ControllerServer(double dt, const ControllerServerConfiguration & config);
52 
54 
56  void handle_requests(mc_rtc::gui::StateBuilder & gui_builder);
57 
59  void handle_requests(mc_rtc::gui::StateBuilder & gui, const char * data);
60 
62  void publish(mc_rtc::gui::StateBuilder & gui_builder);
63 
65  std::pair<const char *, size_t> data() const;
66 
68  inline void set_logger(std::shared_ptr<mc_rtc::Logger> logger) noexcept { logger_ = logger; }
69 
71  inline void push_requests(const std::vector<mc_rtc::Logger::GUIEvent> & requests)
72  {
73  for(const auto & r : requests) { requests_.push_back(r); }
74  }
75 
77  void update_rate(double dt, double server_dt);
78 
79 private:
80  unsigned int iter_;
81  unsigned int rate_;
82 
83  int pub_socket_;
84  int pull_socket_;
85 
86  std::vector<char> buffer_;
87  size_t buffer_size_ = 0;
88 
89  std::shared_ptr<mc_rtc::Logger> logger_;
90 
91  std::vector<mc_rtc::Logger::GUIEvent> requests_;
92 };
93 
94 } // namespace mc_control
MC_CONTROL_DLLAPI
#define MC_CONTROL_DLLAPI
Definition: api.h:50
mc_control::ControllerServer::set_logger
void set_logger(std::shared_ptr< mc_rtc::Logger > logger) noexcept
Definition: ControllerServer.h:68
mc_control::ControllerServer::push_requests
void push_requests(const std::vector< mc_rtc::Logger::GUIEvent > &requests)
Definition: ControllerServer.h:71
StateBuilder.h
ControllerServerConfiguration.h
Logger.h
mc_rtc::gui::StateBuilder
Definition: StateBuilder.h:27
MCController.h
mc_control::ControllerServerConfiguration
Definition: ControllerServerConfiguration.h:40
mc_control
Definition: CompletionCriteria.h:10
mc_control::ControllerServer
Definition: ControllerServer.h:25