Make hwmon work with double or int64 interface

Deduce type based on interface using decltype
and if it is double apply scale to the value.

Tested-by: Noticed that on dbus using busctl and debug
server that doubles were produced and scaled.

Also verifed that hwmon still produced int64_t values when
building with current phosphor-dbus-interfaces.

Change-Id: I00e21d5ef0ea6cee0eb30baa0b39cde95e7f4a86
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index 3c6d232..81faa9b 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -214,10 +214,18 @@
 #endif
     }
     auto sensorValue = valueInterface->value();
-    addThreshold<WarningObject>(
-        sensor.first.first, std::get<sensorID>(properties), sensorValue, info);
-    addThreshold<CriticalObject>(
-        sensor.first.first, std::get<sensorID>(properties), sensorValue, info);
+    int64_t scale = 0;
+    // scale the thresholds only if we're using doubles
+    if constexpr (std::is_same<SensorValueType, double>::value)
+    {
+        scale = sensorObj->getScale();
+    }
+    addThreshold<WarningObject>(sensor.first.first,
+                                std::get<sensorID>(properties), sensorValue,
+                                info, scale);
+    addThreshold<CriticalObject>(sensor.first.first,
+                                 std::get<sensorID>(properties), sensorValue,
+                                 info, scale);
 
     auto target =
         addTarget<hwmon::FanSpeed>(sensor.first, ioAccess, _devPath, info);