From 60b007660c69d635965a187432ad4b87b1c929f9 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Tue, 15 Aug 2017 13:39:06 -0500 Subject: 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 --- control/zone.cpp | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'control/zone.cpp') 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; -- cgit v1.2.1