API
 
Loading...
Searching...
No Matches
telem_pokeloop.hpp
Go to the documentation of this file.
1/** \file telem_pokeloop.hpp
2 * \brief The MagAO-X logger telem_pokeloop log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 */
8#ifndef logger_types_telem_pokeloop_hpp
9#define logger_types_telem_pokeloop_hpp
10
12#include "flatbuffer_log.hpp"
13
14namespace MagAOX
15{
16namespace logger
17{
18
19/// Log entry recording DM poke centering results
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 uint8_t & measuring, ///< [in] flag indicating if the WFS is measuring
37 const float & deltaX, ///< [in] the x delta position
38 const float & deltaY, ///< [in] the y delta position
39 const uint64_t & counter ///< [in] the loop counter
40 )
41 {
42
43 if(measuring == 0)
44 {
45 Telem_pokeloop_fbBuilder telem_pokeloop_builder(builder);
46 telem_pokeloop_builder.add_measuring(measuring);
47 auto fb = telem_pokeloop_builder.Finish();
48 builder.Finish(fb);
49 return;
50 }
51
53
54 builder.Finish(fb);
55 }
56 };
57
58 static bool verify( flatlogs::bufferPtrT &logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
59 flatlogs::msgLenT len ///< [in] length of msgBuffer.
60 )
61 {
62 auto verifier = flatbuffers::Verifier(static_cast<uint8_t *>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
63 return VerifyTelem_pokeloop_fbBuffer(verifier);
64 }
65
66 /// Get the message formatted for human consumption.
67 static std::string msgString( void *msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
68 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
69 )
70 {
71 static_cast<void>(len);
72
73 auto fbs = GetTelem_pokeloop_fb(msgBuffer);
74
75 std::string msg;
76 if(fbs->measuring() == 0)
77 {
78 msg = "[pokeloop] not measuring";
79 }
80 else
81 {
82 msg = "[pokeloop] X: ";
83
84 msg += std::to_string(fbs->deltaX());
85 msg += " Y: ";
86 msg += std::to_string(fbs->deltaY());
87
88 msg += " ctr: ";
89 msg += std::to_string(fbs->counter());
90 }
91
92 return msg;
93 }
94
95 static bool measuring( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
96 {
97 auto fbs = GetTelem_pokeloop_fb(msgBuffer);
98 return fbs->measuring();
99 }
100
101 static float deltaX( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
102 {
103 auto fbs = GetTelem_pokeloop_fb(msgBuffer);
104 return fbs->deltaX();
105 }
106 static float deltaY( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
107 {
108 auto fbs = GetTelem_pokeloop_fb(msgBuffer);
109 return fbs->deltaY();
110 }
111
112 static unsigned long long counter( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
113 {
114 auto fbs = GetTelem_pokeloop_fb(msgBuffer);
115 return fbs->counter();
116 }
117
118 /// Get the logMetaDetail for a member by name
119 /**
120 * \returns the a logMetaDetail filled in with the appropriate details
121 * \returns an empty logMetaDetail if member not recognized
122 */
123 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
124 {
125 if( member == "measuring") return logMetaDetail({"MEASURING", "measuring state", logMeta::valTypes::Bool, logMeta::metaTypes::State, reinterpret_cast<void*>(&measuring), false});
126 else if( member == "deltaX") return logMetaDetail({"DELTA X", "loop delta x", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&deltaX), false});
127 else if( member == "deltaY") return logMetaDetail({"DELTA Y", "loop delta y", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&deltaY), false});
128 else if( member == "counter") return logMetaDetail({"LOOP COUNTER", "loop counter", logMeta::valTypes::ULongLong, logMeta::metaTypes::State, reinterpret_cast<void*>(&counter), false});
129 else
130 {
131 std::cerr << "No member " << member << " in telem_pokeloop\n";
132 return logMetaDetail();
133 }
134 }
135
136}; // telem_pokeloop
137
138} // namespace logger
139} // namespace MagAOX
140
141#endif // logger_types_telem_pokeloop_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_POKELOOP
Definition logCodes.hpp:44
bool VerifyTelem_pokeloop_fbBuffer(::flatbuffers::Verifier &verifier)
inline ::flatbuffers::Offset< Telem_pokeloop_fb > CreateTelem_pokeloop_fb(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t measuring=0, float deltaX=0.0f, float deltaY=0.0f, uint64_t counter=0)
const MagAOX::logger::Telem_pokeloop_fb * GetTelem_pokeloop_fb(const void *buf)
Definition dm.hpp:28
static constexpr logPrioT LOG_TELEM
A telemetry recording.
::flatbuffers::Offset< Telem_pokeloop_fb > Finish()
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 &measuring, const float &deltaX, const float &deltaY, const uint64_t &counter)
Construct from components.
Log entry recording DM poke centering results.
static const flatlogs::logPrioT defaultLevel
The default level.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
static float deltaX(void *msgBuffer)
static unsigned long long counter(void *msgBuffer)
static float deltaY(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
The event code.
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static bool measuring(void *msgBuffer)
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.