Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 1 | #pragma once |
Matthew Barth | a956184 | 2017-06-29 11:43:45 -0500 | [diff] [blame] | 2 | #include <chrono> |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 3 | #include <vector> |
Matthew Barth | bfb1a56 | 2017-10-05 17:03:40 -0500 | [diff] [blame] | 4 | #include <cassert> |
Matthew Barth | e0ca13e | 2017-06-13 16:29:09 -0500 | [diff] [blame] | 5 | #include <algorithm> |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include "fan.hpp" |
| 8 | #include "types.hpp" |
Matthew Barth | 8600d9a | 2017-06-23 14:38:05 -0500 | [diff] [blame] | 9 | #include "timer.hpp" |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 10 | |
| 11 | namespace phosphor |
| 12 | { |
| 13 | namespace fan |
| 14 | { |
| 15 | namespace control |
| 16 | { |
| 17 | |
| 18 | /** |
Matthew Barth | 1418413 | 2017-05-19 14:37:30 -0500 | [diff] [blame] | 19 | * The mode fan control will run in: |
| 20 | * - init - only do the initialization steps |
| 21 | * - control - run normal control algorithms |
| 22 | */ |
| 23 | enum class Mode |
| 24 | { |
| 25 | init, |
| 26 | control |
| 27 | }; |
| 28 | |
| 29 | /** |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 30 | * @class Represents a fan control zone, which is a group of fans |
| 31 | * that behave the same. |
| 32 | */ |
| 33 | class Zone |
| 34 | { |
| 35 | public: |
| 36 | |
| 37 | Zone() = delete; |
| 38 | Zone(const Zone&) = delete; |
| 39 | Zone(Zone&&) = default; |
| 40 | Zone& operator=(const Zone&) = delete; |
| 41 | Zone& operator=(Zone&&) = delete; |
| 42 | ~Zone() = default; |
| 43 | |
| 44 | /** |
| 45 | * Constructor |
| 46 | * Creates the appropriate fan objects based on |
| 47 | * the zone definition data passed in. |
| 48 | * |
Matthew Barth | 1418413 | 2017-05-19 14:37:30 -0500 | [diff] [blame] | 49 | * @param[in] mode - mode of fan control |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 50 | * @param[in] bus - the dbus object |
Matthew Barth | 8600d9a | 2017-06-23 14:38:05 -0500 | [diff] [blame] | 51 | * @param[in] events - sd_event pointer |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 52 | * @param[in] def - the fan zone definition data |
| 53 | */ |
Matthew Barth | 1418413 | 2017-05-19 14:37:30 -0500 | [diff] [blame] | 54 | Zone(Mode mode, |
| 55 | sdbusplus::bus::bus& bus, |
Matthew Barth | 8600d9a | 2017-06-23 14:38:05 -0500 | [diff] [blame] | 56 | phosphor::fan::event::EventPtr& events, |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 57 | const ZoneDefinition& def); |
| 58 | |
| 59 | /** |
| 60 | * Sets all fans in the zone to the speed |
Matthew Barth | 60b0076 | 2017-08-15 13:39:06 -0500 | [diff] [blame] | 61 | * passed in when the zone is active |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 62 | * |
| 63 | * @param[in] speed - the fan speed |
| 64 | */ |
| 65 | void setSpeed(uint64_t speed); |
| 66 | |
| 67 | /** |
Matthew Barth | 60b0076 | 2017-08-15 13:39:06 -0500 | [diff] [blame] | 68 | * Sets the zone to full speed regardless of zone's active state |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 69 | */ |
Matthew Barth | 60b0076 | 2017-08-15 13:39:06 -0500 | [diff] [blame] | 70 | void setFullSpeed(); |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 71 | |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 72 | /** |
Matthew Barth | 861d77c | 2017-05-22 14:18:25 -0500 | [diff] [blame] | 73 | * @brief Sets the automatic fan control allowed active state |
| 74 | * |
| 75 | * @param[in] group - A group that affects the active state |
| 76 | * @param[in] isActiveAllow - Active state according to group |
| 77 | */ |
| 78 | void setActiveAllow(const Group* group, bool isActiveAllow); |
| 79 | |
| 80 | /** |
Matthew Barth | 98726c4 | 2017-10-17 10:35:20 -0500 | [diff] [blame] | 81 | * @brief Sets the floor change allowed state |
| 82 | * |
| 83 | * @param[in] group - A group that affects floor changes |
| 84 | * @param[in] isAllow - Allow state according to group |
| 85 | */ |
| 86 | inline void setFloorChangeAllow(const Group* group, bool isAllow) |
| 87 | { |
| 88 | _floorChange[*(group)] = isAllow; |
| 89 | } |
| 90 | |
| 91 | /** |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 92 | * @brief Sets a given object's property value |
| 93 | * |
| 94 | * @param[in] object - Name of the object containing the property |
Matthew Barth | cec5ab7 | 2017-06-02 15:20:56 -0500 | [diff] [blame] | 95 | * @param[in] interface - Interface name containing the property |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 96 | * @param[in] property - Property name |
| 97 | * @param[in] value - Property value |
| 98 | */ |
Matthew Barth | 9e741ed | 2017-06-02 16:29:09 -0500 | [diff] [blame] | 99 | template <typename T> |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 100 | void setPropertyValue(const char* object, |
Matthew Barth | cec5ab7 | 2017-06-02 15:20:56 -0500 | [diff] [blame] | 101 | const char* interface, |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 102 | const char* property, |
Matthew Barth | 9e741ed | 2017-06-02 16:29:09 -0500 | [diff] [blame] | 103 | T value) |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 104 | { |
Matthew Barth | cec5ab7 | 2017-06-02 15:20:56 -0500 | [diff] [blame] | 105 | _properties[object][interface][property] = value; |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 106 | }; |
| 107 | |
Matthew Barth | 17d1fe2 | 2017-05-11 15:00:36 -0500 | [diff] [blame] | 108 | /** |
| 109 | * @brief Get the value of an object's property |
| 110 | * |
| 111 | * @param[in] object - Name of the object containing the property |
Matthew Barth | cec5ab7 | 2017-06-02 15:20:56 -0500 | [diff] [blame] | 112 | * @param[in] interface - Interface name containing the property |
Matthew Barth | 17d1fe2 | 2017-05-11 15:00:36 -0500 | [diff] [blame] | 113 | * @param[in] property - Property name |
| 114 | * |
| 115 | * @return - The property value |
| 116 | */ |
Matthew Barth | 9e741ed | 2017-06-02 16:29:09 -0500 | [diff] [blame] | 117 | template <typename T> |
Matthew Barth | 17d1fe2 | 2017-05-11 15:00:36 -0500 | [diff] [blame] | 118 | inline auto getPropertyValue(const std::string& object, |
Matthew Barth | cec5ab7 | 2017-06-02 15:20:56 -0500 | [diff] [blame] | 119 | const std::string& interface, |
Matthew Barth | 17d1fe2 | 2017-05-11 15:00:36 -0500 | [diff] [blame] | 120 | const std::string& property) |
| 121 | { |
Matthew Barth | 9e741ed | 2017-06-02 16:29:09 -0500 | [diff] [blame] | 122 | return sdbusplus::message::variant_ns::get<T>( |
Matthew Barth | bc65160 | 2017-08-10 16:59:43 -0500 | [diff] [blame] | 123 | _properties.at(object).at(interface).at(property)); |
Matthew Barth | 17d1fe2 | 2017-05-11 15:00:36 -0500 | [diff] [blame] | 124 | }; |
| 125 | |
Matthew Barth | 1de6662 | 2017-06-12 13:13:02 -0500 | [diff] [blame] | 126 | /** |
Matthew Barth | 604329e | 2017-08-04 11:18:28 -0500 | [diff] [blame] | 127 | * @brief Get the object's property variant |
| 128 | * |
| 129 | * @param[in] object - Name of the object containing the property |
| 130 | * @param[in] interface - Interface name containing the property |
| 131 | * @param[in] property - Property name |
| 132 | * |
| 133 | * @return - The property variant |
| 134 | */ |
| 135 | inline auto getPropValueVariant(const std::string& object, |
| 136 | const std::string& interface, |
| 137 | const std::string& property) |
| 138 | { |
| 139 | return _properties.at(object).at(interface).at(property); |
| 140 | }; |
| 141 | |
| 142 | /** |
Matthew Barth | 55dea64 | 2017-11-06 13:34:32 -0600 | [diff] [blame^] | 143 | * @brief Remove a service associated to a group |
| 144 | * |
| 145 | * @param[in] group - Group associated with service |
| 146 | * @param[in] name - Service name to remove |
| 147 | */ |
| 148 | void removeService(const Group* group, |
| 149 | const std::string& name); |
| 150 | |
| 151 | /** |
Matthew Barth | e59fdf7 | 2017-09-27 09:33:42 -0500 | [diff] [blame] | 152 | * @brief Set or update a service name owner in use |
| 153 | * |
| 154 | * @param[in] group - Group associated with service |
| 155 | * @param[in] name - Service name |
| 156 | * @param[in] hasOwner - Whether the service is owned or not |
| 157 | */ |
| 158 | void setServiceOwner(const Group* group, |
| 159 | const std::string& name, |
| 160 | const bool hasOwner); |
| 161 | |
| 162 | /** |
Matthew Barth | 480787c | 2017-11-06 11:00:00 -0600 | [diff] [blame] | 163 | * @brief Set or update all services for a group |
| 164 | * |
| 165 | * @param[in] group - Group to get service names for |
| 166 | */ |
| 167 | void setServices(const Group* group); |
| 168 | |
| 169 | /** |
Matthew Barth | bfb1a56 | 2017-10-05 17:03:40 -0500 | [diff] [blame] | 170 | * @brief Get the group's list of service names |
| 171 | * |
| 172 | * @param[in] group - Group to get service names for |
| 173 | * |
| 174 | * @return - The list of service names |
| 175 | */ |
| 176 | inline auto getGroupServices(const Group* group) |
| 177 | { |
| 178 | return _services.at(*group); |
| 179 | } |
| 180 | |
| 181 | /** |
Matthew Barth | 604329e | 2017-08-04 11:18:28 -0500 | [diff] [blame] | 182 | * @brief Initialize a set speed event properties and actions |
| 183 | * |
| 184 | * @param[in] event - Set speed event |
| 185 | */ |
| 186 | void initEvent(const SetSpeedEvent& event); |
| 187 | |
| 188 | /** |
Matthew Barth | f6b76d8 | 2017-08-04 12:58:02 -0500 | [diff] [blame] | 189 | * @brief Removes all the set speed event properties and actions |
| 190 | * |
| 191 | * @param[in] event - Set speed event |
| 192 | */ |
| 193 | void removeEvent(const SetSpeedEvent& event); |
| 194 | |
| 195 | /** |
Matthew Barth | 1de6662 | 2017-06-12 13:13:02 -0500 | [diff] [blame] | 196 | * @brief Get the default floor speed |
| 197 | * |
| 198 | * @return - The defined default floor speed |
| 199 | */ |
| 200 | inline auto getDefFloor() |
| 201 | { |
| 202 | return _defFloorSpeed; |
| 203 | }; |
| 204 | |
Matthew Barth | 4af419c | 2017-06-12 13:39:31 -0500 | [diff] [blame] | 205 | /** |
Matthew Barth | e0ca13e | 2017-06-13 16:29:09 -0500 | [diff] [blame] | 206 | * @brief Get the ceiling speed |
| 207 | * |
| 208 | * @return - The current ceiling speed |
| 209 | */ |
| 210 | inline auto& getCeiling() const |
| 211 | { |
| 212 | return _ceilingSpeed; |
| 213 | }; |
| 214 | |
| 215 | /** |
| 216 | * @brief Set the ceiling speed to the given speed |
| 217 | * |
| 218 | * @param[in] speed - Speed to set the ceiling to |
| 219 | */ |
| 220 | inline void setCeiling(uint64_t speed) |
| 221 | { |
| 222 | _ceilingSpeed = speed; |
| 223 | }; |
| 224 | |
| 225 | /** |
| 226 | * @brief Swaps the ceiling key value with what's given and |
| 227 | * returns the value that was swapped. |
| 228 | * |
| 229 | * @param[in] keyValue - New ceiling key value |
| 230 | * |
| 231 | * @return - Ceiling key value prior to swapping |
| 232 | */ |
| 233 | inline auto swapCeilingKeyValue(int64_t keyValue) |
| 234 | { |
| 235 | std::swap(_ceilingKeyValue, keyValue); |
| 236 | return keyValue; |
| 237 | }; |
| 238 | |
Matthew Barth | 2462352 | 2017-06-21 14:09:57 -0500 | [diff] [blame] | 239 | /** |
| 240 | * @brief Get the increase speed delta |
| 241 | * |
| 242 | * @return - The current increase speed delta |
| 243 | */ |
| 244 | inline auto& getIncSpeedDelta() const |
| 245 | { |
| 246 | return _incSpeedDelta; |
| 247 | }; |
| 248 | |
Matthew Barth | 240397b | 2017-06-22 11:23:30 -0500 | [diff] [blame] | 249 | /** |
Matthew Barth | 0ce99d8 | 2017-06-22 15:07:29 -0500 | [diff] [blame] | 250 | * @brief Get the decrease speed delta |
| 251 | * |
| 252 | * @return - The current decrease speed delta |
| 253 | */ |
| 254 | inline auto& getDecSpeedDelta() const |
| 255 | { |
| 256 | return _decSpeedDelta; |
| 257 | }; |
| 258 | |
| 259 | /** |
Matthew Barth | b4a7cb9 | 2017-06-28 15:29:50 -0500 | [diff] [blame] | 260 | * @brief Set the floor speed to the given speed and increase target |
Matthew Barth | 98726c4 | 2017-10-17 10:35:20 -0500 | [diff] [blame] | 261 | * speed to the floor when target is below floor where floor changes |
| 262 | * are allowed. |
Matthew Barth | b4a7cb9 | 2017-06-28 15:29:50 -0500 | [diff] [blame] | 263 | * |
| 264 | * @param[in] speed - Speed to set the floor to |
| 265 | */ |
| 266 | void setFloor(uint64_t speed); |
| 267 | |
| 268 | /** |
Matthew Barth | 1bfdc42 | 2017-09-14 16:23:28 -0500 | [diff] [blame] | 269 | * @brief Set the requested speed base to be used as the speed to |
| 270 | * base a new requested speed target from |
| 271 | * |
| 272 | * @param[in] speedBase - Base speed value to use |
| 273 | */ |
| 274 | inline void setRequestSpeedBase(uint64_t speedBase) |
| 275 | { |
| 276 | _requestSpeedBase = speedBase; |
| 277 | }; |
| 278 | |
| 279 | /** |
Matthew Barth | 240397b | 2017-06-22 11:23:30 -0500 | [diff] [blame] | 280 | * @brief Calculate the requested target speed from the given delta |
| 281 | * and increase the fan speeds, not going above the ceiling. |
| 282 | * |
| 283 | * @param[in] targetDelta - The delta to increase the target speed by |
| 284 | */ |
| 285 | void requestSpeedIncrease(uint64_t targetDelta); |
| 286 | |
Matthew Barth | 0ce99d8 | 2017-06-22 15:07:29 -0500 | [diff] [blame] | 287 | /** |
| 288 | * @brief Calculate the requested target speed from the given delta |
| 289 | * and increase the fan speeds, not going above the ceiling. |
| 290 | * |
| 291 | * @param[in] targetDelta - The delta to increase the target speed by |
| 292 | */ |
| 293 | void requestSpeedDecrease(uint64_t targetDelta); |
| 294 | |
Matthew Barth | 8600d9a | 2017-06-23 14:38:05 -0500 | [diff] [blame] | 295 | /** |
Matthew Barth | 1ee48f2 | 2017-06-27 15:14:48 -0500 | [diff] [blame] | 296 | * @brief Callback function for the increase timer that delays |
| 297 | * processing of requested speed increases while fans are increasing |
| 298 | */ |
| 299 | void incTimerExpired(); |
| 300 | |
| 301 | /** |
Matthew Barth | 8600d9a | 2017-06-23 14:38:05 -0500 | [diff] [blame] | 302 | * @brief Callback function for the decrease timer that processes any |
| 303 | * requested speed decreases if allowed |
| 304 | */ |
| 305 | void decTimerExpired(); |
| 306 | |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 307 | /** |
Matthew Barth | bfb1a56 | 2017-10-05 17:03:40 -0500 | [diff] [blame] | 308 | * @brief Get the event pointer used with this zone's timers |
| 309 | * |
| 310 | * @return - The Dbus event pointer for timers |
| 311 | */ |
| 312 | inline auto& getEventPtr() |
| 313 | { |
| 314 | return _sdEvents; |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * @brief Get the list of timer events |
| 319 | * |
| 320 | * @return - List of timer events |
| 321 | */ |
| 322 | inline auto& getTimerEvents() |
| 323 | { |
| 324 | return _timerEvents; |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * @brief Find the first instance of a timer event |
| 329 | * |
| 330 | * @param[in] eventGroup - Group associated with a timer |
| 331 | * @param[in] eventActions - List of actions associated with a timer |
| 332 | * |
| 333 | * @return - Iterator to the timer event |
| 334 | */ |
| 335 | std::vector<TimerEvent>::iterator findTimer( |
| 336 | const Group& eventGroup, |
| 337 | const std::vector<Action>& eventActions); |
| 338 | |
| 339 | /** |
| 340 | * @brief Add a timer to the list of timer based events |
| 341 | * |
| 342 | * @param[in] data - Event data for timer |
| 343 | * @param[in] timer - Timer to be added |
| 344 | */ |
| 345 | inline void addTimer( |
| 346 | std::unique_ptr<EventData>&& data, |
| 347 | std::unique_ptr<phosphor::fan::util::Timer>&& timer) |
| 348 | { |
| 349 | _timerEvents.emplace_back(std::move(data), std::move(timer)); |
| 350 | }; |
| 351 | |
| 352 | /** |
| 353 | * @brief Remove the given timer event |
| 354 | * |
| 355 | * @param[in] teIter - Iterator pointing to the timer event to remove |
| 356 | */ |
| 357 | inline void removeTimer(std::vector<TimerEvent>::iterator& teIter) |
| 358 | { |
| 359 | assert(teIter != std::end(_timerEvents)); |
| 360 | std::get<timerEventDataPos>(*teIter).reset(); |
| 361 | std::get<timerTimerPos>(*teIter).reset(); |
| 362 | _timerEvents.erase(teIter); |
| 363 | } |
| 364 | |
| 365 | /** |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 366 | * @brief Callback function for event timers that processes the given |
Matthew Barth | f9201ab | 2017-09-11 16:07:58 -0500 | [diff] [blame] | 367 | * actions for a group |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 368 | * |
Matthew Barth | f9201ab | 2017-09-11 16:07:58 -0500 | [diff] [blame] | 369 | * @param[in] eventGroup - Group to process actions on |
| 370 | * @param[in] eventActions - List of event actions to run |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 371 | */ |
Matthew Barth | f9201ab | 2017-09-11 16:07:58 -0500 | [diff] [blame] | 372 | void timerExpired(Group eventGroup, std::vector<Action> eventActions); |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 373 | |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 374 | private: |
| 375 | |
| 376 | /** |
| 377 | * The dbus object |
| 378 | */ |
| 379 | sdbusplus::bus::bus& _bus; |
| 380 | |
| 381 | /** |
| 382 | * Full speed for the zone |
| 383 | */ |
| 384 | const uint64_t _fullSpeed; |
| 385 | |
| 386 | /** |
| 387 | * The zone number |
| 388 | */ |
| 389 | const size_t _zoneNum; |
| 390 | |
| 391 | /** |
Matthew Barth | 1de6662 | 2017-06-12 13:13:02 -0500 | [diff] [blame] | 392 | * The default floor speed for the zone |
| 393 | */ |
| 394 | const uint64_t _defFloorSpeed; |
| 395 | |
| 396 | /** |
Matthew Barth | e0ca13e | 2017-06-13 16:29:09 -0500 | [diff] [blame] | 397 | * The default ceiling speed for the zone |
| 398 | */ |
| 399 | const uint64_t _defCeilingSpeed; |
| 400 | |
| 401 | /** |
Matthew Barth | 4af419c | 2017-06-12 13:39:31 -0500 | [diff] [blame] | 402 | * The floor speed to not go below |
| 403 | */ |
| 404 | uint64_t _floorSpeed = _defFloorSpeed; |
| 405 | |
| 406 | /** |
Matthew Barth | e0ca13e | 2017-06-13 16:29:09 -0500 | [diff] [blame] | 407 | * The ceiling speed to not go above |
| 408 | */ |
| 409 | uint64_t _ceilingSpeed = _defCeilingSpeed; |
| 410 | |
| 411 | /** |
| 412 | * The previous sensor value for calculating the ceiling |
| 413 | */ |
| 414 | int64_t _ceilingKeyValue = 0; |
| 415 | |
| 416 | /** |
Matthew Barth | 861d77c | 2017-05-22 14:18:25 -0500 | [diff] [blame] | 417 | * Automatic fan control active state |
| 418 | */ |
| 419 | bool _isActive = true; |
| 420 | |
| 421 | /** |
Matthew Barth | 240397b | 2017-06-22 11:23:30 -0500 | [diff] [blame] | 422 | * Target speed for this zone |
| 423 | */ |
| 424 | uint64_t _targetSpeed = _fullSpeed; |
| 425 | |
| 426 | /** |
Matthew Barth | 2462352 | 2017-06-21 14:09:57 -0500 | [diff] [blame] | 427 | * Speed increase delta |
| 428 | */ |
| 429 | uint64_t _incSpeedDelta = 0; |
| 430 | |
| 431 | /** |
Matthew Barth | 0ce99d8 | 2017-06-22 15:07:29 -0500 | [diff] [blame] | 432 | * Speed decrease delta |
| 433 | */ |
| 434 | uint64_t _decSpeedDelta = 0; |
| 435 | |
| 436 | /** |
Matthew Barth | 1bfdc42 | 2017-09-14 16:23:28 -0500 | [diff] [blame] | 437 | * Requested speed base |
| 438 | */ |
| 439 | uint64_t _requestSpeedBase = 0; |
| 440 | |
| 441 | /** |
Matthew Barth | a956184 | 2017-06-29 11:43:45 -0500 | [diff] [blame] | 442 | * Speed increase delay in seconds |
| 443 | */ |
| 444 | std::chrono::seconds _incDelay; |
| 445 | |
| 446 | /** |
| 447 | * Speed decrease interval in seconds |
| 448 | */ |
| 449 | std::chrono::seconds _decInterval; |
| 450 | |
| 451 | /** |
Matthew Barth | 1ee48f2 | 2017-06-27 15:14:48 -0500 | [diff] [blame] | 452 | * The increase timer object |
| 453 | */ |
| 454 | phosphor::fan::util::Timer _incTimer; |
| 455 | |
| 456 | /** |
Matthew Barth | 8600d9a | 2017-06-23 14:38:05 -0500 | [diff] [blame] | 457 | * The decrease timer object |
| 458 | */ |
| 459 | phosphor::fan::util::Timer _decTimer; |
| 460 | |
| 461 | /** |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 462 | * Dbus event used on set speed event timers |
| 463 | */ |
| 464 | phosphor::fan::event::EventPtr& _sdEvents; |
| 465 | |
| 466 | /** |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 467 | * The vector of fans in this zone |
| 468 | */ |
| 469 | std::vector<std::unique_ptr<Fan>> _fans; |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 470 | |
| 471 | /** |
| 472 | * @brief Map of object property values |
| 473 | */ |
Matthew Barth | cec5ab7 | 2017-06-02 15:20:56 -0500 | [diff] [blame] | 474 | std::map<std::string, |
| 475 | std::map<std::string, |
| 476 | std::map<std::string, |
Matthew Barth | 9e741ed | 2017-06-02 16:29:09 -0500 | [diff] [blame] | 477 | PropertyVariantType>>> _properties; |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 478 | |
| 479 | /** |
Matthew Barth | 861d77c | 2017-05-22 14:18:25 -0500 | [diff] [blame] | 480 | * @brief Map of active fan control allowed by groups |
| 481 | */ |
Matthew Barth | 60b0076 | 2017-08-15 13:39:06 -0500 | [diff] [blame] | 482 | std::map<const Group, bool> _active; |
Matthew Barth | 861d77c | 2017-05-22 14:18:25 -0500 | [diff] [blame] | 483 | |
| 484 | /** |
Matthew Barth | 98726c4 | 2017-10-17 10:35:20 -0500 | [diff] [blame] | 485 | * @brief Map of floor change allowed by groups |
| 486 | */ |
| 487 | std::map<const Group, bool> _floorChange; |
| 488 | |
| 489 | /** |
Matthew Barth | e59fdf7 | 2017-09-27 09:33:42 -0500 | [diff] [blame] | 490 | * @brief Map of group service names |
| 491 | */ |
| 492 | std::map<const Group, std::vector<Service>> _services; |
| 493 | |
| 494 | /** |
Matthew Barth | f6b76d8 | 2017-08-04 12:58:02 -0500 | [diff] [blame] | 495 | * @brief List of signal event arguments and Dbus matches for callbacks |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 496 | */ |
Matthew Barth | f6b76d8 | 2017-08-04 12:58:02 -0500 | [diff] [blame] | 497 | std::vector<SignalEvent> _signalEvents; |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 498 | |
| 499 | /** |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 500 | * @brief List of timers for events |
| 501 | */ |
Matthew Barth | bfb1a56 | 2017-10-05 17:03:40 -0500 | [diff] [blame] | 502 | std::vector<TimerEvent> _timerEvents; |
Matthew Barth | 9014980 | 2017-08-15 10:51:37 -0500 | [diff] [blame] | 503 | |
| 504 | /** |
Matthew Barth | 4e72854 | 2017-09-14 16:47:55 -0500 | [diff] [blame] | 505 | * @brief Get the request speed base if defined, otherwise the |
| 506 | * the current target speed is returned |
| 507 | * |
| 508 | * @return - The request speed base or current target speed |
| 509 | */ |
| 510 | inline auto getRequestSpeedBase() const |
| 511 | { |
| 512 | return (_requestSpeedBase != 0) ? _requestSpeedBase : _targetSpeed; |
| 513 | }; |
| 514 | |
| 515 | /** |
Matthew Barth | 34f1bda | 2017-05-31 13:45:36 -0500 | [diff] [blame] | 516 | * @brief Dbus signal change callback handler |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 517 | * |
Matthew Barth | 34f1bda | 2017-05-31 13:45:36 -0500 | [diff] [blame] | 518 | * @param[in] msg - Expanded sdbusplus message data |
| 519 | * @param[in] eventData - The single event's data |
Matthew Barth | 38a93a8 | 2017-05-11 14:12:27 -0500 | [diff] [blame] | 520 | */ |
Matthew Barth | 34f1bda | 2017-05-31 13:45:36 -0500 | [diff] [blame] | 521 | void handleEvent(sdbusplus::message::message& msg, |
| 522 | const EventData* eventData); |
Matt Spinler | 7f88fe6 | 2017-04-10 14:39:02 -0500 | [diff] [blame] | 523 | }; |
| 524 | |
| 525 | } |
| 526 | } |
| 527 | } |