API
telem_telenv.hpp
Go to the documentation of this file.
1 /** \file telem_telenv.hpp
2  * \brief The MagAO-X logger telem_telenv 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_telenv_hpp
11 #define logger_types_telem_telenv_hpp
12 
13 #include "generated/telem_telenv_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_TELENV;
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 double & tempout, ///< [in]
40  const double & pressure, ///< [in]
41  const double & humidity, ///< [in]
42  const double & wind, ///< [in]
43  const double & winddir, ///< [in]
44  const double & temptruss, ///< [in]
45  const double & tempcell, ///< [in]
46  const double & tempseccell, ///< [in]
47  const double & tempamb, ///< [in]
48  const double & dewpoint ///< [in]
49  )
50  {
51  auto fp = CreateTelem_telenv_fb(builder, tempout, pressure, humidity, wind,winddir,temptruss,tempcell,tempseccell,tempamb, dewpoint);
52  builder.Finish(fp);
53  }
54 
55  };
56 
57  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
58  flatlogs::msgLenT len ///< [in] length of msgBuffer.
59  )
60  {
61  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
62  return VerifyTelem_telenv_fbBuffer(verifier);
63  }
64 
65  ///Get the message formatte for human consumption.
66  static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
67  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
68  )
69  {
70  static_cast<void>(len);
71 
72  auto fbs = GetTelem_telenv_fb(msgBuffer);
73 
74  std::string msg = "[telenv] ";
75 
76  msg += "tempout: ";
77  msg += std::to_string(fbs->tempout()) + " ";
78 
79  msg += "press: ";
80  msg += std::to_string(fbs->pressure()) + " ";
81 
82  msg += "humidity: ";
83  msg += std::to_string(fbs->humidity()) + " ";
84 
85  msg += "wind: ";
86  msg += std::to_string(fbs->wind()) + " ";
87 
88  msg += "winddir: ";
89  msg += std::to_string(fbs->winddir()) + " ";
90 
91  msg += "temptruss: ";
92  msg += std::to_string(fbs->temptruss()) + " ";
93 
94  msg += "tempcell: ";
95  msg += std::to_string(fbs->tempcell()) + " ";
96 
97  msg += "tempseccell: ";
98  msg += std::to_string(fbs->tempseccell()) + " ";
99 
100  msg += "tempamb: ";
101  msg += std::to_string(fbs->tempamb()) + " ";
102 
103  msg += "dewpoint: ";
104  msg += std::to_string(fbs->dewpoint()) + " ";
105 
106 
107  return msg;
108 
109  }
110 
111 }; //telem_telenv
112 
113 
114 } //namespace logger
115 } //namespace MagAOX
116 
117 #endif //logger_types_telem_telenv_hpp
118 
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_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 &tempout, const double &pressure, const double &humidity, const double &wind, const double &winddir, const double &temptruss, const double &tempcell, const double &tempseccell, const double &tempamb, const double &dewpoint)
Construct from components.
Log entry recording the build-time git state.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static const flatlogs::eventCodeT eventCode
The event code.
static const flatlogs::logPrioT defaultLevel
The default level.