blob: d2b82dc21a480be2b09eb6c5f0086efb2dbd4167 [file] [log] [blame]
Matthew Barth279183f2021-05-25 10:19:43 -05001/**
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 "xyz/openbmc_project/Control/ThermalMode/server.hpp"
19
20/* Extend the Control::ThermalMode interface */
Patrick Williamscb356d42022-07-22 19:26:53 -050021using ThermalModeIntf = sdbusplus::server::object_t<
Matthew Barth279183f2021-05-25 10:19:43 -050022 sdbusplus::xyz::openbmc_project::Control::server::ThermalMode>;
23
24namespace phosphor::fan::control::json
25{
26
27class Zone;
28
29class DBusZone : public ThermalModeIntf
30{
31 public:
32 static constexpr auto thermalModeIntf =
33 "xyz.openbmc_project.Control.ThermalMode";
34 static constexpr auto supportedProp = "Supported";
35 static constexpr auto currentProp = "Current";
36
37 DBusZone() = delete;
38 DBusZone(const DBusZone&) = delete;
39 DBusZone(DBusZone&&) = delete;
40 DBusZone& operator=(const DBusZone&) = delete;
41 DBusZone& operator=(DBusZone&&) = delete;
42 ~DBusZone() = default;
43
44 /**
45 * Constructor
46 * Creates a thermal control dbus object associated with the given zone
47 *
48 * @param[in] zone - Zone object
49 */
Matt Spinler9b062432023-01-26 14:38:50 -060050 explicit DBusZone(const Zone& zone);
Matthew Barth279183f2021-05-25 10:19:43 -050051
52 /**
53 * @brief Overridden thermalmode interface's set 'Current' property function
54 *
55 * @param[in] value - Value to set 'Current' to
56 *
57 * @return - The updated value of the 'Current' property
58 */
59 std::string current(std::string value) override;
60
61 /**
62 * @brief Restore persisted thermalmode `Current` mode property value,
63 * setting the mode to "Default" otherwise
64 */
65 void restoreCurrentMode();
66
67 private:
68 /* Zone object associated with this thermal control dbus object */
69 const Zone& _zone;
70
71 /**
72 * @brief Save the thermalmode `Current` mode property to persisted storage
73 */
74 void saveCurrentMode();
75};
76
77} // namespace phosphor::fan::control::json