summaryrefslogtreecommitdiffstats
path: root/control
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-06-21 14:09:57 -0500
committerMatthew Barth <msbarth@us.ibm.com>2017-07-06 17:10:53 -0500
commit246235237c92bd6a55487bdd9fdc6b4b11466a7e (patch)
tree80239a8ab78877f5283218865a4f206e1521cd73 /control
parente0ca13eb5b2feba044505e3234c8381d3ab03187 (diff)
downloadphosphor-fan-presence-246235237c92bd6a55487bdd9fdc6b4b11466a7e.tar.gz
phosphor-fan-presence-246235237c92bd6a55487bdd9fdc6b4b11466a7e.zip
Add zone net increase set speed action
The net increase speed action provides the ability to determine what the net delta the zone's fan speeds should be updated by from their current target speed. Change-Id: Ib463e5ed4836bebf906cea27ea5788d826ec9c38 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control')
-rw-r--r--control/actions.hpp45
-rw-r--r--control/zone.hpp15
2 files changed, 60 insertions, 0 deletions
diff --git a/control/actions.hpp b/control/actions.hpp
index 4393c4d..60b5484 100644
--- a/control/actions.hpp
+++ b/control/actions.hpp
@@ -209,6 +209,51 @@ auto set_ceiling_from_average_sensor_value(
};
}
+/**
+ * @brief An action to set the speed increase delta and request speed change
+ * @details Provides the ability to determine what the net increase delta the
+ * zone's fan speeds should be updated by from their current target speed and
+ * request that new target speed.
+ *
+ * @param[in] state - State to compare the group's property value to
+ * @param[in] speedDelta - Speed delta of the group
+ *
+ * @return Lambda function
+ * A lambda function that determines the net increase delta and requests
+ * a new target speed with that increase for the zone.
+ */
+template <typename T>
+auto set_net_increase_speed(T&& state, uint64_t speedDelta)
+{
+ return [speedDelta,
+ state = std::forward<T>(state)](auto& zone, auto& group)
+ {
+ auto netDelta = zone.getIncSpeedDelta();
+ std::for_each(
+ group.begin(),
+ group.end(),
+ [&zone, &state, &speedDelta, &netDelta](auto const& entry)
+ {
+ T value = zone.template getPropertyValue<T>(
+ entry.first,
+ std::get<intfPos>(entry.second),
+ std::get<propPos>(entry.second));
+ // TODO openbmc/phosphor-fan-presence#7 - Support possible
+ // state types for comparison
+ if (value >= state)
+ {
+ // Increase by at least a single delta
+ // to attempt bringing under 'state'
+ auto delta = std::max((value - state), 1);
+ // Increase is the difference times the given speed delta
+ netDelta = std::max(netDelta, delta * speedDelta);
+ }
+ }
+ );
+ // TODO Do a request speed change for target speed update
+ };
+}
+
} // namespace action
} // namespace control
} // namespace fan
diff --git a/control/zone.hpp b/control/zone.hpp
index fef3734..20b9ac9 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -168,6 +168,16 @@ class Zone
return keyValue;
};
+ /**
+ * @brief Get the increase speed delta
+ *
+ * @return - The current increase speed delta
+ */
+ inline auto& getIncSpeedDelta() const
+ {
+ return _incSpeedDelta;
+ };
+
private:
/**
@@ -216,6 +226,11 @@ class Zone
bool _isActive = true;
/**
+ * Speed increase delta
+ */
+ uint64_t _incSpeedDelta = 0;
+
+ /**
* The vector of fans in this zone
*/
std::vector<std::unique_ptr<Fan>> _fans;
OpenPOWER on IntegriCloud