API
 
Loading...
Searching...
No Matches
telem_fxngen.hpp
Go to the documentation of this file.
1/** \file telem_fxngen.hpp
2 * \brief The MagAO-X logger telem_fxngen 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_fxngen_hpp
11#define logger_types_telem_fxngen_hpp
12
13#include "generated/telem_fxngen_generated.h"
14#include "flatbuffer_log.hpp"
15
16#define TELEM_FXNGEN_WVTP_DC (0)
17#define TELEM_FXNGEN_WVTP_SINE (1)
18#define TELEM_FXNGEN_WVTP_PULSE (2)
19
20namespace MagAOX
21{
22namespace logger
23{
24
25
26/// Log entry recording the function generator parameters
27/** \ingroup logger_types
28 */
30{
31 ///The event code
32 static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_FXNGEN;
33
34 ///The default level
36
37 static timespec lastRecord; ///< The timestamp of the last time this log was recorded. Used by the telemetry system.
38
39
40
41
42 ///The type of the input message
43 struct messageT : public fbMessage
44 {
45 ///Construct from components
46 messageT( const uint8_t & C1outp, ///< [in] Channel 1 output status
47 const double & C1freq, ///< [in] Channel 1 frequency [Hz]
48 const double & C1vpp, ///< [in] Channel 1 P2P voltage [V]
49 const double & C1ofst, ///< [in] Channel 1 offset [V]
50 const double & C1phse, ///< [in] Channel 1 phase [deg]
51 const uint8_t & C1wvtp, ///< [in] Channel 1 wavetype (SINE or DC)
52 const uint8_t & C2outp, ///< [in] Channel 2 output status
53 const double & C2freq, ///< [in] Channel 2 frequency [Hz]
54 const double & C2vpp, ///< [in] Channel 2 P2P voltage [V]
55 const double & C2ofst, ///< [in] Channel 2 offset [V]
56 const double & C2phse, ///< [in] Channel 2 phase [deg]
57 const uint8_t & C2wvtp, ///< [in] Channel 2 wavetype (SINE or DC)
58 const uint8_t & C1sync, ///< [in] Channel 1 sync status
59 const uint8_t & C2sync, ///< [in] Channel 2 sync status
60 const double & C1wdth, ///< [in] Channel 1 width [s]
61 const double & C2wdth ///< [in] Channel 2 width [s]
62 )
63 {
64 auto fp = CreateTelem_fxngen_fb(builder, C1outp, C1freq, C1vpp, C1ofst, C1phse, C1wvtp,
65 C2outp, C2freq, C2vpp, C2ofst, C2phse, C2wvtp, C1sync, C2sync, C1wdth, C2wdth);
66 builder.Finish(fp);
67 }
68
69 };
70
71 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
72 flatlogs::msgLenT len ///< [in] length of msgBuffer.
73 )
74 {
75 auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
76 return VerifyTelem_fxngen_fbBuffer(verifier);
77 }
78
79 ///Get the message formatte for human consumption.
80 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
81 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
82 )
83 {
84 static_cast<void>(len);
85
86 auto fbs = GetTelem_fxngen_fb(msgBuffer);
87
88 std::string msg = "Ch 1: ";
89
90 if(fbs->C1wvtp() == TELEM_FXNGEN_WVTP_DC) msg += "DC ";
91 else if(fbs->C1wvtp() == TELEM_FXNGEN_WVTP_SINE) msg += "SINE ";
92 else if(fbs->C1wvtp() == TELEM_FXNGEN_WVTP_PULSE) msg += "PULSE ";
93 else msg += "UNK ";
94
95 if(fbs->C1outp() == 0) msg += "OFF ";
96 else if(fbs->C1outp() == 1) msg += "ON ";
97 else msg += "UNK ";
98
99 msg += std::to_string(fbs->C1freq()) + " Hz ";
100 msg += std::to_string(fbs->C1vpp()) + " Vp2p ";
101 msg += std::to_string(fbs->C1ofst()) + " V ";
102 msg += std::to_string(fbs->C1phse()) + " deg ";
103 msg += std::to_string(fbs->C1wdth()) + " s ";
104 msg += "SYNC ";
105 if(fbs->C1sync()) msg += "ON ";
106 else msg += "OFF ";
107
108 msg += " | Ch 2: ";
109
110 if(fbs->C2wvtp() == TELEM_FXNGEN_WVTP_DC) msg += "DC ";
111 else if(fbs->C2wvtp() == TELEM_FXNGEN_WVTP_SINE) msg += "SINE ";
112 else if(fbs->C2wvtp() == TELEM_FXNGEN_WVTP_PULSE) msg += "PULSE ";
113 else msg += "UNK ";
114
115 if(fbs->C2outp() == 0) msg += "OFF ";
116 else if(fbs->C2outp() == 1) msg += "ON ";
117 else msg += "UNK ";
118
119 msg += std::to_string(fbs->C2freq()) + " Hz ";
120 msg += std::to_string(fbs->C2vpp()) + " Vp2p ";
121 msg += std::to_string(fbs->C2ofst()) + " V ";
122 msg += std::to_string(fbs->C2phse()) + " deg ";
123 msg += std::to_string(fbs->C2wdth()) + " s ";
124 msg += "SYNC ";
125 if(fbs->C2sync()) msg += "ON ";
126 else msg += "OFF ";
127
128 return msg;
129
130 }
131
132 static double C1freq( void * msgBuffer )
133 {
134 auto fbs = GetTelem_fxngen_fb(msgBuffer);
135 return fbs->C1freq();
136 }
137
138 static double C2freq( void * msgBuffer )
139 {
140 auto fbs = GetTelem_fxngen_fb(msgBuffer);
141 return fbs->C2freq();
142 }
143
144 /// Get the logMetaDetail for a member by name
145 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
146 {
147 if( member == "C1freq") return logMetaDetail({"C1 FREQ", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&C1freq)});
148 else if(member == "C2freq") return logMetaDetail({"C2 FREQ", logMeta::valTypes::Double, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&C2freq)});
149 else
150 {
151 std::cerr << "No string member " << member << " in telem_fxngen\n";
152 return logMetaDetail();
153 }
154 }
155}; //telem_fxngen
156
157
158
159} //namespace logger
160} //namespace MagAOX
161
162#endif //logger_types_telem_fxngen_hpp
163
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 uint8_t &C1outp, const double &C1freq, const double &C1vpp, const double &C1ofst, const double &C1phse, const uint8_t &C1wvtp, const uint8_t &C2outp, const double &C2freq, const double &C2vpp, const double &C2ofst, const double &C2phse, const uint8_t &C2wvtp, const uint8_t &C1sync, const uint8_t &C2sync, const double &C1wdth, const double &C2wdth)
Construct from components.
Log entry recording the function generator parameters.
static double C1freq(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static const flatlogs::logPrioT defaultLevel
The default level.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static const flatlogs::eventCodeT eventCode
The event code.
static double C2freq(void *msgBuffer)
static timespec lastRecord
The timestamp of the last time this log was recorded. Used by the telemetry system.
#define TELEM_FXNGEN_WVTP_DC
#define TELEM_FXNGEN_WVTP_PULSE
#define TELEM_FXNGEN_WVTP_SINE