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/test/power_supply_tests.cpp b/phosphor-power-supply/test/power_supply_tests.cpp
index 07b4b9e..b028d56 100644
--- a/phosphor-power-supply/test/power_supply_tests.cpp
+++ b/phosphor-power-supply/test/power_supply_tests.cpp
@@ -50,7 +50,7 @@
     // Try where inventory path is empty, constructor should fail.
     try
     {
-        auto psu = std::make_unique<PowerSupply>(bus, "", 3, "0068");
+        auto psu = std::make_unique<PowerSupply>(bus, "", 3, 0x68);
         ADD_FAILURE() << "Should not have reached this line.";
     }
     catch (const std::invalid_argument& e)
@@ -68,7 +68,7 @@
         EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
             .Times(1);
         auto psu =
-            std::make_unique<PowerSupply>(bus, PSUInventoryPath, 3, "0068");
+            std::make_unique<PowerSupply>(bus, PSUInventoryPath, 3, 0x68);
 
         EXPECT_EQ(psu->isPresent(), false);
         EXPECT_EQ(psu->isFaulted(), false);
@@ -87,7 +87,7 @@
     auto bus = sdbusplus::bus::new_default();
 
     EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath))).Times(1);
-    PowerSupply psu{bus, PSUInventoryPath, 4, "0069"};
+    PowerSupply psu{bus, PSUInventoryPath, 4, 0x69};
     psu.analyze();
     // By default, nothing should change.
     EXPECT_EQ(psu.isPresent(), false);
@@ -101,7 +101,7 @@
     EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
         .Times(1)
         .WillOnce(Return(true)); // present
-    PowerSupply psu2{bus, PSUInventoryPath, 5, "006a"};
+    PowerSupply psu2{bus, PSUInventoryPath, 5, 0x6a};
     EXPECT_EQ(psu2.isPresent(), true);
 
     // STATUS_WORD 0x0000 is powered on, no faults.
@@ -193,7 +193,7 @@
         EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
             .Times(1)
             .WillOnce(Return(false));
-        PowerSupply psu{bus, PSUInventoryPath, 4, "0069"};
+        PowerSupply psu{bus, PSUInventoryPath, 4, 0x69};
         MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
         // If it is not present, I should not be trying to write to it.
         EXPECT_CALL(mockPMBus, writeBinary(_, _, _)).Times(0);
@@ -209,7 +209,7 @@
         EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
             .Times(1)
             .WillOnce(Return(true)); // present
-        PowerSupply psu{bus, PSUInventoryPath, 5, "006a"};
+        PowerSupply psu{bus, PSUInventoryPath, 5, 0x6a};
         MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
         // TODO: ???should I check the filename?
         EXPECT_CALL(mockPMBus,
@@ -228,7 +228,7 @@
     EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
         .Times(1)
         .WillOnce(Return(true)); // present
-    PowerSupply psu{bus, PSUInventoryPath, 13, "0068"};
+    PowerSupply psu{bus, PSUInventoryPath, 13, 0x68};
     EXPECT_EQ(psu.isPresent(), true);
     EXPECT_EQ(psu.isFaulted(), false);
     EXPECT_EQ(psu.hasInputFault(), false);
@@ -265,7 +265,7 @@
         EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
             .Times(1)
             .WillOnce(Return(false)); // missing
-        PowerSupply psu{bus, PSUInventoryPath, 3, "0068"};
+        PowerSupply psu{bus, PSUInventoryPath, 3, 0x68};
         MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
         // If it is not present, I should not be trying to read a string
         EXPECT_CALL(mockPMBus, readString(_, _)).Times(0);
@@ -281,7 +281,7 @@
         EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
             .Times(1)
             .WillOnce(Return(true)); // present
-        PowerSupply psu{bus, PSUInventoryPath, 13, "0069"};
+        PowerSupply psu{bus, PSUInventoryPath, 13, 0x69};
         MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
         EXPECT_CALL(mockPMBus, readString(_, _)).WillRepeatedly(Return(""));
         psu.updateInventory();
@@ -306,12 +306,12 @@
 {
     auto bus = sdbusplus::bus::new_default();
     EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath))).Times(1);
-    PowerSupply psu{bus, PSUInventoryPath, 3, "0068"};
+    PowerSupply psu{bus, PSUInventoryPath, 3, 0x68};
     EXPECT_EQ(psu.isPresent(), false);
 
     EXPECT_CALL(mockedUtil, getPresence(_, _))
         .WillOnce(Return(true)); // present
-    PowerSupply psu2{bus, PSUInventoryPath, 10, "006b"};
+    PowerSupply psu2{bus, PSUInventoryPath, 10, 0x6b};
     EXPECT_EQ(psu2.isPresent(), true);
 }
 
@@ -320,7 +320,7 @@
     auto bus = sdbusplus::bus::new_default();
     EXPECT_CALL(mockedUtil, getPresence(_, _))
         .WillOnce(Return(true)); // present
-    PowerSupply psu{bus, PSUInventoryPath, 11, "006f"};
+    PowerSupply psu{bus, PSUInventoryPath, 11, 0x6f};
     EXPECT_EQ(psu.isFaulted(), false);
     MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
     EXPECT_CALL(mockPMBus, read(_, _))
@@ -336,7 +336,7 @@
     auto bus = sdbusplus::bus::new_default();
     EXPECT_CALL(mockedUtil, getPresence(_, _))
         .WillOnce(Return(true)); // present
-    PowerSupply psu{bus, PSUInventoryPath, 3, "0068"};
+    PowerSupply psu{bus, PSUInventoryPath, 3, 0x68};
     MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
     EXPECT_EQ(psu.hasInputFault(), false);
     EXPECT_CALL(mockPMBus, read(_, _)).Times(1).WillOnce(Return(0x0000));
@@ -358,7 +358,7 @@
     auto bus = sdbusplus::bus::new_default();
     EXPECT_CALL(mockedUtil, getPresence(_, _))
         .WillOnce(Return(true)); // present
-    PowerSupply psu{bus, PSUInventoryPath, 3, "0068"};
+    PowerSupply psu{bus, PSUInventoryPath, 3, 0x68};
     MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
     EXPECT_EQ(psu.hasMFRFault(), false);
     EXPECT_CALL(mockPMBus, read(_, _)).Times(1).WillOnce(Return(0x0000));
@@ -380,7 +380,7 @@
     auto bus = sdbusplus::bus::new_default();
     EXPECT_CALL(mockedUtil, getPresence(_, _))
         .WillOnce(Return(true)); // present
-    PowerSupply psu{bus, PSUInventoryPath, 3, "0068"};
+    PowerSupply psu{bus, PSUInventoryPath, 3, 0x68};
     MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
     EXPECT_EQ(psu.hasVINUVFault(), false);
     EXPECT_CALL(mockPMBus, read(_, _)).Times(1).WillOnce(Return(0x0000));