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