blob: a52bd909f823bab519bc47640fb67cba0a869cd3 [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
5#include <sdbusplus/message.hpp>
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05306namespace phosphor
7{
8namespace led
9{
10
11/** @brief Overloaded Property Setter function */
12bool Group::asserted(bool value)
13{
Vishwanatha Subbanna4846e922020-10-09 03:42:57 -050014 // 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 Liuc777bef2020-11-23 17:04:21 +080021 if (customCallBack != nullptr)
22 {
23 // Call the custom callback method
George Liu87fd11c2020-11-23 16:40:14 +080024 customCallBack(this, value);
George Liuc777bef2020-11-23 17:04:21 +080025
26 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
27 value);
28 }
29
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053030 // Introducing these to enable gtest.
Patrick Venture91ac8d32018-11-01 17:03:22 -070031 Manager::group ledsAssert{};
32 Manager::group ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053033
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 Venture91ac8d32018-11-01 17:03:22 -070037 auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053038
George Liu2098aa62020-05-09 11:26:35 +080039 // Store asserted state
40 serialize.storeGroups(path, result);
41
George Liu4c5f5332020-10-10 17:04:28 +080042 // Set OperationalStatus according to the status of asserted property.
43 // If the group is asserted, then the functional status is false and
44 // vice-versa.
45 manager.setOperationalStatus(path, !value);
46
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