etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
spatem_ts_getters.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#pragma once
10
11namespace etsi_its_spatem_ts_msgs {
12
13namespace access {
14
16
23 inline uint16_t getIntersectionID(const IntersectionID& intsct_id) {
24 return intsct_id.value;
25 }
26
29
33 inline uint16_t getIntersectionID(const IntersectionReferenceID& intsct_ref_id) {
34 return getIntersectionID(intsct_ref_id.id);
35 }
36
43 inline uint16_t getIntersectionID(const IntersectionState& intsct) {
44 return getIntersectionID(intsct.id);
45 }
46
53 inline MinuteOfTheYear getMinuteOfTheYear(const IntersectionState& intsct) {
54 throwIfNotPresent(intsct.moy_is_present, "intsct.moy");
55 return intsct.moy;
56 }
57
64 inline DSecond getDSecond(const IntersectionState& intsct) {
65 throwIfNotPresent(intsct.time_stamp_is_present, "intsct.time_stamp");
66 return intsct.time_stamp;
67 }
68
75 inline double getDSecondValue(const DSecond& dsecond) {
76 return ((double)dsecond.value)*1e-3;
77 }
78
85 inline double getDSecondValue(const IntersectionState& intsct) {
86 return getDSecondValue(getDSecond(intsct));
87 }
88
95 inline uint8_t getSignalGroupID(const SignalGroupID& signal_group_id) {
96 return signal_group_id.value;
97 }
98
105 inline uint8_t getSignalGroupID(const MovementState& mvmt_state) {
106 return getSignalGroupID(mvmt_state.signal_group);
107 }
108
115 inline MovementEvent getCurrentMovementEvent(const MovementState& mvmt_state) {
116 if(mvmt_state.state_time_speed.array.size()<=0) {
117 throw std::runtime_error("MovementEventList is empty.");
118 }
119 return mvmt_state.state_time_speed.array[0];
120 }
121
128 inline MovementPhaseState getCurrentMovementPhaseState(const MovementState& mvmt_state) {
129 return getCurrentMovementEvent(mvmt_state).event_state;
130 }
131
138 inline uint8_t getCurrentMovementPhaseStateValue(const MovementState& mvmt_state) {
139 return getCurrentMovementPhaseState(mvmt_state).value;
140 }
141
142} // namespace access
143
144} // namespace etsi_its_spatem_ts_msgs
Sanity-check functions etc.
uint16_t getIntersectionID(const IntersectionID &intsct_id)
Get the intersection-id.
double getDSecondValue(const DSecond &dsecond)
Get the value of a DSecond object in seconds.
uint8_t getSignalGroupID(const SignalGroupID &signal_group_id)
Get the Signal Group-ID of an SignalGroupID object.
DSecond getDSecond(const IntersectionState &intsct)
Get the DSecond object from a given IntersectionState object.
MovementEvent getCurrentMovementEvent(const MovementState &mvmt_state)
Get the current MovementEvent of a given MovementState object.
void throwIfNotPresent(const bool is_present, const std::string val_desc)
Throws an exception if the given value is not present.
MovementPhaseState getCurrentMovementPhaseState(const MovementState &mvmt_state)
Get the Current MovementPhaseState object of a given MovementState object.
MinuteOfTheYear getMinuteOfTheYear(const IntersectionState &intsct)
Get the MinuteOfTheYear object from a given IntersectionState object.
uint8_t getCurrentMovementPhaseStateValue(const MovementState &mvmt_state)
Get the Current MovementPhaseState object of a given MovementState object.