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> |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 17 | #include "fan_enclosure.hpp" |
| 18 | #include "fan_detect_defs.hpp" |
Brad Bishop | ec613db | 2017-06-08 12:12:53 -0400 | [diff] [blame^] | 19 | #include "sdbusplus.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 | { |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 25 | 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 Bishop | ec613db | 2017-06-08 12:12:53 -0400 | [diff] [blame^] | 34 | phosphor::fan::presence::FanEnclosure>(fanProp); |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 35 | for (auto const &fanSensor: std::get<2>(fanProp)) |
| 36 | { |
| 37 | auto sensor = std::make_unique< |
Brad Bishop | ec613db | 2017-06-08 12:12:53 -0400 | [diff] [blame^] | 38 | phosphor::fan::presence::TachSensor>(fanSensor, |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 39 | *fan); |
| 40 | fan->addSensor(std::move(sensor)); |
| 41 | } |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 42 | fans.push_back(std::move(fan)); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 47 | while (true) |
| 48 | { |
Brad Bishop | ec613db | 2017-06-08 12:12:53 -0400 | [diff] [blame^] | 49 | using namespace phosphor::fan::util; |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 50 | // Respond to dbus signals |
Brad Bishop | ec613db | 2017-06-08 12:12:53 -0400 | [diff] [blame^] | 51 | SDBusPlus::getBus().process_discard(); |
| 52 | SDBusPlus::getBus().wait(); |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 53 | } |
| 54 | return 0; |
| 55 | } |