summaryrefslogtreecommitdiffstats
path: root/control/fan.hpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-04-10 14:33:35 -0500
committerMatt Spinler <spinler@us.ibm.com>2017-04-27 10:03:54 -0500
commite2b25cb25702490e1bd8b31ce055249f0158a944 (patch)
tree73bbb10947c59aaaee41a7471499867c5e5cf78f /control/fan.hpp
parent5cfdf94fdf0ac1167c9337cec95ba4d932ad40f7 (diff)
downloadphosphor-fan-presence-e2b25cb25702490e1bd8b31ce055249f0158a944.tar.gz
phosphor-fan-presence-e2b25cb25702490e1bd8b31ce055249f0158a944.zip
Fan control: Create Fan class
This class contains the inventory name of the fan, and the sensor names representing the rotors. Calling setSpeed on this object will set the speed on all contained sensors. Change-Id: I850e2d69067813005270105618fcf69b04382b03 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'control/fan.hpp')
-rw-r--r--control/fan.hpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/control/fan.hpp b/control/fan.hpp
new file mode 100644
index 0000000..e23d44e
--- /dev/null
+++ b/control/fan.hpp
@@ -0,0 +1,79 @@
+#pragma once
+#include <sdbusplus/bus.hpp>
+#include "types.hpp"
+
+namespace phosphor
+{
+namespace fan
+{
+namespace control
+{
+
+
+/**
+ * @class Fan
+ *
+ * Represents a fan. It has sensors used for setting speeds
+ * on all of the contained rotors. There may or may not be
+ * a 1 to 1 correspondence between rotors and sensors, depending
+ * on how the hardware and hwmon is configured.
+ *
+ */
+class Fan
+{
+ public:
+
+ Fan() = delete;
+ Fan(const Fan&) = delete;
+ Fan(Fan&&) = default;
+ Fan& operator=(const Fan&) = delete;
+ Fan& operator=(Fan&&) = default;
+ ~Fan() = default;
+
+ /**
+ * Creates a fan object with sensors specified by
+ * the fan definition data.
+ *
+ * @param[in] bus - the dbus object
+ * @param[in] def - the fan definition data
+ */
+ Fan(sdbusplus::bus::bus& bus, const FanDefinition& def);
+
+ /**
+ * Sets the speed value on all contained sensors
+ *
+ * @param[in] speed - the value to set
+ */
+ void setSpeed(uint64_t speed);
+
+ private:
+
+ /**
+ * Returns the service name to use for interacting
+ * with the fan sensor passed in.
+ *
+ * @param[in] sensor - the fan tach sensor name
+ * @return - the service name
+ */
+ std::string getService(const std::string& sensor);
+
+ /**
+ * The dbus object
+ */
+ sdbusplus::bus::bus& _bus;
+
+ /**
+ * The inventory name of the fan
+ */
+ std::string _name;
+
+ /**
+ * Vector of hwmon sensors for the rotors
+ */
+ std::vector<std::string> _sensors;
+};
+
+
+}
+}
+}
OpenPOWER on IntegriCloud