etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
spatem_ts_getters.h
Go to the documentation of this file.
1/*
2=============================================================================
3MIT License
4
5Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24=============================================================================
25*/
26
31
32#pragma once
33
34namespace etsi_its_spatem_ts_msgs {
35
36namespace access {
37
39
46 inline uint16_t getIntersectionID(const IntersectionID& intsct_id) {
47 return intsct_id.value;
48 }
49
52
56 inline uint16_t getIntersectionID(const IntersectionReferenceID& intsct_ref_id) {
57 return getIntersectionID(intsct_ref_id.id);
58 }
59
66 inline uint16_t getIntersectionID(const IntersectionState& intsct) {
67 return getIntersectionID(intsct.id);
68 }
69
76 inline MinuteOfTheYear getMinuteOfTheYear(const IntersectionState& intsct) {
77 throwIfNotPresent(intsct.moy_is_present, "intsct.moy");
78 return intsct.moy;
79 }
80
87 inline DSecond getDSecond(const IntersectionState& intsct) {
88 throwIfNotPresent(intsct.time_stamp_is_present, "intsct.time_stamp");
89 return intsct.time_stamp;
90 }
91
98 inline double getDSecondValue(const DSecond& dsecond) {
99 return ((double)dsecond.value)*1e-3;
100 }
101
108 inline double getDSecondValue(const IntersectionState& intsct) {
109 return getDSecondValue(getDSecond(intsct));
110 }
111
118 inline uint8_t getSignalGroupID(const SignalGroupID& signal_group_id) {
119 return signal_group_id.value;
120 }
121
128 inline uint8_t getSignalGroupID(const MovementState& mvmt_state) {
129 return getSignalGroupID(mvmt_state.signal_group);
130 }
131
138 inline MovementEvent getCurrentMovementEvent(const MovementState& mvmt_state) {
139 if(mvmt_state.state_time_speed.array.size()<=0) {
140 throw std::runtime_error("MovementEventList is empty.");
141 }
142 return mvmt_state.state_time_speed.array[0];
143 }
144
151 inline MovementPhaseState getCurrentMovementPhaseState(const MovementState& mvmt_state) {
152 return getCurrentMovementEvent(mvmt_state).event_state;
153 }
154
161 inline uint8_t getCurrentMovementPhaseStateValue(const MovementState& mvmt_state) {
162 return getCurrentMovementPhaseState(mvmt_state).value;
163 }
164
165} // namespace access
166
167} // 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.