Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 1 | #include <algorithm> |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 2 | #include "fan_enclosure.hpp" |
| 3 | |
| 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace fan |
| 8 | { |
| 9 | namespace presence |
| 10 | { |
| 11 | |
Matthew Barth | 1562ac7 | 2017-02-20 16:01:21 -0600 | [diff] [blame^] | 12 | FanEnclosure::ObjectMap FanEnclosure::getObjectMap() |
| 13 | { |
| 14 | ObjectMap invObj; |
| 15 | InterfaceMap invIntf; |
| 16 | PropertyMap invProp; |
| 17 | auto presPred = [](auto const& s) {return s->isPresent();}; |
| 18 | // Determine if all sensors show fan is not present |
| 19 | auto isPresent = std::any_of(sensors.begin(), |
| 20 | sensors.end(), |
| 21 | presPred); |
| 22 | invProp.emplace("Present", isPresent); |
| 23 | invProp.emplace("PrettyName", fanDesc); |
| 24 | invIntf.emplace("xyz.openbmc_project.Inventory.Item", std::move(invProp)); |
| 25 | Object fanInvPath = invPath; |
| 26 | invObj.emplace(std::move(fanInvPath), std::move(invIntf)); |
| 27 | |
| 28 | return invObj; |
| 29 | } |
| 30 | |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 31 | void FanEnclosure::addInventory() |
| 32 | { |
| 33 | //TODO Add this fan to inventory |
| 34 | } |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 35 | |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 36 | void FanEnclosure::updInventory() |
| 37 | { |
Matthew Barth | 1562ac7 | 2017-02-20 16:01:21 -0600 | [diff] [blame^] | 38 | //Get inventory object for this fan |
| 39 | ObjectMap invObj = getObjectMap(); |
| 40 | //TODO Update inventory for this fan |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 41 | } |
| 42 | |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 43 | void FanEnclosure::addSensor( |
| 44 | std::unique_ptr<Sensor>&& sensor) |
| 45 | { |
| 46 | FanEnclosure::sensors.push_back(std::move(sensor)); |
| 47 | } |
| 48 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 49 | } // namespace presence |
| 50 | } // namespace fan |
| 51 | } // namespace phosphor |