blob: a6656d38de8c92ef59aa5eb990733e8b974cd2e7 [file] [log] [blame]
George Liu2098aa62020-05-09 11:26:35 +08001#include "config.h"
2
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05303#include "group.hpp"
Patrick Venture91ac8d32018-11-01 17:03:22 -07004
5#include <sdbusplus/message.hpp>
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05306namespace phosphor
7{
8namespace led
9{
10
11/** @brief Overloaded Property Setter function */
12bool Group::asserted(bool value)
13{
Vishwanatha Subbanna4846e922020-10-09 03:42:57 -050014 // If the value is already what is before, return right away
15 if (value ==
16 sdbusplus::xyz::openbmc_project::Led::server::Group::asserted())
17 {
18 return value;
19 }
20
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053021 // Introducing these to enable gtest.
Patrick Venture91ac8d32018-11-01 17:03:22 -070022 Manager::group ledsAssert{};
23 Manager::group ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053024
25 // Group management is handled by Manager. The populated leds* sets are not
26 // really used by production code. They are there to enable gtest for
27 // validation.
Patrick Venture91ac8d32018-11-01 17:03:22 -070028 auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053029
George Liu2098aa62020-05-09 11:26:35 +080030 // Store asserted state
31 serialize.storeGroups(path, result);
32
George Liu4c5f5332020-10-10 17:04:28 +080033 // Set OperationalStatus according to the status of asserted property.
34 // If the group is asserted, then the functional status is false and
35 // vice-versa.
36 manager.setOperationalStatus(path, !value);
37
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053038 // If something does not go right here, then there should be an sdbusplus
39 // exception thrown.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +053040 manager.driveLEDs(ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053041
42 // Set the base class's asserted to 'true' since the getter
43 // operation is handled there.
Patrick Venture91ac8d32018-11-01 17:03:22 -070044 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
45 result);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053046}
47
48} // namespace led
49} // namespace phosphor