API
 
Loading...
Searching...
No Matches
telem_flowrpm.hpp
Go to the documentation of this file.
1/** \file telem_flowrpm.hpp
2 * \brief The MagAO-X logger telem_flowrpm log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 */
7
8#ifndef logger_types_telem_flowrpm_hpp
9#define logger_types_telem_flowrpm_hpp
10
12#include "flatbuffer_log.hpp"
13
14namespace MagAOX
15{
16namespace logger
17{
18
19/// Log entry recording the displayed flow value and source age.
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 double flowRate, /**< [in] displayed flow rate in LPM */
37 const double age, /**< [in] displayed age in seconds */
38 const bool valid /**< [in] whether the displayed value is valid */
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_flowrpm_fbBuffer( verifier );
53 }
54
55 /// Get the message formatted 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_flowrpm_fb( msgBuffer );
63 std::string msg = "[flowrpm] ";
64
65 msg += "flow: ";
66 msg += std::to_string( fbs->flowRate() );
67 msg += " LPM age: ";
68 msg += std::to_string( fbs->age() );
69 msg += " s valid: ";
70 msg += ( fbs->valid() ? "true" : "false" );
71
72 return msg;
73 }
74
75 /// Recover the flow rate from a serialized message.
76 static double flowRate( void *msgBuffer )
77 {
78 return GetTelem_flowrpm_fb( msgBuffer )->flowRate();
79 }
80
81 /// Recover the age from a serialized message.
82 static double age( void *msgBuffer )
83 {
84 return GetTelem_flowrpm_fb( msgBuffer )->age();
85 }
86
87 /// Recover the validity flag from a serialized message.
88 static bool valid( void *msgBuffer )
89 {
90 return GetTelem_flowrpm_fb( msgBuffer )->valid();
91 }
92
93 /// Get the logMetaDetail for a member by name.
94 static logMetaDetail getAccessor( const std::string &member /**< [in] the name of the member */ )
95 {
96 if( member == "flowRate" )
97 {
98 return logMetaDetail( { "FLOW RATE",
99 "LPM",
102 reinterpret_cast<void *>( &flowRate ),
103 true } );
104 }
105 else if( member == "age" )
106 {
107 return logMetaDetail( { "FLOW AGE",
108 "s",
111 reinterpret_cast<void *>( &age ),
112 true } );
113 }
114 else if( member == "valid" )
115 {
116 return logMetaDetail( { "FLOW VALID",
117 "",
120 reinterpret_cast<void *>( &valid ),
121 true } );
122 }
123 else
124 {
125 std::cerr << "No member " << member << " in telem_flowrpm\n";
126 return logMetaDetail();
127 }
128 }
129};
130
131} // namespace logger
132} // namespace MagAOX
133
134#endif // logger_types_telem_flowrpm_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_FLOWRPM
Definition logCodes.hpp:69
const MagAOX::logger::Telem_flowrpm_fb * GetTelem_flowrpm_fb(const void *buf)
inline ::flatbuffers::Offset< Telem_flowrpm_fb > CreateTelem_flowrpm_fb(::flatbuffers::FlatBufferBuilder &_fbb, double flowRate=0.0, double age=0.0, bool valid=false)
bool VerifyTelem_flowrpm_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.
The type of the input message.
messageT(const double flowRate, const double age, const bool valid)
Construct from components.
Log entry recording the displayed flow value and source age.
static const flatlogs::logPrioT defaultLevel
The default level.
static double age(void *msgBuffer)
Recover the age from a serialized message.
static bool valid(void *msgBuffer)
Recover the validity flag from a serialized message.
static const flatlogs::eventCodeT eventCode
The event code.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static double flowRate(void *msgBuffer)
Recover the flow rate from a serialized message.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.