LCOV - code coverage report
Current view: top level - libMagAOX/logger/types - telem_drivetemps.hpp (source / functions) Coverage Total Hit
Test: MagAOX Lines: 50.0 % 26 13
Test Date: 2026-01-03 21:03:39 Functions: 75.0 % 4 3

            Line data    Source code
       1              : /** \file telem_drivetemps.hpp
       2              :   * \brief The MagAO-X logger telem_drivetemps 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              :   */
      10              : #ifndef logger_types_telem_drivetemps_hpp
      11              : #define logger_types_telem_drivetemps_hpp
      12              : 
      13              : #include "generated/telem_drivetemps_generated.h"
      14              : #include "flatbuffer_log.hpp"
      15              : 
      16              : namespace MagAOX
      17              : {
      18              : namespace logger
      19              : {
      20              : 
      21              : 
      22              : /// Log entry recording hdd temperatures
      23              : /** \ingroup logger_types
      24              :   */
      25              : struct telem_drivetemps : public flatbuffer_log
      26              : {
      27              : 
      28              :   static const flatlogs::eventCodeT eventCode = eventCodes::TELEM_DRIVETEMPS;
      29              :   static const flatlogs::logPrioT defaultLevel = flatlogs::logPrio::LOG_TELEM;
      30              : 
      31              :   static timespec lastRecord; ///< The time of the last time this log was recorded.  Used by the telemetry system.
      32              : 
      33              :    ///The type of the input message
      34              :    struct messageT : public fbMessage
      35              :    {
      36              :       ///Construct from components
      37            1 :       messageT( std::vector<std::string> & names,
      38              :                 std::vector<float> & temps )
      39            1 :       {
      40              : 
      41            1 :          auto _namesVec = builder.CreateVectorOfStrings(names);
      42            1 :          auto _tempsVec = builder.CreateVector(temps);
      43              : 
      44            1 :          auto fp = CreateTelem_drivetemps_fb(builder, _namesVec, _tempsVec );
      45              : 
      46            1 :          builder.Finish(fp);
      47              : 
      48            1 :       }
      49              : 
      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_drivetemps_fbBuffer(verifier);
      58              :    }
      59              : 
      60              :    ///Get the message formatted 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              : 
      66              :       static_cast<void>(len); // unused by most log types
      67              : 
      68            0 :       auto rgs = GetTelem_drivetemps_fb(msgBuffer);
      69              : 
      70            0 :       std::string msg;
      71              : 
      72            0 :       if(rgs->diskName() != nullptr && rgs->diskTemp() != nullptr)
      73              :       {
      74            0 :          msg+= "[hdd temps] ";
      75              : 
      76            0 :          int i=0;
      77            0 :          for(flatbuffers::Vector<float>::const_iterator it = rgs->diskTemp()->begin(); it != rgs->diskTemp()->end(); ++it, ++i)
      78              :          {
      79            0 :             msg += rgs->diskName()->GetAsString(i)->c_str();
      80            0 :             msg += ":";
      81            0 :             msg+= std::to_string(*it);
      82            0 :             msg+= "C ";
      83              :          }
      84              :       }
      85              : 
      86            0 :       return msg;
      87              : 
      88            0 :    }
      89              : 
      90              :    /// Get the logMetaDetail for a member by name
      91              :    /**
      92              :      * \returns the a logMetaDetail filled in with the appropriate details
      93              :      * \returns an empty logMetaDetail if member not recognized
      94              :      */
      95            1 :    static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
      96              :    {
      97              :       static_cast<void>(member);
      98            1 :       std::cerr << "Meta data accessor not implemented in telem_drivetemps\n";
      99            1 :       return logMetaDetail();
     100              :   }
     101              : 
     102              : }; //telem_drivetemps
     103              : 
     104              : 
     105              : 
     106              : } //namespace logger
     107              : } //namespace MagAOX
     108              : 
     109              : #endif //logger_types_telem_drivetemps_hpp
        

Generated by: LCOV version 2.0-1