Timer to decrease fan speeds
Create a repeating timer for decreasing fan speeds where the fan speeds
in the zone are decreased when the timer expires and a decrease speed
request exists with no increase request present or active.
Change-Id: I419592f6f50c0ed524f8bf3ebf183854ab5ef2ea
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/zone.cpp b/control/zone.cpp
index 1ca0b81..17e0089 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <chrono>
#include <phosphor-logging/log.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>
@@ -27,18 +28,21 @@
namespace control
{
+using namespace std::chrono;
using namespace phosphor::logging;
using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
Error::InternalFailure;
Zone::Zone(Mode mode,
sdbusplus::bus::bus& bus,
+ phosphor::fan::event::EventPtr& events,
const ZoneDefinition& def) :
_bus(bus),
_fullSpeed(std::get<fullSpeedPos>(def)),
_zoneNum(std::get<zoneNumPos>(def)),
_defFloorSpeed(std::get<floorSpeedPos>(def)),
- _defCeilingSpeed(std::get<fullSpeedPos>(def))
+ _defCeilingSpeed(std::get<fullSpeedPos>(def)),
+ _decTimer(events, [this](){ this->decTimerExpired(); })
{
auto& fanDefs = std::get<fanListPos>(def);
@@ -97,7 +101,13 @@
std::get<actionPos>(event)(*this,
std::get<groupPos>(event));
}
- //TODO openbmc/openbmc#1625 Start timer for fan speed decreases
+ // Start timer for fan speed decreases
+ if (!_decTimer.running())
+ {
+ //TODO Update time value to what's given in zones yaml
+ _decTimer.start(seconds(30),
+ phosphor::fan::util::Timer::TimerType::repeating);
+ }
}
}
@@ -162,9 +172,12 @@
{
_decSpeedDelta = targetDelta;
}
+}
- //TODO openbmc/openbmc#1625 Set decrease target speed when timer expires
+void Zone::decTimerExpired()
+{
// Only decrease speeds when no requested increases exist
+ //TODO Add increase timer not running (i.e. not in the middle of increasing)
if (_incSpeedDelta == 0)
{
// Target speed can not go below the defined floor speed
@@ -181,7 +194,7 @@
}
// Clear decrease delta when timer expires
_decSpeedDelta = 0;
- //TODO openbmc/openbmc#1625 Restart decrease timer
+ // Decrease timer is restarted since its repeating
}
void Zone::getProperty(sdbusplus::bus::bus& bus,