Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include "fan_properties.hpp" |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 5 | #include "sensor_base.hpp" |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 6 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace fan |
| 11 | { |
| 12 | namespace presence |
| 13 | { |
| 14 | |
Matthew Barth | 8db0f6f | 2017-02-23 10:16:57 -0600 | [diff] [blame^] | 15 | typedef enum presenceState |
| 16 | { |
| 17 | NOT_PRESENT, |
| 18 | PRESENT, |
| 19 | UNKNOWN |
| 20 | } presenceState; |
| 21 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 22 | class FanEnclosure |
| 23 | { |
Matthew Barth | 1562ac7 | 2017-02-20 16:01:21 -0600 | [diff] [blame] | 24 | using Property = std::string; |
| 25 | using Value = sdbusplus::message::variant<bool, int64_t, std::string>; |
| 26 | // Association between property and its value |
| 27 | using PropertyMap = std::map<Property, Value>; |
| 28 | using Interface = std::string; |
| 29 | // Association between interface and the dbus property |
| 30 | using InterfaceMap = std::map<Interface, PropertyMap>; |
| 31 | using Object = sdbusplus::message::object_path; |
| 32 | // Association between object and the interface |
| 33 | using ObjectMap = std::map<Object, InterfaceMap>; |
| 34 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 35 | public: |
| 36 | FanEnclosure() = delete; |
| 37 | FanEnclosure(const FanEnclosure&) = delete; |
| 38 | FanEnclosure(FanEnclosure&&) = default; |
| 39 | FanEnclosure& operator=(const FanEnclosure&) = delete; |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 40 | FanEnclosure& operator=(FanEnclosure&&) = delete; |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 41 | ~FanEnclosure() = default; |
| 42 | |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 43 | FanEnclosure(sdbusplus::bus::bus& bus, |
| 44 | const phosphor::fan::Properties& fanProp) : |
| 45 | bus(bus), |
| 46 | invPath(std::get<0>(fanProp)), |
| 47 | fanDesc(std::get<1>(fanProp)) |
| 48 | { |
| 49 | //Add this fan to inventory |
Matthew Barth | 736d143 | 2017-02-20 16:09:21 -0600 | [diff] [blame] | 50 | updInventory(); |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 51 | } |
| 52 | |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 53 | void updInventory(); |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 54 | void addSensor( |
| 55 | std::unique_ptr<Sensor>&& sensor); |
| 56 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 57 | private: |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 58 | sdbusplus::bus::bus& bus; |
| 59 | const std::string invPath; |
| 60 | const std::string fanDesc; |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 61 | std::vector<std::unique_ptr<Sensor>> sensors; |
Matthew Barth | 8db0f6f | 2017-02-23 10:16:57 -0600 | [diff] [blame^] | 62 | presenceState presState = UNKNOWN; |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 63 | |
Matthew Barth | 8db0f6f | 2017-02-23 10:16:57 -0600 | [diff] [blame^] | 64 | presenceState getCurPresState(); |
Matthew Barth | 736d143 | 2017-02-20 16:09:21 -0600 | [diff] [blame] | 65 | //TODO openbmc/openbmc#1299 - Move getInvService() to a utility file |
| 66 | std::string getInvService(); |
Matthew Barth | 8db0f6f | 2017-02-23 10:16:57 -0600 | [diff] [blame^] | 67 | ObjectMap getObjectMap(bool curPresState); |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 68 | |
| 69 | }; |
| 70 | |
| 71 | } // namespace presence |
| 72 | } // namespace fan |
| 73 | } // namespace phosphor |