DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TimestampEstimatorTimeSync.hpp
Go to the documentation of this file.
1
12#ifndef UTILITIES_INCLUDE_UTILITIES_TIMESTAMPESTIMATORTIMESYNC_HPP_
13#define UTILITIES_INCLUDE_UTILITIES_TIMESTAMPESTIMATORTIMESYNC_HPP_
14
15#include "utilities/Issues.hpp"
17
18#include <atomic>
19#include <memory>
20#include <mutex>
21
22namespace dunedaq::utilities {
23
24enum
25{
29};
30
37{
38public:
39 TimestampEstimatorTimeSync(uint32_t run_number, uint64_t clock_frequency_hz); // NOLINT(build/unsigned)
40
41 explicit TimestampEstimatorTimeSync(uint64_t clock_frequency_hz); // NOLINT(build/unsigned)
42
44
45 uint64_t get_timestamp_estimate() const override; // NOLINT(build/unsigned)
46
47 std::chrono::microseconds get_wait_estimate(uint64_t ts) const override; // NOLINT(build/unsigned)
48
49 void add_timestamp_datapoint(uint64_t daq_time, uint64_t system_time); // NOLINT(build/unsigned)
50
51 template<class T>
52 void timesync_callback(const T& tsync);
53
54 uint64_t get_received_timesync_count() const { return m_received_timesync_count.load(); } // NOLINT(build/unsigned)
55
56private:
58 {
59 uint64_t daq_time{ s_invalid_ts }; // NOLINT(build/unsigned)
60 std::chrono::time_point<std::chrono::steady_clock> system_time;
61 };
62
63 std::atomic<TimeSyncPoint> m_current_timestamp_estimate;
64
65 uint64_t m_clock_frequency_hz; // NOLINT(build/unsigned)
66 uint64_t m_most_recent_daq_time{ s_invalid_ts }; // NOLINT(build/unsigned)
67 uint64_t m_most_recent_system_time; // NOLINT(build/unsigned)
69 uint32_t m_run_number{ 0 }; // NOLINT(build/unsigned)
70 std::atomic<uint64_t> m_received_timesync_count; // NOLINT(build/unsigned)
71 uint32_t m_current_process_id; // NOLINT(build/unsigned)
72};
73
74} // namespace dunedaq::utilities
75
77
78#endif // UTILITIES_INCLUDE_UTILITIES_TIMESTAMPESTIMATORTIMESYNC_HPP_
TimestampEstimatorBase is the base class for timestamp-based logic in test systems where the current ...
TimestampEstimatorTimeSync is an implementation of TimestampEstimatorBase that uses TimeSync messages...
void add_timestamp_datapoint(uint64_t daq_time, uint64_t system_time)
uint64_t get_timestamp_estimate() const override
Returns the current timestamp estimate or a special value if no valid timestamp is available.
std::chrono::microseconds get_wait_estimate(uint64_t ts) const override
TimestampEstimatorTimeSync(uint32_t run_number, uint64_t clock_frequency_hz)
PDS Frame with unphysical timestamp detected with ts
std::chrono::time_point< std::chrono::steady_clock > system_time