API
 
Loading...
Searching...
No Matches
telem_tcsi_labmode.hpp
Go to the documentation of this file.
1/** \file telem_tcsi_labmode.hpp
2 * \brief The MagAO-X logger type for tcsInterface lab-mode telemetry.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 */
8#ifndef logger_types_telem_tcsi_labmode_hpp
9#define logger_types_telem_tcsi_labmode_hpp
10
12#include "flatbuffer_log.hpp"
13
14namespace MagAOX
15{
16namespace logger
17{
18
19/// tcsInterface lab-mode telemetry.
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 bool &labMode ///< [in] whether tcsInterface is in lab mode
37 )
38 {
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_tcsi_labmode_fbBuffer( verifier );
51 }
52
53 /// Format the message 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_tcsi_labmode_fb( msgBuffer );
61
62 std::string msg = "[tcsi_labmode] ";
63 msg += "labMode: ";
64 msg += std::to_string( fbs->labMode() );
65
66 return msg;
67 }
68
69 /// Access the lab-mode state.
70 static bool labMode( void *msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
71 {
72 auto fbs = GetTelem_tcsi_labmode_fb( msgBuffer );
73 return fbs->labMode();
74 }
75
76 /// Get the logMetaDetail for a member by name.
77 /**
78 * \returns the a logMetaDetail filled in with the appropriate details
79 * \returns an empty logMetaDetail if member not recognized
80 */
81 static logMetaDetail getAccessor( const std::string &member /**< [in] the name of the member */ )
82 {
83 if( member == "labMode" )
84 {
85 return logMetaDetail( { "LABMODE",
88 reinterpret_cast<void *>( &labMode ) } );
89 }
90 else
91 {
92 std::cerr << "No member " << member << " in telem_tcsi_labmode\n";
93 return logMetaDetail();
94 }
95 }
96};
97
98} // namespace logger
99} // namespace MagAOX
100
101#endif // logger_types_telem_tcsi_labmode_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_TCSI_LABMODE
Definition logCodes.hpp:42
inline ::flatbuffers::Offset< Telem_tcsi_labmode_fb > CreateTelem_tcsi_labmode_fb(::flatbuffers::FlatBufferBuilder &_fbb, bool labMode=false)
const MagAOX::logger::Telem_tcsi_labmode_fb * GetTelem_tcsi_labmode_fb(const void *buf)
bool VerifyTelem_tcsi_labmode_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 &labMode)
Construct from components.
tcsInterface lab-mode telemetry.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Format the message for human consumption.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static const flatlogs::eventCodeT eventCode
The event code.
static const flatlogs::logPrioT defaultLevel
The default level.
static bool labMode(void *msgBuffer)
Access the lab-mode state.
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.