API
 
Loading...
Searching...
No Matches
outlet_state.hpp
Go to the documentation of this file.
1/** \file outlet_state.hpp
2 * \brief The MagAO-X logger outlet_state log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 * History:
8 * - 2018-08-18 created by JRM
9 */
10#ifndef logger_types_outlet_state_hpp
11#define logger_types_outlet_state_hpp
12
13#include "generated/outlet_state_generated.h"
14#include "flatbuffer_log.hpp"
15
16namespace MagAOX
17{
18namespace logger
19{
20
21
22///Application State Change
23/** \ingroup logger_types
24 */
26{
27 //The event code
28 static const flatlogs::eventCodeT eventCode = eventCodes::OUTLET_STATE;
29
30 //The default level
32
33 ///The type of the message
34 struct messageT : public fbMessage
35 {
36 messageT( uint8_t outlet,
37 uint8_t state
38 )
39 {
40 auto gs = CreateOutlet_state_fb(builder, outlet, state);
41 builder.Finish(gs);
42
43 }
44 };
45
46 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
47 flatlogs::msgLenT len ///< [in] length of msgBuffer.
48 )
49 {
50 auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
51 return VerifyOutlet_state_fbBuffer(verifier);
52 }
53
54 /// Format the message for text output, including translation of state codes to text form.
55 /**
56 * \returns the message formatted as "State changed from UNINITIALIZED to INITIALIZED"
57 */
58 static std::string msgString(void * msgBuffer, flatlogs::msgLenT len)
59 {
60 static_cast<void>(len);
61
62 auto rgs = GetOutlet_state_fb(msgBuffer);
63
64 std::stringstream s;
65 s << "Outlet: " << (int) rgs->outlet() << " ";
66
67 if(rgs->state()==2)
68 {
69 s << "ON";
70 }
71 else if(rgs->state()==1)
72 {
73 s << "INT";
74 }
75 else if(rgs->state()==0)
76 {
77 s << "OFF";
78 }
79 else s << "UNK";
80
81 return s.str();
82 }
83};
84
85} //namespace logger
86} //namespace MagAOX
87
88#endif //logger_types_outlet_state_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_INFO
Informational. The info log level is the lowest level recorded during normal operations.
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
messageT(uint8_t outlet, uint8_t state)
Application State Change.
static const flatlogs::eventCodeT eventCode
static const flatlogs::logPrioT defaultLevel
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Format the message for text output, including translation of state codes to text form.