diff options
-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; |