blob: 3eeb13d39366805bc8890631bd897fb48e7076aa [file] [log] [blame]
Matthew Barth0c4b1572020-10-22 14:39:46 -05001/**
Matthew Barth41a34082021-01-27 15:31:48 -06002 * Copyright © 2021 IBM Corporation
Matthew Barth0c4b1572020-10-22 14:39:46 -05003 *
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
Matthew Barth12cb1252021-03-08 16:47:30 -060018#include "../zone.hpp"
Matthew Barth0c4b1572020-10-22 14:39:46 -050019#include "action.hpp"
Matthew Barth12cb1252021-03-08 16:47:30 -060020#include "group.hpp"
Matthew Barth0c4b1572020-10-22 14:39:46 -050021
22#include <nlohmann/json.hpp>
23
24namespace phosphor::fan::control::json
25{
26
27using json = nlohmann::json;
28
29/**
30 * @class DefaultFloor - Action to default the fan floor speed
31 *
32 * Sets the fan floor to the defined default fan floor speed when a
33 * service associated to a given group has terminated. Once all services
34 * are functional and providing the sensors, the fan floor is allowed
35 * to be set normally again.
36 */
37class DefaultFloor : public ActionBase, public ActionRegister<DefaultFloor>
38{
39 public:
40 /* Name of this action */
41 static constexpr auto name = "default_floor_on_missing_owner";
42
43 DefaultFloor() = delete;
44 DefaultFloor(const DefaultFloor&) = delete;
45 DefaultFloor(DefaultFloor&&) = delete;
46 DefaultFloor& operator=(const DefaultFloor&) = delete;
47 DefaultFloor& operator=(DefaultFloor&&) = delete;
48 ~DefaultFloor() = default;
49
Matthew Barth41a34082021-01-27 15:31:48 -060050 /**
51 * @brief Default the fan floor speed
52 *
53 * No JSON configuration parameters required
54 */
Matthew Barth0c4b1572020-10-22 14:39:46 -050055 explicit DefaultFloor(const json&);
56
Matthew Barth41a34082021-01-27 15:31:48 -060057 /**
58 * @brief Run the action
59 *
60 * Updates the services of the group, then determines if any of the
61 * services hosting the members of the group are not owned on dbus
62 * resulting in the zone's floor being set/held at the default floor.
63 *
64 * @param[in] zone - Zone to run the action on
65 * @param[in] group - Group of dbus objects the action runs against
66 */
67 void run(Zone& zone, const Group& group) override;
Matthew Barth0c4b1572020-10-22 14:39:46 -050068};
69
70} // namespace phosphor::fan::control::json