Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp> |
| 5 | #include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp> |
| 6 | #include <xyz/openbmc_project/Sensor/Value/server.hpp> |
| 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace nvme |
| 11 | { |
| 12 | |
| 13 | using ValueIface = sdbusplus::xyz::openbmc_project::Sensor::server::Value; |
| 14 | |
| 15 | using CriticalInterface = |
| 16 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Critical; |
| 17 | |
| 18 | using WarningInterface = |
| 19 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning; |
| 20 | |
| 21 | using NvmeIfaces = |
| 22 | sdbusplus::server::object::object<ValueIface, CriticalInterface, |
| 23 | WarningInterface>; |
| 24 | |
| 25 | class NvmeSSD : public NvmeIfaces |
| 26 | { |
| 27 | public: |
| 28 | NvmeSSD() = delete; |
| 29 | NvmeSSD(const NvmeSSD&) = delete; |
| 30 | NvmeSSD& operator=(const NvmeSSD&) = delete; |
| 31 | NvmeSSD(NvmeSSD&&) = delete; |
| 32 | NvmeSSD& operator=(NvmeSSD&&) = delete; |
| 33 | virtual ~NvmeSSD() = default; |
| 34 | |
| 35 | /** @brief Constructs NvmeSSD |
| 36 | * |
| 37 | * @param[in] bus - Handle to system dbus |
| 38 | * @param[in] objPath - The Dbus path of nvme |
| 39 | */ |
| 40 | NvmeSSD(sdbusplus::bus::bus& bus, const char* objPath) : |
| 41 | NvmeIfaces(bus, objPath), bus(bus) |
| 42 | { |
Potin Lai | 5c4de83 | 2022-03-04 13:19:17 +0800 | [diff] [blame^] | 43 | ValueIface::unit(Unit::DegreesC); |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | /** @brief Set sensor value temperature to nvme D-bus */ |
| 47 | void setSensorValueToDbus(const int8_t value); |
| 48 | /** @brief Check if sensor value higher or lower threshold */ |
| 49 | void checkSensorThreshold(); |
| 50 | /** @brief Set Sensor Threshold to D-bus at beginning */ |
| 51 | void setSensorThreshold(int8_t criticalHigh, int8_t criticalLow, |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 52 | int8_t warningHigh, int8_t warningLow); |
George Hung | 831f204 | 2021-05-19 17:02:29 +0800 | [diff] [blame] | 53 | /** @brief Set Sensor Max/Min value to D-bus at beginning */ |
| 54 | void setSensorMaxMin(int8_t maxValue, int8_t minValue); |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 55 | |
| 56 | private: |
| 57 | sdbusplus::bus::bus& bus; |
| 58 | }; |
| 59 | } // namespace nvme |
Brandon Kim | d5838d1 | 2021-05-19 12:51:55 -0700 | [diff] [blame] | 60 | } // namespace phosphor |