Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 3 | #include "fan.hpp" |
| 4 | #include "rpolicy.hpp" |
| 5 | |
Matthew Barth | 2d2caa3 | 2020-05-26 11:07:24 -0500 | [diff] [blame^] | 6 | #include <functional> |
| 7 | #include <vector> |
| 8 | |
Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 9 | namespace phosphor |
| 10 | { |
| 11 | namespace fan |
| 12 | { |
| 13 | namespace presence |
| 14 | { |
| 15 | |
| 16 | class PresenceSensor; |
| 17 | |
| 18 | /** |
| 19 | * @class AnyOf |
| 20 | * @brief AnyOf redundancy policy. |
| 21 | * |
| 22 | * The any of redundancy policy monitors all sensor |
| 23 | * states in the redundancy set and reports true when any |
| 24 | * sensor in the set reports true. |
| 25 | */ |
| 26 | class AnyOf : public RedundancyPolicy |
| 27 | { |
Matthew Barth | 2d2caa3 | 2020-05-26 11:07:24 -0500 | [diff] [blame^] | 28 | public: |
| 29 | AnyOf() = delete; |
| 30 | AnyOf(const AnyOf&) = default; |
| 31 | AnyOf& operator=(const AnyOf&) = default; |
| 32 | AnyOf(AnyOf&&) = default; |
| 33 | AnyOf& operator=(AnyOf&&) = default; |
| 34 | ~AnyOf() = default; |
Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 35 | |
Matthew Barth | 2d2caa3 | 2020-05-26 11:07:24 -0500 | [diff] [blame^] | 36 | /** |
| 37 | * @brief Construct an any of bitwise policy. |
| 38 | * |
| 39 | * @param[in] fan - The fan associated with the policy. |
| 40 | * @param[in] s - The set of sensors associated with the policy. |
| 41 | */ |
| 42 | AnyOf(const Fan& fan, |
| 43 | const std::vector<std::reference_wrapper<PresenceSensor>>& s); |
Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 44 | |
Matthew Barth | 2d2caa3 | 2020-05-26 11:07:24 -0500 | [diff] [blame^] | 45 | /** |
| 46 | * @brief stateChanged |
| 47 | * |
| 48 | * Update the inventory and execute the fallback |
| 49 | * policy. |
| 50 | * |
| 51 | * @param[in] present - The new presence state according |
| 52 | * to the specified sensor. |
| 53 | * @param[in] sensor - The sensor reporting the new state. |
| 54 | */ |
| 55 | void stateChanged(bool present, PresenceSensor& sensor) override; |
Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 56 | |
Matthew Barth | 2d2caa3 | 2020-05-26 11:07:24 -0500 | [diff] [blame^] | 57 | /** |
| 58 | * @brief monitor |
| 59 | * |
| 60 | * Start monitoring the fan. |
| 61 | */ |
| 62 | void monitor() override; |
Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 63 | |
Matthew Barth | 2d2caa3 | 2020-05-26 11:07:24 -0500 | [diff] [blame^] | 64 | private: |
| 65 | /** @brief All presence sensors in the redundancy set. */ |
| 66 | std::vector<std::tuple<std::reference_wrapper<PresenceSensor>, bool>> state; |
Brad Bishop | 00b5208 | 2017-07-25 19:52:22 -0400 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | } // namespace presence |
| 70 | } // namespace fan |
| 71 | } // namespace phosphor |