ITS
ShortPositionVector.cpp
Go to the documentation of this file.
1 #include "ShortPositionVector.h"
2 
4 {
5  m_gnAddr = GnAddr();
6  m_timestamp = 0;
7  m_latitude = 0;
8  m_longitude = 0;
9 }
10 
11 ShortPositionVector::ShortPositionVector(GnAddr gnA, quint32 tmstmp, qint32 lat, qint32 lon)
12 {
13  m_gnAddr = gnA;
14  m_timestamp = tmstmp;
15  m_latitude = lat;
16  m_longitude = lon;
17 }
18 
19 
21 {
22  this->m_gnAddr = other.gnAddr();
23  this->m_timestamp = other.timestamp();
24  this->m_latitude = other.latitude();
25  this->m_longitude = other.longitude();
26 }
27 
28 quint64 ShortPositionVector::extract(uchar* packet)
29 {
30  quint64 offset = 0;
31 
32  offset += m_gnAddr.extract(packet);
33  offset += get_UINT32(packet + offset, &m_timestamp);
34  offset += get_INT32(packet + offset, &m_latitude);
35  offset += get_INT32(packet + offset, &m_longitude);
36 
37  return offset;
38 }
39 
41 {
42  QByteArray hex;
43  QDataStream ds(&hex, QIODevice::WriteOnly);
44 
45  ds.writeRawData(m_gnAddr.toHex().data(), GnAddr::helper_size);
46  ds << m_timestamp;
47  ds << m_latitude;
48  ds << m_longitude;
49 
50  return hex;
51 }
quint64 get_UINT32(u_char *field, quint32 *uint32)
get_UINT32 Extract an unsigned integer encoded in 32 bits from a byte array.
Definition: apiNetwork.cpp:43
SPV definition.
quint64 extract(uchar *packet)
extract Fill the ShortPositionVector with values contained in the packet
quint64 get_INT32(u_char *field, qint32 *int32)
get_INT32 Extract an integer encoded in 32 bits from a byte array.
Definition: apiNetwork.cpp:29
ShortPositionVector()
ShortPositionVector Default constructor.
QByteArray toHex()
toHex Create a QByteArray containing the hexadecimal format of the ShortPositionVector.
quint64 extract(uchar *packet)
extract Fill the GnAddr with values contained in the packet.
Definition: GnAddr.cpp:55
qint32 latitude() const
latitude Latitude field getter
quint32 timestamp() const
timestamp Timestamp field getter
QByteArray toHex()
toHex Create a QByteArray containing the hexadecimal format of the GnAddr.
Definition: GnAddr.cpp:69
Definition: GnAddr.h:28
qint32 longitude() const
longitude Longitude field getter
GnAddr gnAddr() const
gnAddr GnAddr field getter