summaryrefslogtreecommitdiffstats
path: root/monitor/tach_sensor.hpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-02-19 16:08:04 -0600
committerMatthew Barth <msbarth@us.ibm.com>2018-03-01 09:38:40 -0600
commit3800ae715a5835e72754a03eac230ef00d14c538 (patch)
tree6a7227252fed1d907dce78fc8670477cff60da42 /monitor/tach_sensor.hpp
parent9396bcc3d3a60fdad5875433210038c1b9d20ac5 (diff)
downloadphosphor-fan-presence-3800ae715a5835e72754a03eac230ef00d14c538.tar.gz
phosphor-fan-presence-3800ae715a5835e72754a03eac230ef00d14c538.zip
Define a mode for tach sensor timer
Use a single timer on the tach sensors for delaying both nonfunctional and functional state changes by declaring what mode the timer is in. Since a fan is either transitioning from a functional state to a nonfunctional state or vice-versa, enabling the timer in the mode requested allows the user to define a delay for both of these transition states. Tested: Current nonfunctional timer delay operates the same Change-Id: I0c165355d41d27e1906918953e5226968062ee16 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'monitor/tach_sensor.hpp')
-rw-r--r--monitor/tach_sensor.hpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index ed8caf8..f59f6f5 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -29,6 +29,17 @@ enum class Mode
};
/**
+ * The mode that the timer is running in:
+ * - func - Transition to functional state timer
+ * - nonfunc - Transition to nonfunctional state timer
+ */
+enum class TimerMode
+{
+ func,
+ nonfunc
+};
+
+/**
* @class TachSensor
*
* This class represents the sensor that reads a tach value.
@@ -151,15 +162,12 @@ class TachSensor
}
/**
- * @brief Starts the timer for the amount of time
- * specified in the constructor
+ * @brief Stops the timer when the given mode differs and starts
+ * the associated timer for the mode given if not already running
+ *
+ * @param[in] mode - mode of timer to start
*/
- inline void startTimer()
- {
- _timer.start(
- getTimeout(),
- phosphor::fan::util::Timer::TimerType::oneshot);
- }
+ void startTimer(TimerMode mode);
/**
* @brief Stops the timer
@@ -170,9 +178,11 @@ class TachSensor
}
/**
- * @brief Returns the timeout value to use for the sensor
+ * @brief Return the given timer mode's delay time
+ *
+ * @param[in] mode - mode of timer to get delay time for
*/
- std::chrono::microseconds getTimeout();
+ std::chrono::microseconds getDelay(TimerMode mode);
/**
* Returns the sensor name
@@ -285,6 +295,11 @@ class TachSensor
const size_t _timeout;
/**
+ * @brief Mode that current timer is in
+ */
+ TimerMode _timerMode;
+
+ /**
* The timer object
*/
phosphor::fan::util::Timer _timer;
OpenPOWER on IntegriCloud