blob: c9ad161e3c1e2fdf047b7446a09bc69a85d0e2e5 [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
Patrick Williams158b2c12022-03-17 05:57:44 -05005#include "ledlayout.hpp"
6
Patrick Venture91ac8d32018-11-01 17:03:22 -07007#include <sdbusplus/message.hpp>
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05308namespace phosphor
9{
10namespace led
11{
12
13/** @brief Overloaded Property Setter function */
14bool Group::asserted(bool value)
15{
Vishwanatha Subbanna4846e922020-10-09 03:42:57 -050016 // 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 Liuc777bef2020-11-23 17:04:21 +080023 if (customCallBack != nullptr)
24 {
25 // Call the custom callback method
George Liu87fd11c2020-11-23 16:40:14 +080026 customCallBack(this, value);
George Liuc777bef2020-11-23 17:04:21 +080027
28 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
29 value);
30 }
31
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053032 // Introducing these to enable gtest.
Patrick Williams158b2c12022-03-17 05:57:44 -050033 ActionSet ledsAssert{};
34 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053035
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 Venture91ac8d32018-11-01 17:03:22 -070039 auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053040
George Liu2098aa62020-05-09 11:26:35 +080041 // Store asserted state
George Liu54671852023-10-30 09:09:39 +080042 if (serializePtr)
43 {
44 serializePtr->storeGroups(path, result);
45 }
George Liu2098aa62020-05-09 11:26:35 +080046
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053047 // If something does not go right here, then there should be an sdbusplus
48 // exception thrown.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +053049 manager.driveLEDs(ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053050
51 // Set the base class's asserted to 'true' since the getter
52 // operation is handled there.
Patrick Venture91ac8d32018-11-01 17:03:22 -070053 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
54 result);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053055}
56
57} // namespace led
58} // namespace phosphor