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 | |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame^] | 5 | #include "ledlayout.hpp" |
| 6 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 7 | #include <sdbusplus/message.hpp> |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 8 | namespace phosphor |
| 9 | { |
| 10 | namespace led |
| 11 | { |
| 12 | |
| 13 | /** @brief Overloaded Property Setter function */ |
| 14 | bool Group::asserted(bool value) |
| 15 | { |
Vishwanatha Subbanna | 4846e92 | 2020-10-09 03:42:57 -0500 | [diff] [blame] | 16 | // If the value is already what is before, return right away |
| 17 | if (value == |
| 18 | sdbusplus::xyz::openbmc_project::Led::server::Group::asserted()) |
| 19 | { |
| 20 | return value; |
| 21 | } |
| 22 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 23 | if (customCallBack != nullptr) |
| 24 | { |
| 25 | // Call the custom callback method |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 26 | customCallBack(this, value); |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 27 | |
| 28 | return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted( |
| 29 | value); |
| 30 | } |
| 31 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 32 | // Introducing these to enable gtest. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame^] | 33 | ActionSet ledsAssert{}; |
| 34 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 35 | |
| 36 | // Group management is handled by Manager. The populated leds* sets are not |
| 37 | // really used by production code. They are there to enable gtest for |
| 38 | // validation. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 39 | auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 40 | |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 41 | // Store asserted state |
| 42 | serialize.storeGroups(path, result); |
| 43 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 44 | // If something does not go right here, then there should be an sdbusplus |
| 45 | // exception thrown. |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 46 | manager.driveLEDs(ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 47 | |
| 48 | // Set the base class's asserted to 'true' since the getter |
| 49 | // operation is handled there. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 50 | return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted( |
| 51 | result); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | } // namespace led |
| 55 | } // namespace phosphor |