API
telem_fgtimings.hpp
Go to the documentation of this file.
1 /** \file telem_fgtimings.hpp
2  * \brief The MagAO-X logger telem_fgtimings log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  * History:
8  * - 2022-10-03 created by JRM
9  */
10 #ifndef logger_types_telem_fgtimings_hpp
11 #define logger_types_telem_fgtimings_hpp
12 
13 #include "generated/telem_fgtimings_generated.h"
14 #include "flatbuffer_log.hpp"
15 
16 namespace MagAOX
17 {
18 namespace logger
19 {
20 
21 
22 /// Log entry recording framegrabber timings.
23 /** \ingroup logger_types
24  */
26 {
27  ///The event code
28  static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_FGTIMINGS;
29 
30  ///The default level
32 
33  static timespec lastRecord; ///< The timestamp 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 double & atime, ///< [in] acquisition time deltas
40  const double & atime_jitter, ///< [in] jitter in acquisition time deltas
41  const double & wtime, ///< [in] acquisition time deltas
42  const double & wtime_jitter, ///< [in] jitter in acquisition time deltas
43  const double & mawtime, ///< [in] acquisition time deltas
44  const double & mawtime_jitter ///< [in] jitter in acquisition time deltas
45  )
46  {
47  auto fp = CreateTelem_fgtimings_fb(builder, atime, atime_jitter, wtime, wtime_jitter, mawtime, mawtime_jitter);
48  builder.Finish(fp);
49  }
50 
51  };
52 
53  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
54  flatlogs::msgLenT len ///< [in] length of msgBuffer.
55  )
56  {
57  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
58  return VerifyTelem_fgtimings_fbBuffer(verifier);
59  }
60 
61  ///Get the message formatte for human consumption.
62  static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
63  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
64  )
65  {
66  static_cast<void>(len);
67 
68  char buf[64];
69 
70  auto fbs = GetTelem_fgtimings_fb(msgBuffer);
71 
72  std::string msg = "[fgtimes]";
73 
74  msg += " acq: ";
75 
76  snprintf(buf, sizeof(buf), "%0.10e", fbs->atime());
77  msg += buf;
78  msg += " +/- ";
79  snprintf(buf, sizeof(buf), "%0.5e", fbs->atime_jitter());
80  msg += buf;
81 
82  msg += " wrt: ";
83 
84  snprintf(buf, sizeof(buf), "%0.10e", fbs->wtime());
85  msg += buf;
86  msg += " +/- ";
87  snprintf(buf, sizeof(buf), "%0.5e", fbs->wtime_jitter());
88  msg += buf;
89 
90  msg += " wma: ";
91 
92  snprintf(buf, sizeof(buf), "%0.10e", fbs->wmatime());
93  msg += buf;
94  msg += " +/- ";
95  snprintf(buf, sizeof(buf), "%0.5e", fbs->wmatime_jitter());
96  msg += buf;
97 
98  return msg;
99 
100  }
101 
102  static double atime( void * msgBuffer )
103  {
104  auto fbs = GetTelem_fgtimings_fb(msgBuffer);
105  return fbs->atime();
106  }
107 
108  static double atime_jitter( void * msgBuffer )
109  {
110  auto fbs = GetTelem_fgtimings_fb(msgBuffer);
111  return fbs->atime_jitter();
112  }
113 
114  static double wtime( void * msgBuffer )
115  {
116  auto fbs = GetTelem_fgtimings_fb(msgBuffer);
117  return fbs->wtime();
118  }
119 
120  static double wtime_jitter( void * msgBuffer )
121  {
122  auto fbs = GetTelem_fgtimings_fb(msgBuffer);
123  return fbs->wtime_jitter();
124  }
125 
126  static double wmatime( void * msgBuffer )
127  {
128  auto fbs = GetTelem_fgtimings_fb(msgBuffer);
129  return fbs->wmatime();
130  }
131 
132  static double wmatime_jitter( void * msgBuffer )
133  {
134  auto fbs = GetTelem_fgtimings_fb(msgBuffer);
135  return fbs->wmatime_jitter();
136  }
137 
138  /// Get pointer to the accessor for a member by name
139  /**
140  * \returns the function pointer cast to void*
141  * \returns -1 for an unknown member
142  */
143  static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
144  {
145  if(member == "atime") return logMetaDetail({"ACQ TIME", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&atime)});
146  else if(member == "atime_jitter") return logMetaDetail({"ACQ JITTER", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&atime_jitter)});
147  else if(member == "wtime") return logMetaDetail({"WRT TIME", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&wtime)});
148  else if(member == "wtime_jitter") return logMetaDetail({"WRT JITTER", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&wtime_jitter)});
149  else if(member == "wmatime") return logMetaDetail({"WRT-ACQ TIME", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&wmatime)});
150  else if(member == "wmatime_jitter") return logMetaDetail({"WRT-ACQ JITTER", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&wmatime_jitter)});
151 
152  else
153  {
154  std::cerr << "No string member " << member << " in telem_fgtimings\n";
155  return logMetaDetail();
156  }
157  }
158 
159 }; //telem_fgtimings
160 
161 
162 
163 } //namespace logger
164 } //namespace MagAOX
165 
166 #endif //logger_types_telem_fgtimings_hpp
167 
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 double &atime, const double &atime_jitter, const double &wtime, const double &wtime_jitter, const double &mawtime, const double &mawtime_jitter)
Construct from components.
Log entry recording framegrabber timings.
static double wtime(void *msgBuffer)
static timespec lastRecord
The timestamp of the last time this log was recorded. Used by the telemetry system.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static double wtime_jitter(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
The event code.
static const flatlogs::logPrioT defaultLevel
The default level.
static double wmatime_jitter(void *msgBuffer)
static double atime_jitter(void *msgBuffer)
static double atime(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get pointer to the accessor for a member by name.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static double wmatime(void *msgBuffer)