1*7452a867SVijay Khemka #include "dbusUtils.hpp" 2*7452a867SVijay Khemka 3*7452a867SVijay Khemka #include <sdbusplus/bus.hpp> 4*7452a867SVijay Khemka 5*7452a867SVijay Khemka const char* sensorIntf = "xyz.openbmc_project.Sensor.Value"; 6*7452a867SVijay Khemka 7*7452a867SVijay Khemka class DbusSensor 8*7452a867SVijay Khemka { 9*7452a867SVijay Khemka public: 10*7452a867SVijay Khemka DbusSensor() = delete; 11*7452a867SVijay Khemka virtual ~DbusSensor() = default; 12*7452a867SVijay Khemka 13*7452a867SVijay Khemka /** @brief Constructs DbusSensor 14*7452a867SVijay Khemka * 15*7452a867SVijay Khemka * @param[in] bus - Handle to system dbus 16*7452a867SVijay Khemka * @param[in] path - The Dbus path of sensor 17*7452a867SVijay Khemka */ 18*7452a867SVijay Khemka DbusSensor(sdbusplus::bus::bus& bus, const std::string& path) : 19*7452a867SVijay Khemka bus(bus), path(path) 20*7452a867SVijay Khemka { 21*7452a867SVijay Khemka servName = getService(bus, path, sensorIntf); 22*7452a867SVijay Khemka } 23*7452a867SVijay Khemka 24*7452a867SVijay Khemka /** @brief Get sensor value property from D-bus interface */ 25*7452a867SVijay Khemka double getSensorValue() 26*7452a867SVijay Khemka { 27*7452a867SVijay Khemka return getDbusProperty<double>(bus, servName, path, sensorIntf, 28*7452a867SVijay Khemka "Value"); 29*7452a867SVijay Khemka } 30*7452a867SVijay Khemka 31*7452a867SVijay Khemka private: 32*7452a867SVijay Khemka /** @brief sdbusplus bus client connection. */ 33*7452a867SVijay Khemka sdbusplus::bus::bus& bus; 34*7452a867SVijay Khemka /** @brief complete path for sensor */ 35*7452a867SVijay Khemka std::string path; 36*7452a867SVijay Khemka /** @brief service name for the sensor daemon */ 37*7452a867SVijay Khemka std::string servName; 38*7452a867SVijay Khemka }; 39