1 /**
2  * Copyright © 2017 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <vector>
17 #include <sdbusplus/bus.hpp>
18 #include "fan_enclosure.hpp"
19 #include "fan_detect_defs.hpp"
20 #include "tach_sensor.hpp"
21 
22 
23 int main(void)
24 {
25     auto bus = sdbusplus::bus::new_default();
26 
27     std::vector<std::unique_ptr<phosphor::fan::presence::FanEnclosure>> fans;
28 
29     for (auto const& detectMap: fanDetectMap)
30     {
31         if (detectMap.first == "tach")
32         {
33             for (auto const& fanProp: detectMap.second)
34             {
35                 auto fan = std::make_unique<
36                     phosphor::fan::presence::FanEnclosure>(bus,
37                                                            fanProp);
38                 for (auto const &fanSensor: std::get<2>(fanProp))
39                 {
40                     auto sensor = std::make_unique<
41                         phosphor::fan::presence::TachSensor>(bus,
42                                                              fanSensor,
43                                                              *fan);
44                     fan->addSensor(std::move(sensor));
45                 }
46                 fans.push_back(std::move(fan));
47             }
48         }
49     }
50 
51     while (true)
52     {
53         // Respond to dbus signals
54         bus.process_discard();
55         bus.wait();
56     }
57     return 0;
58 }
59