FrequencyReporter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <mutex>
5 #include <vector>
6 
9 #include "ArmarXCore/interface/observers/ObserverInterface.h"
10 
11 namespace armarx
12 {
13 
14  /**
15  * @brief The FrequencyReporter class.
16  *
17  * Use this class to monitor any periodic event.
18  * The frequency (mean, std) are sent to the DebugObserver.
19  *
20  * Note: This class is thread safe.
21  */
23  {
24  public:
25  /**
26  * @brief Construct a new Frequency Reporter object
27  *
28  * @param debugObserver
29  * @param name used to set the debug observer's channel name
30  */
31  FrequencyReporter(DebugObserverInterfacePrx debugObserver, const std::string& name);
33  virtual ~FrequencyReporter();
34 
35  /**
36  * @brief Add a new timestamp to the reporter.
37  *
38  * @param timestamp in [µs]
39  */
40  void add(armarx::core::time::DateTime timestamp);
41 
42  private:
43  /**
44  * @brief Sends accumulated data to the debug observer.
45  *
46  * Will be called periodically.
47  */
48  void report();
49 
50  DebugObserverInterfacePrx debugObserver;
51  std::string name;
52 
53  std::mutex mtx;
54  std::vector<std::int64_t> timestamps; // [ms]
55 
57 
58  const float frequency {5.F}; // [Hz]
59  };
60 } // namespace armarx
armarx::FrequencyReporter
The FrequencyReporter class.
Definition: FrequencyReporter.h:22
DateTime.h
TaskUtil.h
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::FrequencyReporter::~FrequencyReporter
virtual ~FrequencyReporter()
Definition: FrequencyReporter.cpp:27
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::FrequencyReporter::FrequencyReporter
FrequencyReporter(DebugObserverInterfacePrx debugObserver, const std::string &name)
Construct a new Frequency Reporter object.
Definition: FrequencyReporter.cpp:15
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::FrequencyReporter::add
void add(armarx::core::time::DateTime timestamp)
Add a new timestamp to the reporter.
Definition: FrequencyReporter.cpp:35
armarx::SimplePeriodicTask
Usage:
Definition: ApplicationNetworkStats.h:32