summaryrefslogtreecommitdiffstats
path: root/monitor
diff options
context:
space:
mode:
Diffstat (limited to 'monitor')
-rw-r--r--monitor/Makefile.am3
-rw-r--r--monitor/fan.hpp10
-rw-r--r--monitor/tach_sensor.cpp23
-rw-r--r--monitor/tach_sensor.hpp13
4 files changed, 47 insertions, 2 deletions
diff --git a/monitor/Makefile.am b/monitor/Makefile.am
index 4e2d599..8eda1e0 100644
--- a/monitor/Makefile.am
+++ b/monitor/Makefile.am
@@ -19,7 +19,8 @@ phosphor_fan_monitor_LDADD = \
$(top_builddir)/libfan.la \
$(SDBUSPLUS_LIBS) \
$(PHOSPHOR_LOGGING_LIBS) \
- ${PHOSPHOR_DBUS_INTERFACES_LIBS}
+ ${PHOSPHOR_DBUS_INTERFACES_LIBS} \
+ -lstdc++fs
phosphor_fan_monitor_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index 5a21e31..f22bd9f 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -124,6 +124,16 @@ class Fan
*/
void timerExpired(TachSensor& sensor);
+ /**
+ * @brief Get the name of the fan
+ *
+ * @return - The fan name
+ */
+ inline const std::string& getName() const
+ {
+ return _name;
+ }
+
private:
/**
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_SENSOR_VALUE_INTF = "xyz.openbmc_project.Sensor.Value";
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 @@ TachSensor::TachSensor(sdbusplus::bus::bus& bus,
_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 @@ std::chrono::microseconds TachSensor::getTimeout()
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");
+ }
+}
}
}
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 9b10110..59b99d2 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -167,6 +167,14 @@ class TachSensor
*/
void handleTachChange(sdbusplus::message::message& msg);
+ /**
+ * @brief Updates the Functional property in the inventory
+ * for this tach sensor based on the value passed in.
+ *
+ * @param[in] functional - If the Functional property should
+ * be set to true or false.
+ */
+ void updateInventory(bool functional);
/**
* @brief the dbus object
@@ -186,6 +194,11 @@ class TachSensor
const std::string _name;
/**
+ * @brief The inventory name of the sensor, including the full path
+ */
+ const std::string _invName;
+
+ /**
* @brief If functional (not too slow). The parent
* fan object sets this.
*/
OpenPOWER on IntegriCloud