HeartBeatMonitor.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 // -- BEGIN LICENSE BLOCK ----------------------------------------------
3 // This file is part of the SCHUNK Canopen Driver suite.
4 //
5 // This program is free software licensed under the LGPL
6 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
7 // You can find a copy of this license in LICENSE folder in the top
8 // directory of the source code.
9 //
10 // © Copyright 2016 SCHUNK GmbH, Lauffen/Neckar Germany
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 // -- END LICENSE BLOCK ------------------------------------------------
13 //----------------------------------------------------------------------
20 //----------------------------------------------------------------------
21 
22 #ifndef HEARTBEATMONITOR_H
23 #define HEARTBEATMONITOR_H
24 
25 #include <boost/thread.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include <map>
28 
29 #include <icl_core/TimeStamp.h>
30 
31 namespace icl_hardware{
32 namespace canopen_schunk{
33 
35 {
36 public:
41 
43 
45 
52  void addHeartbeat(const uint8_t node_id);
53 
54 
59  void registerErrorCallback(const boost::function<void()>& f);
60 
70 
79  void setHeartBeatCycleTime (const uint16_t heartbeat_cycle_time_ms) { m_period_time_ms = heartbeat_cycle_time_ms; }
80 
85  void reset();
86 
87 private:
93  void workerFunction();
94 
96  void stop();
97 
99  void start();
100 
101 
102  std::map<uint8_t, icl_core::TimeStamp> m_timestamp_record;
103 
106 
108  boost::thread m_thread;
109 
110  boost::function<void()> m_error_function;
111 
112  bool m_running;
113 };
114 
115 }} // End of NS
116 
117 #endif // HEARTBEATMONITOR_H
uint16_t getHeartBeatCycleTime() const
The HeartbeatMonitor checks for missing heartbeat messages with this cycle time. If the last heartbea...
void workerFunction()
Thread worker function for the Heartbeat monitor. This function will regularly check for missing hear...
std::map< uint8_t, icl_core::TimeStamp > m_timestamp_record
unsigned char uint8_t
boost::shared_ptr< HeartBeatMonitor > Ptr
Shared pointer to a HeartBeatMonitor.
void addHeartbeat(const uint8_t node_id)
Incoming heartbeats will trigger this function to update the most recent heartbeat time...
void setHeartBeatCycleTime(const uint16_t heartbeat_cycle_time_ms)
The HeartbeatMonitor checks for missing heartbeat messages with this cycle time. If the last heartbea...
uint16_t m_period_time_ms
Cycle period of the monitor thread.
boost::thread m_thread
monitor thread handle
void registerErrorCallback(const boost::function< void()> &f)
This function will be called as soon as one node is missing a heartbeat message. Probably this functi...
void reset()
Resets the heartbeat monitor. This will make the monitor forget about all past heartbeats and start f...
unsigned short uint16_t
boost::shared_ptr< const HeartBeatMonitor > ConstPtr
Shared pointer to a const HeartBeatMonitor.


schunk_canopen_driver
Author(s): Felix Mauch , Georg Heppner
autogenerated on Mon Jun 10 2019 15:07:49