frequency.hpp
Go to the documentation of this file.
1 
4 /*****************************************************************************
5 ** Ifdefs
6 *****************************************************************************/
7 
8 #ifndef ecl_time_TIME_FREQUENCY_DIAGNOSTICS_HPP_
9 #define ecl_time_TIME_FREQUENCY_DIAGNOSTICS_HPP_
10 
11 /*****************************************************************************
12 ** Includes
13 *****************************************************************************/
14 
15 #include "timestamp.hpp"
16 
17 /*****************************************************************************
18 ** Namespaces
19 *****************************************************************************/
20 
21 namespace ecl {
22 
23 /*****************************************************************************
24 ** Interfaces
25 *****************************************************************************/
31 struct FrequencyDiagnostics {
32 
34  : has_connection(false)
35  , hz(-1.0)
36  , std_dev(-1.0)
38  , maximum_interval(-1.0)
39  , last_incoming()
40  {}
41 
42  bool has_connection;
43  float hz;
44  float std_dev;
45  float minimum_interval;
46  float maximum_interval;
48 
49 };
50 
83 class FrequencyMonitor {
84 public:
92  const float& window_period = 2.0,
93  const bool& use_realtime_clock=false
94  );
100  void update();
107  const FrequencyDiagnostics& analyse();
108 
113  const FrequencyDiagnostics& diagnostics() const { return current_diagnostics; };
114 
115 protected:
116  FrequencyDiagnostics current_diagnostics;
117  unsigned int incoming_counter;
118  ecl::TimeStamp last_anyalsed;
119  ecl::TimeStamp period;
120  ecl::TimeStamp minimum_interval;
121  ecl::TimeStamp maximum_interval;
122  bool use_realtime_clock;
123  ecl::TimeStamp last_incoming;
124 };
125 
126 /*****************************************************************************
127 ** Trailers
128 *****************************************************************************/
129 
130 } // namespace ecl
131 
132 #endif /* ecl_time_TIME_FREQUENCY_DIAGNOSTICS_HPP_ */
ecl::FrequencyDiagnostics::last_incoming
float last_incoming
Definition: frequency.hpp:61
ecl::FrequencyMonitor::last_incoming
ecl::TimeStamp last_incoming
Definition: frequency.hpp:129
ecl::FrequencyMonitor::update
void update()
Let the diagnostics know that new data has arrived.
Definition: lib/frequency.cpp:43
ecl::FrequencyDiagnostics::hz
float hz
Definition: frequency.hpp:57
ecl::FrequencyMonitor::minimum_interval
ecl::TimeStamp minimum_interval
Definition: frequency.hpp:126
ecl::FrequencyDiagnostics::std_dev
float std_dev
Definition: frequency.hpp:58
ecl::FrequencyDiagnostics::FrequencyDiagnostics
FrequencyDiagnostics()
Definition: frequency.hpp:47
ecl::FrequencyDiagnostics::maximum_interval
float maximum_interval
Definition: frequency.hpp:60
ecl::FrequencyDiagnostics::minimum_interval
float minimum_interval
Definition: frequency.hpp:59
ecl::FrequencyMonitor::maximum_interval
ecl::TimeStamp maximum_interval
Definition: frequency.hpp:127
ecl::FrequencyMonitor::period
ecl::TimeStamp period
Definition: frequency.hpp:125
ecl::FrequencyMonitor::analyse
const FrequencyDiagnostics & analyse()
Analyse the recent updates to generate monitoring statistics.
Definition: lib/frequency.cpp:61
ecl::FrequencyDiagnostics::has_connection
bool has_connection
Definition: frequency.hpp:56
ecl::FrequencyMonitor::diagnostics
const FrequencyDiagnostics & diagnostics() const
Diagnostics getter function.
Definition: frequency.hpp:119
ecl::FrequencyDiagnostics
Data relevant to frequencies of an incoming stream.
Definition: frequency.hpp:37
timestamp.hpp
Cross-platform header inclusions for the timestamp class.
ecl::FrequencyMonitor::use_realtime_clock
bool use_realtime_clock
Definition: frequency.hpp:128
ecl::FrequencyMonitor::FrequencyMonitor
FrequencyMonitor(const float &window_period=2.0, const bool &use_realtime_clock=false)
Setup the frequency monitor.
Definition: lib/frequency.cpp:24
ecl::FrequencyMonitor::incoming_counter
unsigned int incoming_counter
Definition: frequency.hpp:123
ecl::FrequencyMonitor::last_anyalsed
ecl::TimeStamp last_anyalsed
Definition: frequency.hpp:124
ecl::FrequencyMonitor
Lightweight and fast frequency monitor.
Definition: frequency.hpp:89
ecl
Embedded control libraries.
ecl::FrequencyMonitor::current_diagnostics
FrequencyDiagnostics current_diagnostics
Definition: frequency.hpp:119


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:19