Utility functions for the ETSI ITS CAM (EN and TS)
More...
Go to the source code of this file.
|
TimestampIts | getTimestampITSFromGenerationDeltaTime (const GenerationDeltaTime &generation_delta_time, const TimestampIts ×tamp_estimate) |
| Get the TimestampITS from a given GenerationDeltaTime object.
|
|
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.
|
|
uint64_t | getUnixNanosecondsFromGenerationDeltaTime (const GenerationDeltaTime &generation_delta_time, const uint64_t unix_timestamp_estimate, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin() ->second) |
| Get the Unix Nanoseconds from Generation Delta Time object.
|
|
Utility functions for the ETSI ITS CAM (EN and TS)
Definition in file cam_utils.h.
◆ getTimestampITSFromGenerationDeltaTime()
TimestampIts getTimestampITSFromGenerationDeltaTime |
( |
const GenerationDeltaTime & | generation_delta_time, |
|
|
const TimestampIts & | timestamp_estimate ) |
|
inline |
Get the TimestampITS from a given GenerationDeltaTime object.
- Parameters
-
generation_delta_time | the GenerationDeltaTime object to get the TimestampITS from |
timestamp_estimate | estimated time to calculate the corresponding generation from |
- Returns
- TimestampIts the corresponding TimestampITS object
Definition at line 45 of file cam_utils.h.
46 {
47 TimestampIts t_its;
48 t_its.value = std::floor(timestamp_estimate.value / 65536) * 65536 + generation_delta_time.value;
49 throwIfOutOfRange(t_its.value, TimestampIts::MIN, TimestampIts::MAX,
"TimestampIts");
50 return t_its;
51}
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.
◆ getUnixNanosecondsFromGenerationDeltaTime() [1/2]
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 ) |
|
inline |
Get the Unix-Nanoseconds from a given GenerationDeltaTime object.
- Parameters
-
generation_delta_time | the GenerationDeltaTime object to get the Unix-Nanoseconds from |
timestamp_estimate | estimated time to calculate the corresponding generation from |
n_leap_seconds | number of leap-seconds since 2004. (Defaults to the todays number of leap seconds since 2004.) |
- Returns
- uint64_t the corresponding Unix-Nanoseconds
Definition at line 61 of file cam_utils.h.
63 {
65 return t_its.value * 1e6 + etsi_its_msgs::UNIX_SECONDS_2004 * 1e9 - n_leap_seconds * 1e9;
66}
TimestampIts getTimestampITSFromGenerationDeltaTime(const GenerationDeltaTime &generation_delta_time, const TimestampIts ×tamp_estimate)
Get the TimestampITS from a given GenerationDeltaTime object.
◆ getUnixNanosecondsFromGenerationDeltaTime() [2/2]
uint64_t getUnixNanosecondsFromGenerationDeltaTime |
( |
const GenerationDeltaTime & | generation_delta_time, |
|
|
const uint64_t | unix_timestamp_estimate, |
|
|
const uint16_t | n_leap_seconds = etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin()->second ) |
|
inline |
Get the Unix Nanoseconds from Generation Delta Time object.
- Parameters
-
generation_delta_time | the GenerationDeltaTime object to get the Unix-Nanoseconds from |
unix_timestamp_estimate | estimated unix-time (in Nanoseconds) to calculate the corresponding generation from |
n_leap_seconds | number of leap-seconds since 2004. (Defaults to the todays number of leap seconds since 2004.) |
- Returns
- uint64_t the corresponding Unix-Nanoseconds
Definition at line 76 of file cam_utils.h.
78 {
79 TimestampIts t_its;
82}
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.
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.