API
 
Loading...
Searching...
No Matches
telem_loopgain.hpp
Go to the documentation of this file.
1/** \file telem_loopgain.hpp
2 * \brief The MagAO-X logger telem_loopgain log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 * History:
8 * - 2022-11-28 created by JRM
9 */
10#ifndef logger_types_telem_loopgain_hpp
11#define logger_types_telem_loopgain_hpp
12
14#include "flatbuffer_log.hpp"
15
16namespace MagAOX
17{
18namespace logger
19{
20
21/// Log entry recording the build-time git state.
22/** \ingroup logger_types
23 */
25{
26 /// The event code
28
29 /// The default level
31
32 static timespec lastRecord; ///< The time of the last time this log was recorded. Used by the telemetry system.
33
34 /// The type of the input message
35 struct messageT : public fbMessage
36 {
37 /// Construct from components
38 messageT( const uint8_t &state, ///< [in]
39 const float &gain, ///< [in]
40 const float &multcoef, ///< [in]
41 const float &limit ///< [in]
42 )
43 {
45 builder.Finish( fp );
46 }
47 };
48
49 static bool verify( flatlogs::bufferPtrT &logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
50 flatlogs::msgLenT len ///< [in] length of msgBuffer.
51 )
52 {
53 auto verifier = flatbuffers::Verifier( static_cast<uint8_t *>( flatlogs::logHeader::messageBuffer( logBuff ) ),
54 static_cast<size_t>( len ) );
55 return VerifyTelem_loopgain_fbBuffer( verifier );
56 }
57
58 /// Get the message formatte for human consumption.
59 static std::string msgString( void *msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
60 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
61 )
62 {
63 static_cast<void>( len );
64
65 auto fbs = GetTelem_loopgain_fb( msgBuffer );
66
67 std::string msg = "[loopgain] ";
68
69 msg += "state: ";
70 msg += std::to_string( fbs->state() ) + " ";
71
72 msg += "gain: ";
73 msg += std::to_string( fbs->gain() ) + " ";
74
75 msg += "multcoef: ";
76 msg += std::to_string( fbs->multcoef() ) + " ";
77
78 msg += "limit: ";
79 msg += std::to_string( fbs->limit() );
80
81 return msg;
82 }
83
84 static uint8_t state( void *msgBuffer )
85 {
86 auto fbs = GetTelem_loopgain_fb( msgBuffer );
87 return fbs->state();
88 }
89
90 static float gain( void *msgBuffer )
91 {
92 auto fbs = GetTelem_loopgain_fb( msgBuffer );
93 return fbs->gain();
94 }
95
96 static float multcoef( void *msgBuffer )
97 {
98 auto fbs = GetTelem_loopgain_fb( msgBuffer );
99 return fbs->multcoef();
100 }
101
102 static float limit( void *msgBuffer )
103 {
104 auto fbs = GetTelem_loopgain_fb( msgBuffer );
105 return fbs->limit();
106 }
107
108 /// Get the logMetaDetail for a member by name
109 /**
110 * \returns the a logMetaDetail filled in with the appropriate details
111 * \returns an empty logMetaDetail if member not recognized
112 */
113 static logMetaDetail getAccessor( const std::string &member /**< [in] the name of the member */ )
114 {
115 if( member == "state" )
116 return logMetaDetail( { "LOOP STATE",
119 reinterpret_cast<void *>( &state ) } );
120 else if( member == "gain" )
121 return logMetaDetail( { "LOOP GAIN",
124 reinterpret_cast<void *>( &gain ) } );
125 else if( member == "multcoef" )
126 return logMetaDetail( { "LOOP MULTCOEF",
129 reinterpret_cast<void *>( &multcoef ) } );
130 else if( member == "limit" )
131 return logMetaDetail( { "LOOP LIMIT",
134 reinterpret_cast<void *>( &limit ) } );
135 else
136 {
137 std::cerr << "No member " << member << " in telem_loopgain\n";
138 return logMetaDetail();
139 }
140 }
141
142}; // telem_loopgain
143
144} // namespace logger
145} // namespace MagAOX
146
147#endif // logger_types_telem_loopgain_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_LOOPGAIN
Definition logCodes.hpp:59
const MagAOX::logger::Telem_loopgain_fb * GetTelem_loopgain_fb(const void *buf)
bool VerifyTelem_loopgain_fbBuffer(::flatbuffers::Verifier &verifier)
inline ::flatbuffers::Offset< Telem_loopgain_fb > CreateTelem_loopgain_fb(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t state=0, float gain=0.0f, float multcoef=0.0f, float limit=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.
The type of the input message.
messageT(const uint8_t &state, const float &gain, const float &multcoef, const float &limit)
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 float multcoef(void *msgBuffer)
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static const flatlogs::eventCodeT eventCode
The event code.
static float limit(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static const flatlogs::logPrioT defaultLevel
The default level.
static uint8_t state(void *msgBuffer)
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static float gain(void *msgBuffer)