blob: 5da1b48a74e72662859c3312298074ed24284f4e [file] [log] [blame]
Matthew Barth293477d2017-02-17 15:39:36 -06001#include <vector>
2#include <sdbusplus/bus.hpp>
Matthew Barthb8034452017-02-17 16:39:46 -06003#include "fan_enclosure.hpp"
4#include "fan_detect_defs.hpp"
Matthew Barthd6403822017-02-17 17:10:19 -06005#include "tach_sensor.hpp"
Matthew Barthb8034452017-02-17 16:39:46 -06006
Matthew Barth293477d2017-02-17 15:39:36 -06007
8int main(void)
9{
10 auto bus = sdbusplus::bus::new_default();
11
Matthew Barthb8034452017-02-17 16:39:46 -060012 std::vector<std::unique_ptr<phosphor::fan::presence::FanEnclosure>> fans;
13
14 for (auto const& detectMap: fanDetectMap)
15 {
16 if (detectMap.first == "tach")
17 {
18 for (auto const& fanProp: detectMap.second)
19 {
20 auto fan = std::make_unique<
21 phosphor::fan::presence::FanEnclosure>(bus,
22 fanProp);
Matthew Barthd6403822017-02-17 17:10:19 -060023 for (auto const &fanSensor: std::get<2>(fanProp))
24 {
25 auto sensor = std::make_unique<
26 phosphor::fan::presence::TachSensor>(bus,
27 fanSensor,
28 *fan);
29 fan->addSensor(std::move(sensor));
30 }
Matthew Barthb8034452017-02-17 16:39:46 -060031 fans.push_back(std::move(fan));
32 }
33 }
34 }
35
Matthew Barth293477d2017-02-17 15:39:36 -060036 while (true)
37 {
38 // Respond to dbus signals
39 bus.process_discard();
40 bus.wait();
41 }
42 return 0;
43}