Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 1 | /** |
Matthew Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 2 | * Copyright © 2021 IBM Corporation |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 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 | |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 18 | #include "../zone.hpp" |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 19 | #include "action.hpp" |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 20 | #include "group.hpp" |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 21 | |
| 22 | #include <nlohmann/json.hpp> |
| 23 | |
| 24 | namespace phosphor::fan::control::json |
| 25 | { |
| 26 | |
| 27 | using json = nlohmann::json; |
| 28 | |
| 29 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 30 | * @class DefaultFloor - Action to default the fan floor |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 31 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 32 | * Sets the fan floor to the defined default fan floor when a service associated |
| 33 | * to a given group has terminated. Once all services are functional and |
| 34 | * providing the sensors, the fan floor is allowed to be set normally again. |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 35 | */ |
| 36 | class DefaultFloor : public ActionBase, public ActionRegister<DefaultFloor> |
| 37 | { |
| 38 | public: |
| 39 | /* Name of this action */ |
| 40 | static constexpr auto name = "default_floor_on_missing_owner"; |
| 41 | |
| 42 | DefaultFloor() = delete; |
| 43 | DefaultFloor(const DefaultFloor&) = delete; |
| 44 | DefaultFloor(DefaultFloor&&) = delete; |
| 45 | DefaultFloor& operator=(const DefaultFloor&) = delete; |
| 46 | DefaultFloor& operator=(DefaultFloor&&) = delete; |
| 47 | ~DefaultFloor() = default; |
| 48 | |
Matthew Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 49 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 50 | * @brief Default the fan floor |
Matthew Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 51 | * |
Matthew Barth | bfd7e1b | 2021-02-04 14:25:47 -0600 | [diff] [blame] | 52 | * @param[in] jsonObj - JSON configuration of this action |
Matthew Barth | 19c7749 | 2021-04-08 10:06:06 -0500 | [diff] [blame] | 53 | * @param[in] groups - Groups of dbus objects the action uses |
Matthew Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 54 | */ |
Matthew Barth | 19c7749 | 2021-04-08 10:06:06 -0500 | [diff] [blame] | 55 | DefaultFloor(const json& jsonObj, const std::vector<Group>& groups); |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 56 | |
Matthew Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 57 | /** |
| 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 |
Matthew Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 65 | */ |
Matthew Barth | 6d2476c | 2021-04-08 10:48:57 -0500 | [diff] [blame] | 66 | void run(Zone& zone) override; |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | } // namespace phosphor::fan::control::json |