monitor: Add ignoring feedback sensors above allowed max

There may be situations where fan rotor feedback speeds above the
allowed range could be ignored, essentially ignoring any overspeed
detections. This adds an optional `ignore_above_max` attribute to the
fan sensors that can be added, set to 'true', to ignore marking that fan
sensor as nonfunctional when its above the allowed max. Without this
attribute, the fan sensor must remain within the allowed min/max range
to be deemed functional. This is the default behavior.

Change-Id: I4876b4c1963a8a1becd55732ca19496f5df6b003
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index dc8814f..87c69ac 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -10,6 +10,7 @@
 #include <sdeventplus/utility/timer.hpp>
 
 #include <chrono>
+#include <optional>
 #include <utility>
 
 namespace phosphor
@@ -95,6 +96,7 @@
      * @param[in] offset - the offset of the sensor target
      * @param[in] method - the method of out of range
      * @param[in] threshold - the threshold of counter method
+     * @param[in] ignoreAboveMax - whether to ignore being above max or not
      * @param[in] timeout - Normal timeout value to use
      * @param[in] errorDelay - Delay in seconds before creating an error
      *                         or std::nullopt if no errors.
@@ -105,9 +107,9 @@
     TachSensor(Mode mode, sdbusplus::bus::bus& bus, Fan& fan,
                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, size_t countInterval,
-               const sdeventplus::Event& event);
+               size_t method, size_t threshold, bool ignoreAboveMax,
+               size_t timeout, const std::optional<size_t>& errorDelay,
+               size_t countInterval, const sdeventplus::Event& event);
 
     /**
      * @brief Reads a property from the input message and stores it in value.
@@ -337,9 +339,10 @@
      *
      * @param[in] deviation - The configured deviation(in percent) allowed
      *
-     * @return pair - Min/Max range of speeds allowed
+     * @return pair - Min/Max(optional) range of speeds allowed
      */
-    std::pair<uint64_t, uint64_t> getRange(const size_t deviation) const;
+    std::pair<uint64_t, std::optional<uint64_t>>
+        getRange(const size_t deviation) const;
 
     /**
      * @brief Processes the current state of the sensor
@@ -458,6 +461,11 @@
     const size_t _threshold;
 
     /**
+     * @brief Whether to ignore being above the max or not
+     */
+    const bool _ignoreAboveMax;
+
+    /**
      * @brief The counter for count method
      */
     size_t _counter = 0;