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 | */ |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 16 | #include "config.h" |
| 17 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 18 | #include "zone.hpp" |
| 19 | |
Matthew Barth | de90fb4 | 2021-03-04 16:34:28 -0600 | [diff] [blame] | 20 | #include "fan.hpp" |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 21 | |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 22 | #include <cereal/archives/json.hpp> |
| 23 | #include <cereal/cereal.hpp> |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 24 | #include <nlohmann/json.hpp> |
| 25 | #include <phosphor-logging/log.hpp> |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 26 | #include <sdbusplus/bus.hpp> |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 27 | |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 28 | #include <algorithm> |
| 29 | #include <filesystem> |
| 30 | #include <fstream> |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 31 | #include <iterator> |
| 32 | #include <map> |
| 33 | #include <numeric> |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 34 | #include <utility> |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 35 | #include <vector> |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 36 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 37 | namespace phosphor::fan::control::json |
| 38 | { |
| 39 | |
| 40 | using json = nlohmann::json; |
| 41 | using namespace phosphor::logging; |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 42 | namespace fs = std::filesystem; |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 43 | |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 44 | const std::map<std::string, |
| 45 | std::map<std::string, std::function<std::function<void(Zone*)>( |
| 46 | const json&, bool)>>> |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 47 | Zone::_intfPropHandlers = {{thermModeIntf, |
| 48 | {{supportedProp, zone::property::supported}, |
| 49 | {currentProp, zone::property::current}}}}; |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 50 | |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 51 | Zone::Zone(sdbusplus::bus::bus& bus, const json& jsonObj) : |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 52 | ConfigBase(jsonObj), |
| 53 | ThermalObject(bus, (fs::path{CONTROL_OBJPATH} /= getName()).c_str(), true), |
Matthew Barth | 45c44ea | 2021-03-03 13:16:14 -0600 | [diff] [blame^] | 54 | _incDelay(0), _floor(0), _target(0), _incDelta(0), _decDelta(0), |
| 55 | _requestTargetBase(0), _isActive(true) |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 56 | { |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 57 | // Increase delay is optional, defaults to 0 |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 58 | if (jsonObj.contains("increase_delay")) |
| 59 | { |
| 60 | _incDelay = jsonObj["increase_delay"].get<uint64_t>(); |
| 61 | } |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 62 | setDefaultCeiling(jsonObj); |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 63 | setDefaultFloor(jsonObj); |
| 64 | setDecInterval(jsonObj); |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 65 | // Setting properties on interfaces to be served are optional |
| 66 | if (jsonObj.contains("interfaces")) |
| 67 | { |
| 68 | setInterfaces(jsonObj); |
| 69 | } |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 70 | } |
| 71 | |
Matthew Barth | de90fb4 | 2021-03-04 16:34:28 -0600 | [diff] [blame] | 72 | void Zone::addFan(std::unique_ptr<Fan> fan) |
| 73 | { |
| 74 | _fans.emplace_back(std::move(fan)); |
| 75 | } |
| 76 | |
Matthew Barth | 8ba715e | 2021-03-05 09:00:05 -0600 | [diff] [blame] | 77 | void Zone::setTarget(uint64_t target) |
| 78 | { |
| 79 | if (_isActive) |
| 80 | { |
| 81 | _target = target; |
| 82 | for (auto& fan : _fans) |
| 83 | { |
| 84 | fan->setTarget(_target); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | void Zone::setActiveAllow(const std::string& ident, bool isActiveAllow) |
| 90 | { |
| 91 | _active[ident] = isActiveAllow; |
| 92 | if (!isActiveAllow) |
| 93 | { |
| 94 | _isActive = false; |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | // Check all entries are set to allow active fan control |
| 99 | auto actPred = [](const auto& entry) { return entry.second; }; |
| 100 | _isActive = std::all_of(_active.begin(), _active.end(), actPred); |
| 101 | } |
| 102 | } |
| 103 | |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 104 | void Zone::setFloor(uint64_t target) |
| 105 | { |
| 106 | // Check all entries are set to allow floor to be set |
Matthew Barth | 8ba715e | 2021-03-05 09:00:05 -0600 | [diff] [blame] | 107 | auto pred = [](const auto& entry) { return entry.second; }; |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 108 | if (std::all_of(_floorChange.begin(), _floorChange.end(), pred)) |
| 109 | { |
| 110 | _floor = target; |
| 111 | // Floor above target, update target to floor |
| 112 | if (_target < _floor) |
| 113 | { |
| 114 | requestIncrease(_floor - _target); |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | void Zone::requestIncrease(uint64_t targetDelta) |
| 120 | { |
Matthew Barth | 2b3253e | 2021-03-09 14:51:16 -0600 | [diff] [blame] | 121 | // Only increase when delta is higher than the current increase delta for |
| 122 | // the zone and currently under ceiling |
| 123 | if (targetDelta > _incDelta && _target < _ceiling) |
| 124 | { |
| 125 | auto requestTarget = getRequestTargetBase(); |
| 126 | requestTarget = (targetDelta - _incDelta) + requestTarget; |
| 127 | _incDelta = targetDelta; |
| 128 | // Target can not go above a current ceiling |
| 129 | if (requestTarget > _ceiling) |
| 130 | { |
| 131 | requestTarget = _ceiling; |
| 132 | } |
Matthew Barth | 8ba715e | 2021-03-05 09:00:05 -0600 | [diff] [blame] | 133 | setTarget(requestTarget); |
| 134 | // TODO // Restart timer countdown for fan speed increase |
Matthew Barth | 2b3253e | 2021-03-09 14:51:16 -0600 | [diff] [blame] | 135 | // _incTimer.restartOnce(_incDelay); |
| 136 | } |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 137 | } |
| 138 | |
Matthew Barth | 45c44ea | 2021-03-03 13:16:14 -0600 | [diff] [blame^] | 139 | void Zone::requestDecrease(uint64_t targetDelta) |
| 140 | { |
| 141 | // Only decrease the lowest target delta requested |
| 142 | if (_decDelta == 0 || targetDelta < _decDelta) |
| 143 | { |
| 144 | _decDelta = targetDelta; |
| 145 | } |
| 146 | } |
| 147 | |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 148 | void Zone::setPersisted(const std::string& intf, const std::string& prop) |
| 149 | { |
| 150 | if (std::find_if(_propsPersisted[intf].begin(), _propsPersisted[intf].end(), |
| 151 | [&prop](const auto& p) { return prop == p; }) != |
| 152 | _propsPersisted[intf].end()) |
| 153 | { |
| 154 | _propsPersisted[intf].emplace_back(prop); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | std::string Zone::current(std::string value) |
| 159 | { |
| 160 | auto current = ThermalObject::current(); |
| 161 | std::transform(value.begin(), value.end(), value.begin(), toupper); |
| 162 | |
| 163 | auto supported = ThermalObject::supported(); |
| 164 | auto isSupported = |
| 165 | std::any_of(supported.begin(), supported.end(), [&value](auto& s) { |
| 166 | std::transform(s.begin(), s.end(), s.begin(), toupper); |
| 167 | return value == s; |
| 168 | }); |
| 169 | |
| 170 | if (value != current && isSupported) |
| 171 | { |
| 172 | current = ThermalObject::current(value); |
| 173 | if (isPersisted("xyz.openbmc_project.Control.ThermalMode", "Current")) |
| 174 | { |
| 175 | saveCurrentMode(); |
| 176 | } |
| 177 | // TODO Trigger event(s) for current mode property change |
| 178 | // auto eData = |
| 179 | // _objects[_path]["xyz.openbmc_project.Control.ThermalMode"] |
| 180 | // ["Current"]; |
| 181 | // if (eData != nullptr) |
| 182 | // { |
| 183 | // sdbusplus::message::message nullMsg{nullptr}; |
| 184 | // handleEvent(nullMsg, eData); |
| 185 | // } |
| 186 | } |
| 187 | |
| 188 | return current; |
| 189 | } |
| 190 | |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 191 | void Zone::setDefaultCeiling(const json& jsonObj) |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 192 | { |
| 193 | if (!jsonObj.contains("full_speed")) |
| 194 | { |
| 195 | log<level::ERR>("Missing required zone's full speed", |
| 196 | entry("JSON=%s", jsonObj.dump().c_str())); |
| 197 | throw std::runtime_error("Missing required zone's full speed"); |
| 198 | } |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 199 | _defaultCeiling = jsonObj["full_speed"].get<uint64_t>(); |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 200 | // Start with the current target set as the default |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 201 | _target = _defaultCeiling; |
Matthew Barth | 2b3253e | 2021-03-09 14:51:16 -0600 | [diff] [blame] | 202 | // Start with the current ceiling set as the default |
| 203 | _ceiling = _defaultCeiling; |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | void Zone::setDefaultFloor(const json& jsonObj) |
| 207 | { |
| 208 | if (!jsonObj.contains("default_floor")) |
| 209 | { |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 210 | log<level::ERR>("Missing required zone's default floor", |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 211 | entry("JSON=%s", jsonObj.dump().c_str())); |
Matthew Barth | e47c958 | 2021-03-09 14:24:02 -0600 | [diff] [blame] | 212 | throw std::runtime_error("Missing required zone's default floor"); |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 213 | } |
| 214 | _defaultFloor = jsonObj["default_floor"].get<uint64_t>(); |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 215 | // Start with the current floor set as the default |
| 216 | _floor = _defaultFloor; |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | void Zone::setDecInterval(const json& jsonObj) |
| 220 | { |
| 221 | if (!jsonObj.contains("decrease_interval")) |
| 222 | { |
| 223 | log<level::ERR>("Missing required zone's decrease interval", |
| 224 | entry("JSON=%s", jsonObj.dump().c_str())); |
| 225 | throw std::runtime_error("Missing required zone's decrease interval"); |
| 226 | } |
| 227 | _decInterval = jsonObj["decrease_interval"].get<uint64_t>(); |
| 228 | } |
| 229 | |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 230 | void Zone::setInterfaces(const json& jsonObj) |
| 231 | { |
| 232 | for (const auto& interface : jsonObj["interfaces"]) |
| 233 | { |
| 234 | if (!interface.contains("name") || !interface.contains("properties")) |
| 235 | { |
| 236 | log<level::ERR>("Missing required zone interface attributes", |
| 237 | entry("JSON=%s", interface.dump().c_str())); |
| 238 | throw std::runtime_error( |
| 239 | "Missing required zone interface attributes"); |
| 240 | } |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 241 | auto propFuncs = |
| 242 | _intfPropHandlers.find(interface["name"].get<std::string>()); |
| 243 | if (propFuncs == _intfPropHandlers.end()) |
| 244 | { |
| 245 | // Construct list of available configurable interfaces |
| 246 | auto intfs = std::accumulate( |
| 247 | std::next(_intfPropHandlers.begin()), _intfPropHandlers.end(), |
| 248 | _intfPropHandlers.begin()->first, [](auto list, auto intf) { |
| 249 | return std::move(list) + ", " + intf.first; |
| 250 | }); |
| 251 | log<level::ERR>("Configured interface not available", |
| 252 | entry("JSON=%s", interface.dump().c_str()), |
| 253 | entry("AVAILABLE_INTFS=%s", intfs.c_str())); |
| 254 | throw std::runtime_error("Configured interface not available"); |
| 255 | } |
| 256 | |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 257 | for (const auto& property : interface["properties"]) |
| 258 | { |
| 259 | if (!property.contains("name")) |
| 260 | { |
| 261 | log<level::ERR>( |
| 262 | "Missing required interface property attributes", |
| 263 | entry("JSON=%s", property.dump().c_str())); |
| 264 | throw std::runtime_error( |
| 265 | "Missing required interface property attributes"); |
| 266 | } |
| 267 | // Attribute "persist" is optional, defaults to `false` |
| 268 | auto persist = false; |
| 269 | if (property.contains("persist")) |
| 270 | { |
| 271 | persist = property["persist"].get<bool>(); |
| 272 | } |
| 273 | // Property name from JSON must exactly match supported |
| 274 | // index names to functions in property namespace |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 275 | auto propFunc = |
| 276 | propFuncs->second.find(property["name"].get<std::string>()); |
| 277 | if (propFunc == propFuncs->second.end()) |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 278 | { |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 279 | // Construct list of available configurable properties |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 280 | auto props = std::accumulate( |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 281 | std::next(propFuncs->second.begin()), |
| 282 | propFuncs->second.end(), propFuncs->second.begin()->first, |
| 283 | [](auto list, auto prop) { |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 284 | return std::move(list) + ", " + prop.first; |
| 285 | }); |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 286 | log<level::ERR>("Configured property not available", |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 287 | entry("JSON=%s", property.dump().c_str()), |
| 288 | entry("AVAILABLE_PROPS=%s", props.c_str())); |
| 289 | throw std::runtime_error( |
| 290 | "Configured property function not available"); |
| 291 | } |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 292 | auto propHandler = propFunc->second(property, persist); |
| 293 | // Only call non-null set property handler functions |
| 294 | if (propHandler) |
| 295 | { |
| 296 | propHandler(this); |
| 297 | } |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 298 | } |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 299 | } |
| 300 | } |
| 301 | |
Matthew Barth | a0dd135 | 2021-03-09 11:10:49 -0600 | [diff] [blame] | 302 | bool Zone::isPersisted(const std::string& intf, const std::string& prop) |
| 303 | { |
| 304 | auto it = _propsPersisted.find(intf); |
| 305 | if (it == _propsPersisted.end()) |
| 306 | { |
| 307 | return false; |
| 308 | } |
| 309 | |
| 310 | return std::any_of(it->second.begin(), it->second.end(), |
| 311 | [&prop](const auto& p) { return prop == p; }); |
| 312 | } |
| 313 | |
| 314 | void Zone::saveCurrentMode() |
| 315 | { |
| 316 | fs::path path{CONTROL_PERSIST_ROOT_PATH}; |
| 317 | // Append zone name and property description |
| 318 | path /= getName(); |
| 319 | path /= "CurrentMode"; |
| 320 | std::ofstream ofs(path.c_str(), std::ios::binary); |
| 321 | cereal::JSONOutputArchive oArch(ofs); |
| 322 | oArch(ThermalObject::current()); |
| 323 | } |
| 324 | |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 325 | /** |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 326 | * Properties of interfaces supported by the zone configuration that return |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 327 | * a handler function that sets the zone's property value(s) and persist state. |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 328 | */ |
| 329 | namespace zone::property |
| 330 | { |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 331 | // Get a set property handler function for the configured values of the |
| 332 | // "Supported" property |
| 333 | std::function<void(Zone*)> supported(const json& jsonObj, bool persist) |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 334 | { |
| 335 | std::vector<std::string> values; |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 336 | if (!jsonObj.contains("values")) |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 337 | { |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 338 | log<level::ERR>( |
| 339 | "No 'values' found for \"Supported\" property, using an empty list", |
| 340 | entry("JSON=%s", jsonObj.dump().c_str())); |
| 341 | } |
| 342 | else |
| 343 | { |
| 344 | for (const auto& value : jsonObj["values"]) |
| 345 | { |
| 346 | if (!value.contains("value")) |
| 347 | { |
| 348 | log<level::ERR>("No 'value' found for \"Supported\" property " |
| 349 | "entry, skipping", |
| 350 | entry("JSON=%s", value.dump().c_str())); |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | values.emplace_back(value["value"].get<std::string>()); |
| 355 | } |
| 356 | } |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 357 | } |
| 358 | |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 359 | return Zone::setProperty<std::vector<std::string>>( |
| 360 | Zone::thermModeIntf, Zone::supportedProp, &Zone::supported, |
| 361 | std::move(values), persist); |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 362 | } |
| 363 | |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 364 | // Get a set property handler function for a configured value of the "Current" |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 365 | // property |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 366 | std::function<void(Zone*)> current(const json& jsonObj, bool persist) |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 367 | { |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 368 | // Use default value for "Current" property if no "value" entry given |
| 369 | if (!jsonObj.contains("value")) |
| 370 | { |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 371 | log<level::INFO>("No 'value' found for \"Current\" property, " |
| 372 | "using default", |
| 373 | entry("JSON=%s", jsonObj.dump().c_str())); |
| 374 | // Set persist state of property |
| 375 | return Zone::setPropertyPersist(Zone::thermModeIntf, Zone::currentProp, |
| 376 | persist); |
Matthew Barth | 216229c | 2020-09-24 13:47:33 -0500 | [diff] [blame] | 377 | } |
| 378 | |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 379 | return Zone::setProperty<std::string>( |
| 380 | Zone::thermModeIntf, Zone::currentProp, &Zone::current, |
| 381 | jsonObj["value"].get<std::string>(), persist); |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 382 | } |
Matthew Barth | b584d81 | 2021-03-11 15:55:04 -0600 | [diff] [blame] | 383 | |
Matthew Barth | 651f03a | 2020-08-27 16:15:11 -0500 | [diff] [blame] | 384 | } // namespace zone::property |
| 385 | |
Matthew Barth | 4f0d3b7 | 2020-08-27 14:32:15 -0500 | [diff] [blame] | 386 | } // namespace phosphor::fan::control::json |