diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-06-29 11:43:45 -0500 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2017-07-06 17:25:12 -0500 |
commit | a956184bfe6afa6803fc4456eea1f5b6742d8f80 (patch) | |
tree | 490a45ef4feb71435d28860c4758c8a416318137 /control | |
parent | b4a7cb99bb82f602d3cff848a1f14ade1da2ddb5 (diff) | |
download | phosphor-fan-presence-a956184bfe6afa6803fc4456eea1f5b6742d8f80.tar.gz phosphor-fan-presence-a956184bfe6afa6803fc4456eea1f5b6742d8f80.zip |
Add increase & decrease timer values in seconds
Support setting the increase delay time(in seconds) for each zone from
the zone yaml file. Speed increases use a delay type timer where the
amount of time given delays additional increase requests from happening
until the fans within the zone reach the highest net increase in speeds.
Support setting the decrease interval time(in seconds) for each zone
from the zone yaml file. Since decreasing is done on an interval, a
decrease interval time of zero disables the decrease interval timer
causing no decreases in speed to occur. Speed decreases use an interval
type timer to decrease the fan speeds within the zone when no speed
increase requests exist on the given time interval.
Change-Id: I88334a313b6e2820b768fa7e3f1cb65887f29258
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control')
-rwxr-xr-x | control/gen-fan-zone-defs.py | 10 | ||||
-rw-r--r-- | control/types.hpp | 8 | ||||
-rw-r--r-- | control/zone.cpp | 10 | ||||
-rw-r--r-- | control/zone.hpp | 11 |
4 files changed, 32 insertions, 7 deletions
diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py index adef86a..177bfe0 100755 --- a/control/gen-fan-zone-defs.py +++ b/control/gen-fan-zone-defs.py @@ -50,6 +50,8 @@ const std::vector<ZoneGroup> Manager::_zoneLayouts ${zone['num']}, ${zone['full_speed']}, ${zone['default_floor']}, + ${zone['increase_delay']}, + ${zone['decrease_interval']}, std::vector<FanDefinition>{ %for fan in zone['fans']: FanDefinition{ @@ -311,6 +313,14 @@ def buildZoneData(zone_data, fan_data, events_data, zone_conditions_data): zone['default_floor'] = z['default_floor'] + # 'increase_delay' is optional (use 0 by default) + key = 'increase_delay' + zone[key] = z.setdefault(key, 0) + + # 'decrease_interval' is optional (use 0 by default) + key = 'decrease_interval' + zone[key] = z.setdefault(key, 0) + # 'cooling_profiles' is optional (use 'all' instead) if ('cooling_profiles' not in z) or \ (z['cooling_profiles'] is None): diff --git a/control/types.hpp b/control/types.hpp index 6e99950..b6a031f 100644 --- a/control/types.hpp +++ b/control/types.hpp @@ -59,11 +59,15 @@ using EventData = std::tuple<Group, Handler, Action>; constexpr auto zoneNumPos = 0; constexpr auto fullSpeedPos = 1; constexpr auto floorSpeedPos = 2; -constexpr auto fanListPos = 3; -constexpr auto setSpeedEventsPos = 4; +constexpr auto incDelayPos = 3; +constexpr auto decIntervalPos = 4; +constexpr auto fanListPos = 5; +constexpr auto setSpeedEventsPos = 6; using ZoneDefinition = std::tuple<size_t, uint64_t, uint64_t, + size_t, + size_t, std::vector<FanDefinition>, std::vector<SetSpeedEvent>>; diff --git a/control/zone.cpp b/control/zone.cpp index 8f11393..93a616a 100644 --- a/control/zone.cpp +++ b/control/zone.cpp @@ -42,6 +42,8 @@ Zone::Zone(Mode mode, _zoneNum(std::get<zoneNumPos>(def)), _defFloorSpeed(std::get<floorSpeedPos>(def)), _defCeilingSpeed(std::get<fullSpeedPos>(def)), + _incDelay(std::get<incDelayPos>(def)), + _decInterval(std::get<decIntervalPos>(def)), _incTimer(events, [this](){ this->incTimerExpired(); }), _decTimer(events, [this](){ this->decTimerExpired(); }) { @@ -57,10 +59,9 @@ Zone::Zone(Mode mode, { initEvents(def); // Start timer for fan speed decreases - if (!_decTimer.running()) + if (!_decTimer.running() && _decInterval != seconds::zero()) { - //TODO Update time value to what's given in zones yaml - _decTimer.start(seconds(30), + _decTimer.start(_decInterval, phosphor::fan::util::Timer::TimerType::repeating); } } @@ -123,8 +124,7 @@ void Zone::requestSpeedIncrease(uint64_t targetDelta) } setSpeed(_targetSpeed); // Start timer countdown for fan speed increase - //TODO Update time value to what's given in zones yaml - _incTimer.start(seconds(5), + _incTimer.start(_incDelay, phosphor::fan::util::Timer::TimerType::oneshot); } } diff --git a/control/zone.hpp b/control/zone.hpp index 9786db4..706d9c2 100644 --- a/control/zone.hpp +++ b/control/zone.hpp @@ -1,4 +1,5 @@ #pragma once +#include <chrono> #include <vector> #include <algorithm> #include <sdbusplus/bus.hpp> @@ -280,6 +281,16 @@ class Zone uint64_t _decSpeedDelta = 0; /** + * Speed increase delay in seconds + */ + std::chrono::seconds _incDelay; + + /** + * Speed decrease interval in seconds + */ + std::chrono::seconds _decInterval; + + /** * The increase timer object */ phosphor::fan::util::Timer _incTimer; |