psu: Introduce the PowerSupply class

The Power Supply Manager (PSUManager) class will need a list of power
supplies to work with. Create these via the PowerSupply class.

Update Power Supply Manager to call the initialization function, and
update the power state.

Update clearFaults() to go through the list of power supplies and call
their individual clearFaults() functions.

Update the power supply manager analyze() function to go through the
list of power supplies and call their analyze() function.

Update the power supply manager updateInventory() function to call the
updateInventory() function in each power supply in the list.

Update the meson.build file to include the header files in the parent
directory, and link with the library containing the utility functions
the binary will need to use.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I743180d47f1b25d34c7e7001b64a6197905b86ff
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
new file mode 100644
index 0000000..54b20d8
--- /dev/null
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -0,0 +1,40 @@
+#include "psu_manager.hpp"
+
+#include "utility.hpp"
+
+namespace phosphor
+{
+namespace power
+{
+namespace manager
+{
+
+void PSUManager::powerStateChanged(sdbusplus::message::message& msg)
+{
+    int32_t state = 0;
+    std::string msgSensor;
+    std::map<std::string, sdbusplus::message::variant<int32_t>> msgData;
+    msg.read(msgSensor, msgData);
+
+    // Check if it was the Present property that changed.
+    auto valPropMap = msgData.find("state");
+    if (valPropMap != msgData.end())
+    {
+        state = std::get<int32_t>(valPropMap->second);
+
+        // Power is on when state=1. Clear faults.
+        if (state)
+        {
+            powerOn = true;
+            clearFaults();
+        }
+        else
+        {
+            powerOn = false;
+        }
+    }
+}
+
+} // namespace manager
+} // namespace power
+} // namespace phosphor