monitor: Enhance tracing of fan & tach sensor states

Moved the determination of the allowed range of speeds of a tach sensor
from the fan to the tach sensor. Also changed the check for too many
nonfunctional tach sensors to return the count of nonfunctional tach
sensors of a fan so that this could be added to the tracing for when a
fan's functional state is updated.

Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Change-Id: Id65b8064d203bcc63a70f33d4783706e5cc07d2f
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index dc02ade..0e30a10 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -26,6 +26,7 @@
 
 #include <experimental/filesystem>
 #include <functional>
+#include <utility>
 
 namespace phosphor
 {
@@ -153,6 +154,19 @@
     return _tachTarget;
 }
 
+std::pair<uint64_t, uint64_t> TachSensor::getRange(const size_t deviation) const
+{
+    // Determine min/max range applying the deviation
+    uint64_t min = getTarget() * (100 - deviation) / 100;
+    uint64_t max = getTarget() * (100 + deviation) / 100;
+
+    // Adjust the min/max range by applying the factor & offset
+    min = min * _factor + _offset;
+    max = max * _factor + _offset;
+
+    return std::make_pair(min, max);
+}
+
 void TachSensor::setFunctional(bool functional)
 {
     _functional = functional;