Main Page
Namespaces
Namespace List
Namespace Members
All
Functions
Typedefs
Enumerations
Classes
Class List
Class Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
y
z
~
Functions
a
c
d
e
f
g
i
l
m
o
p
r
s
t
u
w
~
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
y
z
Files
File List
File Members
All
_
c
d
f
g
i
m
n
s
t
u
Functions
m
s
t
Variables
Typedefs
d
f
i
s
u
Enumerations
_
Enumerator
s
Macros
_
c
f
i
n
s
t
external
sbgECom
src
binaryLogs
sbgEComBinaryLogShipMotion.c
Go to the documentation of this file.
1
#include "
sbgEComBinaryLogShipMotion.h
"
2
3
//----------------------------------------------------------------------//
4
//- Operations -//
5
//----------------------------------------------------------------------//
6
13
SbgErrorCode
sbgEComBinaryLogParseShipMotionData
(
SbgStreamBuffer
*pInputStream,
SbgLogShipMotionData
*pOutputData)
14
{
15
assert(pInputStream);
16
assert(pOutputData);
17
18
//
19
// Read the frame payload
20
//
21
pOutputData->
timeStamp
=
sbgStreamBufferReadUint32LE
(pInputStream);
22
23
//
24
// Read the main heave period in seconds
25
//
26
pOutputData->
mainHeavePeriod
=
sbgStreamBufferReadFloatLE
(pInputStream);
27
28
//
29
// Read the surge, sway and heave ship motion
30
//
31
pOutputData->
shipMotion
[0] =
sbgStreamBufferReadFloatLE
(pInputStream);
32
pOutputData->
shipMotion
[1] =
sbgStreamBufferReadFloatLE
(pInputStream);
33
pOutputData->
shipMotion
[2] =
sbgStreamBufferReadFloatLE
(pInputStream);
34
35
//
36
// Read the ship accelerations
37
//
38
pOutputData->
shipAccel
[0] =
sbgStreamBufferReadFloatLE
(pInputStream);
39
pOutputData->
shipAccel
[1] =
sbgStreamBufferReadFloatLE
(pInputStream);
40
pOutputData->
shipAccel
[2] =
sbgStreamBufferReadFloatLE
(pInputStream);
41
42
//
43
// Test if we have a additional information such as ship velocity and status (since version 1.4)
44
//
45
if
(
sbgStreamBufferGetSpace
(pInputStream) >= 14)
46
{
47
//
48
// Read new outputs
49
//
50
pOutputData->
shipVel
[0] =
sbgStreamBufferReadFloatLE
(pInputStream);
51
pOutputData->
shipVel
[1] =
sbgStreamBufferReadFloatLE
(pInputStream);
52
pOutputData->
shipVel
[2] =
sbgStreamBufferReadFloatLE
(pInputStream);
53
54
pOutputData->
status
=
sbgStreamBufferReadUint16LE
(pInputStream);
55
}
56
else
57
{
58
//
59
// Those outputs are not available in previous versions
60
//
61
pOutputData->
shipVel
[0] = 0.0f;
62
pOutputData->
shipVel
[1] = 0.0f;
63
pOutputData->
shipVel
[2] = 0.0f;
64
65
pOutputData->
status
= 0;
66
}
67
68
//
69
// Return if any error has occurred while parsing the frame
70
//
71
return
sbgStreamBufferGetLastError
(pInputStream);
72
}
73
80
SbgErrorCode
sbgEComBinaryLogWriteShipMotionData
(
SbgStreamBuffer
*pOutputStream,
const
SbgLogShipMotionData
*pInputData)
81
{
82
assert(pOutputStream);
83
assert(pInputData);
84
85
//
86
// Write the frame payload
87
//
88
sbgStreamBufferWriteUint32LE
(pOutputStream, pInputData->
timeStamp
);
89
90
//
91
// Write the main heave period in seconds
92
//
93
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
mainHeavePeriod
);
94
95
//
96
// Write the surge, sway and heave ship motion
97
//
98
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipMotion
[0]);
99
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipMotion
[1]);
100
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipMotion
[2]);
101
102
//
103
// Write the ship accelerations
104
//
105
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipAccel
[0]);
106
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipAccel
[1]);
107
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipAccel
[2]);
108
109
//
110
// Write additional inforamtion added in version 1.4
111
//
112
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipVel
[0]);
113
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipVel
[1]);
114
sbgStreamBufferWriteFloatLE
(pOutputStream, pInputData->
shipVel
[2]);
115
116
sbgStreamBufferWriteUint16LE
(pOutputStream, pInputData->
status
);
117
118
//
119
// Return if any error has occurred while writing the frame
120
//
121
return
sbgStreamBufferGetLastError
(pOutputStream);
122
}
_SbgLogShipMotionData::shipAccel
float shipAccel[3]
Definition:
sbgEComBinaryLogShipMotion.h:54
sbgStreamBufferWriteFloatLE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
Definition:
sbgStreamBufferLE.h:1753
sbgStreamBufferGetLastError
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)
Definition:
sbgStreamBufferCommon.h:274
_SbgLogShipMotionData::timeStamp
uint32_t timeStamp
Definition:
sbgEComBinaryLogShipMotion.h:50
sbgStreamBufferReadUint16LE
SBG_INLINE uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
Definition:
sbgStreamBufferLE.h:106
_SbgLogShipMotionData::status
uint16_t status
Definition:
sbgEComBinaryLogShipMotion.h:51
sbgEComBinaryLogParseShipMotionData
SbgErrorCode sbgEComBinaryLogParseShipMotionData(SbgStreamBuffer *pInputStream, SbgLogShipMotionData *pOutputData)
Definition:
sbgEComBinaryLogShipMotion.c:13
_SbgLogShipMotionData::shipVel
float shipVel[3]
Definition:
sbgEComBinaryLogShipMotion.h:55
sbgEComBinaryLogShipMotion.h
_SbgLogShipMotionData::mainHeavePeriod
float mainHeavePeriod
Definition:
sbgEComBinaryLogShipMotion.h:52
sbgStreamBufferWriteUint16LE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
Definition:
sbgStreamBufferLE.h:1250
sbgStreamBufferGetSpace
SBG_INLINE size_t sbgStreamBufferGetSpace(SbgStreamBuffer *pHandle)
Definition:
sbgStreamBufferCommon.h:353
sbgStreamBufferReadUint32LE
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
Definition:
sbgStreamBufferLE.h:386
_SbgLogShipMotionData::shipMotion
float shipMotion[3]
Definition:
sbgEComBinaryLogShipMotion.h:53
_SbgStreamBuffer
Definition:
sbgStreamBufferCommon.h:188
_SbgLogShipMotionData
Definition:
sbgEComBinaryLogShipMotion.h:48
SbgErrorCode
enum _SbgErrorCode SbgErrorCode
Header file that defines all error codes for SBG Systems libraries.
sbgEComBinaryLogWriteShipMotionData
SbgErrorCode sbgEComBinaryLogWriteShipMotionData(SbgStreamBuffer *pOutputStream, const SbgLogShipMotionData *pInputData)
Definition:
sbgEComBinaryLogShipMotion.c:80
sbgStreamBufferReadFloatLE
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
Definition:
sbgStreamBufferLE.h:1086
sbgStreamBufferWriteUint32LE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32_t value)
Definition:
sbgStreamBufferLE.h:1499
sbg_driver
Author(s): SBG Systems
autogenerated on Fri Oct 11 2024 02:13:40