1 /** 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 24 namespace phosphor::fan::control::json 25 { 26 27 using json = nlohmann::json; 28 29 /** 30 * @class DefaultFloor - Action to default the fan floor 31 * 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. 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 49 /** 50 * @brief Default the fan floor 51 * 52 * @param[in] jsonObj - JSON configuration of this action 53 * @param[in] groups - Groups of dbus objects the action uses 54 */ 55 DefaultFloor(const json& jsonObj, const std::vector<Group>& groups); 56 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 */ 66 void run(Zone& zone) override; 67 }; 68 69 } // namespace phosphor::fan::control::json 70