summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--control/actions.hpp4
-rw-r--r--control/zone.cpp17
-rw-r--r--control/zone.hpp18
3 files changed, 38 insertions, 1 deletions
diff --git a/control/actions.hpp b/control/actions.hpp
index eb857b6..96da323 100644
--- a/control/actions.hpp
+++ b/control/actions.hpp
@@ -13,7 +13,7 @@ namespace action
/**
* @brief An action to set the speed on a zone
- * @details The zone is set to the given speed when a defined number of
+ * @details The zone is held at the given speed when a defined number of
* properties in the group are set to the given state
*
* @param[in] count - Number of properties
@@ -37,6 +37,8 @@ auto count_state_before_speed(size_t count, bool state, uint64_t speed)
entry.first,
std::get<propPos>(entry.second)) == state;
});
+ // Update group's fan control active allowed based on action results
+ zone.setActiveAllow(&group, !(numAtState >= count));
if (numAtState >= count)
{
zone.setSpeed(speed);
diff --git a/control/zone.cpp b/control/zone.cpp
index 18fd627..35c7d2b 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -73,6 +73,23 @@ void Zone::setSpeed(uint64_t speed)
}
}
+void Zone::setActiveAllow(const Group* group, bool isActiveAllow)
+{
+ _active[group] = isActiveAllow;
+ if (!isActiveAllow)
+ {
+ _isActive = false;
+ }
+ else
+ {
+ // Check all entries are set to allow control active
+ auto actPred = [](auto const& entry) {return entry.second;};
+ _isActive = std::all_of(_active.begin(),
+ _active.end(),
+ actPred);
+ }
+}
+
int Zone::signalHandler(sd_bus_message* msg,
void* data,
sd_bus_error* err)
diff --git a/control/zone.hpp b/control/zone.hpp
index 1a4e173..b727567 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -71,6 +71,14 @@ class Zone
}
/**
+ * @brief Sets the automatic fan control allowed active state
+ *
+ * @param[in] group - A group that affects the active state
+ * @param[in] isActiveAllow - Active state according to group
+ */
+ void setActiveAllow(const Group* group, bool isActiveAllow);
+
+ /**
* @brief Sets a given object's property value
*
* @param[in] object - Name of the object containing the property
@@ -116,6 +124,11 @@ class Zone
const size_t _zoneNum;
/**
+ * Automatic fan control active state
+ */
+ bool _isActive = true;
+
+ /**
* The vector of fans in this zone
*/
std::vector<std::unique_ptr<Fan>> _fans;
@@ -126,6 +139,11 @@ class Zone
std::map<std::string, std::map<std::string, bool>> _properties;
/**
+ * @brief Map of active fan control allowed by groups
+ */
+ std::map<const Group*, bool> _active;
+
+ /**
* @brief List of signal event arguments
*/
std::vector<std::unique_ptr<SignalEvent>> _signalEvents;
OpenPOWER on IntegriCloud