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)