control: Fill in `requestIncrease` method

Copy over the functionality from the `requestSpeedIncrease` method in
YAML based zone object to the JSON based zone object. Currently not able
to complete setting a new target or restarting the timer used when
requested a target increase, so those will be finalized in a follow-up
commit.

Change-Id: I26bdfe07f4187135612769d0e7e261b2c5272a63
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/zone.cpp b/control/json/zone.cpp
index 6054721..3c3f0b3 100644
--- a/control/json/zone.cpp
+++ b/control/json/zone.cpp
@@ -51,7 +51,7 @@
 Zone::Zone(sdbusplus::bus::bus& bus, const json& jsonObj) :
     ConfigBase(jsonObj),
     ThermalObject(bus, (fs::path{CONTROL_OBJPATH} /= getName()).c_str(), true),
-    _incDelay(0), _floor(0), _target(0)
+    _incDelay(0), _floor(0), _target(0), _incDelta(0), _requestTargetBase(0)
 {
     if (jsonObj.contains("profiles"))
     {
@@ -97,7 +97,23 @@
 
 void Zone::requestIncrease(uint64_t targetDelta)
 {
-    // TODO Add from `requestSpeedIncrease` method in YAML zone object
+    // Only increase when delta is higher than the current increase delta for
+    // the zone and currently under ceiling
+    if (targetDelta > _incDelta && _target < _ceiling)
+    {
+        auto requestTarget = getRequestTargetBase();
+        requestTarget = (targetDelta - _incDelta) + requestTarget;
+        _incDelta = targetDelta;
+        // Target can not go above a current ceiling
+        if (requestTarget > _ceiling)
+        {
+            requestTarget = _ceiling;
+        }
+        // TODO Set target and handle increase timer
+        // setTarget(requestTarget);
+        // // Restart timer countdown for fan speed increase
+        // _incTimer.restartOnce(_incDelay);
+    }
 }
 
 void Zone::setPersisted(const std::string& intf, const std::string& prop)
@@ -154,6 +170,8 @@
     _defaultCeiling = jsonObj["full_speed"].get<uint64_t>();
     // Start with the current target set as the default
     _target = _defaultCeiling;
+    // Start with the current ceiling set as the default
+    _ceiling = _defaultCeiling;
 }
 
 void Zone::setDefaultFloor(const json& jsonObj)
diff --git a/control/json/zone.hpp b/control/json/zone.hpp
index e9e51ae..6f80aa5 100644
--- a/control/json/zone.hpp
+++ b/control/json/zone.hpp
@@ -227,6 +227,15 @@
     /* Target for this zone */
     uint64_t _target;
 
+    /* Zone increase delta */
+    uint64_t _incDelta;
+
+    /* The ceiling target to not go above */
+    uint64_t _ceiling;
+
+    /* Requested target base */
+    uint64_t _requestTargetBase;
+
     /* Map of whether floor changes are allowed by a string identifier */
     std::map<std::string, bool> _floorChange;
 
@@ -303,6 +312,17 @@
      * storage
      */
     void saveCurrentMode();
+
+    /**
+     * @brief Get the request target base if defined, otherwise the the current
+     * target is returned
+     *
+     * @return - The request target base or current target
+     */
+    inline auto getRequestTargetBase() const
+    {
+        return (_requestTargetBase != 0) ? _requestTargetBase : _target;
+    };
 };
 
 /**