API
telem_pi335.hpp
Go to the documentation of this file.
1 /** \file telem_pi335.hpp
2  * \brief The MagAO-X logger telem_pi335 log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  */
8 #ifndef logger_types_telem_pi335_hpp
9 #define logger_types_telem_pi335_hpp
10 
11 #include "generated/telem_pi335_generated.h"
12 #include "flatbuffer_log.hpp"
13 
14 namespace MagAOX
15 {
16 namespace logger
17 {
18 
19 /// Log entry recording the build-time git state.
20 /** \ingroup logger_types
21  */
22 struct telem_pi335 : public flatbuffer_log
23 {
24  /// The event code
25  static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_PI335;
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 float & pos1Set, ///< [in]
37  const float & pos1, ///< [in]
38  const float & sva1, ///< [in]
39  const float & pos2Set, ///< [in]
40  const float & pos2, ///< [in]
41  const float & sva2, ///< [in]
42  const float & pos3Set, ///< [in]
43  const float & pos3, ///< [in]
44  const float & sva3 ///< [in]
45  )
46  {
47  auto fp = CreateTelem_pi335_fb(builder, pos1Set, pos1, sva1, pos2Set, pos2, sva2, pos3Set, pos3, sva3);
48  builder.Finish(fp);
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 VerifyTelem_pi335_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 = GetTelem_pi335_fb(msgBuffer);
68 
69  std::string msg = "[pi335] ";
70 
71  msg += "pos1Set: ";
72  msg += std::to_string(fbs->pos1Set()) + " ";
73 
74  msg += "pos1: ";
75  msg += std::to_string(fbs->pos1()) + " ";
76 
77  msg += "sva1: ";
78  msg += std::to_string(fbs->sva1()) + " ";
79 
80  msg += "pos2Set: ";
81  msg += std::to_string(fbs->pos2Set()) + " ";
82 
83  msg += "pos2: ";
84  msg += std::to_string(fbs->pos2()) + " ";
85 
86  msg += "sva2: ";
87  msg += std::to_string(fbs->sva2()) + " ";
88 
89  msg += "pos3Set: ";
90  msg += std::to_string(fbs->pos3Set()) + " ";
91 
92  msg += "pos3: ";
93  msg += std::to_string(fbs->pos3()) + " ";
94 
95  msg += "sva3: ";
96  msg += std::to_string(fbs->sva3());
97 
98  return msg;
99  }
100 
101  static float pos1Set(void *msgBuffer)
102  {
103  auto fbs = GetTelem_pi335_fb(msgBuffer);
104  return fbs->pos1Set();
105  }
106 
107  static float pos1(void *msgBuffer)
108  {
109  auto fbs = GetTelem_pi335_fb(msgBuffer);
110  return fbs->pos1();
111  }
112 
113  static float sva1(void *msgBuffer)
114  {
115  auto fbs = GetTelem_pi335_fb(msgBuffer);
116  return fbs->sva1();
117  }
118 
119  static float pos2Set(void *msgBuffer)
120  {
121  auto fbs = GetTelem_pi335_fb(msgBuffer);
122  return fbs->pos2Set();
123  }
124 
125  static float pos2(void *msgBuffer)
126  {
127  auto fbs = GetTelem_pi335_fb(msgBuffer);
128  return fbs->pos2();
129  }
130 
131  static float sva2(void *msgBuffer)
132  {
133  auto fbs = GetTelem_pi335_fb(msgBuffer);
134  return fbs->sva2();
135  }
136 
137  static float pos3Set(void *msgBuffer)
138  {
139  auto fbs = GetTelem_pi335_fb(msgBuffer);
140  return fbs->pos3Set();
141  }
142 
143  static float pos3(void *msgBuffer)
144  {
145  auto fbs = GetTelem_pi335_fb(msgBuffer);
146  return fbs->pos3();
147  }
148 
149  static float sva3(void *msgBuffer)
150  {
151  auto fbs = GetTelem_pi335_fb(msgBuffer);
152  return fbs->sva3();
153  }
154 
155  /// Get pointer to the accessor for a member by name
156  /**
157  * \returns the function pointer cast to void*
158  * \returns -1 for an unknown member
159  */
160  static logMetaDetail getAccessor(const std::string &member /**< [in] the name of the member */)
161  {
162  if (member == "pos1Set")
163  return logMetaDetail({"POS1 SETPT", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos1Set)});
164  else if (member == "pos1")
165  return logMetaDetail({"POS1", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos1)});
166  else if (member == "sva1")
167  return logMetaDetail({"SVA1", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&sva1)});
168  else if (member == "pos2Set")
169  return logMetaDetail({"POS2 SETPT", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos2Set)});
170  else if (member == "pos2")
171  return logMetaDetail({"POS2", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos2)});
172  else if (member == "sva2")
173  return logMetaDetail({"SVA2", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&sva2)});
174  else if (member == "pos3Set")
175  return logMetaDetail({"POS3 SETPT", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos3Set)});
176  else if (member == "pos3")
177  return logMetaDetail({"POS3", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos3)});
178  else if (member == "sva3")
179  return logMetaDetail({"SVA3", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&sva3)});
180  else
181  {
182  std::cerr << "No string member " << member << " in telem_pi335\n";
183  return logMetaDetail();
184  }
185  }
186 
187 }; // telem_pi335
188 
189 } // namespace logger
190 } // namespace MagAOX
191 
192 #endif // logger_types_telem_pi335_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::ostream & cerr()
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.
Definition: telem_pi335.hpp:34
messageT(const float &pos1Set, const float &pos1, const float &sva1, const float &pos2Set, const float &pos2, const float &sva2, const float &pos3Set, const float &pos3, const float &sva3)
Construct from components.
Definition: telem_pi335.hpp:36
Log entry recording the build-time git state.
Definition: telem_pi335.hpp:23
static float pos3Set(void *msgBuffer)
static float sva3(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
The event code.
Definition: telem_pi335.hpp:25
static float pos2(void *msgBuffer)
static float pos3(void *msgBuffer)
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
Definition: telem_pi335.hpp:52
static float pos1(void *msgBuffer)
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
Definition: telem_pi335.hpp:61
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
Definition: telem_pi335.hpp:30
static float pos1Set(void *msgBuffer)
static float pos2Set(void *msgBuffer)
static const flatlogs::logPrioT defaultLevel
The default level.
Definition: telem_pi335.hpp:28
static logMetaDetail getAccessor(const std::string &member)
Get pointer to the accessor for a member by name.
static float sva1(void *msgBuffer)
static float sva2(void *msgBuffer)