1 #include "psu_manager.hpp"
2 
3 #include "utility.hpp"
4 
5 namespace phosphor
6 {
7 namespace power
8 {
9 namespace manager
10 {
11 
12 void 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
41