API
 
Loading...
Searching...
No Matches
telem_telenv.hpp
Go to the documentation of this file.
1/** \file telem_telenv.hpp
2 * \brief The MagAO-X logger telem_telenv 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_telenv_hpp
11#define logger_types_telem_telenv_hpp
12
14#include "flatbuffer_log.hpp"
15
16namespace MagAOX
17{
18namespace logger
19{
20
21
22/// Log entry recording the build-time git state.
23/** \ingroup logger_types
24 */
26{
27 ///The event code
29
30 ///The default level
32
33 static timespec lastRecord; ///< The time of the last time this log was recorded. Used by the telemetry system.
34
35 ///The type of the input message
36 struct messageT : public fbMessage
37 {
38 ///Construct from components
39 messageT( const double & tempout, ///< [in]
40 const double & pressure, ///< [in]
41 const double & humidity, ///< [in]
42 const double & wind, ///< [in]
43 const double & winddir, ///< [in]
44 const double & temptruss, ///< [in]
45 const double & tempcell, ///< [in]
46 const double & tempseccell, ///< [in]
47 const double & tempamb, ///< [in]
48 const double & dewpoint ///< [in]
49 )
50 {
52 builder.Finish(fp);
53 }
54
55 };
56
57 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
58 flatlogs::msgLenT len ///< [in] length of msgBuffer.
59 )
60 {
61 auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
62 return VerifyTelem_telenv_fbBuffer(verifier);
63 }
64
65 ///Get the message formatte for human consumption.
66 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
67 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
68 )
69 {
70 static_cast<void>(len);
71
72 auto fbs = GetTelem_telenv_fb(msgBuffer);
73
74 std::string msg = "[telenv] ";
75
76 msg += "tempout: ";
77 msg += std::to_string(fbs->tempout()) + " ";
78
79 msg += "press: ";
80 msg += std::to_string(fbs->pressure()) + " ";
81
82 msg += "humidity: ";
83 msg += std::to_string(fbs->humidity()) + " ";
84
85 msg += "wind: ";
86 msg += std::to_string(fbs->wind()) + " ";
87
88 msg += "winddir: ";
89 msg += std::to_string(fbs->winddir()) + " ";
90
91 msg += "temptruss: ";
92 msg += std::to_string(fbs->temptruss()) + " ";
93
94 msg += "tempcell: ";
95 msg += std::to_string(fbs->tempcell()) + " ";
96
97 msg += "tempseccell: ";
98 msg += std::to_string(fbs->tempseccell()) + " ";
99
100 msg += "tempamb: ";
101 msg += std::to_string(fbs->tempamb()) + " ";
102
103 msg += "dewpoint: ";
104 msg += std::to_string(fbs->dewpoint()) + " ";
105
106
107 return msg;
108
109 }
110
111 static double tempout( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
112 {
113 auto fbs = GetTelem_telenv_fb(msgBuffer);
114 return fbs->tempout();
115 }
116
117 static double pressure( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
118 {
119 auto fbs = GetTelem_telenv_fb(msgBuffer);
120 return fbs->pressure();
121 }
122
123 static double humidity( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
124 {
125 auto fbs = GetTelem_telenv_fb(msgBuffer);
126 return fbs->humidity();
127 }
128
129 static double wind( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
130 {
131 auto fbs = GetTelem_telenv_fb(msgBuffer);
132 return fbs->wind();
133 }
134
135 static double winddir( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
136 {
137 auto fbs = GetTelem_telenv_fb(msgBuffer);
138 return fbs->winddir();
139 }
140
141 static double temptruss( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
142 {
143 auto fbs = GetTelem_telenv_fb(msgBuffer);
144 return fbs->temptruss();
145 }
146
147 static double tempcell( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
148 {
149 auto fbs = GetTelem_telenv_fb(msgBuffer);
150 return fbs->tempcell();
151 }
152
153 static double tempseccell( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
154 {
155 auto fbs = GetTelem_telenv_fb(msgBuffer);
156 return fbs->tempseccell();
157 }
158
159 static double tempamb( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
160 {
161 auto fbs = GetTelem_telenv_fb(msgBuffer);
162 return fbs->tempamb();
163 }
164
165 static double dewpoint( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
166 {
167 auto fbs = GetTelem_telenv_fb(msgBuffer);
168 return fbs->dewpoint();
169 }
170
171 /// Get the logMetaDetail for a member by name
172 /**
173 * \returns the a logMetaDetail filled in with the appropriate details
174 * \returns an empty logMetaDetail if member not recognized
175 */
176 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
177 {
178 if( member == "tempout") return logMetaDetail({"OUTSIDE TEMP", "outside temperature [C]", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&tempout), false});
179 else if( member == "pressure") return logMetaDetail({"PRESSURE", "ambient pressure", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&pressure), false});
180 else if( member == "humidity") return logMetaDetail({"HUMIDITY", "relative humidity", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&humidity), false});
181 else if( member == "wind") return logMetaDetail({"WIND SPEED", "wind speed", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&wind), false});
182 else if( member == "winddir") return logMetaDetail({"WIND DIR", "wind direction", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&winddir), false});
183 else if( member == "temptruss") return logMetaDetail({"TRUSS TEMP", "truss temperature [C]", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&temptruss), false});
184 else if( member == "tempcell") return logMetaDetail({"CELL TEMP", "cell temperature [C]", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&tempcell), false});
185 else if( member == "tempseccell") return logMetaDetail({"SEC CELL TEMP", "secondary cell temperature [C]", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&tempseccell), false});
186 else if( member == "tempamb") return logMetaDetail({"AMBIENT TEMP", "ambient temperature [C]", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&tempamb), false});
187 else if( member == "dewpoint") return logMetaDetail({"DEWPOINT", "dew point [C]", logMeta::valTypes::Double, logMeta::metaTypes::State, reinterpret_cast<void*>(&dewpoint), false});
188 else
189 {
190 std::cerr << "No member " << member << " in telem_telenv\n";
191 return logMetaDetail();
192 }
193 }
194}; //telem_telenv
195
196
197} //namespace logger
198} //namespace MagAOX
199
200#endif //logger_types_telem_telenv_hpp
201
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_TELENV
Definition logCodes.hpp:36
inline ::flatbuffers::Offset< Telem_telenv_fb > CreateTelem_telenv_fb(::flatbuffers::FlatBufferBuilder &_fbb, double tempout=0.0, double pressure=0.0, double humidity=0.0, double wind=0.0, double winddir=0.0, double temptruss=0.0, double tempcell=0.0, double tempseccell=0.0, double tempamb=0.0, double dewpoint=0.0)
bool VerifyTelem_telenv_fbBuffer(::flatbuffers::Verifier &verifier)
const MagAOX::logger::Telem_telenv_fb * GetTelem_telenv_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 double &tempout, const double &pressure, const double &humidity, const double &wind, const double &winddir, const double &temptruss, const double &tempcell, const double &tempseccell, const double &tempamb, const double &dewpoint)
Construct from components.
Log entry recording the build-time git state.
static double tempout(void *msgBuffer)
static double pressure(void *msgBuffer)
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static double humidity(void *msgBuffer)
static double temptruss(void *msgBuffer)
static double winddir(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static double tempamb(void *msgBuffer)
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 double wind(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
The event code.
static double tempcell(void *msgBuffer)
static const flatlogs::logPrioT defaultLevel
The default level.
static double dewpoint(void *msgBuffer)
static double tempseccell(void *msgBuffer)