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