ITS
api.h File Reference

Usefull functions and declarations. More...

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <BIT_STRING.h>
#include <QDataStream>
#include <QIODevice>
#include <constantes.h>
#include <confuse.h>
#include <QObject>
#include <QFile>
Include dependency graph for api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EARTH_RADIUS   6378137
 
#define LAT2METER   111132
 
#define NEW_LINE   16
 
#define OCTET   4
 
#define zeroPtOneMicroDegreeToMeter   0.0111178
 
#define DEFAULT_VALUE_POSITION   0
 
#define GPS_CONF_LATITUDE   "Latitude"
 
#define GPS_CONF_LONGITUDE   "Longitude"
 
#define GPS_CONF_ALTITUDE   "Altitude"
 
#define GPS_CONF_HEADING   "Heading"
 
#define GPS_CONF_SEMI_MAJOR_CONFIDENCE   "Semi major confidence"
 
#define GPS_CONF_SEMI_MINOR_CONFIDENCE   "Semi minor confidence"
 
#define GPS_CONF_SEMI_MAJOR_ORIENTATION   "Semi major orientation"
 
#define GPS_CONF_SPEED   "Speed"
 
#define GPS_CONF_TIMESTAMP   "Timestamp"
 
#define SWAP16(nb)   (nb = (nb << 8) | (nb >> 8))
 
#define SWAP32(nb)
 
#define SWAP64(nb)
 

Functions

void format (unsigned char *msg, unsigned long v, int l)
 format Format a number in byte array. More...
 
unsigned long long int split (const unsigned char *msg, int begin, int end)
 split Extract number from byte array. More...
 
void split (const unsigned char *msg, int begin, int end, char *out)
 split Extract sub byte array from byte array More...
 
void print_hexa (const unsigned char *msg, int l, FILE *stream=stdout)
 print_hexa Print a byte array. More...
 
QString printBitString (BIT_STRING_t b)
 printBitString Print a BIT_STRING into a QString. More...
 
int validate_unsigned_int (cfg_t *cfg, cfg_opt_t *opt)
 validate_unsigned_int Check if an option is an unsigned int More...
 
BIT_STRING_t makeBitString (int nbits, cfg_t *cfg, const char *opt_name)
 makeBitString Generate a BIT_STRING from configuration. More...
 
quint64 circAtLat (long l)
 circAtLat Compute the circumference at a latitude. More...
 
unsigned int diameter (long begin, long end, quint64 circ)
 diameter Compute the distance between two point on the same latitude. More...
 
double dist (qint32 x1, qint32 y1, qint32 x2, qint32 y2)
 dist This function calculate the euclidian distance between two points ([x1, y1], [x2, y2]). More...
 
double f (long x, long y, double lengthA, double lengthB, e_shape shape)
 f Compute the f function. More...
 
int g (double dist_r, double dist_f, double dist_fr, int angleThreshold)
 g Compute the g function. More...
 

Detailed Description

Usefull functions and declarations.

Definition in file api.h.

Macro Definition Documentation

◆ DEFAULT_VALUE_POSITION

#define DEFAULT_VALUE_POSITION   0

Definition at line 29 of file api.h.

◆ EARTH_RADIUS

#define EARTH_RADIUS   6378137

Definition at line 22 of file api.h.

Referenced by circAtLat().

◆ GPS_CONF_ALTITUDE

#define GPS_CONF_ALTITUDE   "Altitude"

Definition at line 33 of file api.h.

◆ GPS_CONF_HEADING

#define GPS_CONF_HEADING   "Heading"

Definition at line 34 of file api.h.

◆ GPS_CONF_LATITUDE

#define GPS_CONF_LATITUDE   "Latitude"

Definition at line 31 of file api.h.

◆ GPS_CONF_LONGITUDE

#define GPS_CONF_LONGITUDE   "Longitude"

Definition at line 32 of file api.h.

◆ GPS_CONF_SEMI_MAJOR_CONFIDENCE

#define GPS_CONF_SEMI_MAJOR_CONFIDENCE   "Semi major confidence"

Definition at line 35 of file api.h.

◆ GPS_CONF_SEMI_MAJOR_ORIENTATION

#define GPS_CONF_SEMI_MAJOR_ORIENTATION   "Semi major orientation"

Definition at line 37 of file api.h.

◆ GPS_CONF_SEMI_MINOR_CONFIDENCE

#define GPS_CONF_SEMI_MINOR_CONFIDENCE   "Semi minor confidence"

Definition at line 36 of file api.h.

◆ GPS_CONF_SPEED

#define GPS_CONF_SPEED   "Speed"

