1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 #include <sdbusplus/server/object.hpp> 5 #include <org/open_power/OCC/Status/server.hpp> 6 #include "occ_events.hpp" 7 #include "occ_device.hpp" 8 namespace open_power 9 { 10 namespace occ 11 { 12 13 namespace Base = sdbusplus::org::open_power::OCC::server; 14 using Interface = sdbusplus::server::object::object<Base::Status>; 15 16 // OCC status instance. Ex. for "occ0", the instance is 0 17 using instanceID = int; 18 19 // IPMI sensor ID for a given OCC instance 20 using sensorID = uint8_t; 21 22 /** @class Status 23 * @brief Implementation of OCC Active Status 24 */ 25 class Status : public Interface 26 { 27 public: 28 Status() = delete; 29 ~Status() = default; 30 Status(const Status&) = delete; 31 Status& operator=(const Status&) = delete; 32 Status(Status&&) = default; 33 Status& operator=(Status&&) = default; 34 35 /** @brief Constructs the Status object and 36 * the underlying device object 37 * 38 * @param[in] bus - DBus bus to attach to 39 * @param[in] path - DBus object path 40 */ 41 Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path) 42 : Interface(bus, path), 43 path(path), 44 instance(((this->path.back() - '0'))), 45 device(event, 46 name + std::to_string(instance + 1), 47 std::bind(&Status::deviceErrorHandler, this)) 48 { 49 // Nothing to do here 50 } 51 52 /** @brief Since we are overriding the setter-occActive but not the 53 * getter-occActive, we need to have this using in order to 54 * allow passthrough usage of the getter-occActive 55 */ 56 using Base::Status::occActive; 57 58 /** @brief SET OccActive to True or False 59 * 60 * @param[in] value - Intended value 61 * 62 * @return - Updated value of the property 63 */ 64 bool occActive(bool value) override; 65 66 private: 67 /** @brief OCC dbus object path */ 68 std::string path; 69 70 /** @brief occ name prefix */ 71 std::string name = OCC_NAME; 72 73 /** @brief OCC instance number. Ex, 0,1, etc */ 74 int instance; 75 76 /** @brief OCC instance to Sensor ID mapping */ 77 static const std::map<instanceID, sensorID> sensorMap; 78 79 /** @brief OCC device object to do bind and unbind */ 80 Device device; 81 82 /** @brief Callback handler when device errors are detected */ 83 void deviceErrorHandler(); 84 }; 85 86 } // namespace occ 87 } // namespace open_power 88