etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
cam_utils.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
3
8
11
12#ifndef ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_UTILS_H
13#define ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_UTILS_H
14
22inline TimestampIts getTimestampITSFromGenerationDeltaTime(const GenerationDeltaTime& generation_delta_time,
23 const TimestampIts& timestamp_estimate) {
24 TimestampIts t_its;
25 t_its.value = std::floor(timestamp_estimate.value / 65536) * 65536 + generation_delta_time.value;
26 throwIfOutOfRange(t_its.value, TimestampIts::MIN, TimestampIts::MAX, "TimestampIts");
27 return t_its;
28}
29
39 const GenerationDeltaTime& generation_delta_time, const TimestampIts& timestamp_estimate,
40 const uint16_t n_leap_seconds = etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin()->second) {
41 TimestampIts t_its = getTimestampITSFromGenerationDeltaTime(generation_delta_time, timestamp_estimate);
42 return t_its.value * 1e6 + etsi_its_msgs::UNIX_SECONDS_2004 * 1e9 - n_leap_seconds * 1e9;
43}
44
54 const GenerationDeltaTime& generation_delta_time, const uint64_t unix_timestamp_estimate,
55 const uint16_t n_leap_seconds = etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin()->second) {
56 TimestampIts t_its;
57 setTimestampITS(t_its, unix_timestamp_estimate, n_leap_seconds);
58 return getUnixNanosecondsFromGenerationDeltaTime(generation_delta_time, t_its, n_leap_seconds);
59}
60
61#endif // ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_UTILS_H
uint64_t getUnixNanosecondsFromGenerationDeltaTime(const GenerationDeltaTime &generation_delta_time, const TimestampIts &timestamp_estimate, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin() ->second)
Get the Unix-Nanoseconds from a given GenerationDeltaTime object.
Definition cam_utils.h:38
TimestampIts getTimestampITSFromGenerationDeltaTime(const GenerationDeltaTime &generation_delta_time, const TimestampIts &timestamp_estimate)
Get the TimestampITS from a given GenerationDeltaTime object.
Definition cam_utils.h:22
void setTimestampITS(TimestampIts &timestamp_its, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin() ->second)
Set the TimestampITS object.
Sanity-check functions etc.
void throwIfOutOfRange(const T1 &val, const T2 &min, const T2 &max, const std::string val_desc)
Throws an exception if a given value is out of a defined range.
Definition checks.h:23
File containing constants that are used in the context of ETIS ITS Messages.
const std::map< uint64_t, uint16_t > LEAP_SECOND_INSERTIONS_SINCE_2004
std::map that stores all leap second insertions since 2004 with the corresponding unix-date of the in...
Definition constants.h:22