summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-10-24 15:58:17 -0500
committerMatthew Barth <msbarth@us.ibm.com>2017-11-17 13:14:11 -0600
commit0decd1bd00ecb1d4b7357c49947ee19142ea8e27 (patch)
treeb49f97572b64fa1408f3568e31a7aee0f97ad62e
parent98726c4585d6743c0948ed0140835e438de1df79 (diff)
downloadphosphor-fan-presence-0decd1bd00ecb1d4b7357c49947ee19142ea8e27.tar.gz
phosphor-fan-presence-0decd1bd00ecb1d4b7357c49947ee19142ea8e27.zip
Set fan speed on missing owner action
Sets the zone's fan speeds to a given speed when any service owner associated with an event group is missing. Once all the services are functional and providing the event data again, active fan speed changes are allowed. Change-Id: I318f6114c8d0392432c421f803db07a4683d1097 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--control/actions.cpp21
-rw-r--r--control/actions.hpp14
2 files changed, 35 insertions, 0 deletions
diff --git a/control/actions.cpp b/control/actions.cpp
index 6eda2a6..66bba2b 100644
--- a/control/actions.cpp
+++ b/control/actions.cpp
@@ -99,6 +99,27 @@ void default_floor_on_missing_owner(Zone& zone, const Group& group)
zone.setFloorChangeAllow(&group, !defFloor);
}
+Action set_speed_on_missing_owner(uint64_t speed)
+{
+ return [speed](control::Zone& zone, const Group& group)
+ {
+ auto services = zone.getGroupServices(&group);
+ auto missingOwner = std::any_of(
+ services.begin(),
+ services.end(),
+ [](const auto& s)
+ {
+ return !std::get<hasOwnerPos>(s);
+ });
+ if (missingOwner)
+ {
+ zone.setSpeed(speed);
+ }
+ // Update group's fan control active allowed based on action results
+ zone.setActiveAllow(&group, !missingOwner);
+ };
+}
+
void set_request_speed_base_with_max(control::Zone& zone,
const Group& group)
{
diff --git a/control/actions.hpp b/control/actions.hpp
index 4d2c5c3..55c8af8 100644
--- a/control/actions.hpp
+++ b/control/actions.hpp
@@ -42,6 +42,20 @@ Action call_actions_based_on_timer(
void default_floor_on_missing_owner(Zone& zone, const Group& group);
/**
+ * @brief An action to set a speed when a service owner is missing
+ * @details Sets the fans to the given speed when any service owner associated
+ * to the group is missing. Once all services are functional and providing
+ * the event data again, active fan speed changes are allowed.
+ *
+ * @param[in] speed - Speed to set the zone to
+ *
+ * @return Action lambda function
+ * An Action function that sets the zone to the given speed if any service
+ * owners are missing.
+ */
+Action set_speed_on_missing_owner(uint64_t speed);
+
+/**
* @brief An action to set the request speed base
* @details A new target speed is determined using a speed delta being added
* or subtracted, for increases or decrease respectively, from a base speed.
OpenPOWER on IntegriCloud