monitor: Track fan health in the System object
To prepare for being able to power off the system based on missing fans
or nonfunctional fan sensors, put a global view of this health for all
fans in the System object. This requires now keeping track of fan
presence.
This information is stored in a map based on the fan name. It is done
this way, as opposed to just always calling present/functional APIs on
the Fan objects, so that the code that will be using this information
can be tested in isolation without the System or Fan objects.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ieb1d4003bd13cebc806fd06f0064c63ea8ac6180
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index 537d8fd..a7db524 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -138,6 +138,26 @@
*/
uint64_t findTargetSpeed();
+ /**
+ * @brief Returns the contained TachSensor objects
+ *
+ * @return std::vector<std::shared_ptr<TachSensor>> - The sensors
+ */
+ const std::vector<std::shared_ptr<TachSensor>>& sensors() const
+ {
+ return _sensors;
+ }
+
+ /**
+ * @brief Returns the presence status of the fan
+ *
+ * @return bool - If the fan is present or not
+ */
+ bool present() const
+ {
+ return _present;
+ }
+
private:
/**
* @brief Returns true if the sensor input is not within
@@ -169,6 +189,13 @@
void startMonitor();
/**
+ * @brief Called when the fan presence property changes on D-Bus
+ *
+ * @param[in] msg - The message from the propertiesChanged signal
+ */
+ void presenceChanged(sdbusplus::message::message& msg);
+
+ /**
* @brief the dbus object
*/
sdbusplus::bus::bus& _bus;
@@ -234,6 +261,18 @@
* @brief Reference to the System object
*/
System& _system;
+
+ /**
+ * @brief The match object for propertiesChanged signals
+ * for the inventory item interface to track the
+ * Present property.
+ */
+ sdbusplus::bus::match::match _presenceMatch;
+
+ /**
+ * @brief The current presence state
+ */
+ bool _present = false;
};
} // namespace monitor