API
 
Loading...
Searching...
No Matches
cred2_temps.hpp
Go to the documentation of this file.
1/** \file cred2_temps.hpp
2 * \brief The MagAO-X logger cred2_temps log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 * History:
8 * - 2026-03-27 created by Codex
9 */
10#ifndef logger_types_cred2_temps_hpp
11#define logger_types_cred2_temps_hpp
12
14#include "flatbuffer_log.hpp"
15
16namespace MagAOX
17{
18namespace logger
19{
20
21/// Log entry recording the C-RED 2 detailed temperature channels.
22/** \ingroup logger_types
23 */
25{
26 /// The event code
28
29 /// The default level
31
32 static timespec lastRecord; ///< The timestamp of the last time this log was recorded. Used by telemetry.
33
34 /// The type of the input message
35 struct messageT : public fbMessage
36 {
37 /// Construct from components
38 messageT( const float &motherboard, ///< [in] motherboard temperature [C]
39 const float &frontend, ///< [in] front-end temperature [C]
40 const float &powerboard, ///< [in] power-board temperature [C]
41 const float &snake, ///< [in] detector temperature [C]
42 const float &setpoint, ///< [in] detector setpoint temperature [C]
43 const float &peltier, ///< [in] external TEC temperature [C]
44 const float &heatsink ///< [in] heatsink temperature [C]
45 )
46 {
47 auto fp =
49 builder.Finish( fp );
50 }
51 };
52
53 static bool verify( flatlogs::bufferPtrT &logBuff, ///< [in] buffer containing the flatbuffer serialized message
54 flatlogs::msgLenT len ///< [in] length of msgBuffer
55 )
56 {
57 auto verifier = flatbuffers::Verifier( static_cast<uint8_t *>( flatlogs::logHeader::messageBuffer( logBuff ) ),
58 static_cast<size_t>( len ) );
59 return VerifyCred2_temps_fbBuffer( verifier );
60 }
61
62 /// Get the message formatted for human consumption.
63 static std::string msgString( void *msgBuffer, /**< [in] buffer containing the flatbuffer serialized message */
64 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer */
65 )
66 {
67 static_cast<void>( len );
68
69 auto fbs = GetCred2_temps_fb( msgBuffer );
70
71 std::string msg = "mb: ";
72 msg += std::to_string( fbs->motherboard() ) + " C ";
73
74 msg += "fe: ";
75 msg += std::to_string( fbs->frontend() ) + " C ";
76
77 msg += "pwr: ";
78 msg += std::to_string( fbs->powerboard() ) + " C ";
79
80 msg += "snake: ";
81 msg += std::to_string( fbs->snake() ) + " C ";
82
83 msg += "setpt: ";
84 msg += std::to_string( fbs->setpoint() ) + " C ";
85
86 msg += "pelt: ";
87 msg += std::to_string( fbs->peltier() ) + " C ";
88
89 msg += "sink: ";
90 msg += std::to_string( fbs->heatsink() ) + " C ";
91
92 return msg;
93 }
94
95 static float motherboard( void *msgBuffer /**< [in] buffer containing the flatbuffer serialized message */ )
96 {
97 auto fbs = GetCred2_temps_fb( msgBuffer );
98 return fbs->motherboard();
99 }
100
101 static float frontend( void *msgBuffer /**< [in] buffer containing the flatbuffer serialized message */ )
102 {
103 auto fbs = GetCred2_temps_fb( msgBuffer );
104 return fbs->frontend();
105 }
106
107 static float powerboard( void *msgBuffer /**< [in] buffer containing the flatbuffer serialized message */ )
108 {
109 auto fbs = GetCred2_temps_fb( msgBuffer );
110 return fbs->powerboard();
111 }
112
113 static float snake( void *msgBuffer /**< [in] buffer containing the flatbuffer serialized message */ )
114 {
115 auto fbs = GetCred2_temps_fb( msgBuffer );
116 return fbs->snake();
117 }
118
119 static float setpoint( void *msgBuffer /**< [in] buffer containing the flatbuffer serialized message */ )
120 {
121 auto fbs = GetCred2_temps_fb( msgBuffer );
122 return fbs->setpoint();
123 }
124
125 static float peltier( void *msgBuffer /**< [in] buffer containing the flatbuffer serialized message */ )
126 {
127 auto fbs = GetCred2_temps_fb( msgBuffer );
128 return fbs->peltier();
129 }
130
131 static float heatsink( void *msgBuffer /**< [in] buffer containing the flatbuffer serialized message */ )
132 {
133 auto fbs = GetCred2_temps_fb( msgBuffer );
134 return fbs->heatsink();
135 }
136
137 /// Get the logMetaDetail for a member by name.
138 /**
139 * \returns a logMetaDetail filled in with the appropriate details
140 * \returns an empty logMetaDetail if member not recognized
141 */
142 static logMetaDetail getAccessor( const std::string &member /**< [in] the name of the member */ )
143 {
144 if( member == "motherboard" )
145 return logMetaDetail( { "MB TEMP",
146 "motherboard temperature [C]",
149 reinterpret_cast<void *>( &motherboard ),
150 false } );
151 else if( member == "frontend" )
152 return logMetaDetail( { "FE TEMP",
153 "front-end temperature [C]",
156 reinterpret_cast<void *>( &frontend ),
157 false } );
158 else if( member == "powerboard" )
159 return logMetaDetail( { "PWR TEMP",
160 "power-board temperature [C]",
163 reinterpret_cast<void *>( &powerboard ),
164 false } );
165 else if( member == "snake" )
166 return logMetaDetail( { "SNAKE TEMP",
167 "detector temperature [C]",
170 reinterpret_cast<void *>( &snake ),
171 false } );
172 else if( member == "setpoint" )
173 return logMetaDetail( { "SET TEMP",
174 "detector setpoint temperature [C]",
177 reinterpret_cast<void *>( &setpoint ),
178 false } );
179 else if( member == "peltier" )
180 return logMetaDetail( { "PELTIER TEMP",
181 "external TEC temperature [C]",
184 reinterpret_cast<void *>( &peltier ),
185 false } );
186 else if( member == "heatsink" )
187 return logMetaDetail( { "SINK TEMP",
188 "heatsink temperature [C]",
191 reinterpret_cast<void *>( &heatsink ),
192 false } );
193 else
194 {
195 std::cerr << "No member " << member << " in cred2_temps\n";
196 return logMetaDetail();
197 }
198 }
199};
200
201} // namespace logger
202} // namespace MagAOX
203
204#endif // logger_types_cred2_temps_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 CRED2_TEMPS
Definition logCodes.hpp:30
bool VerifyCred2_temps_fbBuffer(::flatbuffers::Verifier &verifier)
inline ::flatbuffers::Offset< Cred2_temps_fb > CreateCred2_temps_fb(::flatbuffers::FlatBufferBuilder &_fbb, float motherboard=0.0f, float frontend=0.0f, float powerboard=0.0f, float snake=0.0f, float setpoint=0.0f, float peltier=0.0f, float heatsink=0.0f)
const MagAOX::logger::Cred2_temps_fb * GetCred2_temps_fb(const void *buf)
Definition dm.hpp:19
static constexpr logPrioT LOG_TELEM
A telemetry recording.
The type of the input message.
messageT(const float &motherboard, const float &frontend, const float &powerboard, const float &snake, const float &setpoint, const float &peltier, const float &heatsink)
Construct from components.
Log entry recording the C-RED 2 detailed temperature channels.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
static float powerboard(void *msgBuffer)
static timespec lastRecord
The timestamp of the last time this log was recorded. Used by telemetry.
static float peltier(void *msgBuffer)
static float setpoint(void *msgBuffer)
static float heatsink(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
The event code.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static float motherboard(void *msgBuffer)
static float frontend(void *msgBuffer)
static float snake(void *msgBuffer)
static const flatlogs::logPrioT defaultLevel
The default level.
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.