blob: 2449f823958379fbe21d897fd44b5893fdae5f06 [file] [log] [blame]
Matthew Barth5c15b792017-03-01 11:17:00 -06001/**
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 */
Matthew Barth293477d2017-02-17 15:39:36 -060016#include <vector>
17#include <sdbusplus/bus.hpp>
Matthew Barthb8034452017-02-17 16:39:46 -060018#include "fan_enclosure.hpp"
19#include "fan_detect_defs.hpp"
Matthew Barthd6403822017-02-17 17:10:19 -060020#include "tach_sensor.hpp"
Matthew Barthb8034452017-02-17 16:39:46 -060021
Matthew Barth293477d2017-02-17 15:39:36 -060022
23int main(void)
24{
25 auto bus = sdbusplus::bus::new_default();
26
Matthew Barthb8034452017-02-17 16:39:46 -060027 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);
Matthew Barthd6403822017-02-17 17:10:19 -060038 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 }
Matthew Barthb8034452017-02-17 16:39:46 -060046 fans.push_back(std::move(fan));
47 }
48 }
49 }
50
Matthew Barth293477d2017-02-17 15:39:36 -060051 while (true)
52 {
53 // Respond to dbus signals
54 bus.process_discard();
55 bus.wait();
56 }
57 return 0;
58}