Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 1 | #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 | |||||
8 | namespace phosphor::virtualSensor | ||||
9 | { | ||||
10 | |||||
11 | template <typename... T> | ||||
12 | using ServerObject = typename sdbusplus::server::object::object<T...>; | ||||
13 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 14 | namespace threshold_ns = |
15 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server; | ||||
16 | using CriticalObject = ServerObject<threshold_ns::Critical>; | ||||
17 | using WarningObject = ServerObject<threshold_ns::Warning>; | ||||
18 | using SoftShutdownObject = ServerObject<threshold_ns::SoftShutdown>; | ||||
19 | using HardShutdownObject = ServerObject<threshold_ns::HardShutdown>; | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 20 | |
21 | template <typename T> | ||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 22 | struct Threshold; |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 23 | |
24 | template <> | ||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 25 | struct Threshold<WarningObject> : public WarningObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 26 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 27 | static constexpr auto name = "Warning"; |
28 | using WarningObject::WarningObject; | ||||
29 | |||||
30 | auto high() | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 31 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 32 | return warningHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 33 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 34 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 35 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 36 | return warningLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 37 | } |
38 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 39 | template <typename... Args> |
40 | auto alarmHigh(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 41 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 42 | return warningAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 43 | } |
44 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 45 | template <typename... Args> |
46 | auto alarmLow(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 47 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 48 | return warningAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 49 | } |
50 | }; | ||||
51 | |||||
52 | template <> | ||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 53 | struct Threshold<CriticalObject> : public CriticalObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 54 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 55 | static constexpr auto name = "Critical"; |
56 | using CriticalObject::CriticalObject; | ||||
57 | |||||
58 | auto high() | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 59 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 60 | return criticalHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 61 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 62 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 63 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 64 | return criticalLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 65 | } |
66 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 67 | template <typename... Args> |
68 | auto alarmHigh(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 69 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 70 | return criticalAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 71 | } |
72 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 73 | template <typename... Args> |
74 | auto alarmLow(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 75 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 76 | return criticalAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 77 | } |
78 | }; | ||||
79 | |||||
80 | template <> | ||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 81 | struct Threshold<SoftShutdownObject> : public SoftShutdownObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 82 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 83 | static constexpr auto name = "SoftShutdown"; |
84 | using SoftShutdownObject::SoftShutdownObject; | ||||
85 | |||||
86 | auto high() | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 87 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 88 | return softShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 89 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 90 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 91 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 92 | return softShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 93 | } |
94 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 95 | template <typename... Args> |
96 | auto alarmHigh(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 97 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 98 | return softShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 99 | } |
100 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 101 | template <typename... Args> |
102 | auto alarmLow(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 103 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 104 | return softShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 105 | } |
106 | }; | ||||
107 | |||||
108 | template <> | ||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 109 | struct Threshold<HardShutdownObject> : public HardShutdownObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 110 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 111 | static constexpr auto name = "HardShutdown"; |
112 | using HardShutdownObject::HardShutdownObject; | ||||
113 | |||||
114 | auto high() | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 115 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 116 | return hardShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 117 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 118 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 119 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 120 | return hardShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 121 | } |
122 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 123 | template <typename... Args> |
124 | auto alarmHigh(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 125 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 126 | return hardShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 127 | } |
128 | |||||
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 129 | template <typename... Args> |
130 | auto alarmLow(Args... args) | ||||
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 131 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame^] | 132 | return hardShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 133 | } |
134 | }; | ||||
135 | |||||
136 | } // namespace phosphor::virtualSensor |