API
telem_saving.hpp
Go to the documentation of this file.
1 /** \file telem_saving.hpp
2  * \brief The MagAO-X logger telem_saving log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  * History:
8  * - 2019-05-04 created by JRM
9  */
10 #ifndef logger_types_telem_saving_hpp
11 #define logger_types_telem_saving_hpp
12 
13 #include "generated/telem_saving_generated.h"
14 #include "flatbuffer_log.hpp"
15 
16 namespace MagAOX
17 {
18 namespace logger
19 {
20 
21 
22 /// Log entry recording data saving statistics
23 /** \ingroup logger_types
24  */
26 {
27  ///The event code
28  static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_SAVING;
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 uint32_t & rawSize,
40  const uint32_t & compressedSize,
41  const float & encodeRate,
42  const float & differenceRate,
43  const float & reorderRate,
44  const float & compressRate
45  )
46  {
47  auto fp = Createtelem_saving_fb(builder, rawSize,compressedSize, encodeRate, differenceRate, reorderRate, compressRate);
48  builder.Finish(fp);
49 
50  }
51 
52  };
53 
54  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
55  flatlogs::msgLenT len ///< [in] length of msgBuffer.
56  )
57  {
58  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
59  return Verifytelem_saving_fbBuffer(verifier);
60  }
61 
62  ///Get the message formatte for human consumption.
63  static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
64  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
65  )
66  {
67  static_cast<void>(len);
68 
69  auto fbs = Gettelem_saving_fb(msgBuffer);
70 
71 
72  std::stringstream s;
73  s << "Saved " << ((float)fbs->rawSize())/1048576.0 << " MB @ " << ((float) fbs->compressedSize() )/((float) fbs->rawSize()) << "%.";
74  return s.str();
75 
76  }
77 
78 }; //telem_saving
79 
80 
81 } //namespace logger
82 } //namespace MagAOX
83 
84 #endif //logger_types_telem_saving_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_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 uint32_t &rawSize, const uint32_t &compressedSize, const float &encodeRate, const float &differenceRate, const float &reorderRate, const float &compressRate)
Construct from components.
Log entry recording data saving statistics.
static const flatlogs::eventCodeT eventCode
The event code.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static const flatlogs::logPrioT defaultLevel
The default level.
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)