monitor: Move count timer into TachSensor

Instead of the Fan class owning the count error detection method timer,
this commit moves it into each TachSensor object.

This timer will be stopped until the first time Fan::tachChanged()
detects an out of range sensor, then it will be started.  From that
point on, the timer expiration function is what will call Fan::process()
to increment/decrement the count.  If the count goes back to zero, then
the timer will be stopped and Fan::tachChanged() will take back over.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I1cfc8440d299302b088f53764b71c06ea513690b
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 0012a02..ece1d85 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -98,6 +98,7 @@
      * @param[in] timeout - Normal timeout value to use
      * @param[in] errorDelay - Delay in seconds before creating an error
      *                         or std::nullopt if no errors.
+     * @param[in] countInterval - In count mode interval
      *
      * @param[in] event - Event loop reference
      */
@@ -105,7 +106,7 @@
                const std::string& id, bool hasTarget, size_t funcDelay,
                const std::string& interface, double factor, int64_t offset,
                size_t method, size_t threshold, size_t timeout,
-               const std::optional<size_t>& errorDelay,
+               const std::optional<size_t>& errorDelay, size_t countInterval,
                const sdeventplus::Event& event);
 
     /**
@@ -257,6 +258,26 @@
     }
 
     /**
+     * @brief Says if the count timer is running
+     *
+     * @return bool - If count timer running
+     */
+    inline bool countTimerRunning() const
+    {
+        return _countTimer && _countTimer->isEnabled();
+    }
+
+    /**
+     * @brief Stops the count timer
+     */
+    void stopCountTimer();
+
+    /**
+     * @brief Starts the count timer
+     */
+    void startCountTimer();
+
+    /**
      * @brief Return the given timer mode's delay time
      *
      * @param[in] mode - mode of timer to get delay time for
@@ -463,6 +484,20 @@
     std::unique_ptr<
         sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
         _errorTimer;
+
+    /**
+     * @brief The interval, in seconds, to use for the timer that runs
+     *        the checks when using the 'count' method.
+     */
+    size_t _countInterval;
+
+    /**
+     * @brief The timer used by the 'count' method for determining
+     *        functional status.
+     */
+    std::unique_ptr<
+        sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
+        _countTimer;
 };
 
 } // namespace monitor