From 57352a312680c62f231f9c4496b636bad10ef743 Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Mon, 10 Apr 2017 14:48:35 -0500 Subject: Fan control: Fill in Manager class Create Zone objects for the fan zones defined in the definition data that meet all conditions. Change-Id: I9c29be93716cd137f1c714355a0bd2a1c93271cd Signed-off-by: Matt Spinler --- control/manager.cpp | 36 +++++++++++++++++++++++++++++++++++- control/manager.hpp | 9 +++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'control') diff --git a/control/manager.cpp b/control/manager.cpp index 5fe0781..9359a6b 100644 --- a/control/manager.cpp +++ b/control/manager.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include "manager.hpp" namespace phosphor @@ -25,7 +26,40 @@ namespace control Manager::Manager(sdbusplus::bus::bus& bus) : _bus(bus) { - //TODO + //Create the appropriate Zone objects based on the + //actual system configuration. + + //Find the 1 ZoneGroup that meets all of its conditions + for (auto& group : _zoneLayouts) + { + auto& conditions = std::get(group); + + if (std::all_of(conditions.begin(), conditions.end(), + [](const auto& c) + { + //TODO: openbmc/openbmc#1500 + //Still need to actually evaluate the conditions + return true; + })) + { + //Create a Zone object for each zone in this group + auto& zones = std::get(group); + + for (auto& z : zones) + { + _zones.emplace(std::get(z), + std::make_unique(_bus, z)); + } + + break; + } + } + + //Set to full since we don't know state of system yet. + for (auto& z: _zones) + { + z.second->setFullSpeed(); + } } diff --git a/control/manager.hpp b/control/manager.hpp index 44f445e..7f8baa3 100644 --- a/control/manager.hpp +++ b/control/manager.hpp @@ -4,6 +4,7 @@ #include #include #include "types.hpp" +#include "zone.hpp" namespace phosphor { @@ -12,6 +13,9 @@ namespace fan namespace control { +using ZoneMap = std::map>; + /** * @class Fan control manager */ @@ -42,6 +46,11 @@ class Manager */ sdbusplus::bus::bus& _bus; + /** + * The fan zones in the system + */ + ZoneMap _zones; + /** * The fan zone layout for the system. * This is generated data. -- cgit v1.2.1