sbgEComBinaryLogShipMotion.c
Go to the documentation of this file.
2 
3 //----------------------------------------------------------------------//
4 //- Operations -//
5 //----------------------------------------------------------------------//
6 
14 {
15  //
16  // Check input arguments
17  //
18  SBG_ASSERT(pInputStream);
19  SBG_ASSERT(pOutputData);
20 
21  //
22  // Read the frame payload
23  //
24  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
25 
26  //
27  // Read the main heave period in seconds
28  //
29  pOutputData->mainHeavePeriod = sbgStreamBufferReadFloatLE(pInputStream);
30 
31  //
32  // Read the surge, sway and heave ship motion
33  //
34  pOutputData->shipMotion[0] = sbgStreamBufferReadFloatLE(pInputStream);
35  pOutputData->shipMotion[1] = sbgStreamBufferReadFloatLE(pInputStream);
36  pOutputData->shipMotion[2] = sbgStreamBufferReadFloatLE(pInputStream);
37 
38  //
39  // Read the ship accelerations
40  //
41  pOutputData->shipAccel[0] = sbgStreamBufferReadFloatLE(pInputStream);
42  pOutputData->shipAccel[1] = sbgStreamBufferReadFloatLE(pInputStream);
43  pOutputData->shipAccel[2] = sbgStreamBufferReadFloatLE(pInputStream);
44 
45  //
46  // Test if we have a additional information such as ship velocity and status (since version 1.4)
47  //
48  if (sbgStreamBufferGetSpace(pInputStream) >= 14)
49  {
50  //
51  // Read new outputs
52  //
53  pOutputData->shipVel[0] = sbgStreamBufferReadFloatLE(pInputStream);
54  pOutputData->shipVel[1] = sbgStreamBufferReadFloatLE(pInputStream);
55  pOutputData->shipVel[2] = sbgStreamBufferReadFloatLE(pInputStream);
56 
57  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
58  }
59  else
60  {
61  //
62  // Those outputs are not available in previous versions
63  //
64  pOutputData->shipVel[0] = 0.0f;
65  pOutputData->shipVel[1] = 0.0f;
66  pOutputData->shipVel[2] = 0.0f;
67 
68  pOutputData->status = 0;
69  }
70 
71  //
72  // Return if any error has occurred while parsing the frame
73  //
74  return sbgStreamBufferGetLastError(pInputStream);
75 }
76 
84 {
85  //
86  // Check input arguments
87  //
88  SBG_ASSERT(pOutputStream);
89  SBG_ASSERT(pInputData);
90 
91  //
92  // Write the frame payload
93  //
94  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
95 
96  //
97  // Write the main heave period in seconds
98  //
99  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->mainHeavePeriod);
100 
101  //
102  // Write the surge, sway and heave ship motion
103  //
104  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipMotion[0]);
105  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipMotion[1]);
106  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipMotion[2]);
107 
108  //
109  // Write the ship accelerations
110  //
111  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipAccel[0]);
112  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipAccel[1]);
113  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipAccel[2]);
114 
115  //
116  // Write additional inforamtion added in version 1.4
117  //
118  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipVel[0]);
119  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipVel[1]);
120  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->shipVel[2]);
121 
122  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
123 
124  //
125  // Return if any error has occurred while writing the frame
126  //
127  return sbgStreamBufferGetLastError(pOutputStream);
128 }
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
SBG_INLINE uint16 sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComBinaryLogParseShipMotionData(SbgStreamBuffer *pInputStream, SbgLogShipMotionData *pOutputData)
This file is used to parse received ship motion binary logs.
SBG_INLINE size_t sbgStreamBufferGetSpace(SbgStreamBuffer *pHandle)
SBG_INLINE uint32 sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16 value)
SbgErrorCode sbgEComBinaryLogWriteShipMotionData(SbgStreamBuffer *pOutputStream, const SbgLogShipMotionData *pInputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32 value)
#define SBG_ASSERT(expression)
Definition: sbgDebug.h:52
enum _SbgErrorCode SbgErrorCode
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


sbg_driver
Author(s):
autogenerated on Sun Jan 27 2019 03:42:20