DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TimeSync.hpp
Go to the documentation of this file.
1
9#ifndef DFMESSAGES_INCLUDE_DFMESSAGES_TIMESYNC_HPP_
10#define DFMESSAGES_INCLUDE_DFMESSAGES_TIMESYNC_HPP_
11
12#include "dfmessages/Types.hpp"
13
15
16#include <cstddef>
17#include <limits>
18
19namespace dunedaq {
20namespace dfmessages {
25{
31 uint64_t sequence_number{ 0 }; // NOLINT(build/unsigned)
35 uint32_t source_pid{ 0 }; // NOLINT(build/unsigned)
36
37 TimeSync() = default;
38
46 , system_time(sys_time)
47 {}
48
56 {
57 struct timeval tv;
58 gettimeofday(&tv, nullptr);
59 return static_cast<system_time_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
60 }
61
63};
64static_assert(sizeof(TimeSync) == 32, "TimeSync size unexpected!");
65static_assert(offsetof(TimeSync, daq_time) == 0, "TimeSync daq_time field not at expected offset!");
66static_assert(offsetof(TimeSync, system_time) == 8, "TimeSync system_time field not at expected offset!");
67static_assert(offsetof(TimeSync, sequence_number) == 16, "TimeSync sequence_number field not at expected offset!");
68static_assert(offsetof(TimeSync, run_number) == 24, "TimeSync run_number field not at expected offset!");
69static_assert(offsetof(TimeSync, source_pid) == 28, "TimeSync source_pid field not at expected offset!");
70} // namespace dfmessages
72} // namespace dunedaq
73
74#endif // DFMESSAGES_INCLUDE_DFMESSAGES_TIMESYNC_HPP_
#define DUNE_DAQ_SERIALIZABLE(Type, typestring)
static constexpr timestamp_t s_invalid_timestamp
An invalid timestamp.
Definition Types.hpp:65
static constexpr system_time_t s_invalid_system_time
An invalid system time.
Definition Types.hpp:72
daqdataformats::run_number_t run_number_t
Copy daqdataformats::run_number_t.
Definition Types.hpp:34
daqdataformats::timestamp_t timestamp_t
Copy daqdataformats::timestamp_t.
Definition Types.hpp:42
uint64_t system_time_t
System times are represented using a 64-bit unsigned integer This number is defined as the number of ...
Definition Types.hpp:62
Including Qt Headers.
A synthetic message used to ensure that all elements of a DAQ system are synchronized.
Definition TimeSync.hpp:25
timestamp_t daq_time
The current DAQ time.
Definition TimeSync.hpp:27
run_number_t run_number
Run number at time of creation.
Definition TimeSync.hpp:33
TimeSync(timestamp_t daq_time, system_time_t sys_time=gettimeofday_us())
Construct a TimeSync message.
Definition TimeSync.hpp:44
DUNE_DAQ_SERIALIZE(TimeSync, daq_time, system_time, run_number, sequence_number, source_pid)
uint64_t sequence_number
Sequence Number of this message, for debugging.
Definition TimeSync.hpp:31
static system_time_t gettimeofday_us()
Get the current system time.
Definition TimeSync.hpp:55
uint32_t source_pid
PID of the creating process, for debugging.
Definition TimeSync.hpp:35
system_time_t system_time
The current system time.
Definition TimeSync.hpp:29