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
11namespace 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 */
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
std::string timestamp()
void add(armarx::core::time::DateTime timestamp)
Add a new timestamp to the reporter.
FrequencyReporter(DebugObserverInterfacePrx debugObserver, const std::string &name)
Construct a new Frequency Reporter object.
FrequencyReporter(FrequencyReporter &)=delete
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
Represents a point in time.
Definition DateTime.h:25
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx