blob: 6da3091b41481376edf4d86fe56422a95a5141b8 [file] [log] [blame]
Matt Spinler7f88fe62017-04-10 14:39:02 -05001#pragma once
William A. Kennington III8fd879f2018-10-30 19:49:29 -07002#include <algorithm>
William A. Kennington III2c8e1982018-11-12 08:37:07 -08003#include <cassert>
Matthew Bartha9561842017-06-29 11:43:45 -05004#include <chrono>
Matt Spinler7f88fe62017-04-10 14:39:02 -05005#include <sdbusplus/bus.hpp>
William A. Kennington III1cfc2f12018-10-19 17:29:46 -07006#include <sdeventplus/event.hpp>
William A. Kennington III8fd879f2018-10-30 19:49:29 -07007#include <vector>
Matt Spinler7f88fe62017-04-10 14:39:02 -05008#include "fan.hpp"
9#include "types.hpp"
Matthew Barth766f8542019-01-29 12:44:13 -060010#include "sdbusplus.hpp"
Matthew Barth93af4192019-01-18 09:30:57 -060011#include "xyz/openbmc_project/Control/ThermalMode/server.hpp"
Matt Spinler7f88fe62017-04-10 14:39:02 -050012
13namespace phosphor
14{
15namespace fan
16{
17namespace control
18{
19
Matthew Barth93af4192019-01-18 09:30:57 -060020using ThermalObject = sdbusplus::server::object::object<
21 sdbusplus::xyz::openbmc_project::Control::server::ThermalMode>;
22
Matt Spinler7f88fe62017-04-10 14:39:02 -050023/**
Matthew Barth14184132017-05-19 14:37:30 -050024 * The mode fan control will run in:
25 * - init - only do the initialization steps
26 * - control - run normal control algorithms
27 */
28enum class Mode
29{
30 init,
31 control
32};
33
34/**
Matt Spinler7f88fe62017-04-10 14:39:02 -050035 * @class Represents a fan control zone, which is a group of fans
36 * that behave the same.
37 */
Matthew Barth93af4192019-01-18 09:30:57 -060038class Zone : public ThermalObject
Matt Spinler7f88fe62017-04-10 14:39:02 -050039{
40 public:
41
42 Zone() = delete;
43 Zone(const Zone&) = delete;
Matthew Barth0081fdb2017-11-14 14:02:34 -060044 Zone(Zone&&) = delete;
Matt Spinler7f88fe62017-04-10 14:39:02 -050045 Zone& operator=(const Zone&) = delete;
46 Zone& operator=(Zone&&) = delete;
47 ~Zone() = default;
48
49 /**
50 * Constructor
51 * Creates the appropriate fan objects based on
52 * the zone definition data passed in.
53 *
Matthew Barth14184132017-05-19 14:37:30 -050054 * @param[in] mode - mode of fan control
Matt Spinler7f88fe62017-04-10 14:39:02 -050055 * @param[in] bus - the dbus object
Matthew Barth93af4192019-01-18 09:30:57 -060056 * @param[in] path - object instance path
William A. Kennington III1cfc2f12018-10-19 17:29:46 -070057 * @param[in] event - Event loop reference
Matt Spinler7f88fe62017-04-10 14:39:02 -050058 * @param[in] def - the fan zone definition data
59 */
Matthew Barth14184132017-05-19 14:37:30 -050060 Zone(Mode mode,
61 sdbusplus::bus::bus& bus,
Matthew Barth93af4192019-01-18 09:30:57 -060062 const std::string& path,
William A. Kennington III1cfc2f12018-10-19 17:29:46 -070063 const sdeventplus::Event& event,
Matt Spinler7f88fe62017-04-10 14:39:02 -050064 const ZoneDefinition& def);
65
66 /**
67 * Sets all fans in the zone to the speed
Matthew Barth60b00762017-08-15 13:39:06 -050068 * passed in when the zone is active
Matt Spinler7f88fe62017-04-10 14:39:02 -050069 *
70 * @param[in] speed - the fan speed
71 */
72 void setSpeed(uint64_t speed);
73
74 /**
Matthew Barth60b00762017-08-15 13:39:06 -050075 * Sets the zone to full speed regardless of zone's active state
Matt Spinler7f88fe62017-04-10 14:39:02 -050076 */
Matthew Barth60b00762017-08-15 13:39:06 -050077 void setFullSpeed();
Matt Spinler7f88fe62017-04-10 14:39:02 -050078
Matthew Barth38a93a82017-05-11 14:12:27 -050079 /**
Matthew Barth861d77c2017-05-22 14:18:25 -050080 * @brief Sets the automatic fan control allowed active state
81 *
82 * @param[in] group - A group that affects the active state
83 * @param[in] isActiveAllow - Active state according to group
84 */
85 void setActiveAllow(const Group* group, bool isActiveAllow);
86
87 /**
Matthew Barth98726c42017-10-17 10:35:20 -050088 * @brief Sets the floor change allowed state
89 *
90 * @param[in] group - A group that affects floor changes
91 * @param[in] isAllow - Allow state according to group
92 */
93 inline void setFloorChangeAllow(const Group* group, bool isAllow)
94 {
95 _floorChange[*(group)] = isAllow;
96 }
97
98 /**
Matthew Barthe4338cd2017-12-14 11:14:30 -060099 * @brief Sets the decrease allowed state of a group
100 *
101 * @param[in] group - A group that affects speed decreases
102 * @param[in] isAllow - Allow state according to group
103 */
104 inline void setDecreaseAllow(const Group* group, bool isAllow)
105 {
106 _decAllowed[*(group)] = isAllow;
107 }
108
109 /**
Matthew Barth38a93a82017-05-11 14:12:27 -0500110 * @brief Sets a given object's property value
111 *
112 * @param[in] object - Name of the object containing the property
Matthew Barthcec5ab72017-06-02 15:20:56 -0500113 * @param[in] interface - Interface name containing the property
Matthew Barth38a93a82017-05-11 14:12:27 -0500114 * @param[in] property - Property name
115 * @param[in] value - Property value
116 */
Matthew Barth9e741ed2017-06-02 16:29:09 -0500117 template <typename T>
Matthew Barth38a93a82017-05-11 14:12:27 -0500118 void setPropertyValue(const char* object,
Matthew Barthcec5ab72017-06-02 15:20:56 -0500119 const char* interface,
Matthew Barth38a93a82017-05-11 14:12:27 -0500120 const char* property,
Matthew Barth9e741ed2017-06-02 16:29:09 -0500121 T value)
Matthew Barth38a93a82017-05-11 14:12:27 -0500122 {
Matthew Barthcec5ab72017-06-02 15:20:56 -0500123 _properties[object][interface][property] = value;
Matthew Barth38a93a82017-05-11 14:12:27 -0500124 };
125
Matthew Barth17d1fe22017-05-11 15:00:36 -0500126 /**
127 * @brief Get the value of an object's property
128 *
129 * @param[in] object - Name of the object containing the property
Matthew Barthcec5ab72017-06-02 15:20:56 -0500130 * @param[in] interface - Interface name containing the property
Matthew Barth17d1fe22017-05-11 15:00:36 -0500131 * @param[in] property - Property name
132 *
133 * @return - The property value
134 */
Matthew Barth9e741ed2017-06-02 16:29:09 -0500135 template <typename T>
Matthew Barth17d1fe22017-05-11 15:00:36 -0500136 inline auto getPropertyValue(const std::string& object,
Matthew Barthcec5ab72017-06-02 15:20:56 -0500137 const std::string& interface,
Matthew Barth17d1fe22017-05-11 15:00:36 -0500138 const std::string& property)
139 {
Matthew Barth9e741ed2017-06-02 16:29:09 -0500140 return sdbusplus::message::variant_ns::get<T>(
Matthew Barthbc651602017-08-10 16:59:43 -0500141 _properties.at(object).at(interface).at(property));
Matthew Barth17d1fe22017-05-11 15:00:36 -0500142 };
143
Matthew Barth1de66622017-06-12 13:13:02 -0500144 /**
Matthew Barth604329e2017-08-04 11:18:28 -0500145 * @brief Get the object's property variant
146 *
147 * @param[in] object - Name of the object containing the property
148 * @param[in] interface - Interface name containing the property
149 * @param[in] property - Property name
150 *
151 * @return - The property variant
152 */
153 inline auto getPropValueVariant(const std::string& object,
154 const std::string& interface,
155 const std::string& property)
156 {
157 return _properties.at(object).at(interface).at(property);
158 };
159
160 /**
Matthew Barth1499a5c2018-03-20 15:52:33 -0500161 * @brief Remove an object's interface
162 *
163 * @param[in] object - Name of the object with the interface
164 * @param[in] interface - Interface name to remove
165 */
Matthew Barth30abbef2018-04-12 09:40:54 -0500166 inline void removeObjectInterface(const char* object,
167 const char* interface)
Matthew Barth1499a5c2018-03-20 15:52:33 -0500168 {
169 auto it = _properties.find(object);
170 if (it != std::end(_properties))
171 {
172 _properties[object].erase(interface);
173 }
174 }
175
176 /**
Matthew Barth55dea642017-11-06 13:34:32 -0600177 * @brief Remove a service associated to a group
178 *
179 * @param[in] group - Group associated with service
180 * @param[in] name - Service name to remove
181 */
182 void removeService(const Group* group,
183 const std::string& name);
184
185 /**
Matthew Barthe59fdf72017-09-27 09:33:42 -0500186 * @brief Set or update a service name owner in use
187 *
188 * @param[in] group - Group associated with service
189 * @param[in] name - Service name
190 * @param[in] hasOwner - Whether the service is owned or not
191 */
192 void setServiceOwner(const Group* group,
193 const std::string& name,
194 const bool hasOwner);
195
196 /**
Matthew Barth480787c2017-11-06 11:00:00 -0600197 * @brief Set or update all services for a group
198 *
199 * @param[in] group - Group to get service names for
200 */
201 void setServices(const Group* group);
202
203 /**
Matthew Barthbfb1a562017-10-05 17:03:40 -0500204 * @brief Get the group's list of service names
205 *
206 * @param[in] group - Group to get service names for
207 *
208 * @return - The list of service names
209 */
210 inline auto getGroupServices(const Group* group)
211 {
212 return _services.at(*group);
213 }
214
215 /**
Matthew Barth604329e2017-08-04 11:18:28 -0500216 * @brief Initialize a set speed event properties and actions
217 *
218 * @param[in] event - Set speed event
219 */
220 void initEvent(const SetSpeedEvent& event);
221
222 /**
Matthew Barthf6b76d82017-08-04 12:58:02 -0500223 * @brief Removes all the set speed event properties and actions
224 *
225 * @param[in] event - Set speed event
226 */
227 void removeEvent(const SetSpeedEvent& event);
228
229 /**
Matthew Barth1de66622017-06-12 13:13:02 -0500230 * @brief Get the default floor speed
231 *
232 * @return - The defined default floor speed
233 */
234 inline auto getDefFloor()
235 {
236 return _defFloorSpeed;
237 };
238
Matthew Barth4af419c2017-06-12 13:39:31 -0500239 /**
Matthew Barthe0ca13e2017-06-13 16:29:09 -0500240 * @brief Get the ceiling speed
241 *
242 * @return - The current ceiling speed
243 */
244 inline auto& getCeiling() const
245 {
246 return _ceilingSpeed;
247 };
248
249 /**
250 * @brief Set the ceiling speed to the given speed
251 *
252 * @param[in] speed - Speed to set the ceiling to
253 */
254 inline void setCeiling(uint64_t speed)
255 {
256 _ceilingSpeed = speed;
257 };
258
259 /**
260 * @brief Swaps the ceiling key value with what's given and
261 * returns the value that was swapped.
262 *
263 * @param[in] keyValue - New ceiling key value
264 *
265 * @return - Ceiling key value prior to swapping
266 */
267 inline auto swapCeilingKeyValue(int64_t keyValue)
268 {
269 std::swap(_ceilingKeyValue, keyValue);
270 return keyValue;
271 };
272
Matthew Barth24623522017-06-21 14:09:57 -0500273 /**
274 * @brief Get the increase speed delta
275 *
276 * @return - The current increase speed delta
277 */
278 inline auto& getIncSpeedDelta() const
279 {
280 return _incSpeedDelta;
281 };
282
Matthew Barth240397b2017-06-22 11:23:30 -0500283 /**
Matthew Barth0ce99d82017-06-22 15:07:29 -0500284 * @brief Get the decrease speed delta
285 *
286 * @return - The current decrease speed delta
287 */
288 inline auto& getDecSpeedDelta() const
289 {
290 return _decSpeedDelta;
291 };
292
293 /**
Matthew Barthb4a7cb92017-06-28 15:29:50 -0500294 * @brief Set the floor speed to the given speed and increase target
Matthew Barth98726c42017-10-17 10:35:20 -0500295 * speed to the floor when target is below floor where floor changes
296 * are allowed.
Matthew Barthb4a7cb92017-06-28 15:29:50 -0500297 *
298 * @param[in] speed - Speed to set the floor to
299 */
300 void setFloor(uint64_t speed);
301
302 /**
Matthew Barth1bfdc422017-09-14 16:23:28 -0500303 * @brief Set the requested speed base to be used as the speed to
304 * base a new requested speed target from
305 *
306 * @param[in] speedBase - Base speed value to use
307 */
308 inline void setRequestSpeedBase(uint64_t speedBase)
309 {
310 _requestSpeedBase = speedBase;
311 };
312
313 /**
Matthew Barth240397b2017-06-22 11:23:30 -0500314 * @brief Calculate the requested target speed from the given delta
315 * and increase the fan speeds, not going above the ceiling.
316 *
317 * @param[in] targetDelta - The delta to increase the target speed by
318 */
319 void requestSpeedIncrease(uint64_t targetDelta);
320
Matthew Barth0ce99d82017-06-22 15:07:29 -0500321 /**
322 * @brief Calculate the requested target speed from the given delta
323 * and increase the fan speeds, not going above the ceiling.
324 *
325 * @param[in] targetDelta - The delta to increase the target speed by
326 */
327 void requestSpeedDecrease(uint64_t targetDelta);
328
Matthew Barth8600d9a2017-06-23 14:38:05 -0500329 /**
Matthew Barth1ee48f22017-06-27 15:14:48 -0500330 * @brief Callback function for the increase timer that delays
331 * processing of requested speed increases while fans are increasing
332 */
333 void incTimerExpired();
334
335 /**
Matthew Barth8600d9a2017-06-23 14:38:05 -0500336 * @brief Callback function for the decrease timer that processes any
337 * requested speed decreases if allowed
338 */
339 void decTimerExpired();
340
Matthew Barth90149802017-08-15 10:51:37 -0500341 /**
William A. Kennington III1cfc2f12018-10-19 17:29:46 -0700342 * @brief Get the event loop used with this zone's timers
Matthew Barthbfb1a562017-10-05 17:03:40 -0500343 *
William A. Kennington III1cfc2f12018-10-19 17:29:46 -0700344 * @return - The event loop for timers
Matthew Barthbfb1a562017-10-05 17:03:40 -0500345 */
William A. Kennington III1cfc2f12018-10-19 17:29:46 -0700346 inline auto& getEventLoop()
Matthew Barthbfb1a562017-10-05 17:03:40 -0500347 {
William A. Kennington III1cfc2f12018-10-19 17:29:46 -0700348 return _eventLoop;
Matthew Barthbfb1a562017-10-05 17:03:40 -0500349 }
350
351 /**
Matthew Barth33bfe762018-11-05 11:13:25 -0600352 * @brief Get the list of signal events
353 *
354 * @return - List of signal events
355 */
356 inline auto& getSignalEvents()
357 {
358 return _signalEvents;
359 }
360
361 /**
362 * @brief Find the first instance of a signal event
363 *
364 * @param[in] signal - Event signal to find
365 * @param[in] eGroup - Group associated with the signal
366 * @param[in] eActions - List of actions associated with the signal
367 *
368 * @return - Iterator to the stored signal event
369 */
370 std::vector<SignalEvent>::iterator findSignal(
371 const Signal& signal,
372 const Group& eGroup,
373 const std::vector<Action>& eActions);
374
375 /**
376 * @brief Remove the given signal event
377 *
378 * @param[in] seIter - Iterator pointing to the signal event to remove
379 */
380 inline void removeSignal(std::vector<SignalEvent>::iterator& seIter)
381 {
382 assert(seIter != std::end(_signalEvents));
383 std::get<signalEventDataPos>(*seIter).reset();
384 if (std::get<signalMatchPos>(*seIter) != nullptr)
385 {
386 std::get<signalMatchPos>(*seIter).reset();
387 }
388 _signalEvents.erase(seIter);
389 }
390
391 /**
Matthew Barthbfb1a562017-10-05 17:03:40 -0500392 * @brief Get the list of timer events
393 *
394 * @return - List of timer events
395 */
396 inline auto& getTimerEvents()
397 {
398 return _timerEvents;
399 }
400
401 /**
402 * @brief Find the first instance of a timer event
403 *
404 * @param[in] eventGroup - Group associated with a timer
405 * @param[in] eventActions - List of actions associated with a timer
406 *
407 * @return - Iterator to the timer event
408 */
409 std::vector<TimerEvent>::iterator findTimer(
410 const Group& eventGroup,
411 const std::vector<Action>& eventActions);
412
413 /**
414 * @brief Add a timer to the list of timer based events
415 *
William A. Kennington III94fe1a02018-10-30 19:00:27 -0700416 * @param[in] group - Group associated with a timer
417 * @param[in] actions - List of actions associated with a timer
418 * @param[in] tConf - Configuration for the new timer
Matthew Barthbfb1a562017-10-05 17:03:40 -0500419 */
William A. Kennington III94fe1a02018-10-30 19:00:27 -0700420 void addTimer(const Group& group,
421 const std::vector<Action>& actions,
422 const TimerConf& tConf);
Matthew Barthbfb1a562017-10-05 17:03:40 -0500423
424 /**
425 * @brief Remove the given timer event
426 *
427 * @param[in] teIter - Iterator pointing to the timer event to remove
428 */
429 inline void removeTimer(std::vector<TimerEvent>::iterator& teIter)
430 {
Matthew Barthbfb1a562017-10-05 17:03:40 -0500431 _timerEvents.erase(teIter);
432 }
433
434 /**
Matthew Barth90149802017-08-15 10:51:37 -0500435 * @brief Callback function for event timers that processes the given
Matthew Barthf9201ab2017-09-11 16:07:58 -0500436 * actions for a group
Matthew Barth90149802017-08-15 10:51:37 -0500437 *
Matthew Barthf9201ab2017-09-11 16:07:58 -0500438 * @param[in] eventGroup - Group to process actions on
439 * @param[in] eventActions - List of event actions to run
Matthew Barth90149802017-08-15 10:51:37 -0500440 */
William A. Kennington IIIc0c5f072018-10-30 19:11:01 -0700441 void timerExpired(const Group& eventGroup,
442 const std::vector<Action>& eventActions);
Matthew Barth90149802017-08-15 10:51:37 -0500443
Matthew Bartha603ed02018-01-19 16:56:26 -0600444 /**
445 * @brief Get the service for a given path and interface from cached
446 * dataset and add a service that's not found
447 *
448 * @param[in] path - Path to get service for
449 * @param[in] intf - Interface to get service for
450 *
451 * @return - The service name
452 */
453 const std::string& getService(const std::string& path,
454 const std::string& intf);
455
456 /**
457 * @brief Add a set of services for a path and interface
458 * by retrieving all the path subtrees to the given depth
459 * from root for the interface
460 *
461 * @param[in] path - Path to add services for
462 * @param[in] intf - Interface to add services for
463 * @param[in] depth - Depth of tree traversal from root path
464 *
465 * @return - The associated service to the given path and interface
466 * or empty string for no service found
467 */
468 const std::string& addServices(const std::string& path,
469 const std::string& intf,
470 int32_t depth);
471
Matthew Barth6faf8942019-01-22 09:26:09 -0600472 /**
Matthew Barth70b2e7d2019-02-18 11:03:07 -0600473 * @brief Set a property to be persisted
474 *
475 * @param[in] intf - Interface containing property
476 * @param[in] prop - Property to be persisted
477 */
478 inline void setPersisted(const std::string& intf,
479 const std::string& prop)
480 {
481 _persisted[intf].emplace_back(prop);
482 }
483
484 /**
485 * @brief Get persisted property
486 *
487 * @param[in] intf - Interface containing property
488 * @param[in] prop - Property persisted
489 *
490 * @return - True if property is to be persisted, false otherwise
491 */
492 auto getPersisted(const std::string& intf,
493 const std::string& prop);
494
495 /**
Matthew Barth766f8542019-01-29 12:44:13 -0600496 * @brief Get a property value from the zone object or the bus when
497 * the property requested is not on the zone object
498 *
499 * @param[in] path - Path of object
500 * @param[in] intf - Object interface
501 * @param[in] prop - Object property
502 *
503 * @return - Property's value
504 */
505 template <typename T>
506 auto getPropertyByName(const std::string& path,
507 const std::string& intf,
508 const std::string& prop)
509 {
510 T value;
511 auto pathIter = _objects.find(path);
512 if (pathIter != _objects.end())
513 {
514 auto intfIter = pathIter->second.find(intf);
515 if (intfIter != pathIter->second.end())
516 {
517 if (intf == "xyz.openbmc_project.Control.ThermalMode")
518 {
519 auto var = ThermalMode::getPropertyByName(prop);
520 // Use visitor to determine if requested property
521 // type(T) is available on this interface and read it
522 std::visit([&value](auto&& val)
523 {
524 using V = std::decay_t<decltype(val)>;
525 if constexpr(std::is_same_v<T, V>)
526 {
527 value = val;
528 }
529 }, var);
530
531 return value;
532 }
533 }
534 }
535
536 auto service = getService(path, intf);
537 value = util::SDBusPlus::getProperty<T>(_bus,
538 service,
539 path,
540 intf,
541 prop);
542
543 return value;
544 };
545
546 /**
Matthew Barth6faf8942019-01-22 09:26:09 -0600547 * @brief Overridden thermal object's set 'Current' property function
548 *
549 * @param[in] value - Value to set 'Current' to
550 *
551 * @return - The updated value of the 'Current' property
552 */
553 virtual std::string current(std::string value);
554
Matt Spinler7f88fe62017-04-10 14:39:02 -0500555 private:
556
557 /**
558 * The dbus object
559 */
560 sdbusplus::bus::bus& _bus;
561
562 /**
Matthew Barth93af4192019-01-18 09:30:57 -0600563 * Zone object path
564 */
565 const std::string _path;
566
567 /**
Matthew Barth766f8542019-01-29 12:44:13 -0600568 * Zone supported interfaces
569 */
570 const std::vector<std::string> _ifaces;
571
572 /**
Matt Spinler7f88fe62017-04-10 14:39:02 -0500573 * Full speed for the zone
574 */
575 const uint64_t _fullSpeed;
576
577 /**
578 * The zone number
579 */
580 const size_t _zoneNum;
581
582 /**
Matthew Barth1de66622017-06-12 13:13:02 -0500583 * The default floor speed for the zone
584 */
585 const uint64_t _defFloorSpeed;
586
587 /**
Matthew Barthe0ca13e2017-06-13 16:29:09 -0500588 * The default ceiling speed for the zone
589 */
590 const uint64_t _defCeilingSpeed;
591
592 /**
Matthew Barth4af419c2017-06-12 13:39:31 -0500593 * The floor speed to not go below
594 */
595 uint64_t _floorSpeed = _defFloorSpeed;
596
597 /**
Matthew Barthe0ca13e2017-06-13 16:29:09 -0500598 * The ceiling speed to not go above
599 */
600 uint64_t _ceilingSpeed = _defCeilingSpeed;
601
602 /**
603 * The previous sensor value for calculating the ceiling
604 */
605 int64_t _ceilingKeyValue = 0;
606
607 /**
Matthew Barth861d77c2017-05-22 14:18:25 -0500608 * Automatic fan control active state
609 */
610 bool _isActive = true;
611
612 /**
Matthew Barth240397b2017-06-22 11:23:30 -0500613 * Target speed for this zone
614 */
615 uint64_t _targetSpeed = _fullSpeed;
616
617 /**
Matthew Barth24623522017-06-21 14:09:57 -0500618 * Speed increase delta
619 */
620 uint64_t _incSpeedDelta = 0;
621
622 /**
Matthew Barth0ce99d82017-06-22 15:07:29 -0500623 * Speed decrease delta
624 */
625 uint64_t _decSpeedDelta = 0;
626
627 /**
Matthew Barth1bfdc422017-09-14 16:23:28 -0500628 * Requested speed base
629 */
630 uint64_t _requestSpeedBase = 0;
631
632 /**
Matthew Bartha9561842017-06-29 11:43:45 -0500633 * Speed increase delay in seconds
634 */
635 std::chrono::seconds _incDelay;
636
637 /**
638 * Speed decrease interval in seconds
639 */
640 std::chrono::seconds _decInterval;
641
642 /**
Matthew Barth1ee48f22017-06-27 15:14:48 -0500643 * The increase timer object
644 */
William A. Kennington III8fd879f2018-10-30 19:49:29 -0700645 Timer _incTimer;
Matthew Barth1ee48f22017-06-27 15:14:48 -0500646
647 /**
Matthew Barth8600d9a2017-06-23 14:38:05 -0500648 * The decrease timer object
649 */
William A. Kennington III8fd879f2018-10-30 19:49:29 -0700650 Timer _decTimer;
Matthew Barth8600d9a2017-06-23 14:38:05 -0500651
652 /**
William A. Kennington III1cfc2f12018-10-19 17:29:46 -0700653 * Event loop used on set speed event timers
Matthew Barth90149802017-08-15 10:51:37 -0500654 */
William A. Kennington III1cfc2f12018-10-19 17:29:46 -0700655 sdeventplus::Event _eventLoop;
Matthew Barth90149802017-08-15 10:51:37 -0500656
657 /**
Matt Spinler7f88fe62017-04-10 14:39:02 -0500658 * The vector of fans in this zone
659 */
660 std::vector<std::unique_ptr<Fan>> _fans;
Matthew Barth38a93a82017-05-11 14:12:27 -0500661
662 /**
663 * @brief Map of object property values
664 */
Matthew Barthcec5ab72017-06-02 15:20:56 -0500665 std::map<std::string,
666 std::map<std::string,
667 std::map<std::string,
Matthew Barth9e741ed2017-06-02 16:29:09 -0500668 PropertyVariantType>>> _properties;
Matthew Barth38a93a82017-05-11 14:12:27 -0500669
670 /**
Matthew Barth766f8542019-01-29 12:44:13 -0600671 * @brief Map of zone objects
672 */
673 std::map<std::string,
674 std::map<std::string,
675 std::map<std::string,
676 EventData*>>> _objects;
677
678 /**
Matthew Barth70b2e7d2019-02-18 11:03:07 -0600679 * @brief Map of interfaces to persisted properties
680 */
681 std::map<std::string, std::vector<std::string>> _persisted;
682
683 /**
Matthew Barth861d77c2017-05-22 14:18:25 -0500684 * @brief Map of active fan control allowed by groups
685 */
Matthew Barth60b00762017-08-15 13:39:06 -0500686 std::map<const Group, bool> _active;
Matthew Barth861d77c2017-05-22 14:18:25 -0500687
688 /**
Matthew Barth98726c42017-10-17 10:35:20 -0500689 * @brief Map of floor change allowed by groups
690 */
691 std::map<const Group, bool> _floorChange;
692
693 /**
Matthew Barthe4338cd2017-12-14 11:14:30 -0600694 * @brief Map of groups controlling decreases allowed
695 */
696 std::map<const Group, bool> _decAllowed;
697
698 /**
Matthew Barthe59fdf72017-09-27 09:33:42 -0500699 * @brief Map of group service names
700 */
701 std::map<const Group, std::vector<Service>> _services;
702
703 /**
Matthew Bartha603ed02018-01-19 16:56:26 -0600704 * @brief Map tree of paths to services of interfaces
705 */
706 std::map<std::string,
707 std::map<std::string,
708 std::vector<std::string>>> _servTree;
709
710 /**
Matthew Barthf6b76d82017-08-04 12:58:02 -0500711 * @brief List of signal event arguments and Dbus matches for callbacks
Matthew Barth38a93a82017-05-11 14:12:27 -0500712 */
Matthew Barthf6b76d82017-08-04 12:58:02 -0500713 std::vector<SignalEvent> _signalEvents;
Matthew Barth38a93a82017-05-11 14:12:27 -0500714
715 /**
Matthew Barth90149802017-08-15 10:51:37 -0500716 * @brief List of timers for events
717 */
Matthew Barthbfb1a562017-10-05 17:03:40 -0500718 std::vector<TimerEvent> _timerEvents;
Matthew Barth90149802017-08-15 10:51:37 -0500719
720 /**
Matthew Barthcc8912e2019-01-21 11:35:27 -0600721 * @brief Save the thermal control current mode property
722 * to persisted storage
723 */
724 void saveCurrentMode();
725
726 /**
Matthew Barth9e4db252019-01-21 13:08:02 -0600727 * @brief Restore persisted thermal control current mode property
728 * value, setting the mode to "Default" otherwise
729 */
730 void restoreCurrentMode();
731
732 /**
Matthew Barth4e728542017-09-14 16:47:55 -0500733 * @brief Get the request speed base if defined, otherwise the
734 * the current target speed is returned
735 *
736 * @return - The request speed base or current target speed
737 */
738 inline auto getRequestSpeedBase() const
739 {
740 return (_requestSpeedBase != 0) ? _requestSpeedBase : _targetSpeed;
741 };
742
743 /**
Matthew Barth34f1bda2017-05-31 13:45:36 -0500744 * @brief Dbus signal change callback handler
Matthew Barth38a93a82017-05-11 14:12:27 -0500745 *
Matthew Barth34f1bda2017-05-31 13:45:36 -0500746 * @param[in] msg - Expanded sdbusplus message data
747 * @param[in] eventData - The single event's data
Matthew Barth38a93a82017-05-11 14:12:27 -0500748 */
Matthew Barth34f1bda2017-05-31 13:45:36 -0500749 void handleEvent(sdbusplus::message::message& msg,
750 const EventData* eventData);
Matt Spinler7f88fe62017-04-10 14:39:02 -0500751};
752
753}
754}
755}