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 <algorithm>
17 #include "manager.hpp"
18 
19 namespace phosphor
20 {
21 namespace fan
22 {
23 namespace control
24 {
25 
26 Manager::Manager(sdbusplus::bus::bus& bus) :
27     _bus(bus)
28 {
29     //Create the appropriate Zone objects based on the
30     //actual system configuration.
31 
32     //Find the 1 ZoneGroup that meets all of its conditions
33     for (auto& group : _zoneLayouts)
34     {
35         auto& conditions = std::get<conditionListPos>(group);
36 
37         if (std::all_of(conditions.begin(), conditions.end(),
38                         [](const auto& c)
39                         {
40                             //TODO: openbmc/openbmc#1500
41                             //Still need to actually evaluate the conditions
42                             return true;
43                         }))
44         {
45             //Create a Zone object for each zone in this group
46             auto& zones = std::get<zoneListPos>(group);
47 
48             for (auto& z : zones)
49             {
50                 _zones.emplace(std::get<zoneNumPos>(z),
51                                std::make_unique<Zone>(_bus, z));
52             }
53 
54             break;
55         }
56     }
57 
58     //Set to full since we don't know state of system yet.
59     for (auto& z: _zones)
60     {
61         z.second->setFullSpeed();
62     }
63 }
64 
65 
66 }
67 }
68 }
69