API
 
Loading...
Searching...
No Matches
telem_position.hpp
Go to the documentation of this file.
1/** \file telem_position.hpp
2 * \brief The MagAO-X logger telem_position log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 */
8#ifndef logger_types_telem_position_hpp
9#define logger_types_telem_position_hpp
10
11#include "generated/telem_position_generated.h"
12#include "flatbuffer_log.hpp"
13
14namespace MagAOX
15{
16namespace logger
17{
18
19
20/// Log entry recording position stage specific status.
21/** \ingroup logger_types
22 */
24{
25 ///The event code
26 static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_POSITION;
27
28 ///The default level
30
31 static timespec lastRecord; ///< The timestamp of the last time this log was recorded. Used by the telemetry system.
32
33 ///The type of the input message
34 struct messageT : public fbMessage
35 {
36 ///Construct from components
37 messageT( const float & pos /**<[in] stage position in mm */ )
38 {
39 auto fp = CreateTelem_position_fb(builder, pos);
40 builder.Finish(fp);
41 }
42
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)), static_cast<size_t>(len));
51 return VerifyTelem_position_fbBuffer(verifier);
52 }
53
54 ///Get the message formatte for human consumption.
55 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
56 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
57 )
58 {
59 static_cast<void>(len);
60
61 auto fbs = GetTelem_position_fb(msgBuffer);
62
63 std::string msg = "[position] ";
64
65 msg += "pos: ";
66 msg += std::to_string(fbs->pos()) + " ";
67
68 return msg;
69
70 }
71
72 static float pos( void * msgBuffer )
73 {
74 auto fbs = GetTelem_position_fb(msgBuffer);
75 return fbs->pos();
76 }
77
78
79 /// Get the logMetaDetail for a member by name
80 /**
81 * \returns the a logMetaDetail filled in with the appropriate details
82 * \returns an empty logmegaDetail if member not recognized
83 */
84 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
85 {
86 if( member == "pos") return logMetaDetail({"POS", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&pos)});
87 else
88 {
89 std::cerr << "No string member " << member << " in telem_position\n";
90 return logMetaDetail();
91 }
92 }
93
94}; //telem_position
95
96
97
98} //namespace logger
99} //namespace MagAOX
100
101#endif //logger_types_telem_position_hpp
102
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
Definition dm.hpp:24
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 float &pos)
Construct from components.
Log entry recording position stage specific status.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static const flatlogs::eventCodeT eventCode
The event code.
static const flatlogs::logPrioT defaultLevel
The default level.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static timespec lastRecord
The timestamp of the last time this log was recorded. Used by the telemetry system.
static float pos(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.