Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2020 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 "config_base.hpp" |
Matthew Barth | de90fb4 | 2021-03-04 16:34:28 -0600 | [diff] [blame] | 19 | #include "fan.hpp" |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 20 | #include "xyz/openbmc_project/Control/ThermalMode/server.hpp" |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 21 | |
| 22 | #include <nlohmann/json.hpp> |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 23 | #include <sdbusplus/bus.hpp> |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 24 | |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 25 | #include <any> |
| 26 | #include <functional> |
| 27 | #include <map> |
| 28 | #include <tuple> |
| 29 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 30 | namespace phosphor::fan::control::json |
| 31 | { |
| 32 | |
| 33 | using json = nlohmann::json; |
| 34 | |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 35 | /* Extend the Control::ThermalMode interface */ |
| 36 | using ThermalObject = sdbusplus::server::object::object< |
| 37 | sdbusplus::xyz::openbmc_project::Control::server::ThermalMode>; |
| 38 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 39 | /** |
| 40 | * @class Zone - Represents a configured fan control zone |
| 41 | * |
| 42 | * A zone object contains the configured attributes for a zone that groups |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 43 | * a number of fans together to be under the same target control. These |
| 44 | * configuration attributes include, but are not limited to, the default ceiling |
| 45 | * of the fans within the zone, a default floor, the delay between increases, a |
| 46 | * decrease interval, and any profiles(OPTIONAL) the zone should be included in. |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 47 | * |
| 48 | * (When no profile for a zone is given, the zone defaults to always exist) |
| 49 | * |
| 50 | */ |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 51 | class Zone : public ConfigBase, public ThermalObject |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 52 | { |
| 53 | public: |
| 54 | /* JSON file name for zones */ |
| 55 | static constexpr auto confFileName = "zones.json"; |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 56 | static constexpr auto thermModeIntf = |
| 57 | "xyz.openbmc_project.Control.ThermalMode"; |
| 58 | static constexpr auto supportedProp = "Supported"; |
| 59 | static constexpr auto currentProp = "Current"; |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 60 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 61 | Zone() = delete; |
| 62 | Zone(const Zone&) = delete; |
| 63 | Zone(Zone&&) = delete; |
| 64 | Zone& operator=(const Zone&) = delete; |
| 65 | Zone& operator=(Zone&&) = delete; |
| 66 | ~Zone() = default; |
| 67 | |
| 68 | /** |
| 69 | * Constructor |
| 70 | * Parses and populates a zone from JSON object data |
| 71 | * |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 72 | * @param[in] bus - sdbusplus bus object |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 73 | * @param[in] jsonObj - JSON object |
| 74 | */ |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 75 | Zone(sdbusplus::bus::bus& bus, const json& jsonObj); |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 76 | |
| 77 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 78 | * @brief Get the default ceiling |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 79 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 80 | * Default ceiling is the highest target the fans within this zone is |
| 81 | * allowed to increase to. The zone's ceiling defaults to this unless |
| 82 | * changed by some configured event. |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 83 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 84 | * @return Default ceiling of this zone |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 85 | */ |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 86 | inline const auto& getDefaultCeiling() const |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 87 | { |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 88 | return _defaultCeiling; |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 92 | * @brief Get the default floor |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 93 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 94 | * The default floor is the lowest target the fans within this zone |
| 95 | * are allowed to decrease to. The zone's floor defaults to this |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 96 | * unless changed by some configured event. |
| 97 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 98 | * @return Default floor |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 99 | */ |
| 100 | inline const auto& getDefaultFloor() const |
| 101 | { |
| 102 | return _defaultFloor; |
| 103 | } |
| 104 | |
| 105 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 106 | * @brief Get the increase delay(OPTIONAL) |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 107 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 108 | * The increase delay is the amount of time(in seconds) increases |
| 109 | * to a target are delayed before being made. The default is 0, which |
| 110 | * results in immediate increase requests when any events result in |
| 111 | * a change to the target. |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 112 | * |
| 113 | * It is recommend a value other than 0 is configured, but that inherently |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 114 | * depends on the fan controller and configured increases. |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 115 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 116 | * @return Increase delay(in seconds) |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 117 | */ |
| 118 | inline const auto& getIncDelay() const |
| 119 | { |
| 120 | return _incDelay; |
| 121 | } |
| 122 | |
| 123 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 124 | * @brief Get the decrease interval |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 125 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 126 | * Decreases happen on a set interval when no requests for an increase |
| 127 | * in fan targets exists. This is the interval(in seconds) at which the fans |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 128 | * within the zone are decreased if events exist that result in a target |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 129 | * decrease. |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 130 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 131 | * @return Decrease interval(in seconds) |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 132 | */ |
| 133 | inline const auto& getDecInterval() const |
| 134 | { |
| 135 | return _decInterval; |
| 136 | } |
| 137 | |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 138 | /** |
Matthew Barth | de90fb4 | 2021-03-04 16:34:28 -0600 | [diff] [blame] | 139 | * @brief Add a fan object to the zone |
| 140 | * |
| 141 | * @param[in] fan - Unique pointer to a fan object that will be moved into |
| 142 | * the zone |
| 143 | * |
| 144 | * Adds a fan object to the list of fans that make up the zone by moving the |
| 145 | * fan object into the list. |
| 146 | */ |
| 147 | void addFan(std::unique_ptr<Fan> fan); |
| 148 | |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 149 | /** |
Matthew Barth | 8ba715e | 2021-03-05 09:00:05 -0600 | [diff] [blame] | 150 | * Sets all fans in the zone to the target given when the zone is active |
| 151 | * |
| 152 | * @param[in] target - Target for fans |
| 153 | */ |
| 154 | void setTarget(uint64_t target); |
| 155 | |
| 156 | /** |
| 157 | * @brief Sets the automatic fan control allowed active state |
| 158 | * |
| 159 | * @param[in] ident - An identifier that affects the active state |
| 160 | * @param[in] isActiveAllow - Active state according to group |
| 161 | */ |
| 162 | void setActiveAllow(const std::string& ident, bool isActiveAllow); |
| 163 | |
| 164 | /** |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 165 | * @brief Set the floor to the given target and increase target to the floor |
| 166 | * when the target is below the floor value when floor changes are allowed. |
| 167 | * |
| 168 | * @param[in] target - Target to set the floor to |
| 169 | */ |
| 170 | void setFloor(uint64_t target); |
| 171 | |
| 172 | /** |
| 173 | * @brief Sets the floor change allowed state |
| 174 | * |
| 175 | * @param[in] ident - An identifier that affects floor changes |
| 176 | * @param[in] isAllow - Allow state according to the identifier |
| 177 | */ |
| 178 | inline void setFloorChangeAllow(const std::string& ident, bool isAllow) |
| 179 | { |
| 180 | _floorChange[ident] = isAllow; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * @brief Calculate the requested target from the given delta and increases |
| 185 | * the fans, not going above the ceiling. |
| 186 | * |
| 187 | * @param[in] targetDelta - The delta to increase the target by |
| 188 | */ |
| 189 | void requestIncrease(uint64_t targetDelta); |
| 190 | |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 191 | /** |
Matthew Barth | 07fecfc | 2021-01-29 09:04:43 -0600 | [diff] [blame] | 192 | * @brief Set the requested target base to be used as the target to base a |
| 193 | * new requested target from |
| 194 | * |
| 195 | * @param[in] targetBase - Base target value to use |
| 196 | */ |
| 197 | inline void setRequestTargetBase(uint64_t targetBase) |
| 198 | { |
| 199 | _requestTargetBase = targetBase; |
| 200 | }; |
| 201 | |
| 202 | /** |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 203 | * @brief Set a property to be persisted |
| 204 | * |
| 205 | * @param[in] intf - Interface containing property |
| 206 | * @param[in] prop - Property to be persisted |
| 207 | */ |
| 208 | void setPersisted(const std::string& intf, const std::string& prop); |
| 209 | |
| 210 | /** |
| 211 | * @brief Overridden thermal object's set 'Current' property function |
| 212 | * |
| 213 | * @param[in] value - Value to set 'Current' to |
| 214 | * |
| 215 | * @return - The updated value of the 'Current' property |
| 216 | */ |
| 217 | std::string current(std::string value) override; |
| 218 | |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 219 | /** |
| 220 | * @brief A handler function to set/update a property on a zone |
| 221 | * @details Sets or updates a zone's dbus property to the given value using |
| 222 | * the provided base dbus object's set property function |
| 223 | * |
| 224 | * @param[in] intf - Interface on zone object |
| 225 | * @param[in] prop - Property on interface |
| 226 | * @param[in] func - Zone object's set property function pointer |
| 227 | * @param[in] value - Value to set property to |
| 228 | * @param[in] persist - Persist property value or not |
| 229 | * |
| 230 | * @return Lambda function |
| 231 | * A lambda function to set/update the zone's dbus property |
| 232 | */ |
| 233 | template <typename T> |
| 234 | static auto setProperty(const char* intf, const char* prop, |
| 235 | T (Zone::*func)(T), T&& value, bool persist) |
| 236 | { |
| 237 | return [=, value = std::forward<T>(value)](Zone* zone) { |
| 238 | (zone->*func)(value); |
| 239 | if (persist) |
| 240 | { |
| 241 | zone->setPersisted(intf, prop); |
| 242 | } |
| 243 | }; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * @brief A handler function to set/update a zone's dbus property's persist |
| 248 | * state |
| 249 | * @details Sets or updates a zone's dbus property's persist state where the |
| 250 | * value of the property is to be left unchanged |
| 251 | * |
| 252 | * @param[in] intf - Interface on zone object |
| 253 | * @param[in] prop - Property on interface |
| 254 | * @param[in] persist - Persist property value or not |
| 255 | * |
| 256 | * @return Lambda function |
| 257 | * A lambda function to set/update the zone's dbus property's persist |
| 258 | * state |
| 259 | */ |
| 260 | static auto setPropertyPersist(const char* intf, const char* prop, |
| 261 | bool persist) |
| 262 | { |
| 263 | return [=](Zone* zone) { |
| 264 | if (persist) |
| 265 | { |
| 266 | zone->setPersisted(intf, prop); |
| 267 | } |
| 268 | }; |
| 269 | } |
| 270 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 271 | private: |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 272 | /* The zone's default ceiling value for fans */ |
| 273 | uint64_t _defaultCeiling; |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 274 | |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 275 | /* The zone's default floor value for fans */ |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 276 | uint64_t _defaultFloor; |
| 277 | |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 278 | /* Zone's increase delay(in seconds) (OPTIONAL) */ |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 279 | uint64_t _incDelay; |
| 280 | |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 281 | /* Zone's decrease interval(in seconds) */ |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 282 | uint64_t _decInterval; |
| 283 | |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 284 | /* The floor target to not go below */ |
| 285 | uint64_t _floor; |
| 286 | |
| 287 | /* Target for this zone */ |
| 288 | uint64_t _target; |
| 289 | |
Matthew Barth | 2b3253e | 2021-03-09 14:51:16 -0600 | [diff] [blame] | 290 | /* Zone increase delta */ |
| 291 | uint64_t _incDelta; |
| 292 | |
| 293 | /* The ceiling target to not go above */ |
| 294 | uint64_t _ceiling; |
| 295 | |
| 296 | /* Requested target base */ |
| 297 | uint64_t _requestTargetBase; |
| 298 | |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 299 | /* Map of whether floor changes are allowed by a string identifier */ |
| 300 | std::map<std::string, bool> _floorChange; |
| 301 | |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 302 | /* Map of interfaces to persisted properties the zone hosts*/ |
| 303 | std::map<std::string, std::vector<std::string>> _propsPersisted; |
| 304 | |
Matthew Barth | 8ba715e | 2021-03-05 09:00:05 -0600 | [diff] [blame] | 305 | /* Automatic fan control active state */ |
| 306 | bool _isActive; |
| 307 | |
| 308 | /* Map of active fan control allowed by a string identifier */ |
| 309 | std::map<std::string, bool> _active; |
| 310 | |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 311 | /* Interface to property mapping of their associated set property handler |
| 312 | * function */ |
| 313 | static const std::map< |
| 314 | std::string, |
| 315 | std::map<std::string, |
| 316 | std::function<std::function<void(Zone*)>(const json&, bool)>>> |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 317 | _intfPropHandlers; |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 318 | |
Matthew Barth | de90fb4 | 2021-03-04 16:34:28 -0600 | [diff] [blame] | 319 | /* List of fans included in this zone */ |
| 320 | std::vector<std::unique_ptr<Fan>> _fans; |
| 321 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 322 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 323 | * @brief Parse and set the zone's default ceiling value |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 324 | * |
| 325 | * @param[in] jsonObj - JSON object for the zone |
| 326 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 327 | * Sets the default ceiling value for the zone from the JSON configuration |
| 328 | * object |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 329 | */ |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 330 | void setDefaultCeiling(const json& jsonObj); |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 331 | |
| 332 | /** |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 333 | * @brief Parse and set the zone's default floor value |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 334 | * |
| 335 | * @param[in] jsonObj - JSON object for the zone |
| 336 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 337 | * Sets the default floor value for the zone from the JSON configuration |
| 338 | * object |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 339 | */ |
| 340 | void setDefaultFloor(const json& jsonObj); |
| 341 | |
| 342 | /** |
| 343 | * @brief Parse and set the zone's decrease interval(in seconds) |
| 344 | * |
| 345 | * @param[in] jsonObj - JSON object for the zone |
| 346 | * |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 347 | * Sets the decrease interval(in seconds) for the zone from the JSON |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 348 | * configuration object |
| 349 | */ |
| 350 | void setDecInterval(const json& jsonObj); |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 351 | |
| 352 | /** |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 353 | * @brief Parse and set the interfaces served by the zone(OPTIONAL) |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 354 | * |
| 355 | * @param[in] jsonObj - JSON object for the zone |
| 356 | * |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 357 | * Constructs any zone interface handler functions for interfaces that the |
| 358 | * zone serves which contains the interface's property's value and |
| 359 | * persistency state (OPTIONAL). A property's "persist" state is defaulted |
| 360 | * to not be persisted when not given. |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 361 | */ |
| 362 | void setInterfaces(const json& jsonObj); |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 363 | |
| 364 | /** |
| 365 | * @brief Is the property persisted |
| 366 | * |
| 367 | * @param[in] intf - Interface containing property |
| 368 | * @param[in] prop - Property to check if persisted |
| 369 | * |
| 370 | * @return - True if property is to be persisted, false otherwise |
| 371 | */ |
| 372 | bool isPersisted(const std::string& intf, const std::string& prop); |
| 373 | |
| 374 | /** |
| 375 | * @brief Save the thermal control current mode property to persisted |
| 376 | * storage |
| 377 | */ |
| 378 | void saveCurrentMode(); |
Matthew Barth | 2b3253e | 2021-03-09 14:51:16 -0600 | [diff] [blame] | 379 | |
| 380 | /** |
| 381 | * @brief Get the request target base if defined, otherwise the the current |
| 382 | * target is returned |
| 383 | * |
| 384 | * @return - The request target base or current target |
| 385 | */ |
| 386 | inline auto getRequestTargetBase() const |
| 387 | { |
| 388 | return (_requestTargetBase != 0) ? _requestTargetBase : _target; |
| 389 | }; |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 390 | }; |
| 391 | |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 392 | /** |
| 393 | * Properties of interfaces supported by the zone configuration |
| 394 | */ |
| 395 | namespace zone::property |
| 396 | { |
| 397 | |
| 398 | /** |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 399 | * @brief "Supported" property on the "xyz.openbmc_project.Control.ThermalMode" |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 400 | * interface parser. Also creates the handler function for the Zone object to |
| 401 | * initialize the property according to what's parsed from the configuration. |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 402 | * |
| 403 | * @param[in] jsonObj - JSON object for the "Supported" property |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 404 | * @param[in] persist - Whether to persist the value or not |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 405 | * |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 406 | * @return Zone interface set property handler function for the "Supported" |
| 407 | * property |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 408 | */ |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 409 | std::function<void(Zone*)> supported(const json& jsonObj, bool persist); |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 410 | |
| 411 | /** |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 412 | * @brief "Current" property on the "xyz.openbmc_project.Control.ThermalMode" |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 413 | * interface parser. Also creates the handler function for the Zone object to |
| 414 | * initialize the property according to what's parsed from the configuration. |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 415 | * |
| 416 | * @param[in] jsonObj - JSON object for the "Current" property |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 417 | * @param[in] persist - Whether to persist the value or not |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 418 | * |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 419 | * @return Zone interface set property handler function for the "Current" |
| 420 | * property |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 421 | */ |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 422 | std::function<void(Zone*)> current(const json& jsonObj, bool persist); |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 423 | |
| 424 | } // namespace zone::property |
| 425 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 426 | } // namespace phosphor::fan::control::json |