etsi_its_messages 1.0.0
Loading...
Searching...
No Matches
cam_utils.h File Reference

Utility functions for the ETSI ITS CAM (EN and TS) More...

Go to the source code of this file.

Functions

TimestampIts getTimestampITSFromGenerationDeltaTime (const GenerationDeltaTime &generation_delta_time, const TimestampIts &timestamp_estimate)
 Get the TimestampITS from a given GenerationDeltaTime object.
 
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.end() ->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.end() ->second)
 Get the Unix Nanoseconds from Generation Delta Time object.
 

Detailed Description

Utility functions for the ETSI ITS CAM (EN and TS)

Definition in file cam_utils.h.

Function Documentation

◆ getTimestampITSFromGenerationDeltaTime()

TimestampIts getTimestampITSFromGenerationDeltaTime ( const GenerationDeltaTime & generation_delta_time,
const TimestampIts & timestamp_estimate )
inline

Get the TimestampITS from a given GenerationDeltaTime object.

Parameters
generation_delta_timethe GenerationDeltaTime object to get the TimestampITS from
timestamp_estimateestimated 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}

◆ 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.end()->second )
inline

Get the Unix-Nanoseconds from a given GenerationDeltaTime object.

Parameters
generation_delta_timethe GenerationDeltaTime object to get the Unix-Nanoseconds from
timestamp_estimateestimated time to calculate the corresponding generation from
n_leap_secondsnumber of leap-seconds since 2004. (Default: etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end()->second)
Returns
uint64_t the corresponding Unix-Nanoseconds

Definition at line 61 of file cam_utils.h.

63 {
64 TimestampIts t_its = getTimestampITSFromGenerationDeltaTime(generation_delta_time, timestamp_estimate);
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 &timestamp_estimate)
Get the TimestampITS from a given GenerationDeltaTime object.
Definition cam_utils.h:45

◆ 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.end()->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
Returns
uint64_t the corresponding Unix-Nanoseconds

Definition at line 75 of file cam_utils.h.

77 {
78 TimestampIts t_its;
79 setTimestampITS(t_its, unix_timestamp_estimate, n_leap_seconds);
80 return getUnixNanosecondsFromGenerationDeltaTime(generation_delta_time, t_its, n_leap_seconds);
81}
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.end() ->second)
Get the Unix-Nanoseconds from a given GenerationDeltaTime object.
Definition cam_utils.h:61
void setTimestampITS(TimestampIts &timestamp_its, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end() ->second)
Set the TimestampITS object.