API
 
Loading...
Searching...
No Matches
telem_w2tcsoffloader.hpp
Go to the documentation of this file.
1/** \file telem_w2tcsoffloader.hpp
2 * \brief The MagAO-X logger telem_w2tcsoffloader log type.
3 *
4 * \ingroup logger_types_files
5 *
6 */
7#ifndef logger_types_telem_w2tcsoffloader_hpp
8#define logger_types_telem_w2tcsoffloader_hpp
9
11#include "flatbuffer_log.hpp"
12
13namespace MagAOX
14{
15namespace logger
16{
17
18/// Log entry recording the woofer-to-TCS Zernike coefficient vector.
19/** \ingroup logger_types
20 */
22{
23 /// The event code.
25
26 /// The default level.
28
29 static timespec lastRecord; ///< The time of the last time this log was recorded. Used by the telemetry system.
30
31 /// The type of the input message.
32 struct messageT : public fbMessage
33 {
34 /// Construct from components.
35 explicit messageT( const std::vector<float> &coeffs /**< [in] the offloaded Zernike coefficients */ )
36 {
37 auto coeffVec = builder.CreateVector( coeffs );
38 auto fp = CreateTelem_w2tcsoffloader_fb( builder, coeffVec );
39
40 builder.Finish( fp );
41 }
42 };
43
44 static bool verify( flatlogs::bufferPtrT &logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
45 flatlogs::msgLenT len ///< [in] length of msgBuffer.
46 )
47 {
48 auto verifier = flatbuffers::Verifier( static_cast<uint8_t *>( flatlogs::logHeader::messageBuffer( logBuff ) ),
49 static_cast<size_t>( len ) );
50 return VerifyTelem_w2tcsoffloader_fbBuffer( verifier );
51 }
52
53 /// Get the message formatted for human consumption.
54 static std::string msgString( void *msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message. */
55 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer. */
56 )
57 {
58 static_cast<void>( len );
59
60 auto fbs = GetTelem_w2tcsoffloader_fb( msgBuffer );
61
62 std::string msg = "[w2tcsoffloader coeffs] ";
63
64 if( fbs->coeffs() != nullptr )
65 {
66 for( flatbuffers::Vector<float>::const_iterator it = fbs->coeffs()->begin(); it != fbs->coeffs()->end();
67 ++it )
68 {
69 msg += std::to_string( *it );
70 msg += " ";
71 }
72 }
73
74 return msg;
75 }
76
77 /// Recover the coefficient vector from a serialized message.
78 static std::vector<float> coeffs( void *msgBuffer )
79 {
80 std::vector<float> coeffVec;
81 auto fbs = GetTelem_w2tcsoffloader_fb( msgBuffer );
82
83 if( fbs->coeffs() != nullptr )
84 {
85 for( flatbuffers::Vector<float>::const_iterator it = fbs->coeffs()->begin(); it != fbs->coeffs()->end();
86 ++it )
87 {
88 coeffVec.push_back( *it );
89 }
90 }
91
92 return coeffVec;
93 }
94
95 /// Get the logMetaDetail for a member by name.
96 /**
97 * \returns a logMetaDetail filled in with the appropriate details
98 * \returns an empty logMetaDetail if member not recognized
99 */
100 static logMetaDetail getAccessor( const std::string &member /**< [in] the name of the member */ )
101 {
102 if( member == "coeffs" )
103 {
104 return logMetaDetail( { "COEFFS",
107 reinterpret_cast<void *>( &coeffs ),
108 false } );
109 }
110 else
111 {
112 std::cerr << "No member " << member << " in telem_w2tcsoffloader\n";
113 return logMetaDetail();
114 }
115 }
116
117}; // struct telem_w2tcsoffloader
118
119} // namespace logger
120} // namespace MagAOX
121
122#endif // logger_types_telem_w2tcsoffloader_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_W2TCSOFFLOADER
Definition logCodes.hpp:68
bool VerifyTelem_w2tcsoffloader_fbBuffer(::flatbuffers::Verifier &verifier)
const MagAOX::logger::Telem_w2tcsoffloader_fb * GetTelem_w2tcsoffloader_fb(const void *buf)
inline ::flatbuffers::Offset< Telem_w2tcsoffloader_fb > CreateTelem_w2tcsoffloader_fb(::flatbuffers::FlatBufferBuilder &_fbb, ::flatbuffers::Offset<::flatbuffers::Vector< float > > coeffs=0)
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 std::vector< float > &coeffs)
Construct from components.
Log entry recording the woofer-to-TCS Zernike coefficient vector.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static const flatlogs::logPrioT defaultLevel
The default level.
static const flatlogs::eventCodeT eventCode
The event code.
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
static std::vector< float > coeffs(void *msgBuffer)
Recover the coefficient vector from a serialized message.