etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
denm_setters_common.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#ifndef ETSI_ITS_MSGS_UTILS_IMPL_DENM_DENM_SETTERS_COMMON_H
33#define ETSI_ITS_MSGS_UTILS_IMPL_DENM_DENM_SETTERS_COMMON_H
34
37#include <etsi_its_msgs_utils/impl/asn1_primitives/asn1_primitives_setters.h>
38
46inline void setReferenceTime(
47 DENM& denm, const uint64_t unix_nanosecs,
48 const uint16_t n_leap_seconds = etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin()->second) {
49 TimestampIts t_its;
50 setTimestampITS(t_its, unix_nanosecs, n_leap_seconds);
51 throwIfOutOfRange(t_its.value, TimestampIts::MIN, TimestampIts::MAX, "TimestampIts");
52 denm.denm.management.reference_time = t_its;
53}
54
61inline void setStationType(DENM& denm, const int value) { setStationType(denm.denm.management.station_type, value); }
62
74inline void setReferencePosition(DENM& denm, const double latitude, const double longitude,
75 const double altitude = AltitudeValue::UNAVAILABLE) {
76 setReferencePosition(denm.denm.management.event_position, latitude, longitude, altitude);
77}
78
85inline void setIsSpeedPresent(DENM& denm, bool presence_of_speed) {
86 if (denm.denm.location_is_present) {
87 denm.denm.location.event_speed_is_present = presence_of_speed;
88 } else {
89 throw std::invalid_argument("LocationContainer is not present!");
90 }
91}
92
100inline void setSpeed(DENM& denm, const double speed_val, const double confidence = std::numeric_limits<double>::infinity()) {
101 if (denm.denm.location_is_present) {
102 setSpeed(denm.denm.location.event_speed, speed_val, confidence);
103 setIsSpeedPresent(denm, true);
104 } else {
105 throw std::invalid_argument("LocationContainer is not present!");
106 }
107}
108
121inline void setFromUTMPosition(DENM& denm, const gm::PointStamped& utm_position, const int& zone, const bool& northp) {
122 setFromUTMPosition(denm.denm.management.event_position, utm_position, zone, northp);
123}
124
131inline void setDrivingLaneStatus(DrivingLaneStatus& driving_lane_status, const std::vector<bool>& bits) {
132 setBitString(driving_lane_status, bits);
133}
134
141inline void setLightBarSirenInUse(LightBarSirenInUse& light_bar_siren_in_use, const std::vector<bool>& bits) {
142 setBitString(light_bar_siren_in_use, bits);
143}
144
145#endif // ETSI_ITS_MSGS_UTILS_IMPL_DENM_DENM_SETTERS_COMMON_H
void setTimestampITS(TimestampIts &timestamp_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.
Sanity-check functions etc.
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.
Definition checks.h:46
File containing constants that are used in the context of ETIS ITS Messages.
const std::map< uint64_t, uint16_t > LEAP_SECOND_INSERTIONS_SINCE_2004
std::map that stores all leap second insertions since 2004 with the corresponding unix-date of the in...
Definition constants.h:45
void setLightBarSirenInUse(LightBarSirenInUse &light_bar_siren_in_use, const std::vector< bool > &bits)
Set the Lightbar Siren In Use by a vector of bools.
void setFromUTMPosition(DENM &denm, const gm::PointStamped &utm_position, const int &zone, const bool &northp)
Set the ReferencePosition of a DENM from a given UTM-Position.
void setSpeed(DENM &denm, const double speed_val, const double confidence=std::numeric_limits< double >::infinity())
Set the vehicle speed.
void setStationType(DENM &denm, const int value)
Set the StationType for a DENM.
void setIsSpeedPresent(DENM &denm, bool presence_of_speed)
Set the IsSpeedPresent object for DENM.
void setReferencePosition(DENM &denm, const double latitude, const double longitude, const double altitude=AltitudeValue::UNAVAILABLE)
Set the ReferencePositionWithConfidence for a DENM.
void setReferenceTime(DENM &denm, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin() ->second)
Set the ReferenceTime-value.
void setDrivingLaneStatus(DrivingLaneStatus &driving_lane_status, const std::vector< bool > &bits)
Set the Driving Lane Status by a vector of bools.