-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgroup.cpp
82 lines (67 loc) · 2.16 KB
/
group.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "config.h"
#include "group.hpp"
#include <sdbusplus/message.hpp>
#ifdef IBM_SAI
#include "ibm-sai.hpp"
#endif
namespace phosphor
{
namespace led
{
/** @brief Overloaded Property Setter function */
bool Group::asserted(bool value)
{
// If the value is already what is before, return right away
if (value ==
sdbusplus::xyz::openbmc_project::Led::server::Group::asserted())
{
return value;
}
if (customCallBack != nullptr)
{
// Call the custom callback method
customCallBack(this, value);
return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
value);
}
// Introducing these to enable gtest.
Manager::group ledsAssert{};
Manager::group ledsDeAssert{};
// Group management is handled by Manager. The populated leds* sets are not
// really used by production code. They are there to enable gtest for
// validation.
auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
// Store asserted state
serialize.storeGroups(path, result);
#ifdef IBM_SAI
// When setting the associated FRU's operational status for
// platform and partition SAI, we need to be sure that when
// the status is being set to good, both platform and partition
// SAI group objects are de-asserted.
std::string otherPath;
if (path == phosphor::led::ibm::PARTITION_SAI)
{
otherPath = phosphor::led::ibm::PLATFORM_SAI;
}
else if (path == phosphor::led::ibm::PLATFORM_SAI)
{
otherPath = phosphor::led::ibm::PARTITION_SAI;
}
if (!otherPath.empty())
{
if (value || (!value && !manager.isAsserted(otherPath)))
{
phosphor::led::ibm::setOperationalStatus(path, !value);
}
}
#endif
// If something does not go right here, then there should be an sdbusplus
// exception thrown.
manager.driveLEDs(ledsAssert, ledsDeAssert);
// Set the base class's asserted to 'true' since the getter
// operation is handled there.
return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
result);
}
} // namespace led
} // namespace phosphor