Add functional property for each tach sensor

Each fan's tach sensor creates a child inventory object under the fan's
inventory path containing the sensor's functional state. This child
inventory object path is the fan's path plus the tach sensor's defined
id.
i.e.)
/xyz/openbmc_project/inventory/system/chassis/motherboard/fan0/fan0_0

Change-Id: I0fe5000eadbe55d60b475ccad700b0264ed0ac75
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 040e8f9..a272681 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -13,11 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <experimental/filesystem>
 #include <phosphor-logging/log.hpp>
 #include "fan.hpp"
 #include "sdbusplus.hpp"
 #include "tach_sensor.hpp"
-#include "../utility.hpp"
+#include "utility.hpp"
 
 namespace phosphor
 {
@@ -31,6 +32,7 @@
 constexpr auto FAN_TARGET_PROPERTY = "Target";
 constexpr auto FAN_VALUE_PROPERTY = "Value";
 
+using namespace std::experimental::filesystem;
 
 /**
  * @brief Helper function to read a property
@@ -71,6 +73,7 @@
     _bus(bus),
     _fan(fan),
     _name(FAN_SENSOR_PATH + id),
+    _invName(path(fan.getName()) / id),
     _hasTarget(hasTarget),
     _timeout(timeout),
     _timer(events, [this, &fan](){ fan.timerExpired(*this); })
@@ -192,6 +195,24 @@
     return duration_cast<microseconds>(seconds(_timeout));
 }
 
+void TachSensor::updateInventory(bool functional)
+{
+    auto objectMap = util::getObjMap<bool>(
+            _invName,
+            util::OPERATIONAL_STATUS_INTF,
+            util::FUNCTIONAL_PROPERTY,
+            functional);
+    auto response = util::SDBusPlus::lookupAndCallMethod(
+            _bus,
+            util::INVENTORY_PATH,
+            util::INVENTORY_INTF,
+            "Notify",
+            objectMap);
+    if (response.is_method_error())
+    {
+        log<level::ERR>("Error in notify update of tach sensor inventory");
+    }
+}
 
 }
 }