George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 3 | #include "group.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 4 | |
| 5 | #include <sdbusplus/message.hpp> |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 6 | namespace phosphor |
| 7 | { |
| 8 | namespace led |
| 9 | { |
| 10 | |
| 11 | /** @brief Overloaded Property Setter function */ |
| 12 | bool Group::asserted(bool value) |
| 13 | { |
Vishwanatha Subbanna | 4846e92 | 2020-10-09 03:42:57 -0500 | [diff] [blame] | 14 | // 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 Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 21 | // Introducing these to enable gtest. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 22 | Manager::group ledsAssert{}; |
| 23 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 24 | |
| 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 Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 28 | auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 29 | |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 30 | // Store asserted state |
| 31 | serialize.storeGroups(path, result); |
| 32 | |
George Liu | 4c5f533 | 2020-10-10 17:04:28 +0800 | [diff] [blame^] | 33 | // 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 Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 38 | // If something does not go right here, then there should be an sdbusplus |
| 39 | // exception thrown. |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 40 | manager.driveLEDs(ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 41 | |
| 42 | // Set the base class's asserted to 'true' since the getter |
| 43 | // operation is handled there. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 44 | return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted( |
| 45 | result); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | } // namespace led |
| 49 | } // namespace phosphor |