psu-ng: Add Availability support to power supplies

Add support for determining if a power supply is considered 'available'
or not, and set the Available D-Bus property on the
xyz.openbmc_project.State.Decorator.Availability interface with the
result.

A power supply is considered unavailable if any of the following are
true:
 - it isn't present
 - there is a input fault active
 - there is a Vin UV fault active
 - there is a PS KILL fault active
 - there is a Iout OC fault active

The latter four faults are the faults where it can't provide good
output power, hence the PS is unavailable.  These faults also don't
call out the power supply directly, so the Functional property won't
get set to false, unlike other faults.

The Available D-Bus property is then able to be used in Redfish
responses for the heath and state properties in the power supply
schema.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I349eddb8c052cf238276c832af0dde9e49f6d3f0
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index b7459f5..c49039a 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -407,6 +407,23 @@
      */
     void getInputVoltage(double& actualInputVoltage, int& inputVoltage) const;
 
+    /**
+     * @brief Check if the PS is considered to be available or not
+     *
+     * It is unavailable if any of:
+     * - not present
+     * - input fault active
+     * - Vin UV fault active
+     * - PS KILL fault active
+     * - Iout OC fault active
+     *
+     * Other faults will, through creating error logs with callouts, already
+     * be setting the Functional property to false.
+     *
+     * On changes, the Available property is updated in the inventory.
+     */
+    void checkAvailability();
+
   private:
     /** @brief systemd bus member */
     sdbusplus::bus::bus& bus;
@@ -662,6 +679,13 @@
     std::string bindDevice;
 
     /**
+     * @brief The result of the most recent availability check
+     *
+     * Saved on the object so changes can be detected.
+     */
+    bool available = false;
+
+    /**
      * @brief Binds or unbinds the power supply device driver
      *
      * Called when a presence change is detected to either bind the device