summaryrefslogtreecommitdiffstats
path: root/control/zone.hpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-10-05 17:03:40 -0500
committerMatthew Barth <msbarth@us.ibm.com>2017-11-17 13:14:11 -0600
commitbfb1a566b781e63dfda6038d9918706423410c26 (patch)
tree92197497cb281cff15d69fd91b331c0bba367718 /control/zone.hpp
parent7b7ceb8deb48d6d5833b02bc33987fca2e647a68 (diff)
downloadphosphor-fan-presence-bfb1a566b781e63dfda6038d9918706423410c26.tar.gz
phosphor-fan-presence-bfb1a566b781e63dfda6038d9918706423410c26.zip
Add timer event management
Events defined to have timers require the ability to find a timer, add a timer to the event, and removing a timer event entirely. These event timers are intended to allow actions based on the event to be delayed or recurring based on the timer defined. Change-Id: Ieaf26f031c5e5aac9472e92354bfb76392642cb4 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control/zone.hpp')
-rw-r--r--control/zone.hpp73
1 files changed, 72 insertions, 1 deletions
diff --git a/control/zone.hpp b/control/zone.hpp
index 9c08032..1fdeaf2 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <chrono>
#include <vector>
+#include <cassert>
#include <algorithm>
#include <sdbusplus/bus.hpp>
#include "fan.hpp"
@@ -139,6 +140,18 @@ class Zone
const bool hasOwner);
/**
+ * @brief Get the group's list of service names
+ *
+ * @param[in] group - Group to get service names for
+ *
+ * @return - The list of service names
+ */
+ inline auto getGroupServices(const Group* group)
+ {
+ return _services.at(*group);
+ }
+
+ /**
* @brief Initialize a set speed event properties and actions
*
* @param[in] event - Set speed event
@@ -264,6 +277,64 @@ class Zone
void decTimerExpired();
/**
+ * @brief Get the event pointer used with this zone's timers
+ *
+ * @return - The Dbus event pointer for timers
+ */
+ inline auto& getEventPtr()
+ {
+ return _sdEvents;
+ }
+
+ /**
+ * @brief Get the list of timer events
+ *
+ * @return - List of timer events
+ */
+ inline auto& getTimerEvents()
+ {
+ return _timerEvents;
+ }
+
+ /**
+ * @brief Find the first instance of a timer event
+ *
+ * @param[in] eventGroup - Group associated with a timer
+ * @param[in] eventActions - List of actions associated with a timer
+ *
+ * @return - Iterator to the timer event
+ */
+ std::vector<TimerEvent>::iterator findTimer(
+ const Group& eventGroup,
+ const std::vector<Action>& eventActions);
+
+ /**
+ * @brief Add a timer to the list of timer based events
+ *
+ * @param[in] data - Event data for timer
+ * @param[in] timer - Timer to be added
+ */
+ inline void addTimer(
+ std::unique_ptr<EventData>&& data,
+ std::unique_ptr<phosphor::fan::util::Timer>&& timer)
+ {
+ _timerEvents.emplace_back(std::move(data), std::move(timer));
+ };
+
+ /**
+ * @brief Remove the given timer event
+ *
+ * @param[in] teIter - Iterator pointing to the timer event to remove
+ */
+ inline void removeTimer(std::vector<TimerEvent>::iterator& teIter)
+ {
+ assert(teIter != std::end(_timerEvents));
+ std::get<timerEventDataPos>(*teIter).reset();
+ std::get<timerTimerPos>(*teIter).reset();
+ _timerEvents.erase(teIter);
+ }
+
+ /**
* @brief Callback function for event timers that processes the given
* actions for a group
*
@@ -395,7 +466,7 @@ class Zone
/**
* @brief List of timers for events
*/
- std::vector<std::unique_ptr<phosphor::fan::util::Timer>> _timerEvents;
+ std::vector<TimerEvent> _timerEvents;
/**
* @brief Get the request speed base if defined, otherwise the
OpenPOWER on IntegriCloud