28 using namespace SGCTP;
47 uint16_t __ui16tData =
48 ( _ui8tBits &
BITMASK[_ui8tBitsCount] )
50 *(
unsigned char*)(
pucBufferPut+__ui32tBufferByteOffset) |=
51 (
unsigned char)( __ui16tData >> 8 );
52 *(
unsigned char*)(
pucBufferPut+__ui32tBufferByteOffset+1) |=
53 (
unsigned char)( __ui16tData & 0xFF );
58 const unsigned char *_pucBytes )
61 putBits( 8 - __ui8tBufferBitAlign, 0 );
62 if( _ui16tBytesCount == 0 )
65 memcpy(
pucBufferPut+__ui32tBufferByteOffset, _pucBytes, _ui16tBytesCount );
73 uint16_t __ui16tBits =
74 (uint16_t)( *(
unsigned char*)(
pucBufferGet+__ui32tBufferByteOffset) ) << 8
75 | *(
unsigned char*)(
pucBufferGet+__ui32tBufferByteOffset+1);
78 return __ui16tBits &
BITMASK[_ui8tBitsCount];
82 unsigned char *_pucBytes )
85 getBits( 8 - __ui8tBufferBitAlign );
86 if( _ui16tBytesCount == 0 )
89 memcpy( _pucBytes,
pucBufferGet+__ui32tBufferByteOffset, _ui16tBytesCount );
94 const CData &_roData )
106 uint8_t __ui8tIDLength = strlen( _roData.
pcID );
115 bool __b2DGndCourse =
118 bool __b3DGndCourse =
121 bool __b2DGndCourseDt =
124 bool __b3DGndCourseDt =
127 bool __b2DAppCourse =
131 bool __bExtendedContent =
false;
132 bool __b2SourceType =
134 __bExtendedContent |= __b2SourceType;
135 bool __b2DPositionError =
138 __bExtendedContent |= __b2DPositionError;
139 bool __b3DPositionError =
142 __bExtendedContent |= __b3DPositionError;
143 bool __b2DGndCourseError =
146 __bExtendedContent |= __b2DGndCourseError;
147 bool __b3DGndCourseError =
150 __bExtendedContent |= __b3DGndCourseError;
151 bool __b2DGndCourseDtError =
154 __bExtendedContent |= __b2DGndCourseDtError;
155 bool __b3DGndCourseDtError =
156 __b2DGndCourseDtError
158 __bExtendedContent |= __b3DGndCourseDtError;
159 bool __b2DAppCourseError =
162 __bExtendedContent |= __b2DAppCourseError;
169 putBits( 1, __b2DGndCourseDt );
170 putBits( 1, __b3DGndCourseDt );
172 putBits( 1, __bExtendedContent );
177 if( __ui8tIDLength > 0 )
178 putBytes( __ui8tIDLength, (
unsigned char*)_roData.
pcID );
254 if( __b2DGndCourseDt )
263 if( __b3DGndCourseDt )
282 if( __bExtendedContent )
285 putBits( 1, __b2DPositionError );
286 putBits( 1, __b3DPositionError );
287 putBits( 1, __b2DGndCourseError );
288 putBits( 1, __b3DGndCourseError );
289 putBits( 1, __b2DGndCourseDtError );
290 putBits( 1, __b3DGndCourseDtError );
291 putBits( 1, __b2DAppCourseError );
298 if( __b2DPositionError )
307 if( __b3DPositionError )
315 if( __b2DGndCourseError )
322 if( __b3DGndCourseError )
329 if( __b2DGndCourseDtError )
336 if( __b3DGndCourseDtError )
343 if( __b2DAppCourseError )
356 const unsigned char *_pucBuffer,
357 uint16_t _ui16tPayloadSize )
368 _poData->
reset(
false );
372 bool __b2DPosition = (bool)
getBits( 1 );
373 bool __b3DPosition = (bool)
getBits( 1 );
374 bool __b2DGndCourse = (bool)
getBits( 1 );
375 bool __b3DGndCourse = (bool)
getBits( 1 );
376 bool __b2DGndCourseDt = (bool)
getBits( 1 );
377 bool __b3DGndCourseDt = (bool)
getBits( 1 );
378 bool __b2DAppCourse = (bool)
getBits( 1 );
379 bool __bExtendedContent = (bool)
getBits( 1 );
382 uint8_t __ui8tIDLength =
getBits( 7 );
383 bool __bData = (bool)
getBits( 1 );
384 if( __ui8tIDLength > 0 )
385 getBytes( __ui8tIDLength, (
unsigned char*)_poData->
pcID );
386 _poData->
pcID[__ui8tIDLength] =
'\0';
391 uint16_t __ui16tDataSize =
getBits( 7 );
393 __ui16tDataSize |=
getBits( 8 ) << 7;
402 uint32_t __ui32tData;
406 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
407 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
409 ( __ui32tData == ( 0xFFFFFFFF >> 9 ) )
418 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
419 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
420 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
422 ( __ui32tData == ( 0xFFFFFFFF >> 2 ) )
427 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
428 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
429 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
431 ( __ui32tData == ( 0xFFFFFFFF >> 1 ) )
439 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
440 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
442 ( __ui32tData == ( 0xFFFFFFFF >> 13 ) )
452 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
454 ( __ui32tData == ( 0xFFFFFFFF >> 20 ) )
459 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
461 ( __ui32tData == ( 0xFFFFFFFF >> 16 ) )
469 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
471 ( __ui32tData == ( 0xFFFFFFFF >> 19 ) )
477 if( __b2DGndCourseDt )
481 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
483 ( __ui32tData == ( 0xFFFFFFFF >> 22 ) )
488 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
490 ( __ui32tData == ( 0xFFFFFFFF >> 20 ) )
494 if( __b3DGndCourseDt )
498 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
500 ( __ui32tData == ( 0xFFFFFFFF >> 20 ) )
510 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
512 ( __ui32tData == ( 0xFFFFFFFF >> 20 ) )
517 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
519 ( __ui32tData == ( 0xFFFFFFFF >> 16 ) )
526 bool __b2DPositionError =
false;
527 bool __b3DPositionError =
false;
528 bool __b2DGndCourseError =
false;
529 bool __b3DGndCourseError =
false;
530 bool __b2DGndCourseDtError =
false;
531 bool __b3DGndCourseDtError =
false;
532 bool __b2DAppCourseError =
false;
533 if( __bExtendedContent )
536 __b2DPositionError = (bool)
getBits( 1 );
537 __b3DPositionError = (bool)
getBits( 1 );
538 __b2DGndCourseError = (bool)
getBits( 1 );
539 __b3DGndCourseError = (bool)
getBits( 1 );
540 __b2DGndCourseDtError = (bool)
getBits( 1 );
541 __b3DGndCourseDtError = (bool)
getBits( 1 );
542 __b2DAppCourseError = (bool)
getBits( 1 );
553 if( __b2DPositionError )
557 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
559 ( __ui32tData == ( 0xFFFFFFFF >> 20 ) )
564 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
566 ( __ui32tData == ( 0xFFFFFFFF >> 20 ) )
570 if( __b3DPositionError )
574 __ui32tData <<= 8; __ui32tData |=
getBits( 8 );
576 ( __ui32tData == ( 0xFFFFFFFF >> 20 ) )
582 if( __b2DGndCourseError )
587 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
593 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
597 if( __b3DGndCourseError )
602 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
608 if( __b2DGndCourseDtError )
613 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
619 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
623 if( __b3DGndCourseDtError )
628 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
634 if( __b2DAppCourseError )
639 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
645 ( __ui32tData == ( 0xFFFFFFFF >> 24 ) )
virtual int unserialize(CData *_poData, const unsigned char *_pucBuffer, uint16_t _ui16tBufferSize)
Unserialize the SGCTP data from the given payload buffer.
uint32_t ui32tHeadingError
Heading error.
uint32_t ui32tElevationError
Elevation error.
uint32_t ui32tSourceType
Source type.
char pcID[MAX_ID_SIZE]
ID string (max. 127 characters)
uint32_t ui32tBearingError
Bearing error.
uint32_t ui32tVrtSpeed
Vertical speed.
uint32_t ui32tGndSpeed
Ground speed.
uint8_t getBits(uint8_t _ui8tBitsSize)
Retrieve the given bits from the payload.
uint16_t ui16tDataSize
Data size.
void reset(bool _bDataFree=true)
Reset (undefine) all data.
uint32_t ui32tBufferBitOffset
SGCTP payload bit position.
uint32_t ui32tElevation
Elevation.
uint32_t ui32tLatitudeError
Latitude error.
static const uint32_t OVERFLOW_UINT32
Internal (integer) positive overflow value.
virtual int serialize(unsigned char *_pucBuffer, const CData &_roData)
Serialize the given SGCTP data into the given payload buffer.
void putBytes(uint16_t _ui16tBytesSize, const unsigned char *_pucBytes)
Add the given bytes to the payload.
unsigned char * pucBufferPut
SGCTP payload export buffer pointer.
uint32_t ui32tGndSpeedError
Ground speed error.
unsigned char * pucData
Data (max. 32767 symbols)
uint32_t ui32tBearingDtError
Bearing variation over time (rate of turn) error.
uint32_t ui32tLatitude
Latitude.
uint32_t ui32tHeading
Heading.
uint32_t ui32tLongitudeError
Longitude error.
void putBits(uint8_t _ui8tBitsSize, uint8_t _ui8tBits)
Add the given bits to the payload.
uint32_t ui32tVrtSpeedDt
Vertical speed variation over time (acceleration)
static const uint32_t UNDEFINED_UINT32
Internal (integer) undefined value.
uint32_t ui32tAppSpeedError
Apparent speed error.
void freeData()
Clear (free) the data container.
static void zeroBuffer(unsigned char *_pucBuffer)
Zero-out a buffer required for payload (un-)serialization.
const unsigned char * pucBufferGet
SGCTP payload import buffer pointer.
uint16_t allocData(uint16_t _ui16tDataSize)
Allocate the memory for the data container (max. 32767 symbols)
uint32_t ui32tLongitude
Longitude.
static const uint8_t BITMASK[9]
Bit masks used to (un-)serialize data bit-per-bit.
uint32_t ui32tBearingDt
Bearing variation over time (rate of turn)
uint32_t ui32tBearing
Bearing.
uint32_t ui32tGndSpeedDt
Ground speed variation over time (acceleration)
uint32_t ui32tVrtSpeedError
Vertical speed error.
uint32_t ui32tGndSpeedDtError
Ground speed variation over time (acceleration) error.
void getBytes(uint16_t _ui16tBytesSize, unsigned char *_pucBytes)
Retrieve the given bytes from the payload.
uint32_t ui32tVrtSpeedDtError
Vertical speed variation over time (acceleration) error.
uint32_t ui32tAppSpeed
Apparent speed.