1 #ifndef artdaq_core_Data_detail_RawFragmentHeader_hh
2 #define artdaq_core_Data_detail_RawFragmentHeader_hh
10 #include "artdaq-core/Data/dictionarycontrol.hh"
11 #include "cetlib_except/exception.h"
12 #include "artdaq-core/Utilities/TimeUtils.hh"
20 struct RawFragmentHeader;
69 return std::map<type_t, std::string>{
83 return std::map<type_t, std::string>{
114 return "EndOfSubrun";
158 static constexpr std::size_t
num_words();
175 struct timespec atime();
176 struct timespec getLatency(bool touch);
182 inline constexpr std::size_t
193 "sizeof(RawFragmentHeader) is not an integer "
194 "multiple of sizeof(RawDataType)!");
199 if (utype < FIRST_USER_TYPE || utype > LAST_USER_TYPE)
201 throw cet::exception(
"InvalidValue")
202 <<
"RawFragmentHeader user types must be in the range of "
203 << ((int)FIRST_USER_TYPE) <<
" to " << ((int)LAST_USER_TYPE)
204 <<
" (bad type is " << ((int)utype) <<
").";
212 if (stype < FIRST_SYSTEM_TYPE /*|| stype > LAST_SYSTEM_TYPE*/)
214 throw cet::exception(
"InvalidValue")
215 <<
"RawFragmentHeader system types must be in the range of "
216 << ((int)FIRST_SYSTEM_TYPE) <<
" to " << ((int)LAST_SYSTEM_TYPE);
221 inline void artdaq::detail::RawFragmentHeader::touch()
224 atime_ns = time.tv_nsec;
225 atime_s = time.tv_sec;
228 inline struct timespec artdaq::detail::RawFragmentHeader::atime()
231 ts.tv_nsec = atime_ns;
236 inline struct timespec artdaq::detail::RawFragmentHeader::getLatency(bool touch)
238 auto a_time = atime();
241 a_time.tv_sec = time.tv_sec - a_time.tv_sec;
243 if (a_time.tv_nsec > time.tv_nsec)
246 a_time.tv_nsec = 1000000000 + time.tv_nsec - a_time.tv_nsec;
250 a_time.tv_nsec = time.tv_nsec - a_time.tv_nsec;
255 atime_ns = time.tv_nsec;
256 atime_s = time.tv_sec;
struct timespec get_realtime_clock()
Get the current time of day as a pair of seconds and nanoseconds (from clock_gettime(CLOCK_REALTIME, ...) system call)