1 /** 2 * Copyright © 2021 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 "../zone.hpp" 19 #include "action.hpp" 20 #include "group.hpp" 21 22 #include <nlohmann/json.hpp> 23 24 namespace phosphor::fan::control::json 25 { 26 27 using json = nlohmann::json; 28 29 /** 30 * @class RequestTargetBase - Action to set the requested target base 31 * 32 * Sets the base of a calculated requested target to the maximum value found 33 * from the properties given within a group. The requested target base is what 34 * the calculated requested target should be determined from when changing fan 35 * targets. By default, the base of the next calculated requested target is the 36 * current target of the zone. This action allows that base to be changed 37 * according to the maximum value found from a given group of dbus objects. 38 */ 39 class RequestTargetBase : 40 public ActionBase, 41 public ActionRegister<RequestTargetBase> 42 { 43 public: 44 /* Name of this action */ 45 static constexpr auto name = "set_request_target_base_with_max"; 46 47 RequestTargetBase() = delete; 48 RequestTargetBase(const RequestTargetBase&) = delete; 49 RequestTargetBase(RequestTargetBase&&) = delete; 50 RequestTargetBase& operator=(const RequestTargetBase&) = delete; 51 RequestTargetBase& operator=(RequestTargetBase&&) = delete; 52 ~RequestTargetBase() = default; 53 54 /** 55 * @brief Update the requested target base 56 * 57 * @param[in] jsonObj - JSON configuration of this action 58 * @param[in] groups - Groups of dbus objects the action uses 59 */ 60 RequestTargetBase(const json& jsonObj, const std::vector<Group>& groups); 61 62 /** 63 * @brief Run the action 64 * 65 * Determines the maximum value from the properties of the group of dbus 66 * objects and sets the requested target base to this value. Only positive 67 * integer or floating point types are supported as these are the only 68 * valid types for a fan target to be based off of. 69 * 70 * @param[in] zone - Zone to run the action on 71 */ 72 void run(Zone& zone) override; 73 }; 74 75 } // namespace phosphor::fan::control::json 76