blob: e53e496f6601308585829bfeb230ecaae0d6b8d6 [file] [log] [blame]
Matt Spinler8f5e6112021-01-15 10:44:32 -06001#pragma once
2
3#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
4#include <xyz/openbmc_project/Sensor/Threshold/HardShutdown/server.hpp>
5#include <xyz/openbmc_project/Sensor/Threshold/SoftShutdown/server.hpp>
6#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
7
8namespace phosphor::virtualSensor
9{
10
11template <typename... T>
12using ServerObject = typename sdbusplus::server::object::object<T...>;
13
Patrick Williamsfdb826d2021-01-20 14:37:53 -060014namespace threshold_ns =
15 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server;
16using CriticalObject = ServerObject<threshold_ns::Critical>;
17using WarningObject = ServerObject<threshold_ns::Warning>;
18using SoftShutdownObject = ServerObject<threshold_ns::SoftShutdown>;
19using HardShutdownObject = ServerObject<threshold_ns::HardShutdown>;
Matt Spinler8f5e6112021-01-15 10:44:32 -060020
21template <typename T>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060022struct Threshold;
Matt Spinler8f5e6112021-01-15 10:44:32 -060023
24template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060025struct Threshold<WarningObject> : public WarningObject
Matt Spinler8f5e6112021-01-15 10:44:32 -060026{
Patrick Williamsfdb826d2021-01-20 14:37:53 -060027 static constexpr auto name = "Warning";
28 using WarningObject::WarningObject;
29
30 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -060031 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060032 return warningHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -060033 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -060034 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -060035 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060036 return warningLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -060037 }
38
Patrick Williamsfdb826d2021-01-20 14:37:53 -060039 template <typename... Args>
40 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060041 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060042 return warningAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060043 }
44
Patrick Williamsfdb826d2021-01-20 14:37:53 -060045 template <typename... Args>
46 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060047 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060048 return warningAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060049 }
50};
51
52template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060053struct Threshold<CriticalObject> : public CriticalObject
Matt Spinler8f5e6112021-01-15 10:44:32 -060054{
Patrick Williamsfdb826d2021-01-20 14:37:53 -060055 static constexpr auto name = "Critical";
56 using CriticalObject::CriticalObject;
57
58 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -060059 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060060 return criticalHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -060061 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -060062 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -060063 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060064 return criticalLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -060065 }
66
Patrick Williamsfdb826d2021-01-20 14:37:53 -060067 template <typename... Args>
68 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060069 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060070 return criticalAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060071 }
72
Patrick Williamsfdb826d2021-01-20 14:37:53 -060073 template <typename... Args>
74 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060075 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060076 return criticalAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060077 }
78};
79
80template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060081struct Threshold<SoftShutdownObject> : public SoftShutdownObject
Matt Spinler8f5e6112021-01-15 10:44:32 -060082{
Patrick Williamsfdb826d2021-01-20 14:37:53 -060083 static constexpr auto name = "SoftShutdown";
84 using SoftShutdownObject::SoftShutdownObject;
85
86 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -060087 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060088 return softShutdownHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -060089 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -060090 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -060091 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060092 return softShutdownLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -060093 }
94
Patrick Williamsfdb826d2021-01-20 14:37:53 -060095 template <typename... Args>
96 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060097 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060098 return softShutdownAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060099 }
100
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600101 template <typename... Args>
102 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600103 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600104 return softShutdownAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600105 }
106};
107
108template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600109struct Threshold<HardShutdownObject> : public HardShutdownObject
Matt Spinler8f5e6112021-01-15 10:44:32 -0600110{
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600111 static constexpr auto name = "HardShutdown";
112 using HardShutdownObject::HardShutdownObject;
113
114 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600115 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600116 return hardShutdownHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600117 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600118 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600119 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600120 return hardShutdownLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600121 }
122
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600123 template <typename... Args>
124 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600125 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600126 return hardShutdownAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600127 }
128
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600129 template <typename... Args>
130 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600131 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600132 return hardShutdownAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600133 }
134};
135
136} // namespace phosphor::virtualSensor