Matthew Barth | 5c15b79 | 2017-03-01 11:17:00 -0600 | [diff] [blame] | 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 | */ |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 16 | #include <vector> |
| 17 | #include <sdbusplus/bus.hpp> |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 18 | #include "fan_enclosure.hpp" |
| 19 | #include "fan_detect_defs.hpp" |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 20 | #include "tach_sensor.hpp" |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 21 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 22 | |
| 23 | int main(void) |
| 24 | { |
| 25 | auto bus = sdbusplus::bus::new_default(); |
| 26 | |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 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); |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 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 | } |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 46 | fans.push_back(std::move(fan)); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 51 | while (true) |
| 52 | { |
| 53 | // Respond to dbus signals |
| 54 | bus.process_discard(); |
| 55 | bus.wait(); |
| 56 | } |
| 57 | return 0; |
| 58 | } |