Matthew Barth | a227a16 | 2020-08-05 10:51:45 -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 | |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 18 | #include "action.hpp" |
Matthew Barth | 44ab769 | 2021-03-26 11:40:10 -0500 | [diff] [blame] | 19 | #include "config_base.hpp" |
| 20 | #include "event.hpp" |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 21 | #include "group.hpp" |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 22 | #include "json_config.hpp" |
Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 23 | #include "profile.hpp" |
Matthew Barth | 9403a21 | 2021-05-17 09:31:50 -0500 | [diff] [blame] | 24 | #include "sdbusplus.hpp" |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 25 | #include "zone.hpp" |
Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 26 | |
Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 27 | #include <nlohmann/json.hpp> |
| 28 | #include <sdbusplus/bus.hpp> |
Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 29 | #include <sdeventplus/event.hpp> |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 30 | #include <sdeventplus/utility/timer.hpp> |
| 31 | |
| 32 | #include <chrono> |
| 33 | #include <map> |
| 34 | #include <memory> |
| 35 | #include <optional> |
| 36 | #include <tuple> |
| 37 | #include <utility> |
| 38 | #include <vector> |
Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 39 | |
| 40 | namespace phosphor::fan::control::json |
| 41 | { |
| 42 | |
| 43 | using json = nlohmann::json; |
| 44 | |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 45 | /* Application name to be appended to the path for loading a JSON config file */ |
| 46 | constexpr auto confAppName = "control"; |
| 47 | |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 48 | /* Type of timers supported */ |
| 49 | enum class TimerType |
| 50 | { |
| 51 | oneshot, |
| 52 | repeating, |
| 53 | }; |
| 54 | /** |
| 55 | * Package of data required when a timer expires |
| 56 | * Tuple constructed of: |
| 57 | * std::string = Timer package unique identifier |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 58 | * std::vector<std::unique_ptr<ActionBase>> = List of pointers to actions |
| 59 | * that run when the timer expires |
| 60 | */ |
Matthew Barth | 00f6aa0 | 2021-04-09 10:49:47 -0500 | [diff] [blame] | 61 | using TimerPkg = |
| 62 | std::tuple<std::string, std::vector<std::unique_ptr<ActionBase>>&>; |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 63 | /** |
| 64 | * Data associated with a running timer that's used when it expires |
| 65 | * Pair constructed of: |
| 66 | * TimerType = Type of timer to manage expired timer instances |
| 67 | * TimerPkg = Package of data required when the timer expires |
| 68 | */ |
| 69 | using TimerData = std::pair<TimerType, TimerPkg>; |
| 70 | /* Dbus event timer */ |
| 71 | using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>; |
| 72 | |
Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 73 | /* Dbus signal object */ |
| 74 | constexpr auto Path = 0; |
| 75 | constexpr auto Intf = 1; |
| 76 | constexpr auto Prop = 2; |
| 77 | using SignalObject = std::tuple<std::string, std::string, std::string>; |
| 78 | /* Dbus signal actions */ |
| 79 | using SignalActions = |
| 80 | std::vector<std::reference_wrapper<std::unique_ptr<ActionBase>>>; |
| 81 | /** |
| 82 | * Signal handler function that handles parsing a signal's message for a |
| 83 | * particular signal object and stores the results in the manager |
| 84 | */ |
| 85 | using SignalHandler = std::function<bool(sdbusplus::message::message&, |
| 86 | const SignalObject&, Manager&)>; |
| 87 | /** |
| 88 | * Package of data required when a signal is received |
| 89 | * Tuple constructed of: |
| 90 | * SignalHandler = Signal handler function |
| 91 | * SignalObject = Dbus signal object |
| 92 | * SignalActions = List of actions that are run when the signal is received |
| 93 | */ |
| 94 | using SignalPkg = std::tuple<SignalHandler, SignalObject, SignalActions>; |
| 95 | /** |
| 96 | * Data associated to a subscribed signal |
| 97 | * Tuple constructed of: |
| 98 | * std::unique_ptr<std::vector<SignalPkg>> = |
| 99 | * Pointer to the signal's packages |
| 100 | * std::unique_ptr<sdbusplus::server::match::match> = |
| 101 | * Pointer to match holding the subscription to a signal |
| 102 | */ |
| 103 | using SignalData = std::tuple<std::unique_ptr<std::vector<SignalPkg>>, |
| 104 | std::unique_ptr<sdbusplus::server::match::match>>; |
| 105 | |
Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 106 | /** |
| 107 | * @class Manager - Represents the fan control manager's configuration |
| 108 | * |
| 109 | * A fan control manager configuration is optional, therefore the "manager.json" |
| 110 | * file is also optional. The manager configuration is used to populate |
| 111 | * fan control's manager parameters which are used in how the application |
| 112 | * operates, not in how the fans are controlled. |
| 113 | * |
| 114 | * When no manager configuration exists, the fan control application starts, |
| 115 | * processes any configured events and then begins controlling fans according |
| 116 | * to those events. |
| 117 | */ |
| 118 | class Manager |
| 119 | { |
| 120 | public: |
| 121 | Manager() = delete; |
| 122 | Manager(const Manager&) = delete; |
| 123 | Manager(Manager&&) = delete; |
| 124 | Manager& operator=(const Manager&) = delete; |
| 125 | Manager& operator=(Manager&&) = delete; |
| 126 | ~Manager() = default; |
| 127 | |
| 128 | /** |
| 129 | * Constructor |
| 130 | * Parses and populates the fan control manager attributes from a json file |
| 131 | * |
Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 132 | * @param[in] event - sdeventplus event loop |
Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 133 | */ |
Matthew Barth | 9403a21 | 2021-05-17 09:31:50 -0500 | [diff] [blame] | 134 | Manager(const sdeventplus::Event& event); |
Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 135 | |
| 136 | /** |
Matthew Barth | e91ac86 | 2021-05-25 16:22:17 -0500 | [diff] [blame^] | 137 | * @brief Callback function to handle receiving a HUP signal to reload the |
| 138 | * JSON configurations. |
| 139 | */ |
| 140 | void sighupHandler(sdeventplus::source::Signal&, |
| 141 | const struct signalfd_siginfo*); |
| 142 | |
| 143 | /** |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 144 | * @brief Get the active profiles of the system where an empty list |
| 145 | * represents that only configuration entries without a profile defined will |
| 146 | * be loaded. |
| 147 | * |
| 148 | * @return - The list of active profiles |
| 149 | */ |
| 150 | static const std::vector<std::string>& getActiveProfiles(); |
| 151 | |
| 152 | /** |
| 153 | * @brief Load the configuration of a given JSON class object based on the |
| 154 | * active profiles |
| 155 | * |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 156 | * @param[in] isOptional - JSON configuration file is optional or not |
Matthew Barth | 603ef16 | 2021-03-24 15:34:53 -0500 | [diff] [blame] | 157 | * @param[in] args - Arguments to be forwarded to each instance of `T` |
Matthew Barth | e6d1f78 | 2021-05-14 12:52:20 -0500 | [diff] [blame] | 158 | * (*Note that a sdbusplus bus object is required as the first argument) |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 159 | * |
| 160 | * @return Map of configuration entries |
| 161 | * Map of configuration keys to their corresponding configuration object |
| 162 | */ |
Matthew Barth | 603ef16 | 2021-03-24 15:34:53 -0500 | [diff] [blame] | 163 | template <typename T, typename... Args> |
Matthew Barth | e6d1f78 | 2021-05-14 12:52:20 -0500 | [diff] [blame] | 164 | static std::map<configKey, std::unique_ptr<T>> getConfig(bool isOptional, |
| 165 | Args&&... args) |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 166 | { |
| 167 | std::map<configKey, std::unique_ptr<T>> config; |
| 168 | |
Matthew Barth | 9403a21 | 2021-05-17 09:31:50 -0500 | [diff] [blame] | 169 | auto confFile = |
| 170 | fan::JsonConfig::getConfFile(util::SDBusPlus::getBus(), confAppName, |
| 171 | T::confFileName, isOptional); |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 172 | if (!confFile.empty()) |
| 173 | { |
| 174 | for (const auto& entry : fan::JsonConfig::load(confFile)) |
| 175 | { |
| 176 | if (entry.contains("profiles")) |
| 177 | { |
| 178 | std::vector<std::string> profiles; |
| 179 | for (const auto& profile : entry["profiles"]) |
| 180 | { |
| 181 | profiles.emplace_back( |
| 182 | profile.template get<std::string>()); |
| 183 | } |
| 184 | // Do not create the object if its profiles are not in the |
| 185 | // list of active profiles |
Matthew Barth | 4242805 | 2021-03-30 12:50:59 -0500 | [diff] [blame] | 186 | if (!profiles.empty() && |
| 187 | !std::any_of(profiles.begin(), profiles.end(), |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 188 | [](const auto& name) { |
| 189 | return std::find( |
| 190 | getActiveProfiles().begin(), |
| 191 | getActiveProfiles().end(), |
| 192 | name) != |
| 193 | getActiveProfiles().end(); |
| 194 | })) |
| 195 | { |
| 196 | continue; |
| 197 | } |
| 198 | } |
Matthew Barth | 603ef16 | 2021-03-24 15:34:53 -0500 | [diff] [blame] | 199 | auto obj = |
| 200 | std::make_unique<T>(entry, std::forward<Args>(args)...); |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 201 | config.emplace( |
| 202 | std::make_pair(obj->getName(), obj->getProfiles()), |
| 203 | std::move(obj)); |
| 204 | } |
| 205 | } |
| 206 | return config; |
| 207 | } |
| 208 | |
| 209 | /** |
Matthew Barth | 0206c72 | 2021-03-30 15:20:05 -0500 | [diff] [blame] | 210 | * @brief Check if the given input configuration key matches with another |
| 211 | * configuration key that it's to be included in |
| 212 | * |
| 213 | * @param[in] input - Config key to be included in another config object |
| 214 | * @param[in] comp - Config key of the config object to compare with |
| 215 | * |
| 216 | * @return Whether the configuration object should be included |
| 217 | */ |
| 218 | static bool inConfig(const configKey& input, const configKey& comp); |
| 219 | |
| 220 | /** |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 221 | * @brief Check if the given path and inteface is owned by a dbus service |
| 222 | * |
| 223 | * @param[in] path - Dbus object path |
| 224 | * @param[in] intf - Dbus object interface |
| 225 | * |
| 226 | * @return - Whether the service has an owner for the given object path and |
| 227 | * interface |
| 228 | */ |
| 229 | static bool hasOwner(const std::string& path, const std::string& intf); |
| 230 | |
| 231 | /** |
Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 232 | * @brief Sets the dbus service owner state of a given object |
| 233 | * |
| 234 | * @param[in] path - Dbus object path |
| 235 | * @param[in] serv - Dbus service name |
| 236 | * @param[in] intf - Dbus object interface |
| 237 | * @param[in] isOwned - Dbus service owner state |
| 238 | */ |
| 239 | void setOwner(const std::string& path, const std::string& serv, |
| 240 | const std::string& intf, bool isOwned); |
| 241 | |
| 242 | /** |
| 243 | * @brief Add a set of services for a path and interface by retrieving all |
| 244 | * the path subtrees to the given depth from root for the interface |
| 245 | * |
Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 246 | * @param[in] intf - Interface to add services for |
| 247 | * @param[in] depth - Depth of tree traversal from root path |
| 248 | * |
| 249 | * @throws - DBusMethodError |
| 250 | * Throws a DBusMethodError when the `getSubTree` method call fails |
| 251 | */ |
Matthew Barth | 98f6fc1 | 2021-04-16 10:48:37 -0500 | [diff] [blame] | 252 | static void addServices(const std::string& intf, int32_t depth); |
Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * @brief Get the service for a given path and interface from cached |
| 256 | * dataset and attempt to add all the services for the given path/interface |
| 257 | * when it's not found |
| 258 | * |
| 259 | * @param[in] path - Path to get service for |
| 260 | * @param[in] intf - Interface to get service for |
| 261 | * |
| 262 | * @return - The now cached service name |
| 263 | * |
| 264 | * @throws - DBusMethodError |
| 265 | * Ripples up a DBusMethodError exception from calling addServices |
| 266 | */ |
| 267 | static const std::string& getService(const std::string& path, |
| 268 | const std::string& intf); |
| 269 | |
| 270 | /** |
Matthew Barth | f41e947 | 2021-05-13 16:38:06 -0500 | [diff] [blame] | 271 | * @brief Get all the object paths for a given service and interface from |
| 272 | * the cached dataset and try to add all the services for the given |
| 273 | * interface when no paths are found and then attempt to get all the object |
| 274 | * paths again |
| 275 | * |
| 276 | * @param[in] serv - Service name to get paths for |
| 277 | * @param[in] intf - Interface to get paths for |
| 278 | * |
| 279 | * @return The cached object paths |
| 280 | */ |
| 281 | std::vector<std::string> getPaths(const std::string& serv, |
| 282 | const std::string& intf); |
| 283 | |
| 284 | /** |
| 285 | * @brief Add objects to the cached dataset by first using |
| 286 | * `getManagedObjects` for the same service providing the given path and |
| 287 | * interface or just add the single object of the given path, interface, and |
| 288 | * property if that fails. |
| 289 | * |
| 290 | * @param[in] path - Dbus object's path |
| 291 | * @param[in] intf - Dbus object's interface |
| 292 | * @param[in] prop - Dbus object's property |
| 293 | * |
| 294 | * @throws - DBusMethodError |
| 295 | * Throws a DBusMethodError when the the service is failed to be found or |
| 296 | * when the `getManagedObjects` method call fails |
| 297 | */ |
| 298 | void addObjects(const std::string& path, const std::string& intf, |
| 299 | const std::string& prop); |
| 300 | |
| 301 | /** |
| 302 | * @brief Get an object's property value |
| 303 | * |
| 304 | * @param[in] path - Dbus object's path |
| 305 | * @param[in] intf - Dbus object's interface |
| 306 | * @param[in] prop - Dbus object's property |
| 307 | */ |
| 308 | const std::optional<PropertyVariantType> |
| 309 | getProperty(const std::string& path, const std::string& intf, |
| 310 | const std::string& prop); |
| 311 | |
| 312 | /** |
Matthew Barth | baeeb8f | 2021-05-13 16:03:54 -0500 | [diff] [blame] | 313 | * @brief Set/update an object's property value |
| 314 | * |
| 315 | * @param[in] path - Dbus object's path |
| 316 | * @param[in] intf - Dbus object's interface |
| 317 | * @param[in] prop - Dbus object's property |
| 318 | * @param[in] value - Dbus object's property value |
| 319 | */ |
| 320 | void setProperty(const std::string& path, const std::string& intf, |
| 321 | const std::string& prop, PropertyVariantType value) |
| 322 | { |
| 323 | _objects[path][intf][prop] = std::move(value); |
| 324 | } |
| 325 | |
| 326 | /** |
Matthew Barth | c269140 | 2021-05-13 16:20:32 -0500 | [diff] [blame] | 327 | * @brief Remove an object's interface |
| 328 | * |
| 329 | * @param[in] path - Dbus object's path |
| 330 | * @param[in] intf - Dbus object's interface |
| 331 | */ |
| 332 | inline void removeInterface(const std::string& path, |
| 333 | const std::string& intf) |
| 334 | { |
| 335 | auto itPath = _objects.find(path); |
| 336 | if (itPath != std::end(_objects)) |
| 337 | { |
| 338 | _objects[path].erase(intf); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | /** |
Matthew Barth | 07fecfc | 2021-01-29 09:04:43 -0600 | [diff] [blame] | 343 | * @brief Get the object's property value as a variant |
| 344 | * |
| 345 | * @param[in] path - Path of the object containing the property |
| 346 | * @param[in] intf - Interface name containing the property |
| 347 | * @param[in] prop - Name of property |
| 348 | * |
| 349 | * @return - The object's property value as a variant |
| 350 | */ |
| 351 | static inline auto getObjValueVariant(const std::string& path, |
| 352 | const std::string& intf, |
| 353 | const std::string& prop) |
| 354 | { |
| 355 | return _objects.at(path).at(intf).at(prop); |
| 356 | }; |
| 357 | |
| 358 | /** |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 359 | * @brief Add a dbus timer |
| 360 | * |
| 361 | * @param[in] type - Type of timer |
| 362 | * @param[in] interval - Timer interval in microseconds |
| 363 | * @param[in] pkg - Packaged data for when timer expires |
| 364 | */ |
| 365 | void addTimer(const TimerType type, |
| 366 | const std::chrono::microseconds interval, |
| 367 | std::unique_ptr<TimerPkg> pkg); |
| 368 | |
| 369 | /** |
| 370 | * @brief Callback when a timer expires |
| 371 | * |
| 372 | * @param[in] data - Data to be used when the timer expired |
| 373 | */ |
| 374 | void timerExpired(TimerData& data); |
| 375 | |
| 376 | /** |
Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 377 | * @brief Get the signal data for a given match string |
| 378 | * |
| 379 | * @param[in] sigMatch - Signal match string |
| 380 | * |
| 381 | * @return - Reference to the signal data for the given match string |
| 382 | */ |
| 383 | std::vector<SignalData>& getSignal(const std::string& sigMatch) |
| 384 | { |
| 385 | return _signals[sigMatch]; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * @brief Handle receiving signals |
| 390 | * |
| 391 | * @param[in] msg - Signal message containing the signal's data |
| 392 | * @param[in] pkgs - Signal packages associated to the signal being handled |
| 393 | */ |
| 394 | void handleSignal(sdbusplus::message::message& msg, |
| 395 | const std::vector<SignalPkg>* pkgs); |
| 396 | |
| 397 | /** |
Matthew Barth | eebde06 | 2021-04-14 12:48:52 -0500 | [diff] [blame] | 398 | * @brief Get the sdbusplus bus object |
| 399 | */ |
| 400 | inline auto& getBus() |
| 401 | { |
| 402 | return _bus; |
| 403 | } |
| 404 | |
| 405 | /** |
Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 406 | * @brief Get the configured power on delay(OPTIONAL) |
| 407 | * |
| 408 | * @return Power on delay in seconds |
| 409 | * Configured power on delay in seconds, otherwise 0 |
| 410 | */ |
| 411 | unsigned int getPowerOnDelay(); |
| 412 | |
| 413 | private: |
| 414 | /* JSON file name for manager configuration attributes */ |
| 415 | static constexpr auto confFileName = "manager.json"; |
| 416 | |
| 417 | /* The parsed JSON object */ |
| 418 | json _jsonObj; |
Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 419 | |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 420 | /** |
| 421 | * The sdbusplus bus object to use |
| 422 | */ |
| 423 | sdbusplus::bus::bus& _bus; |
| 424 | |
| 425 | /** |
| 426 | * The sdeventplus even loop to use |
| 427 | */ |
| 428 | sdeventplus::Event _event; |
| 429 | |
Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 430 | /* List of profiles configured */ |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 431 | std::map<configKey, std::unique_ptr<Profile>> _profiles; |
Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 432 | |
| 433 | /* List of active profiles */ |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 434 | static std::vector<std::string> _activeProfiles; |
| 435 | |
Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 436 | /* Subtree map of paths to services of interfaces(with ownership state) */ |
| 437 | static std::map< |
| 438 | std::string, |
| 439 | std::map<std::string, std::pair<bool, std::vector<std::string>>>> |
Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 440 | _servTree; |
| 441 | |
Matthew Barth | 07fecfc | 2021-01-29 09:04:43 -0600 | [diff] [blame] | 442 | /* Object map of paths to interfaces of properties and their values */ |
| 443 | static std::map< |
| 444 | std::string, |
| 445 | std::map<std::string, std::map<std::string, PropertyVariantType>>> |
| 446 | _objects; |
| 447 | |
Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 448 | /* List of timers and their data to be processed when expired */ |
| 449 | std::vector<std::pair<std::unique_ptr<TimerData>, Timer>> _timers; |
| 450 | |
Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 451 | /* Map of signal match strings to a list of signal handler data */ |
| 452 | std::unordered_map<std::string, std::vector<SignalData>> _signals; |
| 453 | |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 454 | /* List of zones configured */ |
| 455 | std::map<configKey, std::unique_ptr<Zone>> _zones; |
| 456 | |
Matthew Barth | 44ab769 | 2021-03-26 11:40:10 -0500 | [diff] [blame] | 457 | /* List of events configured */ |
| 458 | std::map<configKey, std::unique_ptr<Event>> _events; |
| 459 | |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 460 | /** |
Matthew Barth | e91ac86 | 2021-05-25 16:22:17 -0500 | [diff] [blame^] | 461 | * @brief Load all the fan control JSON configuration files |
| 462 | * |
| 463 | * This is where all the fan control JSON configuration files are parsed and |
| 464 | * loaded into their associated objects. Anything that needs to be done when |
| 465 | * the Manager object is constructed or handling a SIGHUP to reload the |
| 466 | * configurations needs to be done here. |
| 467 | */ |
| 468 | void load(); |
| 469 | |
| 470 | /** |
Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 471 | * @brief Find the service name for a given path and interface from the |
| 472 | * cached dataset |
| 473 | * |
| 474 | * @param[in] path - Path to get service for |
| 475 | * @param[in] intf - Interface to get service for |
| 476 | * |
| 477 | * @return - The cached service name |
| 478 | */ |
| 479 | static const std::string& findService(const std::string& path, |
| 480 | const std::string& intf); |
| 481 | |
| 482 | /** |
Matthew Barth | f41e947 | 2021-05-13 16:38:06 -0500 | [diff] [blame] | 483 | * @brief Find all the paths for a given service and interface from the |
| 484 | * cached dataset |
| 485 | * |
| 486 | * @param[in] serv - Service name to get paths for |
| 487 | * @param[in] intf - Interface to get paths for |
| 488 | * |
| 489 | * @return - The cached object paths |
| 490 | */ |
| 491 | std::vector<std::string> findPaths(const std::string& serv, |
| 492 | const std::string& intf); |
| 493 | |
| 494 | /** |
Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 495 | * @brief Parse and set the configured profiles from the profiles JSON file |
| 496 | * |
| 497 | * Retrieves the optional profiles JSON configuration file, parses it, and |
| 498 | * creates a list of configured profiles available to the other |
| 499 | * configuration files. These profiles can be used to remove or include |
| 500 | * entries within the other configuration files. |
| 501 | */ |
| 502 | void setProfiles(); |
Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 503 | }; |
| 504 | |
| 505 | } // namespace phosphor::fan::control::json |