summaryrefslogtreecommitdiffstats
path: root/presence/tach.hpp
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-06-14 16:54:03 -0400
committerPatrick Williams <patrick@stwcx.xyz>2017-08-02 20:18:19 +0000
commitdd62e36eabe275348bc7e74201f960197b01bd0c (patch)
treeca6948e8867d7028df60612b399b624c9f88b46b /presence/tach.hpp
parent221b36b5a84e7e2d7488a6333e3d32982adae9aa (diff)
downloadphosphor-fan-presence-dd62e36eabe275348bc7e74201f960197b01bd0c.tar.gz
phosphor-fan-presence-dd62e36eabe275348bc7e74201f960197b01bd0c.zip
presence: Add new tach sensor implementation
Add a new fan speed (tach) presence implementation for the new PresenceSensor interface. This fan tach sensor behaves mostly like the existing one, with the addition of support for multiple tach sensors for the single PresenceSensor instance, and implementation of the PresenceSensor start and stop interfaces. Change-Id: I535a3e2c78ef0f06f10b6f4cda9a7e2d0e9c11db Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'presence/tach.hpp')
-rw-r--r--presence/tach.hpp110
1 files changed, 110 insertions, 0 deletions
diff --git a/presence/tach.hpp b/presence/tach.hpp
new file mode 100644
index 0000000..4f02521
--- /dev/null
+++ b/presence/tach.hpp
@@ -0,0 +1,110 @@
+#pragma once
+
+#include <sdbusplus/message.hpp>
+#include <sdbusplus/bus/match.hpp>
+#include <string>
+#include <vector>
+#include "psensor.hpp"
+#include "sdbusplus.hpp"
+
+namespace phosphor
+{
+namespace fan
+{
+namespace presence
+{
+class RedundancyPolicy;
+
+/**
+ * @class Tach
+ * @brief Fan tach sensor presence implementation.
+ *
+ * The Tach class uses one or more tach speed indicators
+ * to determine presence state.
+ */
+class Tach : public PresenceSensor
+{
+ public:
+ /**
+ * @brief
+ *
+ * Cannot move or copy due to this ptr as context
+ * for sdbus callbacks.
+ */
+ Tach() = delete;
+ Tach(const Tach&) = delete;
+ Tach& operator=(const Tach&) = delete;
+ Tach(Tach&&) = delete;
+ Tach& operator=(Tach&&) = delete;
+ ~Tach() = default;
+
+ /**
+ * @brief ctor
+ *
+ * @param[in] sensors - Fan tach sensors for this psensor.
+ */
+ Tach(const std::vector<std::string>& sensors);
+
+ /**
+ * @brief start
+ *
+ * Register for dbus signal callbacks on fan
+ * tach sensor change. Query initial tach speeds.
+ *
+ * @return The current sensor state.
+ */
+ bool start() override;
+
+ /**
+ * @brief stop
+ *
+ * De-register dbus signal callbacks.
+ */
+ void stop() override;
+
+ /**
+ * @brief Check the sensor.
+ *
+ * Query the tach speeds.
+ */
+ bool present() override;
+
+ private :
+ /**
+ * @brief Get the policy associated with this sensor.
+ */
+ virtual RedundancyPolicy& getPolicy() = 0;
+
+ /**
+ * @brief Properties changed handler for tach sensor updates.
+ *
+ * @param[in] sensor - The sensor that changed.
+ * @param[in] props - The properties that changed.
+ */
+ void propertiesChanged(
+ size_t sensor,
+ const phosphor::fan::util::Properties<int64_t>& props);
+
+ /**
+ * @brief Properties changed handler for tach sensor updates.
+ *
+ * @param[in] sensor - The sensor that changed.
+ * @param[in] msg - The sdbusplus signal message.
+ */
+ void propertiesChanged(
+ size_t sensor,
+ sdbusplus::message::message& msg);
+
+ /** @brief array of tach sensors dbus matches, and tach values. */
+ std::vector<std::tuple<
+ std::string,
+ std::unique_ptr<sdbusplus::bus::match::match>,
+ int64_t>> state;
+
+ /** The current state of the sensor. */
+ bool currentState;
+};
+
+} // namespace presence
+} // namespace fan
+} // namespace phosphor
OpenPOWER on IntegriCloud