monitor.h
Go to the documentation of this file.
1 // Monitors execution of a launch file
2 // Author: Max Schwarz <max.schwarz@uni-bonn.de>
3 
4 #ifndef ROSMON_MONITOR_MONITOR_H
5 #define ROSMON_MONITOR_MONITOR_H
6 
7 #include "../fd_watcher.h"
8 #include "../launch/launch_config.h"
9 #include "../log_event.h"
10 
11 #include "node_monitor.h"
12 #include "linux_process_info.h"
13 
14 #include <boost/signals2.hpp>
15 
16 #include <ros/node_handle.h>
17 
18 namespace rosmon
19 {
20 
21 namespace monitor
22 {
23 
24 class Monitor
25 {
26 public:
27 public:
29 
30  void setParameters();
31  void start();
32  void shutdown();
33  void forceExit();
34  bool allShutdown();
35 
36  double shutdownTimeout();
37 
38  inline bool ok() const
39  { return m_ok; }
40 
41  const std::vector<NodeMonitor::Ptr>& nodes() const
42  { return m_nodes; }
43  std::vector<NodeMonitor::Ptr>& nodes()
44  { return m_nodes; }
45 
47  { return m_config; }
48 
49  boost::signals2::signal<void(LogEvent)> logMessageSignal;
50 private:
51  struct ProcessInfo
52  {
54  bool active;
55  };
56 
57  template<typename... Args>
58  void log(const char* fmt, Args&& ... args);
59 
60  template<typename... Args>
61  void logTyped(LogEvent::Type type, const char* fmt, Args&& ... args);
62 
63  void handleRequiredNodeExit(const std::string& name);
64 
65 #if HAVE_STEADYTIMER
66  void updateStats(const ros::SteadyTimerEvent& event);
67 #else
68  void updateStats(const ros::WallTimerEvent& event);
69 #endif
70 
72 
75 
76  std::vector<NodeMonitor::Ptr> m_nodes;
77 
78  bool m_ok;
79 
80 #if HAVE_STEADYTIMER
82 #else
84 #endif
85 
86  std::map<int, ProcessInfo> m_processInfos;
87 };
88 
89 }
90 
91 }
92 
93 #endif
ros::WallTimer m_statTimer
Definition: monitor.h:83
const std::vector< NodeMonitor::Ptr > & nodes() const
Definition: monitor.h:41
boost::signals2::signal< void(LogEvent)> logMessageSignal
Definition: monitor.h:49
std::map< int, ProcessInfo > m_processInfos
Definition: monitor.h:86
process_info::ProcessStat stat
Definition: monitor.h:53
std::vector< NodeMonitor::Ptr > & nodes()
Definition: monitor.h:43
void log(const char *fmt, Args &&...args)
Definition: monitor.cpp:157
std::vector< NodeMonitor::Ptr > m_nodes
Definition: monitor.h:76
Monitor(launch::LaunchConfig::ConstPtr config, FDWatcher::Ptr watcher)
Definition: monitor.cpp:35
bool ok() const
Definition: monitor.h:38
void logTyped(LogEvent::Type type, const char *fmt, Args &&...args)
Definition: monitor.cpp:166
ros::NodeHandle m_nh
Definition: monitor.h:73
FDWatcher::Ptr m_fdWatcher
Definition: monitor.h:74
std::shared_ptr< const LaunchConfig > ConstPtr
launch::LaunchConfig::ConstPtr config() const
Definition: monitor.h:46
void handleRequiredNodeExit(const std::string &name)
Definition: monitor.cpp:150
void updateStats(const ros::WallTimerEvent &event)
Definition: monitor.cpp:178
launch::LaunchConfig::ConstPtr m_config
Definition: monitor.h:71


rosmon_core
Author(s): Max Schwarz
autogenerated on Sat Jan 9 2021 03:35:43