API
pico_channel.hpp
Go to the documentation of this file.
1 /** \file pico_channel.hpp
2  * \brief The MagAO-X logger pico_channel log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  * History:
8  * - 2018-08-18 created by JRM
9  */
10 #ifndef logger_types_pico_channel_hpp
11 #define logger_types_pico_channel_hpp
12 
13 #include "generated/pico_channel_generated.h"
14 #include "flatbuffer_log.hpp"
15 
16 namespace MagAOX
17 {
18 namespace logger
19 {
20 
21 
22 ///Application State Change
23 /** \ingroup logger_types
24  */
26 {
27  //The event code
28  static const flatlogs::eventCodeT eventCode = eventCodes::PICO_CHANNEL;
29 
30  //The default level
32 
33  ///The type of the message
34  struct messageT : public fbMessage
35  {
36  messageT( const std::string & name,
37  uint8_t channel
38  )
39  {
40  auto _name = builder.CreateString(name);
41 
42  auto gs = CreatePico_channel_fb(builder, _name, channel);
43  builder.Finish(gs);
44 
45  }
46  };
47 
48  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
49  flatlogs::msgLenT len ///< [in] length of msgBuffer.
50  )
51  {
52  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
53  return VerifyPico_channel_fbBuffer(verifier);
54  }
55 
56  /// Format the message for text output, including translation of state codes to text form.
57  /**
58  * \returns the message formatted as "State changed from UNINITIALIZED to INITIALIZED"
59  */
60  static std::string msgString(void * msgBuffer, flatlogs::msgLenT len)
61  {
62  static_cast<void>(len);
63 
64  auto rgs = GetPico_channel_fb(msgBuffer);
65 
66 
67  std::string s = "Pico Motor: ";
68 
69  if(rgs->name())
70  {
71  s += rgs->name()->c_str();
72  }
73 
74  s += " ch: ";
75  s += std::to_string(rgs->channel());
76 
77  return s;
78  }
79 };
80 
81 } //namespace logger
82 } //namespace MagAOX
83 
84 #endif //logger_types_pico_channel_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
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.
messageT(const std::string &name, uint8_t channel)
Application State Change.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Format the message for text output, including translation of state codes to text form.
static const flatlogs::logPrioT defaultLevel
static const flatlogs::eventCodeT eventCode
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)