summaryrefslogtreecommitdiffstats
path: root/control/zone.hpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-06-13 16:29:09 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-06-28 15:59:11 +0000
commite0ca13eb5b2feba044505e3234c8381d3ab03187 (patch)
tree01002dfa5a34d991477e3f3347b8c1e05457c5e8 /control/zone.hpp
parent618027abcf491b0b58f71bfe2b48c55dfb86462e (diff)
downloadphosphor-fan-presence-e0ca13eb5b2feba044505e3234c8381d3ab03187.tar.gz
phosphor-fan-presence-e0ca13eb5b2feba044505e3234c8381d3ab03187.zip
Enable setting/adjusting fan ceiling speed
Set the default ceiling to be what's given as full speed and adjust the ceiling speed based on an average of a given set of sensor values. The ceiling is chosen from a given map's key transition values. The map consists of key, value pairs where each key is the sensor value transition point and the value is the ceiling speed for when that transition occurs. The previous key value is needed to determine the direction in which to chose the appropriate ceiling speed allowing a buffer zone between ceiling changes if defined to. Resolves openbmc/openbmc#1628 Change-Id: I7c9c553b5d0c3219c51b563aec7dd5d5f090916b Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control/zone.hpp')
-rw-r--r--control/zone.hpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/control/zone.hpp b/control/zone.hpp
index 24739f8..fef3734 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -1,5 +1,6 @@
#pragma once
#include <vector>
+#include <algorithm>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
#include "fan.hpp"
@@ -133,6 +134,40 @@ class Zone
_floorSpeed = speed;
};
+ /**
+ * @brief Get the ceiling speed
+ *
+ * @return - The current ceiling speed
+ */
+ inline auto& getCeiling() const
+ {
+ return _ceilingSpeed;
+ };
+
+ /**
+ * @brief Set the ceiling speed to the given speed
+ *
+ * @param[in] speed - Speed to set the ceiling to
+ */
+ inline void setCeiling(uint64_t speed)
+ {
+ _ceilingSpeed = speed;
+ };
+
+ /**
+ * @brief Swaps the ceiling key value with what's given and
+ * returns the value that was swapped.
+ *
+ * @param[in] keyValue - New ceiling key value
+ *
+ * @return - Ceiling key value prior to swapping
+ */
+ inline auto swapCeilingKeyValue(int64_t keyValue)
+ {
+ std::swap(_ceilingKeyValue, keyValue);
+ return keyValue;
+ };
+
private:
/**
@@ -156,11 +191,26 @@ class Zone
const uint64_t _defFloorSpeed;
/**
+ * The default ceiling speed for the zone
+ */
+ const uint64_t _defCeilingSpeed;
+
+ /**
* The floor speed to not go below
*/
uint64_t _floorSpeed = _defFloorSpeed;
/**
+ * The ceiling speed to not go above
+ */
+ uint64_t _ceilingSpeed = _defCeilingSpeed;
+
+ /**
+ * The previous sensor value for calculating the ceiling
+ */
+ int64_t _ceilingKeyValue = 0;
+
+ /**
* Automatic fan control active state
*/
bool _isActive = true;
OpenPOWER on IntegriCloud