regulators: Create DBusSensors class

Create the DBusSensors class.  This is a concrete implementation of the
Sensors abstract base class.  This class manages all the voltage
regulator sensors in the system.

Also add a lastUpdateTime data member to the DBusSensor class.  This
data member is set whenever the sensor is updated.  This enables the
DBusSensors class to detect sensors that were not updated during the
current monitoring cycle.

Sensors that were not updated during the current monitoring cycle are
deleted.  These sensors were likely produced by a hardware device that
was removed or replaced with a different version.

Tested:
* Ran through entire monitoring cycle multiple times
* Tested that lastUpdateTime is set correctly when a sensor is modified
  * Sensor value updated
  * Sensor disabled
  * Sensor put in error state
* Tested where new sensor was created
* Tested where existing sensor was updated
* Tested where all sensors disabled
* Tested where all sensors for a rail put in error state
* Tested where sensors removed due to not being updated this cycle
* Tested where D-Bus exception occurs when trying to create a sensor
* See complete test plan at
  https://gist.github.com/smccarney/69efb813c0005571aee687f67e489278

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ib1fc399f100188cc048ac3ab5892117b74f844e9
diff --git a/phosphor-regulators/src/dbus_sensor.hpp b/phosphor-regulators/src/dbus_sensor.hpp
index 4e39c34..1ac9b61 100644
--- a/phosphor-regulators/src/dbus_sensor.hpp
+++ b/phosphor-regulators/src/dbus_sensor.hpp
@@ -24,6 +24,7 @@
 #include <xyz/openbmc_project/State/Decorator/Availability/server.hpp>
 #include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp>
 
+#include <chrono>
 #include <memory>
 #include <string>
 #include <tuple>
@@ -107,6 +108,8 @@
     /**
      * Constructor.
      *
+     * Throws an exception if an error occurs.
+     *
      * @param bus D-Bus bus object
      * @param name sensor name
      * @param type sensor type
@@ -134,6 +137,16 @@
     void disable();
 
     /**
+     * Return the last time this sensor was updated.
+     *
+     * @return last update time
+     */
+    const std::chrono::system_clock::time_point& getLastUpdateTime() const
+    {
+        return lastUpdateTime;
+    }
+
+    /**
      * Return the sensor name.
      *
      * @return sensor name
@@ -277,6 +290,14 @@
                                 double& minValue, double& maxValue);
 
     /**
+     * Set the last time this sensor was updated.
+     */
+    void setLastUpdateTime()
+    {
+        lastUpdateTime = std::chrono::system_clock::now();
+    }
+
+    /**
      * Set the sensor value on D-Bus to NaN.
      */
     void setValueToNaN();
@@ -327,6 +348,11 @@
      * interfaces via templates and multiple inheritance.
      */
     std::unique_ptr<DBusSensorObject> dbusObject{};
+
+    /**
+     * Last time this sensor was updated.
+     */
+    std::chrono::system_clock::time_point lastUpdateTime{};
 };
 
 } // namespace phosphor::power::regulators