API
 
Loading...
Searching...
No Matches
ocam_temps.hpp
Go to the documentation of this file.
1/** \file ocam_temps.hpp
2 * \brief The MagAO-X logger ocam_temps 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_ocam_temps_hpp
11#define logger_types_ocam_temps_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 float & ccd, ///<[in] CCD temperature
40 const float & cpu, ///<[in] CPU temperature
41 const float & power, ///<[in] Power unit temperature
42 const float & bias, ///<[in] Bias temperature
43 const float & water, ///<[in] Water temperature
44 const float & left, ///<[in] Left temperature
45 const float & right, ///<[in] Right temperature
46 const float & cooling ///<[in] Cooling power
47 )
48 {
50 builder.Finish(fp);
51 }
52
53 };
54
55 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
56 flatlogs::msgLenT len ///< [in] length of msgBuffer.
57 )
58 {
59 auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
60 return VerifyOcam_temps_fbBuffer(verifier);
61 }
62
63 ///Get the message formatte for human consumption.
64 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
65 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
66 )
67 {
68 static_cast<void>(len);
69
70 auto fbs = GetOcam_temps_fb(msgBuffer);
71
72 std::string msg = "ccd: ";
73 msg += std::to_string(fbs->ccd()) + " C ";
74
75 msg += "cpu: ";
76 msg += std::to_string(fbs->cpu()) + " C ";
77
78 msg += "pwr: ";
79 msg += std::to_string(fbs->power()) + " C ";
80
81 msg += "bias: ";
82 msg += std::to_string(fbs->bias()) + " C ";
83
84 msg += "water: ";
85 msg += std::to_string(fbs->water()) + " C ";
86
87 msg += "left: ";
88 msg += std::to_string(fbs->left()) + " C ";
89
90 msg += "right: ";
91 msg += std::to_string(fbs->right()) + " C ";
92
93 msg += "cool-pwr: ";
94 msg += std::to_string(fbs->cooling()) + " mW ";
95
96 return msg;
97
98 }
99
100 static float ccd( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
101 {
102 auto fbs = GetOcam_temps_fb(msgBuffer);
103 return fbs->ccd();
104 }
105
106 static float cpu( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
107 {
108 auto fbs = GetOcam_temps_fb(msgBuffer);
109 return fbs->cpu();
110 }
111
112 static float power( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
113 {
114 auto fbs = GetOcam_temps_fb(msgBuffer);
115 return fbs->power();
116 }
117
118 static float bias( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
119 {
120 auto fbs = GetOcam_temps_fb(msgBuffer);
121 return fbs->bias();
122 }
123
124 static float water( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
125 {
126 auto fbs = GetOcam_temps_fb(msgBuffer);
127 return fbs->water();
128 }
129
130 static float left( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
131 {
132 auto fbs = GetOcam_temps_fb(msgBuffer);
133 return fbs->left();
134 }
135
136 static float right( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
137 {
138 auto fbs = GetOcam_temps_fb(msgBuffer);
139 return fbs->right();
140 }
141
142 static float cooling( void * msgBuffer /**< [in] Buffer containing the flatbuffer serialized message.*/ )
143 {
144 auto fbs = GetOcam_temps_fb(msgBuffer);
145 return fbs->cooling();
146 }
147
148 /// Get the logMetaDetail for a member by name
149 /**
150 * \returns the a logMetaDetail filled in with the appropriate details
151 * \returns an empty logMetaDetail if member not recognized
152 */
153 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
154 {
155 if( member == "ccd") return logMetaDetail({"CCD TEMP", "CCD temperature [C]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&ccd), false});
156 else if( member == "cpu") return logMetaDetail({"CPU TEMP", "CPU temperature [C]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&cpu), false});
157 else if( member == "power") return logMetaDetail({"PWR TEMP", "power temperature [C]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&power), false});
158 else if( member == "bias") return logMetaDetail({"BIAS TEMP", "bias temperature [C]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&bias), false});
159 else if( member == "water") return logMetaDetail({"WATER TEMP", "water temperature [C]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(water), false});
160 else if( member == "left") return logMetaDetail({"LEFT TEMP", "left temperature [C]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&left), false});
161 else if( member == "right") return logMetaDetail({"RIGHT TEMP", "right temperature [C]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&right), false});
162 else if( member == "cooling") return logMetaDetail({"COOLING PWR", "cooling power [mW]", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&cooling), false});
163 else
164 {
165 std::cerr << "No member " << member << " in ocam_temps\n";
166 return logMetaDetail();
167 }
168 }
169}; //ocam_temps
170
171
172
173} //namespace logger
174} //namespace MagAOX
175
176#endif //logger_types_ocam_temps_hpp
177
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 OCAM_TEMPS
Definition logCodes.hpp:29
bool VerifyOcam_temps_fbBuffer(::flatbuffers::Verifier &verifier)
const MagAOX::logger::Ocam_temps_fb * GetOcam_temps_fb(const void *buf)
inline ::flatbuffers::Offset< Ocam_temps_fb > CreateOcam_temps_fb(::flatbuffers::FlatBufferBuilder &_fbb, float ccd=0.0f, float cpu=0.0f, float power=0.0f, float bias=0.0f, float water=0.0f, float left=0.0f, float right=0.0f, float cooling=0.0f)
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 float &ccd, const float &cpu, const float &power, const float &bias, const float &water, const float &left, const float &right, const float &cooling)
Construct from components.
Log entry recording the build-time git state.
static const flatlogs::eventCodeT eventCode
The event code.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static float bias(void *msgBuffer)
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
static float ccd(void *msgBuffer)
static float water(void *msgBuffer)
static float right(void *msgBuffer)
static float left(void *msgBuffer)
static float power(void *msgBuffer)
static float cpu(void *msgBuffer)
static float cooling(void *msgBuffer)
static const flatlogs::logPrioT defaultLevel
The default level.