API
 
Loading...
Searching...
No Matches
telem_coreloads.hpp
Go to the documentation of this file.
1/** \file telem_coreloads.hpp
2 * \brief The MagAO-X logger telem_coreloads log type.
3 * \author Chris Bohlman (cbohlmanaz@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 * History:
8 * - 2018-10-15 created by CJB
9 * - 2019-11-15 refactored by JRM
10 */
11#ifndef logger_types_telem_coreloads_hpp
12#define logger_types_telem_coreloads_hpp
13
14#include "generated/telem_coreloads_generated.h"
15#include "flatbuffer_log.hpp"
16
17namespace MagAOX
18{
19namespace logger
20{
21
22
23/// Log entry recording CPU loads.
24/** \ingroup logger_types
25 */
27{
28
29 static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_CORELOADS;
31
32 static timespec lastRecord; ///< The time of the last time this log was recorded. Used by the telemetry system.
33
34 ///The type of the input message
35 struct messageT : public fbMessage
36 {
37 ///Construct from components
38 messageT( std::vector<float> & cpu_core_loads )
39 {
40
41 auto _coreLoadsVec = builder.CreateVector(cpu_core_loads);
42
43 auto fp = CreateTelem_coreloads_fb(builder, _coreLoadsVec);
44
45 builder.Finish(fp);
46
47 }
48
49 };
50
51 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
52 flatlogs::msgLenT len ///< [in] length of msgBuffer.
53 )
54 {
55 auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
56 return VerifyTelem_coreloads_fbBuffer(verifier);
57 }
58
59 ///Get the message formatte for human consumption.
60 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
61 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
62 )
63 {
64
65 static_cast<void>(len); // unused by most log types
66
67 auto rgs = GetTelem_coreloads_fb(msgBuffer);
68
69 std::string msg;
70
71 if (rgs->loads() != nullptr)
72 {
73 msg+= "[cpu loads] ";
74 for(flatbuffers::Vector<float>::const_iterator it = rgs->loads()->begin(); it != rgs->loads()->end(); ++it)
75 {
76 msg+= std::to_string(*it);
77 msg+= " ";
78 }
79 }
80
81
82 return msg;
83
84 }
85
86}; //telem_coreloads
87
88
89
90} //namespace logger
91} //namespace MagAOX
92
93#endif //logger_types_telem_coreloads_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
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.
messageT(std::vector< float > &cpu_core_loads)
Construct from components.
Log entry recording CPU loads.
static const flatlogs::logPrioT defaultLevel
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 const flatlogs::eventCodeT eventCode
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)