summaryrefslogtreecommitdiffstats
path: root/tach_detect.cpp
blob: 5da1b48a74e72662859c3312298074ed24284f4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <vector>
#include <sdbusplus/bus.hpp>
#include "fan_enclosure.hpp"
#include "fan_detect_defs.hpp"
#include "tach_sensor.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);
                for (auto const &fanSensor: std::get<2>(fanProp))
                {
                    auto sensor = std::make_unique<
                        phosphor::fan::presence::TachSensor>(bus,
                                                             fanSensor,
                                                             *fan);
                    fan->addSensor(std::move(sensor));
                }
                fans.push_back(std::move(fan));
            }
        }
    }

    while (true)
    {
        // Respond to dbus signals
        bus.process_discard();
        bus.wait();
    }
    return 0;
}
OpenPOWER on IntegriCloud