summaryrefslogtreecommitdiffstats
path: root/control/zone.cpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-06-23 14:38:05 -0500
committerMatthew Barth <msbarth@us.ibm.com>2017-07-06 17:25:12 -0500
commit8600d9a0058071951e0881037deff77fc03d1601 (patch)
tree6d1b42e94f22db089ed39534555acaacd337bee9 /control/zone.cpp
parent0ce99d8b377e68b5286c37e7e644301051972083 (diff)
downloadphosphor-fan-presence-8600d9a0058071951e0881037deff77fc03d1601.tar.gz
phosphor-fan-presence-8600d9a0058071951e0881037deff77fc03d1601.zip
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>
Diffstat (limited to 'control/zone.cpp')
-rw-r--r--control/zone.cpp21
1 files changed, 17 insertions, 4 deletions
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 fan
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 @@ Zone::Zone(Mode mode,
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 @@ void Zone::requestSpeedDecrease(uint64_t targetDelta)
{
_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 @@ void Zone::requestSpeedDecrease(uint64_t targetDelta)
}
// 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,
OpenPOWER on IntegriCloud