etsi_its_messages
v3.5.0
Toggle main menu visibility
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
9
#include <
etsi_its_msgs_utils/impl/checks.h
>
10
#include <
etsi_its_msgs_utils/impl/constants.h
>
11
12
#ifndef ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_UTILS_H
13
#define ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_UTILS_H
14
22
inline
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
38
inline
uint64_t
getUnixNanosecondsFromGenerationDeltaTime
(
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
53
inline
uint64_t
getUnixNanosecondsFromGenerationDeltaTime
(
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
getUnixNanosecondsFromGenerationDeltaTime
uint64_t getUnixNanosecondsFromGenerationDeltaTime(const GenerationDeltaTime &generation_delta_time, const TimestampIts ×tamp_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
getTimestampITSFromGenerationDeltaTime
TimestampIts getTimestampITSFromGenerationDeltaTime(const GenerationDeltaTime &generation_delta_time, const TimestampIts ×tamp_estimate)
Get the TimestampITS from a given GenerationDeltaTime object.
Definition
cam_utils.h:22
setTimestampITS
void setTimestampITS(TimestampIts ×tamp_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.
Definition
cdd_setters_common.h:53
checks.h
Sanity-check functions etc.
throwIfOutOfRange
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
constants.h
File containing constants that are used in the context of ETIS ITS Messages.
etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004
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
etsi_its_msgs_utils
include
etsi_its_msgs_utils
impl
cam
cam_utils.h
Generated by
1.17.0