control: Add zone increase & decrease timers

Add the increase and decrease timers to the JSON based zone objects to
handle target increase and decrease on their configured intervals.

Change-Id: I55f777b5f88b6fc05937c7acf91428e31c138b90
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/zone.hpp b/control/json/zone.hpp
index 5256018..e39a735 100644
--- a/control/json/zone.hpp
+++ b/control/json/zone.hpp
@@ -22,8 +22,10 @@
 #include <nlohmann/json.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdeventplus/event.hpp>
+#include <sdeventplus/utility/timer.hpp>
 
 #include <any>
+#include <chrono>
 #include <functional>
 #include <map>
 #include <tuple>
@@ -39,6 +41,9 @@
 using ThermalObject = sdbusplus::server::object::object<
     sdbusplus::xyz::openbmc_project::Control::server::ThermalMode>;
 
+/* Dbus event timer */
+using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
+
 /**
  * @class Zone - Represents a configured fan control zone
  *
@@ -236,6 +241,12 @@
     void requestIncrease(uint64_t targetDelta);
 
     /**
+     * @brief Callback function for the increase timer that delays
+     * processing of requested target increases while fans are increasing
+     */
+    void incTimerExpired();
+
+    /**
      * @brief Calculate the lowest requested decrease target from the given
      * delta within a decrease interval.
      *
@@ -244,6 +255,12 @@
     void requestDecrease(uint64_t targetDelta);
 
     /**
+     * @brief Callback function for the decrease timer that processes any
+     * requested target decreases if allowed
+     */
+    void decTimerExpired();
+
+    /**
      * @brief Set the requested target base to be used as the target to base a
      * new requested target from
      *
@@ -334,10 +351,10 @@
     uint64_t _defaultFloor;
 
     /* Zone's increase delay(in seconds) (OPTIONAL) */
-    uint64_t _incDelay;
+    std::chrono::seconds _incDelay;
 
     /* Zone's decrease interval(in seconds) */
-    uint64_t _decInterval;
+    std::chrono::seconds _decInterval;
 
     /* The floor target to not go below */
     uint64_t _floor;
@@ -369,6 +386,12 @@
     /* Automatic fan control active state */
     bool _isActive;
 
+    /* The target increase timer object */
+    Timer _incTimer;
+
+    /* The target decrease timer object */
+    Timer _decTimer;
+
     /* Map of active fan control allowed by a string identifier */
     std::map<std::string, bool> _active;