Matthew Barth | d106605 | 2017-04-12 09:47:28 -0500 | [diff] [blame^] | 1 | #include "data_types.hpp" |
| 2 | #include "functor.hpp" |
| 3 | #include "monitor.hpp" |
| 4 | #include "conditions.hpp" |
| 5 | #include "actions.hpp" |
| 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace dbus |
| 10 | { |
| 11 | namespace monitoring |
| 12 | { |
| 13 | |
| 14 | // Example vector of sensors constructing a group |
| 15 | static Group fan_zone_group = { |
| 16 | std::make_tuple( |
| 17 | "/xyz/openbmc_project/sensors/fan_tach/fan0", |
| 18 | static_cast<int64_t>(0) |
| 19 | ), |
| 20 | std::make_tuple( |
| 21 | "/xyz/openbmc_project/sensors/fan_tach/fan1", |
| 22 | static_cast<int64_t>(0) |
| 23 | ), |
| 24 | std::make_tuple( |
| 25 | "/xyz/openbmc_project/sensors/fan_tach/fan2", |
| 26 | static_cast<int64_t>(0) |
| 27 | ), |
| 28 | std::make_tuple( |
| 29 | "/xyz/openbmc_project/sensors/fan_tach/fan3", |
| 30 | static_cast<int64_t>(0) |
| 31 | ) |
| 32 | }; |
| 33 | |
| 34 | const std::vector<std::tuple<std::vector<std::shared_ptr<Event>>, |
| 35 | std::vector<Action>>> |
| 36 | Monitor::events |
| 37 | { // Example vector of Events with START trigger |
| 38 | {std::make_tuple(std::vector<std::shared_ptr<Event>>( |
| 39 | { // Example vector of StartEvent |
| 40 | std::make_shared<StartEvent>( |
| 41 | std::vector<Condition>( |
| 42 | { // Example vector of StartEvent conditions |
| 43 | make_condition(propertyStart<int64_t>( |
| 44 | "/xyz/openbmc_project/sensors/fan_tach/fan0", |
| 45 | "xyz.openbmc_project.Sensor.Value", |
| 46 | "Value", |
| 47 | condition::countAtOrAbove( |
| 48 | fan_zone_group, |
| 49 | "/xyz/openbmc_project/sensors/fan_tach/fan0", |
| 50 | static_cast<size_t>(3), |
| 51 | static_cast<int64_t>(8000ll) |
| 52 | ) |
| 53 | )), |
| 54 | make_condition(propertyStart<int64_t>( |
| 55 | "/xyz/openbmc_project/sensors/fan_tach/fan1", |
| 56 | "xyz.openbmc_project.Sensor.Value", |
| 57 | "Value", |
| 58 | condition::countAtOrAbove( |
| 59 | fan_zone_group, |
| 60 | "/xyz/openbmc_project/sensors/fan_tach/fan1", |
| 61 | static_cast<size_t>(3), |
| 62 | static_cast<int64_t>(8000ll) |
| 63 | ) |
| 64 | )), |
| 65 | make_condition(propertyStart<int64_t>( |
| 66 | "/xyz/openbmc_project/sensors/fan_tach/fan2", |
| 67 | "xyz.openbmc_project.Sensor.Value", |
| 68 | "Value", |
| 69 | condition::countAtOrAbove( |
| 70 | fan_zone_group, |
| 71 | "/xyz/openbmc_project/sensors/fan_tach/fan2", |
| 72 | static_cast<size_t>(3), |
| 73 | static_cast<int64_t>(8000ll) |
| 74 | ) |
| 75 | )), |
| 76 | make_condition(propertyStart<int64_t>( |
| 77 | "/xyz/openbmc_project/sensors/fan_tach/fan3", |
| 78 | "xyz.openbmc_project.Sensor.Value", |
| 79 | "Value", |
| 80 | condition::countAtOrAbove( |
| 81 | fan_zone_group, |
| 82 | "/xyz/openbmc_project/sensors/fan_tach/fan3", |
| 83 | static_cast<size_t>(3), |
| 84 | static_cast<int64_t>(8000ll) |
| 85 | ) |
| 86 | )), |
| 87 | } |
| 88 | ) |
| 89 | ), |
| 90 | std::make_shared<SignalEvent>( |
| 91 | "interface='org.freedesktop.DBus.Properties'," |
| 92 | "member='PropertiesChanged'," |
| 93 | "type='signal'," |
| 94 | "path='/xyz/openbmc_project/sensors/fan_tach/fan0'", |
| 95 | std::vector<Condition>( |
| 96 | { // Example vector of SignalEvent conditions |
| 97 | make_condition(propertySignal<int64_t>( |
| 98 | "xyz.openbmc_project.Sensor.Value", |
| 99 | "Value", |
| 100 | condition::countAtOrAbove( |
| 101 | fan_zone_group, |
| 102 | "/xyz/openbmc_project/sensors/fan_tach/fan0", |
| 103 | static_cast<size_t>(3), |
| 104 | static_cast<int64_t>(8000ll) |
| 105 | ) |
| 106 | )) |
| 107 | } |
| 108 | ) |
| 109 | ), |
| 110 | std::make_shared<SignalEvent>( |
| 111 | "interface='org.freedesktop.DBus.Properties'," |
| 112 | "member='PropertiesChanged'," |
| 113 | "type='signal'," |
| 114 | "path='/xyz/openbmc_project/sensors/fan_tach/fan1'", |
| 115 | std::vector<Condition>( |
| 116 | { // Example vector of SignalEvent conditions |
| 117 | make_condition(propertySignal<int64_t>( |
| 118 | "xyz.openbmc_project.Sensor.Value", |
| 119 | "Value", |
| 120 | condition::countAtOrAbove( |
| 121 | fan_zone_group, |
| 122 | "/xyz/openbmc_project/sensors/fan_tach/fan1", |
| 123 | static_cast<size_t>(3), |
| 124 | static_cast<int64_t>(8000ll) |
| 125 | ) |
| 126 | )) |
| 127 | } |
| 128 | ) |
| 129 | ), |
| 130 | std::make_shared<SignalEvent>( |
| 131 | "interface='org.freedesktop.DBus.Properties'," |
| 132 | "member='PropertiesChanged'," |
| 133 | "type='signal'," |
| 134 | "path='/xyz/openbmc_project/sensors/fan_tach/fan2'", |
| 135 | std::vector<Condition>( |
| 136 | { // Example vector of SignalEvent conditions |
| 137 | make_condition(propertySignal<int64_t>( |
| 138 | "xyz.openbmc_project.Sensor.Value", |
| 139 | "Value", |
| 140 | condition::countAtOrAbove( |
| 141 | fan_zone_group, |
| 142 | "/xyz/openbmc_project/sensors/fan_tach/fan2", |
| 143 | static_cast<size_t>(3), |
| 144 | static_cast<int64_t>(8000ll) |
| 145 | ) |
| 146 | )) |
| 147 | } |
| 148 | ) |
| 149 | ), |
| 150 | std::make_shared<SignalEvent>( |
| 151 | "interface='org.freedesktop.DBus.Properties'," |
| 152 | "member='PropertiesChanged'," |
| 153 | "type='signal'," |
| 154 | "path='/xyz/openbmc_project/sensors/fan_tach/fan3'", |
| 155 | std::vector<Condition>( |
| 156 | { // Example vector of SignalEvent conditions |
| 157 | make_condition(propertySignal<int64_t>( |
| 158 | "xyz.openbmc_project.Sensor.Value", |
| 159 | "Value", |
| 160 | condition::countAtOrAbove( |
| 161 | fan_zone_group, |
| 162 | "/xyz/openbmc_project/sensors/fan_tach/fan3", |
| 163 | static_cast<size_t>(3), |
| 164 | static_cast<int64_t>(8000ll) |
| 165 | ) |
| 166 | )) |
| 167 | } |
| 168 | ) |
| 169 | ) |
| 170 | }), |
| 171 | std::vector<Action>( |
| 172 | { |
| 173 | make_action( |
| 174 | action::log_error( |
| 175 | "ERROR: Number of fans at or above 8000rpms reached" |
| 176 | ) |
| 177 | ) |
| 178 | }) |
| 179 | )} |
| 180 | }; |
| 181 | |
| 182 | } // namespace monitoring |
| 183 | } // namespace dbus |
| 184 | } // namespace phosphor |