API
telem_pokeloop.hpp
Go to the documentation of this file.
1 /** \file telem_pokeloop.hpp
2  * \brief The MagAO-X logger telem_pokeloop log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  */
8 #ifndef logger_types_telem_pokeloop_hpp
9 #define logger_types_telem_pokeloop_hpp
10 
11 #include "generated/telem_pokeloop_generated.h"
12 #include "flatbuffer_log.hpp"
13 
14 namespace MagAOX
15 {
16 namespace logger
17 {
18 
19 /// Log entry recording DM poke centering results
20 /** \ingroup logger_types
21  */
23 {
24  /// The event code
25  static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_POKELOOP;
26 
27  /// The default level
29 
30  static timespec lastRecord; ///< The time of the last time this log was recorded. Used by the telemetry system.
31 
32  /// The type of the input message
33  struct messageT : public fbMessage
34  {
35  /// Construct from components
36  messageT( const uint8_t & measuring, ///< [in] flag indicating if the WFS is measuring
37  const float & deltaX, ///< [in] the x delta position
38  const float & deltaY, ///< [in] the y delta position
39  const uint64_t & counter ///< [in] the loop counter
40  )
41  {
42 
43  if(measuring == 0)
44  {
45  Telem_pokecenter_fbBuilder telem_pokecenter_builder(builder);
46  telem_pokecenter_builder.add_measuring(measuring);
47  auto fb = telem_pokecenter_builder.Finish();
48  builder.Finish(fb);
49  return;
50  }
51 
52  auto fb = CreateTelem_pokeloop_fb(builder, measuring, deltaX, deltaY, counter);
53 
54  builder.Finish(fb);
55  }
56  };
57 
58  static bool verify( flatlogs::bufferPtrT &logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
59  flatlogs::msgLenT len ///< [in] length of msgBuffer.
60  )
61  {
62  auto verifier = flatbuffers::Verifier(static_cast<uint8_t *>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
63  return VerifyTelem_pokeloop_fbBuffer(verifier);
64  }
65 
66  /// Get the message formatted for human consumption.
67  static std::string msgString( void *msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
68  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
69  )
70  {
71  static_cast<void>(len);
72 
73  auto fbs = GetTelem_pokeloop_fb(msgBuffer);
74 
75  std::string msg;
76  if(fbs->measuring() == 0)
77  {
78  msg = "[pokeloop] not measuring";
79  }
80  else
81  {
82  msg = "[pokeloop] X: ";
83 
84  msg += std::to_string(fbs->deltaX());
85  msg += " Y: ";
86  msg += std::to_string(fbs->deltaY());
87 
88  msg += " ctr: ";
89  msg += std::to_string(fbs->counter());
90  }
91 
92  return msg;
93  }
94 
95 }; // telem_pokeloop
96 
97 } // namespace logger
98 } // namespace MagAOX
99 
100 #endif // logger_types_telem_pokeloop_hpp
The MagAO-X logger flatbuffer log base type.
uint16_t eventCodeT
The type of an event code (16-bit unsigned int).
Definition: logDefs.hpp:40
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
Definition: logDefs.hpp:69
int8_t logPrioT
The type of the log priority code.
Definition: logDefs.hpp:21
static void * messageBuffer(bufferPtrT &logBuffer)
Get the message buffer address.
Definition: logHeader.hpp:621
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition: logHeader.hpp:58
std::stringstream msg
Definition: dm.hpp:24
constexpr static logPrioT LOG_TELEM
A telemetry recording.
Definition: logPriority.hpp:58
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
The type of the input message.
messageT(const uint8_t &measuring, const float &deltaX, const float &deltaY, const uint64_t &counter)
Construct from components.
Log entry recording DM poke centering results.
static const flatlogs::logPrioT defaultLevel
The default level.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
static const flatlogs::eventCodeT eventCode
The event code.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.