API
 
Loading...
Searching...
No Matches
telem_dmmodes.hpp
Go to the documentation of this file.
1/** \file telem_dmmodes.hpp
2 * \brief The MagAO-X logger telem_dmmodes log type.
3 * \author Jared Males (jrmales@arizona.edu)
4 *
5 * \ingroup logger_types_files
6 *
7 * History:
8 * - 2022-10-09 created by JRM
9 */
10#ifndef logger_types_telem_dmmodes_hpp
11#define logger_types_telem_dmmodes_hpp
12
13#include "generated/telem_dmmodes_generated.h"
14#include "flatbuffer_log.hpp"
15
16namespace MagAOX
17{
18namespace logger
19{
20
21
22/// Log entry recording DM Mode Amplitudes
23/** \ingroup logger_types
24 */
26{
27
28 static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_DMMODES;
30
31 static timespec lastRecord; ///< The time 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 explicit messageT( std::vector<float> & amps )
38 {
39 auto _ampsVec = builder.CreateVector(amps);
40
41 auto fp = CreateTelem_dmmodes_fb(builder, _ampsVec );
42
43 builder.Finish(fp);
44 }
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)), static_cast<size_t>(len));
53 return VerifyTelem_dmmodes_fbBuffer(verifier);
54 }
55
56 ///Get the message formatte for human consumption.
57 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
58 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
59 )
60 {
61
62 static_cast<void>(len); // unused by most log types
63
64 auto rgs = GetTelem_dmmodes_fb(msgBuffer);
65
66 std::string msg;
67
68 msg+= "[dmmodes amps] ";
69
70 if (rgs->amps() != nullptr)
71 {
72 for(flatbuffers::Vector<float>::const_iterator it = rgs->amps()->begin(); it != rgs->amps()->end(); ++it)
73 {
74 msg+= std::to_string(*it);
75 msg+= " ";
76 }
77 }
78
79 return msg;
80
81 }
82
83 static std::vector<float> amps( void * msgBuffer )
84 {
85 std::vector<float> amps;
86 auto fbs = GetTelem_dmmodes_fb(msgBuffer);
87
88 if (fbs->amps() != nullptr)
89 {
90 for(flatbuffers::Vector<float>::const_iterator it = fbs->amps()->begin(); it != fbs->amps()->end(); ++it)
91 {
92 amps.push_back(*it);
93 }
94 }
95
96 return amps;
97 }
98
99 /// Get the logMetaDetail for a member by name
100 /**
101 * \returns the a logMetaDetail filled in with the appropriate details
102 * \returns an empty logmegaDetail if member not recognized
103 */
104 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
105 {
106 if(member == "amps") return logMetaDetail({"AMPS", logMeta::valTypes::Vector_Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&amps), false});
107 else
108 {
109 std::cerr << "No string member " << member << " in telem_dmmodes\n";
110 return logMetaDetail();
111 }
112 }
113
114}; //telem_dmmodes
115
116
117
118} //namespace logger
119} //namespace MagAOX
120
121#endif //logger_types_telem_dmmodes_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
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(std::vector< float > &amps)
Construct from components.
Log entry recording DM Mode Amplitudes.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static const flatlogs::logPrioT defaultLevel
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static std::vector< float > amps(void *msgBuffer)
static const flatlogs::eventCodeT eventCode