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 | |
| 18 | #include "action.hpp" |
| 19 | #include "types.hpp" |
Matthew Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 20 | #include "zone.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 | /** |
| 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 | */ |
| 37 | class 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 Barth | 41a3408 | 2021-01-27 15:31:48 -0600 | [diff] [blame] | 50 | /** |
| 51 | * @brief Default the fan floor speed |
| 52 | * |
| 53 | * No JSON configuration parameters required |
| 54 | */ |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 55 | explicit DefaultFloor(const json&); |
| 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 |
| 65 | * @param[in] group - Group of dbus objects the action runs against |
| 66 | */ |
| 67 | void run(Zone& zone, const Group& group) override; |
Matthew Barth | 0c4b157 | 2020-10-22 14:39:46 -0500 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | } // namespace phosphor::fan::control::json |