API
ttmmod_params.hpp
Go to the documentation of this file.
1 /** \file ttmmod_params.hpp
2  * \brief The MagAO-X logger ttmmod_params log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  * History:
8  * - 2018-09-06 created by JRM
9  */
10 #ifndef logger_types_ttmmod_params_hpp
11 #define logger_types_ttmmod_params_hpp
12 
13 #include "generated/ttmmod_params_generated.h"
14 #include "flatbuffer_log.hpp"
15 
16 namespace MagAOX
17 {
18 namespace logger
19 {
20 
21 
22 /// Log entry recording the build-time git state.
23 /** \ingroup logger_types
24  */
26 {
27  ///The event code
28  static const flatlogs::eventCodeT eventCode = eventCodes::TTMMOD_PARAMS;
29 
30  ///The default level
32 
33 
34  ///The type of the input message
35  struct messageT : public fbMessage
36  {
37  ///Construct from components
38  messageT( const uint8_t & modState,
39  const double & modFreq,
40  const double & modRad,
41  const double & offset1,
42  const double & offset2
43  )
44  {
45  auto fp = CreateTtmmod_params_fb(builder, modState, modFreq, modRad, offset1, offset2);
46  builder.Finish(fp);
47 
48  }
49 
50  };
51 
52  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
53  flatlogs::msgLenT len ///< [in] length of msgBuffer.
54  )
55  {
56  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
57  return VerifyTtmmod_params_fbBuffer(verifier);
58  }
59 
60  ///Get the message formatte for human consumption.
61  static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
62  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
63  )
64  {
65  static_cast<void>(len);
66 
67  auto fbs = GetTtmmod_params_fb(msgBuffer);
68 
69 
70  std::string msg = "UNK";
71 
72  if(fbs->modState() == 0) msg = "OFF";
73  if(fbs->modState() == 1) msg = "REST";
74  if(fbs->modState() == 2) msg = "INT";
75  if(fbs->modState() == 3) msg = "SET";
76  if(fbs->modState() == 4)
77  {
78  msg = "MOD";
79 
80  msg += " Freq: ";
81  msg += std::to_string(fbs->modFreq()) + " Hz";
82 
83  msg += " Rad: ";
84  msg += std::to_string(fbs->modRad()) + " lam/D";
85  }
86 
87  return msg;
88 
89  }
90 
91 }; //ttmmod_params
92 
93 
94 } //namespace logger
95 } //namespace MagAOX
96 
97 #endif //logger_types_ttmmod_params_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_INFO
Informational. The info log level is the lowest level recorded during normal operations.
Definition: logPriority.hpp:49
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 &modState, const double &modFreq, const double &modRad, const double &offset1, const double &offset2)
Construct from components.
Log entry recording the build-time git state.
static const flatlogs::eventCodeT eventCode
The event code.
static const flatlogs::logPrioT defaultLevel
The default level.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.