blob: 5461b0847c60d7bd2c3c1e760417000869a57ae4 [file] [log] [blame]
Matthew Barthcd4f4d12017-02-17 17:48:56 -06001#include <algorithm>
Matthew Barth293477d2017-02-17 15:39:36 -06002#include "fan_enclosure.hpp"
3
4
5namespace phosphor
6{
7namespace fan
8{
9namespace presence
10{
11
Matthew Barth1562ac72017-02-20 16:01:21 -060012FanEnclosure::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 Barthb8034452017-02-17 16:39:46 -060031void FanEnclosure::addInventory()
32{
33 //TODO Add this fan to inventory
34}
Matthew Barth293477d2017-02-17 15:39:36 -060035
Matthew Barthcd4f4d12017-02-17 17:48:56 -060036void FanEnclosure::updInventory()
37{
Matthew Barth1562ac72017-02-20 16:01:21 -060038 //Get inventory object for this fan
39 ObjectMap invObj = getObjectMap();
40 //TODO Update inventory for this fan
Matthew Barthcd4f4d12017-02-17 17:48:56 -060041}
42
Matthew Barthd6403822017-02-17 17:10:19 -060043void FanEnclosure::addSensor(
44 std::unique_ptr<Sensor>&& sensor)
45{
46 FanEnclosure::sensors.push_back(std::move(sensor));
47}
48
Matthew Barth293477d2017-02-17 15:39:36 -060049} // namespace presence
50} // namespace fan
51} // namespace phosphor