blob: d728f2b48be6450dced5f20cf35bf564982fe8e7 [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
42 serialize.storeGroups(path, result);
43
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053044 // If something does not go right here, then there should be an sdbusplus
45 // exception thrown.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +053046 manager.driveLEDs(ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053047
48 // Set the base class's asserted to 'true' since the getter
49 // operation is handled there.
Patrick Venture91ac8d32018-11-01 17:03:22 -070050 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
51 result);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053052}
53
54} // namespace led
55} // namespace phosphor