Definition at line 38 of file api.h.

◆ GPS_CONF_TIMESTAMP

#define GPS_CONF_TIMESTAMP   "Timestamp"

Definition at line 39 of file api.h.

◆ LAT2METER

◆ NEW_LINE

#define NEW_LINE   16

Definition at line 25 of file api.h.

Referenced by print_hexa().

◆ OCTET

#define OCTET   4

Definition at line 26 of file api.h.

Referenced by print_hexa().

◆ SWAP16

#define SWAP16 (   nb)    (nb = (nb << 8) | (nb >> 8))

Definition at line 41 of file api.h.

Referenced by CommonHeader::CommonHeader().

◆ SWAP32

#define SWAP32 (   nb)
Value:
(nb = ((nb & 0x000f) << 24) | \
((nb & 0x00f0) << 16) | \
((nb & 0x0f00) >> 8) | \
((nb & 0xf000) >> 24))

Definition at line 42 of file api.h.

◆ SWAP64

#define SWAP64 (   nb)
Value:
(nb = ((nb & 0x0000000f) << 56) | \
((nb & 0x000000f0) << 48) | \
((nb & 0x00000f00) << 40) | \
((nb & 0x0000f000) << 32) | \
((nb & 0x000f0000) >> 8) | \
((nb & 0x00f00000) >> 24) | \
((nb & 0x0f000000) >> 40) | \
((nb & 0xf0000000) >> 56))

Definition at line 46 of file api.h.

◆ zeroPtOneMicroDegreeToMeter

#define zeroPtOneMicroDegreeToMeter   0.0111178

Definition at line 27 of file api.h.

Function Documentation

◆ circAtLat()

quint64 circAtLat ( long  l)

circAtLat Compute the circumference at a latitude.

Parameters
lThe latitude.
Returns
The circumference.

Definition at line 211 of file api.cpp.

References EARTH_RADIUS.

Referenced by GeoNet::advancedForwarding(), GeoNet::contentionBasedForwardingAlgorithm(), GeoNet::gacPacketProcessing(), GeoNet::gbcPacketProcessing(), denMessageTableForwarding::inRelevanceArea(), GeoNet::sendGAC(), and GeoNet::simpleForwardingAlgorithm().

Here is the caller graph for this function:

◆ diameter()

unsigned int diameter ( long  begin,
long  end,
quint64  circ 
)

diameter Compute the distance between two point on the same latitude.

Parameters
beginThe first point.
endThe seconde point.
circThe circumference at the latitude.
Returns
The distance between the two point.

Definition at line 220 of file api.cpp.

Referenced by GeoNet::advancedForwarding(), GeoNet::contentionBasedForwardingAlgorithm(), GeoNet::gacPacketProcessing(), GeoNet::gbcPacketProcessing(), denMessageTableForwarding::inRelevanceArea(), GeoNet::sendGAC(), and GeoNet::simpleForwardingAlgorithm().

Here is the caller graph for this function:

◆ dist()

double dist ( qint32  x1,
qint32  y1,
qint32  x2,
qint32  y2 
)

dist This function calculate the euclidian distance between two points ([x1, y1], [x2, y2]).

Parameters
x1X1 is the latitude of the first point.
y1Y1 is the longitude of the first point.
x2X2 is the latitude of the second point.
y2Y2 is the longitude of the second point.
Returns
Return the distance between the two points

Definition at line 228 of file api.cpp.

Referenced by GeoNet::advancedForwarding(), GeoNet::CBFUnicast(), caBasicService::checkCamGeneration(), GeoNet::contentionBasedForwardingAlgorithm(), and GeoNet::greedy().

Here is the caller graph for this function:

◆ f()

double f ( long  x,
long  y,
double  lengthA,
double  lengthB,
e_shape  shape 
)

f Compute the f function.

Parameters
xThe x position of the point.
yThe y position of the point.
lengthAThe length of the semi minor axis.
lengthBThe length of the semi major axis.
shapeThe shape of the area.
Returns
  • 1 for x = 0 and y = 0 (at the center point)
  • > 0 inside the geographical area
  • 0 at the border of the geographical area
  • -1 outside the geographical area
See also
ETSI EN 302 636-4-1 v1.2.1 (2014-07)

Definition at line 236 of file api.cpp.

References shape_circle, shape_ellipse, shape_none, and shape_rectangle.

Referenced by GeoNet::advancedForwarding(), ber_tlv_tag_fwrite(), GeoNet::contentionBasedForwardingAlgorithm(), GeoNet::gacPacketProcessing(), GeoNet::gbcPacketProcessing(), denMessageTableForwarding::inRelevanceArea(), GeoNet::sendGAC(), AppDenmResultData::setFailureNotification(), and GeoNet::simpleForwardingAlgorithm().

