Vanetza
 
Loading...
Searching...
No Matches
cam_functions.hpp
1#ifndef CAM_FUNCTIONS_HPP_PUFKBEM8
2#define CAM_FUNCTIONS_HPP_PUFKBEM8
3
4#include <vanetza/asn1/its/AltitudeConfidence.h>
5#include <vanetza/asn1/its/AltitudeValue.h>
6#include <vanetza/asn1/its/Heading.h>
7#include <vanetza/asn1/its/ReferencePosition.h>
8#include <vanetza/common/position_fix.hpp>
9#include <vanetza/security/cam_ssp.hpp>
10#include <vanetza/units/angle.hpp>
11#include <vanetza/units/length.hpp>
12
13// forward declaration of asn1c generated struct
14struct BasicVehicleContainerLowFrequency;
15
16namespace vanetza
17{
18
19// forward declaration of CAM message wrapper
20namespace asn1 { class Cam; }
21
22namespace facilities
23{
24
25class PathHistory;
26
27/**
28 * Copy PathHistory into BasicVehicleContainerLowFrequency's pathHistory element
29 * \param Facilities' path history object (source)
30 * \param ASN.1 CAM container (destination)
31 */
32void copy(const PathHistory&, BasicVehicleContainerLowFrequency&);
33
34/**
35 * Check if difference of two given heading values is within a limit
36 * \param a one heading
37 * \param b another heading
38 * \param limit maximum difference (positive)
39 * \return true if similar enough
40 */
41bool similar_heading(const Heading& a, const Heading& b, units::Angle limit);
42bool similar_heading(const Heading& a, units::Angle b, units::Angle limit);
43bool similar_heading(units::Angle a, units::Angle b, units::Angle limit);
44
45/**
46 * Calculate distance between positions
47 * \param a one position
48 * \param b another position
49 * \return distance between given positions (or NaN if some position is unavailable)
50 */
51units::Length distance(const ReferencePosition_t& a, const ReferencePosition_t& b);
52units::Length distance(const ReferencePosition_t& a, units::GeoAngle lat, units::GeoAngle lon);
53
54/**
55 * Check if ASN.1 data element indicates unavailable value
56 * \return true if value is available
57 */
58bool is_available(const Heading&);
59bool is_available(const ReferencePosition_t&);
60
61/**
62 * Copy position information into a ReferencePosition structure from CDD
63 */
64void copy(const PositionFix&, ReferencePosition&);
65
66/**
67 * Convert altitude to AltitudeValue from CDD
68 */
69AltitudeValue_t to_altitude_value(units::Length);
70
71/**
72 * Convert altitude confidence to AltitudeConfidence from CDD
73 */
74AltitudeConfidence_t to_altitude_confidence(units::Length);
75
76/**
77 * Check if a CAM contains only allowed data elements
78 * \param cam CA message
79 * \param ssp CA service specific permissions
80 * \return true if no forbidden data elements are included
81 */
82bool check_service_specific_permissions(const asn1::Cam& cam, security::CamPermissions ssp);
83
84/**
85 * Print CAM content with indentation of nested fields
86 * \param os output stream
87 * \param cam CA message
88 * \param indent indentation marker, by default one tab per level
89 * \param start initial level of indentation
90 *
91 * This function is an idea of Erik de Britto e Silva (erikbritto@github)
92 * from University of Antwerp - erik.debrittoesilva@uantwerpen.be
93 */
94void print_indented(std::ostream& os, const asn1::Cam& cam, const std::string& indent = "\t", unsigned start = 0);
95
96} // namespace facilities
97} // namespace vanetza
98
99#endif /* CAM_FUNCTIONS_HPP_PUFKBEM8 */