TimestampEstimatorBase is the base class for timestamp-based logic in test systems where the current timestamp must be estimated somehow (eg, because there is no hardware timing system).
More...
#include <TimestampEstimatorBase.hpp>
|
static constexpr uint64_t | s_invalid_ts = std::numeric_limits<uint64_t>::max() |
|
TimestampEstimatorBase is the base class for timestamp-based logic in test systems where the current timestamp must be estimated somehow (eg, because there is no hardware timing system).
Definition at line 25 of file TimestampEstimatorBase.hpp.
◆ WaitStatus
◆ ~TimestampEstimatorBase()
virtual dunedaq::utilities::TimestampEstimatorBase::~TimestampEstimatorBase |
( |
| ) |
|
|
virtualdefault |
◆ get_timestamp_estimate()
virtual uint64_t dunedaq::utilities::TimestampEstimatorBase::get_timestamp_estimate |
( |
| ) |
const |
|
pure virtual |
◆ get_wait_estimate()
virtual std::chrono::microseconds dunedaq::utilities::TimestampEstimatorBase::get_wait_estimate |
( |
uint64_t | ts | ) |
const |
|
pure virtual |
◆ wait_for_requested_timestamp() [1/2]
WaitStatus dunedaq::utilities::TimestampEstimatorBase::wait_for_requested_timestamp |
( |
uint64_t | ts, |
|
|
std::atomic< bool > & | continue_flag ) |
|
inline |
Wait for the current timestamp estimate to reach ts, or for continue_flag to become false.
Returns kFinished if the timestamp became valid, or kInterrupted if continue_flag became false first
Definition at line 61 of file TimestampEstimatorBase.hpp.
62 {
65 }
WaitStatus wait_for_requested_timestamp(uint64_t ts, std::atomic< bool > &continue_flag)
static constexpr uint64_t s_invalid_ts
PDS Frame with unphysical timestamp detected with ts
◆ wait_for_requested_timestamp() [2/2]
Definition at line 45 of file TimestampEstimatorBase.cpp.
48{
50 auto get_sleep_time = [
this,
ts]() {
52 auto pest = static_cast<std::chrono::microseconds::rep>(static_cast<double>(est.count()) * 0.8);
53 if (pest < 1 && est != std::chrono::microseconds(0))
54 return std::chrono::microseconds(1);
55 return std::chrono::microseconds(pest);
56 };
57 auto sleep_time = get_sleep_time();
58
60 std::this_thread::sleep_for(sleep_time);
61 sleep_time = get_sleep_time();
62 }
65}
virtual std::chrono::microseconds get_wait_estimate(uint64_t ts) const =0
virtual uint64_t get_timestamp_estimate() const =0
◆ wait_for_valid_timestamp() [1/2]
WaitStatus dunedaq::utilities::TimestampEstimatorBase::wait_for_valid_timestamp |
( |
std::atomic< bool > & | continue_flag | ) |
|
|
inline |
Wait for the current timestamp estimate to become valid, or for continue_flag to become false. The timestamp becomes valid once at least one TimeSync message has been received.
Returns kFinished if the timestamp became valid, or kInterrupted if continue_flag became false first
Definition at line 47 of file TimestampEstimatorBase.hpp.
48 {
51 }
WaitStatus wait_for_valid_timestamp(std::atomic< bool > &continue_flag)
◆ wait_for_valid_timestamp() [2/2]
Waits for a valid timestamp to become available. Returns a status value that indicates whether a valid timestamp is available or not.
- Parameters
-
continue_flag | whether to continue waiting until a valid timestamp is available or return immediately |
last_seen_ts | (Output parameter) the last timestamp seen by the method |
The value of the continue_flag can be changed from true to false externally to this method, and that will cause the method to exit soon thereafter (on the order of 10 msec) and return the current status.
- Returns
- kFinished if a valid timestamp is available or kInterrupted if one is not
Definition at line 27 of file TimestampEstimatorBase.cpp.
28{
30 auto sleep_time = std::chrono::microseconds(1);
31
33 std::this_thread::sleep_for(sleep_time);
34 if (sleep_time < std::chrono::milliseconds(10)) {
35 sleep_time *= 2;
36 }
37 }
38
39
40
42}
◆ s_invalid_ts
uint64_t dunedaq::utilities::TimestampEstimatorBase::s_invalid_ts = std::numeric_limits<uint64_t>::max() |
|
staticconstexpr |
The documentation for this class was generated from the following files: