blob: 85e5ed9e8e8475f60a3adacd3d7561ab788c259b [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 Barth07fecfc2021-01-29 09:04:43 -060058 */
Matthew Barthbfd7e1b2021-02-04 14:25:47 -060059 explicit RequestTargetBase(const json& jsonObj);
Matthew Barth07fecfc2021-01-29 09:04:43 -060060
61 /**
62 * @brief Run the action
63 *
64 * Determines the maximum value from the properties of the group of dbus
65 * objects and sets the requested target base to this value. Only positive
66 * integer or floating point types are supported as these are the only
67 * valid types for a fan target to be based off of.
68 *
69 * @param[in] zone - Zone to run the action on
70 * @param[in] group - Group of dbus objects the action runs against
71 */
72 void run(Zone& zone, const Group& group) override;
73};
74
75} // namespace phosphor::fan::control::json