blob: e5a3469e076cc182028a2b927a2991a905896e38 [file] [log] [blame]
Matthew Barth07fecfc2021-01-29 09:04:43 -06001/**
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
24namespace phosphor::fan::control::json
25{
26
27using 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 */
39class RequestTargetBase :
40 public ActionBase,
41 public ActionRegister<RequestTargetBase>
42{
43 public:
44 /* Name of this action */
45 static constexpr auto name = "set_request_speed_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 *
Matthew Barthbfd7e1b2021-02-04 14:25:47 -060057 * @param[in] jsonObj - JSON configuration of this action
Matthew Barth19c77492021-04-08 10:06:06 -050058 * @param[in] groups - Groups of dbus objects the action uses
Matthew Barth07fecfc2021-01-29 09:04:43 -060059 */
Matthew Barth19c77492021-04-08 10:06:06 -050060 RequestTargetBase(const json& jsonObj, const std::vector<Group>& groups);
Matthew Barth07fecfc2021-01-29 09:04:43 -060061
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
Matthew Barth07fecfc2021-01-29 09:04:43 -060071 */
Matthew Barth6d2476c2021-04-08 10:48:57 -050072 void run(Zone& zone) override;
Matthew Barth07fecfc2021-01-29 09:04:43 -060073};
74
75} // namespace phosphor::fan::control::json