Add Unit property to dbus interfaces

Previously, the lack of the Unit property on the Value interfaces
provided by dbus-sensors meant that readings from its sensors weren't
displayed in phosphor-webui/webui-vue.  Here it's added as an extra
parameter to setInitialProperties, allowing sensors that handle multiple
types of data (e.g. IpmbSensor, PSUSensor) to determine the appropriate
string to pass once they've had time to determine that.

Tested: PSUSensor, ADCSensor, CPUSensor, TachSensor, and HwmonTempSensor
all have an appropriate Unit property available on dbus, and are
displayed in webui-vue.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I5e6df74cc42d9fb84852c5bf3ea5d3b383a16cdc
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index e292863..a528819 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -41,7 +41,7 @@
                      boost::asio::io_service& io, const std::string& sensorName,
                      std::vector<thresholds::Threshold>&& thresholdsIn,
                      const std::string& sensorConfiguration,
-                     std::string& sensorTypeName, unsigned int factor,
+                     const std::string& sensorUnits, unsigned int factor,
                      double max, double min, const std::string& label,
                      size_t tSize) :
     Sensor(boost::replace_all_copy(sensorName, " ", "_"),
@@ -51,13 +51,14 @@
     inputDev(io), waitTimer(io), path(path), pathRatedMax(""), pathRatedMin(""),
     sensorFactor(factor), minMaxReadCounter(0)
 {
+    std::string unitPath = sensor_paths::getPathForUnits(sensorUnits);
     if constexpr (debug)
     {
         std::cerr << "Constructed sensor: path " << path << " type "
                   << objectType << " config " << sensorConfiguration
-                  << " typename " << sensorTypeName << " factor " << factor
-                  << " min " << min << " max " << max << " name \""
-                  << sensorName << "\"\n";
+                  << " typename " << unitPath << " factor " << factor << " min "
+                  << min << " max " << max << " name \"" << sensorName
+                  << "\"\n";
     }
 
     fd = open(path.c_str(), O_RDONLY);
@@ -68,7 +69,7 @@
     }
     inputDev.assign(fd);
 
-    std::string dbusPath = sensorPathPrefix + sensorTypeName + name;
+    std::string dbusPath = sensorPathPrefix + unitPath + "/" + name;
 
     sensorInterface = objectServer.add_interface(
         dbusPath, "xyz.openbmc_project.Sensor.Value");
@@ -89,11 +90,11 @@
     // register and initialize "Associations" property.
     if (label.empty() || tSize == thresholds.size())
     {
-        setInitialProperties(conn);
+        setInitialProperties(conn, sensorUnits);
     }
     else
     {
-        setInitialProperties(conn, label, tSize);
+        setInitialProperties(conn, sensorUnits, label, tSize);
     }
 
     association = objectServer.add_interface(dbusPath, association::interface);