blob: eb857b6f6b223b1dd75ebc3a3a48e8d849af56ba (
plain)
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
|
#pragma once
#include <algorithm>
namespace phosphor
{
namespace fan
{
namespace control
{
namespace action
{
/**
* @brief An action to set the speed on a zone
* @details The zone is set to the given speed when a defined number of
* properties in the group are set to the given state
*
* @param[in] count - Number of properties
* @param[in] state - Value the property(s) needed to be set at
* @param[in] speed - Speed to set the zone to
*
* @return Lambda function
* A lambda function to set the zone speed when the number of properties
* within the group are at a certain value
*/
auto count_state_before_speed(size_t count, bool state, uint64_t speed)
{
return [=](auto& zone, auto& group)
{
size_t numAtState = std::count_if(
group.begin(),
group.end(),
[&zone, &state](auto const& entry)
{
return zone.getPropertyValue(
entry.first,
std::get<propPos>(entry.second)) == state;
});
if (numAtState >= count)
{
zone.setSpeed(speed);
}
};
}
} // namespace action
} // namespace control
} // namespace fan
} // namespace phosphor
|