API
telem_telcat.hpp
Go to the documentation of this file.
1 /** \file telem_telcat.hpp
2  * \brief The MagAO-X logger telem_telcat 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_telem_telcat_hpp
11 #define logger_types_telem_telcat_hpp
12 
13 #include "generated/telem_telcat_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::TELEM_TELCAT;
29 
30  ///The default level
32 
33  static timespec lastRecord; ///< The time of the last time this log was recorded. Used by the telemetry system.
34 
35  ///The type of the input message
36  struct messageT : public fbMessage
37  {
38  ///Construct from components
39  messageT( const std::string & catObj, ///< [in] Catalog object name
40  const std::string & catRm, ///< [in] Catalog rotator mode
41  const double & catRa, ///< [in] Catalog right ascension [degrees]
42  const double & catDec, ///< [in] Catalog declination [degrees]
43  const double & catEp, ///< [in] Catalog epoch
44  const double & catRo ///< [in] Catalog rotator offset
45  )
46  {
47  auto _catObj = builder.CreateString(catObj);
48  auto _catRm = builder.CreateString(catRm);
49  auto fp = CreateTelem_telcat_fb(builder, _catObj, _catRm, catRa, catDec, catEp, catRo);
50  builder.Finish(fp);
51  }
52 
53  };
54 
55  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
56  flatlogs::msgLenT len ///< [in] length of msgBuffer.
57  )
58  {
59  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
60  return VerifyTelem_telcat_fbBuffer(verifier);
61  }
62 
63  ///Get the message formatte for human consumption.
64  static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
65  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
66  )
67  {
68  static_cast<void>(len);
69 
70  auto fbs = GetTelem_telcat_fb(msgBuffer);
71 
72  std::string msg = "[telcat] ";
73 
74  if(fbs->catObj() != nullptr)
75  {
76  msg += "obj: ";
77  msg += fbs->catObj()->c_str() ;
78  msg += " ";
79  }
80 
81  msg += "ra: ";
82  msg += std::to_string(fbs->catRa()) + " ";
83 
84  msg += "dec: ";
85  msg += std::to_string(fbs->catDec()) + " ";
86 
87  msg += "ep: ";
88  msg += std::to_string(fbs->catEp()) + " ";
89 
90  if(fbs->catRm() != nullptr)
91  {
92  msg += "rm: ";
93  msg += fbs->catRm()->c_str() ;
94  msg += " ";
95  }
96 
97  msg += "ro: ";
98  msg += std::to_string(fbs->catRo()) + " ";
99 
100 
101 
102  return msg;
103 
104  }
105 
106  static std::string catObj(void * msgBuffer)
107  {
108  auto fbs = GetTelem_telcat_fb(msgBuffer);
109  if(fbs->catObj() != nullptr)
110  {
111  return std::string(fbs->catObj()->c_str());
112  }
113  else
114  {
115  return std::string("");
116  }
117  }
118 
119  static std::string catRm(void * msgBuffer)
120  {
121  auto fbs = GetTelem_telcat_fb(msgBuffer);
122  if(fbs->catRm() != nullptr)
123  {
124  return std::string(fbs->catRm()->c_str());
125  }
126  else
127  {
128  return std::string("");
129  }
130  }
131 
132  static double catRA(void * msgBuffer)
133  {
134  auto fbs = GetTelem_telcat_fb(msgBuffer);
135  return fbs->catRa();
136  }
137 
138  static double catDec(void * msgBuffer)
139  {
140  auto fbs = GetTelem_telcat_fb(msgBuffer);
141  return fbs->catDec();
142  }
143 
144  static double catEp(void * msgBuffer)
145  {
146  auto fbs = GetTelem_telcat_fb(msgBuffer);
147  return fbs->catEp();
148  }
149 
150  static double catRo(void * msgBuffer)
151  {
152  auto fbs = GetTelem_telcat_fb(msgBuffer);
153  return fbs->catRo();
154  }
155 
156  /// Get the logMetaDetail for a member by name
157  /**
158  * \returns the function pointer cast to void*
159  * \returns -1 for an unknown member
160  */
161  static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
162  {
163  if( member == "catObj") return logMetaDetail({"OBJECT", logMeta::valTypes::String, logMeta::metaTypes::State, reinterpret_cast<void*>(&catObj), false});
164  else if(member == "catRm") return logMetaDetail({"CATRM", logMeta::valTypes::String, logMeta::metaTypes::State, reinterpret_cast<void*>(&catRm), false});
165  else if(member == "catRA") return logMetaDetail({"CATRA", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&catRA), false});
166  else if(member == "catDec") return logMetaDetail({"CATDEC", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&catDec), false});
167  else if(member == "catEp") return logMetaDetail({"CATEP", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&catEp), false});
168  else if(member == "catRo") return logMetaDetail({"CATRO", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&catRo), false});
169  else
170  {
171  std::cerr << "No string member " << member << " in telem_telcat\n";
172  return logMetaDetail();
173  }
174  }
175 
176 }; //telem_telcat
177 
178 
179 
180 } //namespace logger
181 } //namespace MagAOX
182 
183 #endif //logger_types_telem_telcat_hpp
184 
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.
messageT(const std::string &catObj, const std::string &catRm, const double &catRa, const double &catDec, const double &catEp, const double &catRo)
Construct from components.
Log entry recording the build-time git state.
static const flatlogs::logPrioT defaultLevel
The default level.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static std::string catObj(void *msgBuffer)
static double catRo(void *msgBuffer)
static std::string catRm(void *msgBuffer)
static double catRA(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
The event code.
static double catEp(void *msgBuffer)
static double catDec(void *msgBuffer)