Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 1 | #include <vector> |
| 2 | #include <sdbusplus/bus.hpp> |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 3 | #include "fan_enclosure.hpp" |
| 4 | #include "fan_detect_defs.hpp" |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame^] | 5 | #include "tach_sensor.hpp" |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 6 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 7 | |
| 8 | int main(void) |
| 9 | { |
| 10 | auto bus = sdbusplus::bus::new_default(); |
| 11 | |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 12 | 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 Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame^] | 23 | 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 Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 31 | fans.push_back(std::move(fan)); |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 36 | while (true) |
| 37 | { |
| 38 | // Respond to dbus signals |
| 39 | bus.process_discard(); |
| 40 | bus.wait(); |
| 41 | } |
| 42 | return 0; |
| 43 | } |