LCOV - code coverage report
Current view: top level - libMagAOX/logger/types - ocam_temps.hpp (source / functions) Coverage Total Hit
Test: MagAOX Lines: 30.2 % 63 19
Test Date: 2026-01-03 21:03:39 Functions: 25.0 % 12 3

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

Generated by: LCOV version 2.0-1