API
 
Loading...
Searching...
No Matches
telem_offloading.hpp
Go to the documentation of this file.
1/** \file telem_offloading.hpp
2 * \brief The MagAO-X logger telem_offloading log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 */
8#ifndef logger_types_telem_offloading_hpp
9#define logger_types_telem_offloading_hpp
10
12#include "flatbuffer_log.hpp"
13
14namespace MagAOX
15{
16namespace logger
17{
18
19/// Log entry recording the build-time git state.
20/** \ingroup logger_types
21 */
23{
24 /// The event code
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 uint32_t &num_modes, ///< [in] the number of modes being offloaded
37 const uint32_t &num_average, ///< [in] the number of frames being averaged
38 const float &fps ///< [in] the rate of offloading, in frames per second
39 )
40 {
42 builder.Finish( fp );
43 }
44 };
45
46 static bool verify( flatlogs::bufferPtrT &logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
47 flatlogs::msgLenT len ///< [in] length of msgBuffer.
48 )
49 {
50 auto verifier = flatbuffers::Verifier( static_cast<uint8_t *>( flatlogs::logHeader::messageBuffer( logBuff ) ),
51 static_cast<size_t>( len ) );
52 return VerifyTelem_offloading_fbBuffer( verifier );
53 }
54
55 /// Get the message formatte for human consumption.
56 static std::string msgString( void *msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
57 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
58 )
59 {
60 static_cast<void>( len );
61
62 auto fbs = GetTelem_offloading_fb( msgBuffer );
63
64 std::string msg = "[offloading] ";
65
66 msg += "modes: ";
67 msg += std::to_string( fbs->num_modes() ) + " ";
68
69 msg += "n-avg: ";
70 msg += std::to_string( fbs->num_average() ) + " ";
71
72 msg += "fps: ";
73 msg += std::to_string( fbs->fps() ) + " ";
74
75 return msg;
76 }
77
78 static uint32_t num_modes( void *msgBuffer )
79 {
80 auto fbs = GetTelem_offloading_fb( msgBuffer );
81 return fbs->num_modes();
82 }
83
84 static uint32_t num_average( void *msgBuffer )
85 {
86 auto fbs = GetTelem_offloading_fb( msgBuffer );
87 return fbs->num_average();
88 }
89
90 static float fps( void *msgBuffer )
91 {
92 auto fbs = GetTelem_offloading_fb( msgBuffer );
93 return fbs->fps();
94 }
95
96 /// Get the logMetaDetail for a member by name
97 /**
98 * \returns the a logMetaDetail filled in with the appropriate details
99 * \returns an empty logMetaDetail if member not recognized
100 */
101 static logMetaDetail getAccessor( const std::string &member /**< [in] the name of the member */ )
102 {
103 if( member == "num_modes" )
104 return logMetaDetail( { "NUMBER OF MODES",
107 reinterpret_cast<void *>( &num_modes ) } );
108 else if( member == "num_average" )
109 return logMetaDetail( { "FRAMES AVERAGED",
112 reinterpret_cast<void *>( &num_average ) } );
113 else if( member == "fps" )
114 return logMetaDetail(
115 { "FPS", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void *>( &fps ) } );
116 else
117 {
118 std::cerr << "No member " << member << " in telem_offloading\n";
119 return logMetaDetail();
120 }
121 }
122
123}; // telem_offloading
124
125} // namespace logger
126} // namespace MagAOX
127
128#endif // logger_types_telem_offloading_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.
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition logHeader.hpp:58
static constexpr flatlogs::eventCodeT TELEM_OFFLOADING
Definition logCodes.hpp:61
const MagAOX::logger::Telem_offloading_fb * GetTelem_offloading_fb(const void *buf)
bool VerifyTelem_offloading_fbBuffer(::flatbuffers::Verifier &verifier)
inline ::flatbuffers::Offset< Telem_offloading_fb > CreateTelem_offloading_fb(::flatbuffers::FlatBufferBuilder &_fbb, uint32_t num_modes=0, uint32_t num_average=0, float fps=0.0f)
Definition dm.hpp:19
static constexpr logPrioT LOG_TELEM
A telemetry recording.
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
messageT(const uint32_t &num_modes, const uint32_t &num_average, const float &fps)
Construct from components.
Log entry recording the build-time git state.
static const flatlogs::eventCodeT eventCode
The event code.
static float fps(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static uint32_t num_modes(void *msgBuffer)
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 uint32_t num_average(void *msgBuffer)
static const flatlogs::logPrioT defaultLevel
The default level.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.