blob: 54b20d838961bdcef623b264d686184bfe9d4c60 [file] [log] [blame]
Brandon Wymana0f33ce2019-10-17 18:32:29 -05001#include "psu_manager.hpp"
2
3#include "utility.hpp"
4
5namespace phosphor
6{
7namespace power
8{
9namespace manager
10{
11
12void PSUManager::powerStateChanged(sdbusplus::message::message& msg)
13{
14 int32_t state = 0;
15 std::string msgSensor;
16 std::map<std::string, sdbusplus::message::variant<int32_t>> msgData;
17 msg.read(msgSensor, msgData);
18
19 // Check if it was the Present property that changed.
20 auto valPropMap = msgData.find("state");
21 if (valPropMap != msgData.end())
22 {
23 state = std::get<int32_t>(valPropMap->second);
24
25 // Power is on when state=1. Clear faults.
26 if (state)
27 {
28 powerOn = true;
29 clearFaults();
30 }
31 else
32 {
33 powerOn = false;
34 }
35 }
36}
37
38} // namespace manager
39} // namespace power
40} // namespace phosphor