LCOV - code coverage report
Current view: top level - apps/trippLitePDU - trippLitePDU_simulator.hpp (source / functions) Coverage Total Hit
Test: MagAOX Lines: 0.0 % 50 0
Test Date: 2026-01-03 21:03:39 Functions: 0.0 % 7 0

            Line data    Source code
       1              : /** \file trippLitePDU_simulator.hpp
       2              :   * \brief The MagAO-X Tripp Lite Power Distribution Unit ontroller Simulator.
       3              :   *
       4              :   * \ingroup trippLitePDU_files
       5              :   */
       6              : 
       7              : #ifndef trippLitePDU_simulator_hpp
       8              : #define trippLitePDU_simulator_hpp
       9              : 
      10              : struct trippLitePDU_simulator
      11              : {
      12              :     float m_voltage {120};
      13              :     float m_frequency {60};
      14              :     float m_lowTransferVoltage {70};
      15              : 
      16              :     float m_current {4};
      17              : 
      18              :     std::vector<int> m_outlets;
      19              : 
      20            0 :     trippLitePDU_simulator()
      21            0 :     {
      22            0 :         m_outlets.resize(8,false);
      23            0 :     }
      24              : 
      25            0 :     int connect( const std::string & ipAddr,
      26              :                  const std::string & port
      27              :                )
      28              :     {
      29              :         static_cast<void>(ipAddr);
      30              :         static_cast<void>(port);
      31              : 
      32            0 :         return 0;
      33              :     }
      34              : 
      35            0 :     int login( const std::string & user,
      36              :                const std::string & pass
      37              :              )
      38              :     {
      39              :         static_cast<void>(user);
      40              :         static_cast<void>(pass);
      41              : 
      42            0 :         return 0;
      43              :     }
      44              : 
      45              : 
      46            0 :     void postLogin()
      47              :     {
      48            0 :     }
      49              : 
      50            0 :     int turnOutletOn( uint16_t outletNum )
      51              :     {
      52            0 :         if(outletNum >= m_outlets.size())
      53              :         {
      54            0 :             return -1;
      55              :         }
      56              : 
      57            0 :         m_outlets[outletNum] = 1;
      58              : 
      59            0 :         return 0;
      60              :     }
      61              : 
      62            0 :     int turnOutletOff( uint16_t outletNum )
      63              :     {
      64            0 :         if(outletNum >= m_outlets.size())
      65              :         {
      66            0 :             return -1;
      67              :         }
      68              : 
      69            0 :         m_outlets[outletNum] = 0;
      70              : 
      71            0 :         return 0;
      72              :     }
      73              : 
      74            0 :     int devStatus(std::string & strRead)
      75              :     {
      76              :         char vstr[64];
      77            0 :         snprintf(vstr, sizeof(vstr), "%0.1f", m_voltage);
      78              : 
      79              :         char fstr[64];
      80            0 :         snprintf(fstr, sizeof(fstr), "%0.1f", m_frequency);
      81              : 
      82              :         char tvstr[64];
      83            0 :         snprintf(tvstr, sizeof(tvstr), "%0.1f", m_lowTransferVoltage);
      84              : 
      85              :         char cstr[64];
      86            0 :         snprintf(cstr, sizeof(cstr), "%0.2f", m_current);
      87              : 
      88            0 :         strRead =  "-------------------------------------------------------------------------------\n";
      89            0 :         strRead += "01: PDUMH20NET2LX 'Device0062'\n";
      90            0 :         strRead += "--------------------------------------------------------------------------------\n";
      91            0 :         strRead += "Device Type:                    PDU\n";
      92            0 :         strRead += "Device Status:                  WARNING        !\n";
      93            0 :         strRead += "\n";
      94            0 :         strRead += "Input Voltage:                  " + std::string(vstr) + " V    \n"     ;
      95            0 :         strRead += "Input Frequency:                " + std::string(fstr) + " Hz       \n"  ;
      96            0 :         strRead += "Low Transfer Voltage:           " + std::string(tvstr) + " V          \n";
      97            0 :         strRead += "\n";
      98            0 :         strRead += "Output Current:                 " + std::string(cstr) + " A - Total  \n";
      99            0 :         strRead += "\n";
     100            0 :         strRead += "Outlets On:                     ";
     101              : 
     102              :         //Print outlet numbers of on-outlets, with no space at beginning or end.
     103            0 :         bool prev = false;
     104            0 :         bool none = true;
     105            0 :         for(size_t n=0; n < m_outlets.size(); ++n)
     106              :         {
     107            0 :             if(m_outlets[n])
     108              :             {
     109            0 :                 if(prev) strRead += " ";
     110            0 :                 strRead += std::to_string(n+1);
     111            0 :                 prev = true;
     112            0 :                 none = false;
     113              :             }
     114              :         }
     115            0 :         if(none)
     116              :         {
     117            0 :             strRead += "NONE";
     118              :         }
     119              : 
     120            0 :         strRead += "\n";
     121              : 
     122            0 :         return 0;
     123              :     }
     124              : };
     125              : 
     126              : 
     127              : #endif //trippLitePDU_simulator_hpp
        

Generated by: LCOV version 2.0-1