etsi_its_messages v3.3.0
 
Loading...
Searching...
No Matches
mcm_utils.h File Reference

Utility functions for the ETSI ITS MCM (TR) More...

Go to the source code of this file.

Functions

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.
 

Detailed Description

Utility functions for the ETSI ITS MCM (TR)

Definition in file mcm_utils.h.

Function Documentation

◆ getUnixNanosecondsFromGenerationDeltaTime()

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_timethe GenerationDeltaTime object to get the Unix-Nanoseconds from
unix_timestamp_estimateestimated unix-time (in Nanoseconds) to calculate the corresponding generation from
n_leap_secondsnumber 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 46 of file mcm_utils.h.

48 {
49 uint64_t ms_estimate_after_utc_2004 =
50 unix_timestamp_estimate * 1e-6 + (uint64_t)(n_leap_seconds * 1e3) - etsi_its_msgs::UNIX_SECONDS_2004 * 1e3;
51 uint64_t ms_after_utc_2004 = std::floor(ms_estimate_after_utc_2004 / 65536) * 65536 + generation_delta_time.value;
52 return ms_after_utc_2004 * 1e6 + etsi_its_msgs::UNIX_SECONDS_2004 * 1e9 - n_leap_seconds * 1e9;
53}