pseq: Add setPowerSupplyError D-Bus method

Add a setPowerSupplyError method to the org.openbmc.control.Power
D-Bus interface.  When a power supply error is detected which is severe
enough to cause a power good failure, that error should be used in
preference to the power good error. Add a D-Bus method to allow this to
be communicated between the applications.  The parameter passed should
be the power supply error to log, for example
"xyz.openbmc_project.Power.PowerSupply.Error.PSKillFault".

Signed-off-by: Jim Wright <jlwright@us.ibm.com>
Change-Id: I8500ace4638236dda2d7ff4361b61efa30a50ac1
diff --git a/phosphor-power-sequencer/src/power_control.cpp b/phosphor-power-sequencer/src/power_control.cpp
index aa47598..9e8b1b4 100644
--- a/phosphor-power-sequencer/src/power_control.cpp
+++ b/phosphor-power-sequencer/src/power_control.cpp
@@ -44,21 +44,17 @@
 PowerControl::PowerControl(sdbusplus::bus::bus& bus,
                            const sdeventplus::Event& event) :
     PowerObject{bus, POWER_OBJ_PATH, true},
-    bus{bus}, timer{event, std::bind(&PowerControl::pollPgood, this),
-                    pollInterval}
+    bus{bus}, match{bus,
+                    sdbusplus::bus::match::rules::interfacesAdded() +
+                        sdbusplus::bus::match::rules::sender(
+                            "xyz.openbmc_project.EntityManager"),
+                    std::bind(&PowerControl::interfacesAddedHandler, this,
+                              std::placeholders::_1)},
+    timer{event, std::bind(&PowerControl::pollPgood, this), pollInterval}
 {
     // Obtain dbus service name
     bus.request_name(POWER_IFACE);
 
-    // Subscribe to D-Bus interfacesAdded signal from Entity Manager.  This
-    // notifies us if the interface becomes available later.
-    match = std::make_unique<sdbusplus::bus::match_t>(
-        bus,
-        sdbusplus::bus::match::rules::interfacesAdded() +
-            sdbusplus::bus::match::rules::sender(
-                "xyz.openbmc_project.EntityManager"),
-        std::bind(&PowerControl::interfacesAddedHandler, this,
-                  std::placeholders::_1));
     setUpDevice();
     setUpGpio();
 }
@@ -100,6 +96,7 @@
                 .c_str());
         // Create device object
         device = std::make_unique<UCD90320Monitor>(bus, *i2cBus, *i2cAddress);
+        deviceFound = true;
     }
 }
 
@@ -120,8 +117,8 @@
 
 void PowerControl::interfacesAddedHandler(sdbusplus::message::message& msg)
 {
-    // Verify message is valid
-    if (!msg)
+    // Only continue if message is valid and device has not already been found
+    if (!msg || deviceFound)
     {
         return;
     }
@@ -236,6 +233,11 @@
     }
 }
 
+void PowerControl::setPowerSupplyError(const std::string& error)
+{
+    powerSupplyError = error;
+}
+
 void PowerControl::setState(int s)
 {
     if (state == s)