sbgEComBinaryLogShipMotion.c
Go to the documentation of this file.
2 
3 //----------------------------------------------------------------------//
4 //- Operations -//
5 //----------------------------------------------------------------------//
6 
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 
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 }
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
SBG_INLINE uint16_t 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)
SbgErrorCode sbgEComBinaryLogWriteShipMotionData(SbgStreamBuffer *pOutputStream, const SbgLogShipMotionData *pInputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32_t value)
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
enum _SbgErrorCode SbgErrorCode
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


sbg_driver
Author(s): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:35