chassis-psu: New Functions for MultiChassis App

Implemented several functions for monitoring power supplies in
multi-chassis systems. Added a new main function, made minor
modification to the PowerSupply class, and added several functions to
the Chassis and ChassisManager classes.

The following is a summary of each object class new addition or modified
functions:

ChassisManager:
  - initChassisPowerMonitoring(): Loops through all the chassis in the
    system and initializes power monitoring process for each chassis's
    PSUs.

Chassis:
 - initPowerMonitoring(): Subscribe to D-Bus power change and initialize
   power monitoring.
 - supportedConfigurationInterfaceAdded(): Handle addition of supported
   configuration and update missing PSUs.
 - psuInterfaceAdded(): Handle addition of PSUs on D-Bus.
 - validatePsuConfigAndInterfacesProcessed(): Validate the PSU
   configuration and reset validation timer if power is on, supported
   configs and have PSUs.
 - analyzeBrownout(): Analyze PSUs for a brownout failure and log error.
 - syncHistory(): Toggles the GPIO to sync power supply input history
   readings.
 - setInputVoltageRating(): Inform each PSUs to set its PSU input.
 - createError(): Create OpenBMC error.
 - hasRequiredPSUs(): TODO
 - updateMissingPSUs(): Update PSU inventory.
 - getSupportedConfiguration(): Retrieve supported configuration from
   D-BUS and matches chassis ID with the  current chassis id to update
   chassis configuration.
 - saveChassisName(): Save chassis short name in the class.
 - powerStateChanged(): Handle for power state property changes.
 - attemptToCreatePowerConfigGPIO(): Attempt to create GPIO

 PowerSupply:
  - PowerSupply(): Added additional class constructors. The constructors
    have the same parameters as the original, except that the new
    constructor include an extra parameter chassis short name.
 - The PowerSupply class functions implementation remains the same as
   the original, except for minor change in
   PowerSupply::setupInputPowerPeakSensor(), where the sensorPath was
   modified to include chassis name.

Test in simulation:
  - Verified supported configuration added, where it polpulates
    supported properties and updates PSUs changes.
  - Validated some of the brownout functionality using fault injection.
  - Validated the PowerSupply class sets the appropriate input voltage
    for the target chassis PSUs.
  - Verified that the chassis name is included in the PSU power input
    peak sensors on D-bus.

Change-Id: I75a1ab1dd004767f072e35f3ce2c83ff281eb1ca
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/phosphor-power-supply/chassis_manager.cpp b/phosphor-power-supply/chassis_manager.cpp
index 710b5dc..db16ac2 100644
--- a/phosphor-power-supply/chassis_manager.cpp
+++ b/phosphor-power-supply/chassis_manager.cpp
@@ -3,6 +3,7 @@
 #include "chassis_manager.hpp"
 
 #include <phosphor-logging/lg2.hpp>
+
 using namespace phosphor::logging;
 
 namespace phosphor::power::chassis_manager
@@ -40,6 +41,7 @@
     auto interval = std::chrono::milliseconds(1000);
     timer = std::make_unique<utility::Timer<ClockId::Monotonic>>(
         e, std::bind(&ChassisManager::analyze, this), interval);
+    initChassisPowerMonitoring();
 }
 
 void ChassisManager::entityManagerIfaceAdded(sdbusplus::message_t& msg)
@@ -65,9 +67,8 @@
             {
                 lg2::debug("InterfacesAdded for: {SUPPORTED_CONFIGURATION}",
                            "SUPPORTED_CONFIGURATION", supportedConfIntf);
-                // Future implementation
-                // chassisMatchPtr->supportedConfigurationInterfaceAdded(
-                //     itInterface->second);
+                chassisMatchPtr->supportedConfigurationInterfaceAdded(
+                    itInterface->second);
             }
         }
         itInterface = interfaces.find(IBMCFFPSInterface);
@@ -81,16 +82,14 @@
             {
                 lg2::info("InterfacesAdded for: {IBMCFFPSINTERFACE}",
                           "IBMCFFPSINTERFACE", IBMCFFPSInterface);
-                // Future implementation
-                // chassisMatchPtr->psuInterfaceAdded(itInterface->second);
+                chassisMatchPtr->psuInterfaceAdded(itInterface->second);
             }
         }
         if (chassisMatchPtr != nullptr)
         {
             lg2::debug(
                 "InterfacesAdded validatePsuConfigAndInterfacesProcessed()");
-            // Future implementation
-            // chassisMatchPtr->validatePsuConfigAndInterfacesProcessed();
+            chassisMatchPtr->validatePsuConfigAndInterfacesProcessed();
         }
     }
     catch (const std::exception& e)
@@ -142,4 +141,13 @@
                    e);
     }
 }
+
+void ChassisManager::initChassisPowerMonitoring()
+{
+    for (const auto& chassis : listOfChassis)
+    {
+        chassis->initPowerMonitoring();
+    }
+}
+
 } // namespace phosphor::power::chassis_manager