API
 
Loading...
Searching...
No Matches
telem_psfacq.hpp
Go to the documentation of this file.
1/** \file telem_psfacq.hpp
2 * \brief The MagAO-X logger telem_psfacq log type.
3 *
4 * \ingroup logger_types_files
5 *
6 */
7#ifndef logger_types_telem_psfacq_hpp
8#define logger_types_telem_psfacq_hpp
9
11#include "flatbuffer_log.hpp"
12
13namespace MagAOX
14{
15namespace logger
16{
17
18/// Log entry recording psf acquisition per-star properties.
19/** \ingroup logger_types
20 */
22{
23 /// The event code
25
26 /// The default level
28
29 static timespec lastRecord; ///< The timestamp of the last time this log was recorded. Used by telemetry.
30
31 /// The type of the input message
32 struct messageT : public fbMessage
33 {
34 /// Construct from components
35 messageT( const int &star_no, /**< [in] one-based index of this star within the emitted set. */
36 const int &num_stars, /**< [in] total stars emitted in this telemetry cycle. */
37 const float &x_pos, /**< [in] x position in pixels. */
38 const float &y_pos, /**< [in] y position in pixels. */
39 const float &m_pix, /**< [in] peak pixel value. */
40 const float &fwhm, /**< [in] full-width at half-maximum in pixels. */
41 const float &seeing /**< [in] seeing in arcseconds. */ )
42 {
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_psfacq_fbBuffer( verifier );
55 }
56
57 /// Get the message format 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 static_cast<void>( len );
62
63 auto fbs = GetTelem_psfacq_fb( msgBuffer );
64
65 std::string msg = "[psfAcq] ";
66 msg += "star_no: " + std::to_string( fbs->star_no() ) + "/" + std::to_string( fbs->num_stars() ) + " ";
67 msg += "x_pos: " + std::to_string( fbs->x_pos() ) + " ";
68 msg += "y_pos: " + std::to_string( fbs->y_pos() ) + " ";
69 msg += "m_pix: " + std::to_string( fbs->m_pix() ) + " ";
70 msg += "fwhm: " + std::to_string( fbs->fwhm() ) + " ";
71 msg += "seeing: " + std::to_string( fbs->seeing() ) + " ";
72
73 return msg;
74 }
75
76 /// Get the one-based star index.
77 static int star_no( void *msgBuffer )
78 {
79 auto fbs = GetTelem_psfacq_fb( msgBuffer );
80 return fbs->star_no();
81 }
82
83 /// Get the total number of stars emitted this cycle.
84 static int num_stars( void *msgBuffer )
85 {
86 auto fbs = GetTelem_psfacq_fb( msgBuffer );
87 return fbs->num_stars();
88 }
89
90 static float x_pos( void *msgBuffer )
91 {
92 auto fbs = GetTelem_psfacq_fb( msgBuffer );
93 return fbs->x_pos();
94 }
95
96 static float y_pos( void *msgBuffer )
97 {
98 auto fbs = GetTelem_psfacq_fb( msgBuffer );
99 return fbs->y_pos();
100 }
101
102 static float m_pix( void *msgBuffer )
103 {
104 auto fbs = GetTelem_psfacq_fb( msgBuffer );
105 return fbs->m_pix();
106 }
107
108 static float fwhm( void *msgBuffer )
109 {
110 auto fbs = GetTelem_psfacq_fb( msgBuffer );
111 return fbs->fwhm();
112 }
113
114 static float seeing( void *msgBuffer )
115 {
116 auto fbs = GetTelem_psfacq_fb( msgBuffer );
117 return fbs->seeing();
118 }
119
120 /// Get the logMetaDetail for a member by name
121 /**
122 * \returns a logMetaDetail filled in with the appropriate details
123 * \returns an empty logMetaDetail if member not recognized
124 */
125 static logMetaDetail getAccessor( const std::string &member /**< [in] the name of the member */ )
126 {
127 if( member == "star_no" )
128 {
129 return logMetaDetail( { "STAR NO", logMeta::valTypes::Int, logMeta::metaTypes::State, reinterpret_cast<void *>( &star_no ) } );
130 }
131 else if( member == "num_stars" )
132 {
133 return logMetaDetail( { "NUM STARS", logMeta::valTypes::Int, logMeta::metaTypes::State, reinterpret_cast<void *>( &num_stars ) } );
134 }
135 else if( member == "x_pos" )
136 {
137 return logMetaDetail( { "X POS", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>( &x_pos ) } );
138 }
139 else if( member == "y_pos" )
140 {
141 return logMetaDetail( { "Y POS", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>( &y_pos ) } );
142 }
143 else if( member == "m_pix" )
144 {
145 return logMetaDetail( { "M PIX", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>( &m_pix ) } );
146 }
147 else if( member == "fwhm" )
148 {
149 return logMetaDetail( { "FWHM", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>( &fwhm ) } );
150 }
151 else if( member == "seeing" )
152 {
153 return logMetaDetail( { "SEEING", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>( &seeing ) } );
154 }
155 else
156 {
157 std::cerr << "No member " << member << " in telem_psfacq\n";
158 return logMetaDetail();
159 }
160 }
161
162}; //telem_psfacq
163
164} //namespace logger
165} //namespace MagAOX
166
167#endif //logger_types_telem_psfacq_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_PSFACQ
Definition logCodes.hpp:47
bool VerifyTelem_psfacq_fbBuffer(::flatbuffers::Verifier &verifier)
inline ::flatbuffers::Offset< Telem_psfacq_fb > CreateTelem_psfacq_fb(::flatbuffers::FlatBufferBuilder &_fbb, float x_pos=0.0f, float y_pos=0.0f, float m_pix=0.0f, float fwhm=0.0f, float seeing=0.0f, int32_t star_no=0, int32_t num_stars=0)
const MagAOX::logger::Telem_psfacq_fb * GetTelem_psfacq_fb(const void *buf)
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 int &star_no, const int &num_stars, const float &x_pos, const float &y_pos, const float &m_pix, const float &fwhm, const float &seeing)
Construct from components.
Log entry recording psf acquisition per-star properties.
static float m_pix(void *msgBuffer)
static float x_pos(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static int star_no(void *msgBuffer)
Get the one-based star index.
static int num_stars(void *msgBuffer)
Get the total number of stars emitted this cycle.
static const flatlogs::eventCodeT eventCode
The event code.
static float seeing(void *msgBuffer)
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static const flatlogs::logPrioT defaultLevel
The default level.
static float y_pos(void *msgBuffer)
static timespec lastRecord
The timestamp of the last time this log was recorded. Used by telemetry.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message format for human consumption.
static float fwhm(void *msgBuffer)