Add sensor reading timer

Added timer for reading sensor at regular interval defined for each
sensor in configuration file.

Tested: Verified this by running following busctrl command and checked
value as it is changing regularly.
busctl introspect --no-page xyz.openbmc_project.HealthMon
/xyz/openbmc_project/sensors/utilization/CPU
busctl introspect --no-page xyz.openbmc_project.HealthMon
/xyz/openbmc_project/sensors/utilization/Memory

Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Change-Id: I7da085e24b68c0b9f9bf1c13c567024c69f65d70
diff --git a/healthMonitor.cpp b/healthMonitor.cpp
index af69ecb..42bf77d 100644
--- a/healthMonitor.cpp
+++ b/healthMonitor.cpp
@@ -168,6 +168,34 @@
         valQueue.push_back(value);
     }
     setSensorValueToDbus(value);
+
+    /* Start the timer for reading sensor data at regular interval */
+    readTimer.restart(std::chrono::milliseconds(sensorConfig.freq * 1000));
+}
+
+void HealthSensor::readHealthSensor()
+{
+    /* Read current sensor value */
+    double value = readSensors[sensorConfig.name]();
+    if (value < 0)
+    {
+        log<level::ERR>("Reading Sensor Utilization failed",
+                        entry("NAME = %s", sensorConfig.name.c_str()));
+        return;
+    }
+
+    /* Remove first item from the queue */
+    valQueue.pop_front();
+    /* Add new item at the back */
+    valQueue.push_back(value);
+
+    /* Calculate average values for the given window size */
+    double avgValue = 0;
+    avgValue = accumulate(valQueue.begin(), valQueue.end(), avgValue);
+    avgValue = avgValue / sensorConfig.windowSize;
+
+    /* Set this new value to dbus */
+    setSensorValueToDbus(avgValue);
 }
 
 void printConfig(HealthConfig& cfg)
diff --git a/healthMonitor.hpp b/healthMonitor.hpp
index e8230fa..09f5539 100644
--- a/healthMonitor.hpp
+++ b/healthMonitor.hpp
@@ -1,6 +1,8 @@
 #include <nlohmann/json.hpp>
 #include <sdbusplus/bus.hpp>
+#include <sdeventplus/clock.hpp>
 #include <sdeventplus/event.hpp>
+#include <sdeventplus/utility/timer.hpp>
 #include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
 #include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
 #include <xyz/openbmc_project/Sensor/Value/server.hpp>
@@ -58,7 +60,9 @@
     HealthSensor(sdbusplus::bus::bus& bus, const char* objPath,
                  HealthConfig& sensorConfig) :
         healthIfaces(bus, objPath),
-        bus(bus), sensorConfig(sensorConfig)
+        bus(bus), sensorConfig(sensorConfig),
+        timerEvent(sdeventplus::Event::get_default()),
+        readTimer(timerEvent, std::bind(&HealthSensor::readHealthSensor, this))
     {
         initHealthSensor();
     }
@@ -73,8 +77,17 @@
     void setSensorThreshold(double criticalHigh, double warningHigh);
 
   private:
+    /** @brief sdbusplus bus client connection. */
     sdbusplus::bus::bus& bus;
+    /** @brief Sensor config from config file */
     HealthConfig& sensorConfig;
+    /** @brief the Event Loop structure */
+    sdeventplus::Event timerEvent;
+    /** @brief Sensor Read Timer */
+    sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> readTimer;
+
+    /** @brief Read sensor at regular intrval */
+    void readHealthSensor();
 };
 
 class HealthMon