10c4b1574SMatthew Barth /** 241a3408dSMatthew Barth * Copyright © 2021 IBM Corporation 30c4b1574SMatthew Barth * 40c4b1574SMatthew Barth * Licensed under the Apache License, Version 2.0 (the "License"); 50c4b1574SMatthew Barth * you may not use this file except in compliance with the License. 60c4b1574SMatthew Barth * You may obtain a copy of the License at 70c4b1574SMatthew Barth * 80c4b1574SMatthew Barth * http://www.apache.org/licenses/LICENSE-2.0 90c4b1574SMatthew Barth * 100c4b1574SMatthew Barth * Unless required by applicable law or agreed to in writing, software 110c4b1574SMatthew Barth * distributed under the License is distributed on an "AS IS" BASIS, 120c4b1574SMatthew Barth * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130c4b1574SMatthew Barth * See the License for the specific language governing permissions and 140c4b1574SMatthew Barth * limitations under the License. 150c4b1574SMatthew Barth */ 160c4b1574SMatthew Barth #pragma once 170c4b1574SMatthew Barth 1812cb125aSMatthew Barth #include "../zone.hpp" 190c4b1574SMatthew Barth #include "action.hpp" 2012cb125aSMatthew Barth #include "group.hpp" 210c4b1574SMatthew Barth 220c4b1574SMatthew Barth #include <nlohmann/json.hpp> 230c4b1574SMatthew Barth 240c4b1574SMatthew Barth namespace phosphor::fan::control::json 250c4b1574SMatthew Barth { 260c4b1574SMatthew Barth 270c4b1574SMatthew Barth using json = nlohmann::json; 280c4b1574SMatthew Barth 290c4b1574SMatthew Barth /** 30e47c9588SMatthew Barth * @class DefaultFloor - Action to default the fan floor 310c4b1574SMatthew Barth * 32e47c9588SMatthew Barth * Sets the fan floor to the defined default fan floor when a service associated 33e47c9588SMatthew Barth * to a given group has terminated. Once all services are functional and 34e47c9588SMatthew Barth * providing the sensors, the fan floor is allowed to be set normally again. 350c4b1574SMatthew Barth */ 360c4b1574SMatthew Barth class DefaultFloor : public ActionBase, public ActionRegister<DefaultFloor> 370c4b1574SMatthew Barth { 380c4b1574SMatthew Barth public: 390c4b1574SMatthew Barth /* Name of this action */ 400c4b1574SMatthew Barth static constexpr auto name = "default_floor_on_missing_owner"; 410c4b1574SMatthew Barth 420c4b1574SMatthew Barth DefaultFloor() = delete; 430c4b1574SMatthew Barth DefaultFloor(const DefaultFloor&) = delete; 440c4b1574SMatthew Barth DefaultFloor(DefaultFloor&&) = delete; 450c4b1574SMatthew Barth DefaultFloor& operator=(const DefaultFloor&) = delete; 460c4b1574SMatthew Barth DefaultFloor& operator=(DefaultFloor&&) = delete; 470c4b1574SMatthew Barth ~DefaultFloor() = default; 480c4b1574SMatthew Barth 4941a3408dSMatthew Barth /** 50e47c9588SMatthew Barth * @brief Default the fan floor 5141a3408dSMatthew Barth * 52bfd7e1b7SMatthew Barth * @param[in] jsonObj - JSON configuration of this action 5319c77494SMatthew Barth * @param[in] groups - Groups of dbus objects the action uses 5441a3408dSMatthew Barth */ 5519c77494SMatthew Barth DefaultFloor(const json& jsonObj, const std::vector<Group>& groups); 560c4b1574SMatthew Barth 5741a3408dSMatthew Barth /** 5841a3408dSMatthew Barth * @brief Run the action 5941a3408dSMatthew Barth * 6041a3408dSMatthew Barth * Updates the services of the group, then determines if any of the 6141a3408dSMatthew Barth * services hosting the members of the group are not owned on dbus 6241a3408dSMatthew Barth * resulting in the zone's floor being set/held at the default floor. 6341a3408dSMatthew Barth * 6441a3408dSMatthew Barth * @param[in] zone - Zone to run the action on 6541a3408dSMatthew Barth */ 66*6d2476c9SMatthew Barth void run(Zone& zone) override; 670c4b1574SMatthew Barth }; 680c4b1574SMatthew Barth 690c4b1574SMatthew Barth } // namespace phosphor::fan::control::json 70