blob: c9a133ef356d58a96e541b495b5f8bd5c064a51b [file] [log] [blame]
Tony Lee6c595012019-06-19 10:54:59 +08001#pragma once
2
3#include "config.h"
4
5#include <sdbusplus/bus.hpp>
6#include <sdbusplus/server.hpp>
7#include <sdeventplus/clock.hpp>
8#include <sdeventplus/event.hpp>
9#include <sdeventplus/utility/timer.hpp>
10#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
11#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
12#include <xyz/openbmc_project/Sensor/Value/server.hpp>
13
14namespace phosphor
15{
16namespace nvme
17{
18
19using ValueIface = sdbusplus::xyz::openbmc_project::Sensor::server::Value;
20
21using CriticalInterface =
22 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Critical;
23
24using WarningInterface =
25 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning;
26
27using NvmeIfaces =
28 sdbusplus::server::object::object<ValueIface, CriticalInterface,
29 WarningInterface>;
30
31class NvmeSSD : public NvmeIfaces
32{
33 public:
34 NvmeSSD() = delete;
35 NvmeSSD(const NvmeSSD&) = delete;
36 NvmeSSD& operator=(const NvmeSSD&) = delete;
37 NvmeSSD(NvmeSSD&&) = delete;
38 NvmeSSD& operator=(NvmeSSD&&) = delete;
39 virtual ~NvmeSSD() = default;
40
41 /** @brief Constructs NvmeSSD
42 *
43 * @param[in] bus - Handle to system dbus
44 * @param[in] objPath - The Dbus path of nvme
45 */
46 NvmeSSD(sdbusplus::bus::bus& bus, const char* objPath) :
47 NvmeIfaces(bus, objPath), bus(bus)
48 {
49 }
50
51 /** @brief Set sensor value temperature to nvme D-bus */
52 void setSensorValueToDbus(const int8_t value);
53 /** @brief Check if sensor value higher or lower threshold */
54 void checkSensorThreshold();
55 /** @brief Set Sensor Threshold to D-bus at beginning */
56 void setSensorThreshold(int8_t criticalHigh, int8_t criticalLow,
57 int8_t maxValue, int8_t minValue,
58 int8_t warningHigh, int8_t warningLow);
59
60 private:
61 sdbusplus::bus::bus& bus;
62};
63} // namespace nvme
64} // namespace phosphor