Here is the caller graph for this function:

◆ format()

void format ( unsigned char *  msg,
unsigned long  v,
int  l 
)

format Format a number in byte array.

Parameters
msgThe byte array.
vThe number to format.
lThe intended byte number.
Warning
This function erase the previous byte array value.
Note
To put a number in msg[x], use it with &msg[x].

Definition at line 35 of file api.cpp.

Referenced by SecurityProfile_CAM::secureHeader(), and GeoNet::send().

Here is the caller graph for this function:

◆ g()

int g ( double  dist_r,
double  dist_f,
double  dist_fr,
int  angleThreshold 
)

g Compute the g function.

Parameters
dist_rDistance to the router.
dist_fDistance to the forwarder.
dist_frFSR.
angleThresholdANGLE_TH.
Returns
  • +1 for (DIST_R < DIST_F) AND (DITS_F < DIST_MAX) AND (FSR < ANGLE_TH)
  • -1 otherwise
See also
ETSI EN 302 636-4-1 v1.2.1 (2014-07)

Definition at line 272 of file api.cpp.

References itsGnDefaultMaxCommunicationRange.

Referenced by GeoNet::advancedForwarding(), constr_GenerationDeltaTime(), cpy_GenerationDeltaTime(), make_GenerationDeltaTime(), and setGenerationDeltaTime().

Here is the caller graph for this function:

◆ makeBitString()

BIT_STRING_t makeBitString ( int  nbits,
cfg_t *  cfg,
const char *  opt_name 
)

makeBitString Generate a BIT_STRING from configuration.

Parameters
nbitsNumber of bits needed.
cfgThe configuration.
opt_nameThe option name.
Returns
The generated BIT_STRING.

Definition at line 198 of file api.cpp.

References BIT_STRING_s::bits_unused, BIT_STRING_s::buf, and BIT_STRING_s::size.

Referenced by ParameterCAN::read(), ParameterApplication::read(), and ParameterConfiguration::read().

Here is the caller graph for this function:

◆ print_hexa()

void print_hexa ( const unsigned char *  msg,
int  l,
FILE *  stream = stdout 
)

print_hexa Print a byte array.

Parameters
msgThe byte array
lThe byte array length
stdoutThe output stream.

Definition at line 89 of file api.cpp.

References NEW_LINE, and OCTET.

Referenced by denTriggeringManagement::AppDENM_cancellation(), denReceptionManagement::AppDENM_negation(), denTriggeringManagement::AppDENM_trigger(), caReceptionManagement::decodeCam(), and UpperTester::readPendingDatagrams().

Here is the caller graph for this function:

◆ printBitString()

QString printBitString ( BIT_STRING_t  b)

printBitString Print a BIT_STRING into a QString.

Parameters
bThe BIT_STRING to print.
Returns
The printed BIT_STRING.

Definition at line 175 of file api.cpp.

References BIT_STRING_s::bits_unused, BIT_STRING_s::buf, and BIT_STRING_s::size.

Referenced by ParameterCAN::readDebug(), ParameterApplication::readDebug(), and ParameterConfiguration::readDebug().

Here is the caller graph for this function:

◆ split() [1/2]

unsigned long long int split ( const unsigned char *  msg,
int  begin,
int  end 
)

split Extract number from byte array.

Parameters
msgThe byte array.
beginStart bit.
endEnd bit
Returns
The extracted number
Note
The interval is [begin ; end[.

Definition at line 47 of file api.cpp.

Referenced by Facilities::getNetworkAndTransportLayerIndication().

Here is the caller graph for this function:

◆ split() [2/2]

void split ( const unsigned char *  msg,
int  begin,
int  end,
char *  out 
)

split Extract sub byte array from byte array

Parameters
msgThe byte array.
beginStart of the value.
endEnd of the value
outThe extracted byte array
Note
The interval is [begin ; end[.

Definition at line 68 of file api.cpp.

◆ validate_unsigned_int()

int validate_unsigned_int ( cfg_t *  cfg,
cfg_opt_t *  opt 
)

validate_unsigned_int Check if an option is an unsigned int

Parameters
cfgConfiguration file.
optParameter list.
Returns
0 if success, -1 otherwise.

Definition at line 186 of file api.cpp.

Referenced by ParameterUpperTester::read(), ParameterGPS::read(), ParameterCAN::read(), ParameterApplication::read(), and ParameterConfiguration::read().

Here is the caller graph for this function: