psu-ng: Add method to get PSU conf from D-Bus.

Add a getPSUProperties method that will get the power supply unit
configuration information from the D-Bus properties populated by
entity-manager. The IBM common form factor power supplies will have
these properties under the interface called
xyz.openbmc_project.Configuration.IBMCFFPSConnector. See
I45b724238cffe6fb7f1f8f9947fa1c2c9e9e8015 for changes to add the
necessary updates to entity-manager.

The D-Bus property for I2CAddress is a uint64_t type, while the JSON
configuration file had a string. Move the PowerSupply constructor to the
cpp file, updated to take in uint16_t for the i2caddr.

Update PSUManager::getJSONProperties() to convert Address from string to
uint16_t.

Add in a PSUManager constructor to use the getPSUProperties() function.

Add code to handle interfacesAdded from entity-manager prior to
getPSUProperties() or getSystemProperties().

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I553e8982cf008828823cea2c0f017ff23c9070ab
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 63697f4..cedc184 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -19,6 +19,39 @@
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Device::Error;
 
+PowerSupply::PowerSupply(sdbusplus::bus::bus& bus, const std::string& invpath,
+                         std::uint8_t i2cbus, std::uint16_t i2caddr) :
+    bus(bus),
+    inventoryPath(invpath)
+{
+    if (inventoryPath.empty())
+    {
+        throw std::invalid_argument{"Invalid empty inventoryPath"};
+    }
+
+    // Setup the functions to call when the D-Bus inventory path for the
+    // Present property changes.
+    presentMatch = std::make_unique<sdbusplus::bus::match_t>(
+        bus,
+        sdbusplus::bus::match::rules::propertiesChanged(inventoryPath,
+                                                        INVENTORY_IFACE),
+        [this](auto& msg) { this->inventoryChanged(msg); });
+
+    presentAddedMatch = std::make_unique<sdbusplus::bus::match_t>(
+        bus,
+        sdbusplus::bus::match::rules::interfacesAdded() +
+            sdbusplus::bus::match::rules::argNpath(0, inventoryPath),
+        [this](auto& msg) { this->inventoryAdded(msg); });
+
+    std::ostringstream ss;
+    ss << std::hex << std::setw(4) << std::setfill('0') << i2caddr;
+    std::string addrStr = ss.str();
+    pmbusIntf = phosphor::pmbus::createPMBus(i2cbus, addrStr);
+
+    // Get the current state of the Present property.
+    updatePresence();
+}
+
 void PowerSupply::updatePresence()
 {
     try