API
 
Loading...
Searching...
No Matches
telem_modalgainopt.hpp
Go to the documentation of this file.
1/** \file telem_modalgainopt.hpp
2 * \brief The MagAO-X logger telem_modalgainopt log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 */
7
8#ifndef logger_types_telem_modalgainopt_hpp
9#define logger_types_telem_modalgainopt_hpp
10
12#include "flatbuffer_log.hpp"
13
14namespace MagAOX
15{
16namespace logger
17{
18
19/// Log entry recording modalGainOpt control state.
20/** \ingroup logger_types
21 */
23{
26
27 static timespec lastRecord; ///< The time of the last telemetry record.
28
29 struct messageT : public fbMessage
30 {
31 messageT( const bool updateAuto, ///< [in] whether update_auto is enabled
32 const bool opticalGainTracking, ///< [in] whether optical gain tracking is enabled
33 const float opticalGain, ///< [in] in-use optical gain
34 const float gainGain, ///< [in] SI gain integrator gain coefficient
35 const float gainLeak ///< [in] SI gain integrator leak coefficient
36 )
37 {
43 gainLeak );
44 builder.Finish( fp );
45 }
46 };
47
48 static bool verify( flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len )
49 {
50 auto verifier = flatbuffers::Verifier( static_cast<uint8_t *>( flatlogs::logHeader::messageBuffer( logBuff ) ),
51 static_cast<size_t>( len ) );
52 return VerifyTelem_modalgainopt_fbBuffer( verifier );
53 }
54
55 static std::string msgString( void *msgBuffer, flatlogs::msgLenT len )
56 {
57 static_cast<void>( len );
58
59 auto fbs = GetTelem_modalgainopt_fb( msgBuffer );
60 std::string msg = "[modalgainopt] ";
61
62 msg += "updateAuto: ";
63 msg += ( fbs->update_auto() ? "true" : "false" );
64 msg += " opticalGainTracking: ";
65 msg += ( fbs->optical_gain_tracking() ? "true" : "false" );
66 msg += " opticalGain: ";
67 msg += std::to_string( fbs->optical_gain() );
68 msg += " gainGain: ";
69 msg += std::to_string( fbs->gain_gain() );
70 msg += " gainLeak: ";
71 msg += std::to_string( fbs->gain_leak() );
72
73 return msg;
74 }
75
76 static bool updateAuto( void *msgBuffer )
77 {
78 return GetTelem_modalgainopt_fb( msgBuffer )->update_auto();
79 }
80
81 static bool opticalGainTracking( void *msgBuffer )
82 {
83 return GetTelem_modalgainopt_fb( msgBuffer )->optical_gain_tracking();
84 }
85
86 static float opticalGain( void *msgBuffer )
87 {
88 return GetTelem_modalgainopt_fb( msgBuffer )->optical_gain();
89 }
90
91 static float gainGain( void *msgBuffer )
92 {
93 return GetTelem_modalgainopt_fb( msgBuffer )->gain_gain();
94 }
95
96 static float gainLeak( void *msgBuffer )
97 {
98 return GetTelem_modalgainopt_fb( msgBuffer )->gain_leak();
99 }
100
101 static logMetaDetail getAccessor( const std::string &member )
102 {
103 if( member == "updateAuto" )
104 {
105 return logMetaDetail( { "UPDATE AUTO",
106 "",
109 reinterpret_cast<void *>( &updateAuto ),
110 true } );
111 }
112 else if( member == "opticalGainTracking" )
113 {
114 return logMetaDetail( { "OPTICAL GAIN TRACKING",
115 "",
118 reinterpret_cast<void *>( &opticalGainTracking ),
119 true } );
120 }
121 else if( member == "opticalGain" )
122 {
123 return logMetaDetail( { "OPTICAL GAIN",
124 "",
127 reinterpret_cast<void *>( &opticalGain ),
128 true } );
129 }
130 else if( member == "gainGain" )
131 {
132 return logMetaDetail( { "GAIN GAIN",
133 "",
136 reinterpret_cast<void *>( &gainGain ),
137 true } );
138 }
139 else if( member == "gainLeak" )
140 {
141 return logMetaDetail( { "GAIN LEAK",
142 "",
145 reinterpret_cast<void *>( &gainLeak ),
146 true } );
147 }
148 else
149 {
150 std::cerr << "No member " << member << " in telem_modalgainopt\n";
151 return logMetaDetail();
152 }
153 }
154};
155
156} // namespace logger
157} // namespace MagAOX
158
159#endif // logger_types_telem_modalgainopt_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_MODALGAINOPT
Definition logCodes.hpp:65
inline ::flatbuffers::Offset< Telem_modalgainopt_fb > CreateTelem_modalgainopt_fb(::flatbuffers::FlatBufferBuilder &_fbb, bool update_auto=false, bool optical_gain_tracking=false, float optical_gain=0.0f, float gain_gain=0.0f, float gain_leak=0.0f)
const MagAOX::logger::Telem_modalgainopt_fb * GetTelem_modalgainopt_fb(const void *buf)
bool VerifyTelem_modalgainopt_fbBuffer(::flatbuffers::Verifier &verifier)
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 bool updateAuto, const bool opticalGainTracking, const float opticalGain, const float gainGain, const float gainLeak)
Log entry recording modalGainOpt control state.
static bool opticalGainTracking(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
static logMetaDetail getAccessor(const std::string &member)
static const flatlogs::logPrioT defaultLevel
static float gainLeak(void *msgBuffer)
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static timespec lastRecord
The time of the last telemetry record.
static float gainGain(void *msgBuffer)
static float opticalGain(void *msgBuffer)
static bool updateAuto(void *msgBuffer)