summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-08-15 13:39:06 -0500
committerMatthew Barth <msbarth@us.ibm.com>2017-08-16 09:51:37 -0500
commit60b007660c69d635965a187432ad4b87b1c929f9 (patch)
tree51a45654307d72fdebb1b648db27215f0a29c345
parent9014980aa76692cd7f08b5e69565133122c758cd (diff)
downloadphosphor-fan-presence-60b007660c69d635965a187432ad4b87b1c929f9.tar.gz
phosphor-fan-presence-60b007660c69d635965a187432ad4b87b1c929f9.zip
Updates enabling zone active fan control
A zone is actively controlling its fan speeds when all groups subscribed to allow active control are set to true. The zone keeps a list of these groups and their active allow state, if at anytime an action (or precondition) sets a group's active state to false, any dynamic set speed requests do not occur. Only requests to set the zone's fans to full speed is allowed. Related to this, the zone's target speed should only be updated when a requested speed is successfully set. Change-Id: Iec6f15346fee5a6c6046d5b00e949e46aef400b9 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--control/actions.hpp4
-rw-r--r--control/preconditions.hpp6
-rw-r--r--control/zone.cpp43
-rw-r--r--control/zone.hpp14
4 files changed, 39 insertions, 28 deletions
diff --git a/control/actions.hpp b/control/actions.hpp
index 167149b..ecf900e 100644
--- a/control/actions.hpp
+++ b/control/actions.hpp
@@ -50,12 +50,12 @@ auto count_state_before_speed(size_t count, T&& state, uint64_t speed)
return false;
}
});
- // Update group's fan control active allowed based on action results
- zone.setActiveAllow(&group, !(numAtState >= count));
if (numAtState >= count)
{
zone.setSpeed(speed);
}
+ // Update group's fan control active allowed based on action results
+ zone.setActiveAllow(&group, !(numAtState >= count));
};
}
diff --git a/control/preconditions.hpp b/control/preconditions.hpp
index 8b2e93e..65eb0e2 100644
--- a/control/preconditions.hpp
+++ b/control/preconditions.hpp
@@ -54,8 +54,6 @@ auto property_states_match(std::vector<PrecondGroup>&& pg,
}
});
- // Update group's fan control active allowed
- zone.setActiveAllow(&group, (precondState == pg.size()));
if (precondState == pg.size())
{
// Init the event when all the precondition(s) are true
@@ -63,10 +61,12 @@ auto property_states_match(std::vector<PrecondGroup>&& pg,
}
else
{
- zone.setFullSpeed();
// Unsubscribe the event signals when any precondition is false
zone.removeEvent(sse);
+ zone.setFullSpeed();
}
+ // Update group's fan control active allowed
+ zone.setActiveAllow(&group, (precondState == pg.size()));
};
}
diff --git a/control/zone.cpp b/control/zone.cpp
index 9670127..56c6cb6 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -73,18 +73,33 @@ Zone::Zone(Mode mode,
}
}
-
void Zone::setSpeed(uint64_t speed)
{
- for (auto& fan : _fans)
+ if (_isActive)
+ {
+ _targetSpeed = speed;
+ for (auto& fan : _fans)
+ {
+ fan->setSpeed(_targetSpeed);
+ }
+ }
+}
+
+void Zone::setFullSpeed()
+{
+ if (_fullSpeed != 0)
{
- fan->setSpeed(speed);
+ _targetSpeed = _fullSpeed;
+ for (auto& fan : _fans)
+ {
+ fan->setSpeed(_targetSpeed);
+ }
}
}
void Zone::setActiveAllow(const Group* group, bool isActiveAllow)
{
- _active[group] = isActiveAllow;
+ _active[*(group)] = isActiveAllow;
if (!isActiveAllow)
{
_isActive = false;
@@ -116,19 +131,20 @@ void Zone::requestSpeedIncrease(uint64_t targetDelta)
if (targetDelta > _incSpeedDelta &&
_targetSpeed < _ceilingSpeed)
{
- _targetSpeed = (targetDelta - _incSpeedDelta) + _targetSpeed;
+ auto requestTarget = _targetSpeed;
+ requestTarget = (targetDelta - _incSpeedDelta) + requestTarget;
_incSpeedDelta = targetDelta;
// Target speed can not go above a defined ceiling speed
- if (_targetSpeed > _ceilingSpeed)
+ if (requestTarget > _ceilingSpeed)
{
- _targetSpeed = _ceilingSpeed;
+ requestTarget = _ceilingSpeed;
}
// Cancel current timer countdown
if (_incTimer.running())
{
_incTimer.stop();
}
- setSpeed(_targetSpeed);
+ setSpeed(requestTarget);
// Start timer countdown for fan speed increase
_incTimer.start(_incDelay,
phosphor::fan::util::Timer::TimerType::oneshot);
@@ -157,17 +173,18 @@ void Zone::decTimerExpired()
// the increase timer is not running (i.e. not in the middle of increasing)
if (_incSpeedDelta == 0 && !_incTimer.running())
{
+ auto requestTarget = _targetSpeed;
// Target speed can not go below the defined floor speed
- if ((_targetSpeed < _decSpeedDelta) ||
- (_targetSpeed - _decSpeedDelta < _floorSpeed))
+ if ((requestTarget < _decSpeedDelta) ||
+ (requestTarget - _decSpeedDelta < _floorSpeed))
{
- _targetSpeed = _floorSpeed;
+ requestTarget = _floorSpeed;
}
else
{
- _targetSpeed = _targetSpeed - _decSpeedDelta;
+ requestTarget = requestTarget - _decSpeedDelta;
}
- setSpeed(_targetSpeed);
+ setSpeed(requestTarget);
}
// Clear decrease delta when timer expires
_decSpeedDelta = 0;
diff --git a/control/zone.hpp b/control/zone.hpp
index 6e81bd1..cb1ce69 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -57,22 +57,16 @@ class Zone
/**
* Sets all fans in the zone to the speed
- * passed in
+ * passed in when the zone is active
*
* @param[in] speed - the fan speed
*/
void setSpeed(uint64_t speed);
/**
- * Sets the zone to full speed
+ * Sets the zone to full speed regardless of zone's active state
*/
- inline void setFullSpeed()
- {
- if (_fullSpeed != 0)
- {
- setSpeed(_fullSpeed);
- }
- }
+ void setFullSpeed();
/**
* @brief Sets the automatic fan control allowed active state
@@ -359,7 +353,7 @@ class Zone
/**
* @brief Map of active fan control allowed by groups
*/
- std::map<const Group*, bool> _active;
+ std::map<const Group, bool> _active;
/**
* @brief List of signal event arguments and Dbus matches for callbacks
OpenPOWER on IntegriCloud