API
trippLitePDU_simulator.hpp
Go to the documentation of this file.
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 
11 {
12  float m_voltage {120};
13  float m_frequency {60};
15 
16  float m_current {4};
17 
18  std::vector<int> m_outlets;
19 
21  {
22  m_outlets.resize(8,false);
23  }
24 
25  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  return 0;
33  }
34 
35  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  return 0;
43  }
44 
45 
46  void postLogin()
47  {
48  }
49 
50  int turnOutletOn( uint16_t outletNum )
51  {
52  if(outletNum >= m_outlets.size())
53  {
54  return -1;
55  }
56 
57  m_outlets[outletNum] = 1;
58 
59  return 0;
60  }
61 
62  int turnOutletOff( uint16_t outletNum )
63  {
64  if(outletNum >= m_outlets.size())
65  {
66  return -1;
67  }
68 
69  m_outlets[outletNum] = 0;
70 
71  return 0;
72  }
73 
74  int devStatus(std::string & strRead)
75  {
76  char vstr[64];
77  snprintf(vstr, sizeof(vstr), "%0.1f", m_voltage);
78 
79  char fstr[64];
80  snprintf(fstr, sizeof(fstr), "%0.1f", m_frequency);
81 
82  char tvstr[64];
83  snprintf(tvstr, sizeof(tvstr), "%0.1f", m_lowTransferVoltage);
84 
85  char cstr[64];
86  snprintf(cstr, sizeof(cstr), "%0.2f", m_current);
87 
88  strRead = "-------------------------------------------------------------------------------\n";
89  strRead += "01: PDUMH20NET2LX 'Device0062'\n";
90  strRead += "--------------------------------------------------------------------------------\n";
91  strRead += "Device Type: PDU\n";
92  strRead += "Device Status: WARNING !\n";
93  strRead += "\n";
94  strRead += "Input Voltage: " + std::string(vstr) + " V \n" ;
95  strRead += "Input Frequency: " + std::string(fstr) + " Hz \n" ;
96  strRead += "Low Transfer Voltage: " + std::string(tvstr) + " V \n";
97  strRead += "\n";
98  strRead += "Output Current: " + std::string(cstr) + " A - Total \n";
99  strRead += "\n";
100  strRead += "Outlets On: ";
101 
102  //Print outlet numbers of on-outlets, with no space at beginning or end.
103  bool prev = false;
104  bool none = true;
105  for(size_t n=0; n < m_outlets.size(); ++n)
106  {
107  if(m_outlets[n])
108  {
109  if(prev) strRead += " ";
110  strRead += std::to_string(n+1);
111  prev = true;
112  none = false;
113  }
114  }
115  if(none)
116  {
117  strRead += "NONE";
118  }
119 
120  strRead += "\n";
121 
122  return 0;
123  }
124 };
125 
126 
127 #endif //trippLitePDU_simulator_hpp
@ none
Don't publish.
int connect(const std::string &ipAddr, const std::string &port)
int devStatus(std::string &strRead)
int turnOutletOff(uint16_t outletNum)
int login(const std::string &user, const std::string &pass)
int turnOutletOn(uint16_t outletNum)