diff options
-rw-r--r-- | control/Makefile.am | 4 | ||||
-rw-r--r-- | control/generated.cpp | 25 | ||||
-rw-r--r-- | control/main.cpp | 3 | ||||
-rw-r--r-- | control/manager.cpp | 34 | ||||
-rw-r--r-- | control/manager.hpp | 55 |
5 files changed, 120 insertions, 1 deletions
diff --git a/control/Makefile.am b/control/Makefile.am index dce5df0..adfd227 100644 --- a/control/Makefile.am +++ b/control/Makefile.am @@ -5,7 +5,9 @@ sbin_PROGRAMS = \ phosphor-fan-control phosphor_fan_control_SOURCES = \ - main.cpp + generated.cpp \ + main.cpp \ + manager.cpp phosphor_fan_control_LDADD = \ $(SDBUSPLUS_LIBS) \ diff --git a/control/generated.cpp b/control/generated.cpp new file mode 100644 index 0000000..e6ed723 --- /dev/null +++ b/control/generated.cpp @@ -0,0 +1,25 @@ +#include "manager.hpp" + +//This will eventually be generated by a script. + +using namespace phosphor::fan::control; + +const std::vector<ZoneGroup> Manager::_zoneLayouts +{ + //Air cooled + std::make_tuple(std::vector<Condition>{}, + std::vector<ZoneDefinition>{std::make_tuple(0, 10500, + std::vector<FanDefinition>{ + std::make_tuple("/system/chassis/motherboard/fan0", std::vector<std::string>{"fan0"}), + std::make_tuple("/system/chassis/motherboard/fan1", std::vector<std::string>{"fan1"}), + std::make_tuple("/system/chassis/motherboard/fan2", std::vector<std::string>{"fan2"}), + std::make_tuple("/system/chassis/motherboard/fan3", std::vector<std::string>{"fan3"})})}), + + //Water and air cooled + std::make_tuple(std::vector<Condition>{}, + std::vector<ZoneDefinition>{std::make_tuple(0, 10500, + std::vector<FanDefinition>{ + std::make_tuple("/system/chassis/motherboard/fan0", std::vector<std::string>{"fan0"}), + std::make_tuple("/system/chassis/motherboard/fan2", std::vector<std::string>{"fan2"}), + std::make_tuple("/system/chassis/motherboard/fan3", std::vector<std::string>{"fan3"})})}) +}; diff --git a/control/main.cpp b/control/main.cpp index e332dda..08a7dc9 100644 --- a/control/main.cpp +++ b/control/main.cpp @@ -14,11 +14,14 @@ * limitations under the License. */ #include <sdbusplus/bus.hpp> +#include "manager.hpp" int main(int argc, char* argv[]) { auto bus = sdbusplus::bus::new_default(); + phosphor::fan::control::Manager manager(bus); + while (true) { bus.process_discard(); diff --git a/control/manager.cpp b/control/manager.cpp new file mode 100644 index 0000000..5fe0781 --- /dev/null +++ b/control/manager.cpp @@ -0,0 +1,34 @@ +/** + * Copyright © 2017 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "manager.hpp" + +namespace phosphor +{ +namespace fan +{ +namespace control +{ + +Manager::Manager(sdbusplus::bus::bus& bus) : + _bus(bus) +{ + //TODO +} + + +} +} +} diff --git a/control/manager.hpp b/control/manager.hpp new file mode 100644 index 0000000..44f445e --- /dev/null +++ b/control/manager.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include <memory> +#include <vector> +#include <sdbusplus/bus.hpp> +#include "types.hpp" + +namespace phosphor +{ +namespace fan +{ +namespace control +{ + +/** + * @class Fan control manager + */ +class Manager +{ + public: + + Manager() = delete; + Manager(const Manager&) = delete; + Manager(Manager&&) = default; + Manager& operator=(const Manager&) = delete; + Manager& operator=(Manager&&) = delete; + ~Manager() = default; + + /** + * Constructor + * Creates the Zone objects based on the + * _zoneLayouts data. + * + * @param[in] bus - The dbus object + */ + Manager(sdbusplus::bus::bus& bus); + + private: + + /** + * The dbus object + */ + sdbusplus::bus::bus& _bus; + + /** + * The fan zone layout for the system. + * This is generated data. + */ + static const std::vector<ZoneGroup> _zoneLayouts; +}; + + +} +} +} |