summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-02-17 16:39:46 -0600
committerMatthew Barth <msbarth@us.ibm.com>2017-03-15 12:17:32 -0500
commitb803445f7095c9b1e2ab40dc37526b15e7006393 (patch)
treef590d6b285ad1e7379a4f61dd32491758ade065e
parent681c98db43500d34cb93739fc97e6da05450f75c (diff)
downloadphosphor-fan-presence-b803445f7095c9b1e2ab40dc37526b15e7006393.tar.gz
phosphor-fan-presence-b803445f7095c9b1e2ab40dc37526b15e7006393.zip
Create fan enclosure objects
For tach feedback based presence detected fans, a fan enclosure object is created from the properties given within the yaml file. Change-Id: I698dd7c8d05863aaaab4dcb5d4c696b15fdf941d Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--fan_enclosure.cpp4
-rw-r--r--fan_enclosure.hpp20
-rw-r--r--fan_properties.hpp18
-rw-r--r--tach_detect.cpp20
4 files changed, 61 insertions, 1 deletions
diff --git a/fan_enclosure.cpp b/fan_enclosure.cpp
index 5bd14e5..346911d 100644
--- a/fan_enclosure.cpp
+++ b/fan_enclosure.cpp
@@ -8,6 +8,10 @@ namespace fan
namespace presence
{
+void FanEnclosure::addInventory()
+{
+ //TODO Add this fan to inventory
+}
} // namespace presence
} // namespace fan
diff --git a/fan_enclosure.hpp b/fan_enclosure.hpp
index a94ffe7..f214f18 100644
--- a/fan_enclosure.hpp
+++ b/fan_enclosure.hpp
@@ -1,5 +1,8 @@
#pragma once
+#include <sdbusplus/bus.hpp>
+#include "fan_properties.hpp"
+
namespace phosphor
{
@@ -15,10 +18,25 @@ class FanEnclosure
FanEnclosure(const FanEnclosure&) = delete;
FanEnclosure(FanEnclosure&&) = default;
FanEnclosure& operator=(const FanEnclosure&) = delete;
- FanEnclosure& operator=(FanEnclosure&&) = default;
+ FanEnclosure& operator=(FanEnclosure&&) = delete;
~FanEnclosure() = default;
+ FanEnclosure(sdbusplus::bus::bus& bus,
+ const phosphor::fan::Properties& fanProp) :
+ bus(bus),
+ invPath(std::get<0>(fanProp)),
+ fanDesc(std::get<1>(fanProp))
+ {
+ //Add this fan to inventory
+ addInventory();
+ }
+
private:
+ sdbusplus::bus::bus& bus;
+ const std::string invPath;
+ const std::string fanDesc;
+
+ void addInventory();
};
diff --git a/fan_properties.hpp b/fan_properties.hpp
new file mode 100644
index 0000000..22d655a
--- /dev/null
+++ b/fan_properties.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <string>
+#include <vector>
+#include <tuple>
+
+
+namespace phosphor
+{
+namespace fan
+{
+
+using Properties = std::tuple<std::string,
+ std::string,
+ std::vector<std::string>>;
+
+} // namespace fan
+} // namespace phosphor
diff --git a/tach_detect.cpp b/tach_detect.cpp
index 9b2ccd1..e3d2389 100644
--- a/tach_detect.cpp
+++ b/tach_detect.cpp
@@ -1,10 +1,30 @@
#include <vector>
#include <sdbusplus/bus.hpp>
+#include "fan_enclosure.hpp"
+#include "fan_detect_defs.hpp"
+
int main(void)
{
auto bus = sdbusplus::bus::new_default();
+ std::vector<std::unique_ptr<phosphor::fan::presence::FanEnclosure>> fans;
+
+ for (auto const& detectMap: fanDetectMap)
+ {
+ if (detectMap.first == "tach")
+ {
+ for (auto const& fanProp: detectMap.second)
+ {
+ auto fan = std::make_unique<
+ phosphor::fan::presence::FanEnclosure>(bus,
+ fanProp);
+ // TODO Add sensors to fan object
+ fans.push_back(std::move(fan));
+ }
+ }
+ }
+
while (true)
{
// Respond to dbus signals
OpenPOWER on IntegriCloud