Add double support for sensor interface

Add support for reading sensors that produce a double
as the value. Use a visitor to pull out the sensor value
so type doesn't matter.

Change-Id: I37c05e7077ead6f3084ab9704a1b2c62becb5e19
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/dbus/util.cpp b/dbus/util.cpp
index 91cc840..ffdfe1f 100644
--- a/dbus/util.cpp
+++ b/dbus/util.cpp
@@ -4,7 +4,7 @@
 #include "dbus/util.hpp"
 
 using Property = std::string;
-using Value = sdbusplus::message::variant<int64_t, std::string>;
+using Value = sdbusplus::message::variant<int64_t, double, std::string>;
 using PropertyMap = std::map<Property, Value>;
 
 /* TODO(venture): Basically all phosphor apps need this, maybe it should be a
@@ -69,12 +69,25 @@
     valueResponseMsg.read(propMap);
 
     // If no error was set, the values should all be there.
-    prop->unit = sdbusplus::message::variant_ns::get<std::string>(
-        propMap["Unit"]);
-    prop->scale = sdbusplus::message::variant_ns::get<int64_t>(
-        propMap["Scale"]);
-    prop->value = sdbusplus::message::variant_ns::get<int64_t>(
-        propMap["Value"]);
+    auto findUnit = propMap.find("Unit");
+    if (findUnit != propMap.end())
+    {
+        prop->unit =
+            sdbusplus::message::variant_ns::get<std::string>(findUnit->second);
+    }
+    auto findScale = propMap.find("Scale");
+    if (findScale != propMap.end())
+    {
+        prop->scale =
+            sdbusplus::message::variant_ns::get<int64_t>(findScale->second);
+    }
+    else
+    {
+        prop->scale = 0;
+    }
+
+    prop->value =
+        mapbox::util::apply_visitor(VariantToDoubleVisitor(), propMap["Value"]);
 
     return;
 }