1 /** 2 * Copyright © 2020 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 #pragma once 17 18 #include <nlohmann/json.hpp> 19 #include <sdbusplus/bus.hpp> 20 21 namespace phosphor::fan::control::json 22 { 23 24 using json = nlohmann::json; 25 26 /** 27 * @class Manager - Represents the fan control manager's configuration 28 * 29 * A fan control manager configuration is optional, therefore the "manager.json" 30 * file is also optional. The manager configuration is used to populate 31 * fan control's manager parameters which are used in how the application 32 * operates, not in how the fans are controlled. 33 * 34 * When no manager configuration exists, the fan control application starts, 35 * processes any configured events and then begins controlling fans according 36 * to those events. 37 */ 38 class Manager 39 { 40 public: 41 Manager() = delete; 42 Manager(const Manager&) = delete; 43 Manager(Manager&&) = delete; 44 Manager& operator=(const Manager&) = delete; 45 Manager& operator=(Manager&&) = delete; 46 ~Manager() = default; 47 48 /** 49 * Constructor 50 * Parses and populates the fan control manager attributes from a json file 51 * 52 * @param[in] bus - sdbusplus bus object 53 */ 54 explicit Manager(sdbusplus::bus::bus& bus); 55 56 /** 57 * @brief Get the configured power on delay(OPTIONAL) 58 * 59 * @return Power on delay in seconds 60 * Configured power on delay in seconds, otherwise 0 61 */ 62 unsigned int getPowerOnDelay(); 63 64 private: 65 /* JSON file name for manager configuration attributes */ 66 static constexpr auto confFileName = "manager.json"; 67 68 /* The parsed JSON object */ 69 json _jsonObj; 70 }; 71 72 } // namespace phosphor::fan::control::json 73