LCOV - code coverage report
Current view: top level - libMagAOX/logger/types - telem_pi335.hpp (source / functions) Coverage Total Hit
Test: MagAOX Lines: 25.3 % 79 20
Test Date: 2026-01-03 21:03:39 Functions: 23.1 % 13 3

            Line data    Source code
       1              : /** \file telem_pi335.hpp
       2              :  * \brief The MagAO-X logger telem_pi335 log type.
       3              :  * \author Jared R. Males (jaredmales@gmail.com)
       4              :  *
       5              :  * \ingroup logger_types_files
       6              :  *
       7              :  */
       8              : #ifndef logger_types_telem_pi335_hpp
       9              : #define logger_types_telem_pi335_hpp
      10              : 
      11              : #include "generated/telem_pi335_generated.h"
      12              : #include "flatbuffer_log.hpp"
      13              : 
      14              : namespace MagAOX
      15              : {
      16              : namespace logger
      17              : {
      18              : 
      19              : /// Log entry recording the build-time git state.
      20              : /** \ingroup logger_types
      21              :  */
      22              : struct telem_pi335 : public flatbuffer_log
      23              : {
      24              :     /// The event code
      25              :     static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_PI335;
      26              : 
      27              :     /// The default level
      28              :     static const flatlogs::logPrioT defaultLevel = flatlogs::logPrio::LOG_TELEM;
      29              : 
      30              :     static timespec lastRecord; ///< The time of the last time this log was recorded.  Used by the telemetry system.
      31              : 
      32              :     /// The type of the input message
      33              :     struct messageT : public fbMessage
      34              :     {
      35              :         /// Construct from components
      36            1 :         messageT( const float & pos1Set, ///< [in]
      37              :                   const float & pos1,    ///< [in]
      38              :                   const float & sva1,    ///< [in]
      39              :                   const float & pos2Set, ///< [in]
      40              :                   const float & pos2,    ///< [in]
      41              :                   const float & sva2,    ///< [in]
      42              :                   const float & pos3Set, ///< [in]
      43              :                   const float & pos3,    ///< [in]
      44              :                   const float & sva3     ///< [in]
      45              :         )
      46            1 :         {
      47            1 :             auto fp = CreateTelem_pi335_fb(builder, pos1Set, pos1, sva1, pos2Set, pos2, sva2, pos3Set, pos3, sva3);
      48            1 :             builder.Finish(fp);
      49            1 :         }
      50              :     };
      51              : 
      52            1 :     static bool verify(flatlogs::bufferPtrT &logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
      53              :                        flatlogs::msgLenT len          ///< [in] length of msgBuffer.
      54              :     )
      55              :     {
      56            1 :         auto verifier = flatbuffers::Verifier(static_cast<uint8_t *>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
      57            2 :         return VerifyTelem_pi335_fbBuffer(verifier);
      58              :     }
      59              : 
      60              :     /// Get the message formatte for human consumption.
      61            0 :     static std::string msgString(void *msgBuffer,      /**< [in] Buffer containing the flatbuffer serialized message.*/
      62              :                                  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
      63              :     )
      64              :     {
      65              :         static_cast<void>(len);
      66              : 
      67            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
      68              : 
      69            0 :         std::string msg = "[pi335] ";
      70              : 
      71            0 :         msg += "pos1Set: ";
      72            0 :         msg += std::to_string(fbs->pos1Set()) + " ";
      73              : 
      74            0 :         msg += "pos1: ";
      75            0 :         msg += std::to_string(fbs->pos1()) + " ";
      76              : 
      77            0 :         msg += "sva1: ";
      78            0 :         msg += std::to_string(fbs->sva1()) + " ";
      79              : 
      80            0 :         msg += "pos2Set: ";
      81            0 :         msg += std::to_string(fbs->pos2Set()) + " ";
      82              : 
      83            0 :         msg += "pos2: ";
      84            0 :         msg += std::to_string(fbs->pos2()) + " ";
      85              : 
      86            0 :         msg += "sva2: ";
      87            0 :         msg += std::to_string(fbs->sva2()) + " ";
      88              : 
      89            0 :         msg += "pos3Set: ";
      90            0 :         msg += std::to_string(fbs->pos3Set()) + " ";
      91              : 
      92            0 :         msg += "pos3: ";
      93            0 :         msg += std::to_string(fbs->pos3()) + " ";
      94              : 
      95            0 :         msg += "sva3: ";
      96            0 :         msg += std::to_string(fbs->sva3());
      97              : 
      98            0 :         return msg;
      99            0 :     }
     100              : 
     101            0 :     static float pos1Set(void *msgBuffer)
     102              :     {
     103            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     104            0 :         return fbs->pos1Set();
     105              :     }
     106              : 
     107            0 :     static float pos1(void *msgBuffer)
     108              :     {
     109            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     110            0 :         return fbs->pos1();
     111              :     }
     112              : 
     113            0 :     static float sva1(void *msgBuffer)
     114              :     {
     115            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     116            0 :         return fbs->sva1();
     117              :     }
     118              : 
     119            0 :     static float pos2Set(void *msgBuffer)
     120              :     {
     121            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     122            0 :         return fbs->pos2Set();
     123              :     }
     124              : 
     125            0 :     static float pos2(void *msgBuffer)
     126              :     {
     127            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     128            0 :         return fbs->pos2();
     129              :     }
     130              : 
     131            0 :     static float sva2(void *msgBuffer)
     132              :     {
     133            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     134            0 :         return fbs->sva2();
     135              :     }
     136              : 
     137            0 :     static float pos3Set(void *msgBuffer)
     138              :     {
     139            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     140            0 :         return fbs->pos3Set();
     141              :     }
     142              : 
     143            0 :     static float pos3(void *msgBuffer)
     144              :     {
     145            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     146            0 :         return fbs->pos3();
     147              :     }
     148              : 
     149            0 :     static float sva3(void *msgBuffer)
     150              :     {
     151            0 :         auto fbs = GetTelem_pi335_fb(msgBuffer);
     152            0 :         return fbs->sva3();
     153              :     }
     154              : 
     155              :     /// Get the logMetaDetail for a member by name
     156              :     /**
     157              :      * \returns the a logMetaDetail filled in with the appropriate details
     158              :      * \returns an empty logMetaDetail if member not recognized
     159              :      */
     160            1 :     static logMetaDetail getAccessor(const std::string &member /**< [in] the name of the member */)
     161              :     {
     162            1 :         if (member == "pos1Set")
     163            0 :             return logMetaDetail({"POS1 SETPT", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos1Set)});
     164            1 :         else if (member == "pos1")
     165            0 :             return logMetaDetail({"POS1", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos1)});
     166            1 :         else if (member == "sva1")
     167            0 :             return logMetaDetail({"SVA1", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&sva1)});
     168            1 :         else if (member == "pos2Set")
     169            0 :             return logMetaDetail({"POS2 SETPT", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos2Set)});
     170            1 :         else if (member == "pos2")
     171            0 :             return logMetaDetail({"POS2", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos2)});
     172            1 :         else if (member == "sva2")
     173            0 :             return logMetaDetail({"SVA2", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&sva2)});
     174            1 :         else if (member == "pos3Set")
     175            0 :             return logMetaDetail({"POS3 SETPT", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos3Set)});
     176            1 :         else if (member == "pos3")
     177            0 :             return logMetaDetail({"POS3", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&pos3)});
     178            1 :         else if (member == "sva3")
     179            0 :             return logMetaDetail({"SVA3", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void *>(&sva3)});
     180              :         else
     181              :         {
     182            1 :             std::cerr << "No member " << member << " in telem_pi335\n";
     183            1 :             return logMetaDetail();
     184              :         }
     185              :     }
     186              : 
     187              : }; // telem_pi335
     188              : 
     189              : } // namespace logger
     190              : } // namespace MagAOX
     191              : 
     192              : #endif // logger_types_telem_pi335_hpp
        

Generated by: LCOV version 2.0-1