blob: dc6356a2ea4eb1792271e025b6ff6367c34c0820 [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>
Matthew Barthb8034452017-02-17 16:39:46 -060017#include "fan_enclosure.hpp"
18#include "fan_detect_defs.hpp"
Brad Bishopec613db2017-06-08 12:12:53 -040019#include "sdbusplus.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{
Matthew Barthb8034452017-02-17 16:39:46 -060025 std::vector<std::unique_ptr<phosphor::fan::presence::FanEnclosure>> fans;
26
27 for (auto const& detectMap: fanDetectMap)
28 {
29 if (detectMap.first == "tach")
30 {
31 for (auto const& fanProp: detectMap.second)
32 {
33 auto fan = std::make_unique<
Brad Bishopec613db2017-06-08 12:12:53 -040034 phosphor::fan::presence::FanEnclosure>(fanProp);
Matthew Barthd6403822017-02-17 17:10:19 -060035 for (auto const &fanSensor: std::get<2>(fanProp))
36 {
37 auto sensor = std::make_unique<
Brad Bishopec613db2017-06-08 12:12:53 -040038 phosphor::fan::presence::TachSensor>(fanSensor,
Matthew Barthd6403822017-02-17 17:10:19 -060039 *fan);
40 fan->addSensor(std::move(sensor));
41 }
Matthew Barthb8034452017-02-17 16:39:46 -060042 fans.push_back(std::move(fan));
43 }
44 }
45 }
46
Matthew Barth293477d2017-02-17 15:39:36 -060047 while (true)
48 {
Brad Bishopec613db2017-06-08 12:12:53 -040049 using namespace phosphor::fan::util;
Matthew Barth293477d2017-02-17 15:39:36 -060050 // Respond to dbus signals
Brad Bishopec613db2017-06-08 12:12:53 -040051 SDBusPlus::getBus().process_discard();
52 SDBusPlus::getBus().wait();
Matthew Barth293477d2017-02-17 15:39:36 -060053 }
54 return 0;
55}