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 | |
| 14 | using CriticalIface = |
| 15 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Critical; |
| 16 | using CriticalObject = ServerObject<CriticalIface>; |
| 17 | |
| 18 | using WarningIface = |
| 19 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning; |
| 20 | using WarningObject = ServerObject<WarningIface>; |
| 21 | |
| 22 | using SoftShutdownIface = |
| 23 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::SoftShutdown; |
| 24 | using SoftShutdownObject = ServerObject<SoftShutdownIface>; |
| 25 | |
| 26 | using HardShutdownIface = |
| 27 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::HardShutdown; |
| 28 | using HardShutdownObject = ServerObject<HardShutdownIface>; |
| 29 | |
| 30 | template <typename T> |
| 31 | struct Threshold |
| 32 | {}; |
| 33 | |
| 34 | template <> |
| 35 | struct Threshold<WarningObject> |
| 36 | { |
| 37 | public: |
| 38 | static double high(WarningObject* iface) |
| 39 | { |
| 40 | return iface->warningHigh(); |
| 41 | } |
| 42 | static double low(WarningObject* iface) |
| 43 | { |
| 44 | return iface->warningLow(); |
| 45 | } |
| 46 | |
| 47 | static bool alarmHigh(WarningObject* iface) |
| 48 | { |
| 49 | return iface->warningAlarmHigh(); |
| 50 | } |
| 51 | |
| 52 | static bool alarmLow(WarningObject* iface) |
| 53 | { |
| 54 | return iface->warningAlarmLow(); |
| 55 | } |
| 56 | |
| 57 | static void alarmHigh(WarningObject* iface, bool value) |
| 58 | { |
| 59 | iface->warningAlarmHigh(value); |
| 60 | } |
| 61 | |
| 62 | static void alarmLow(WarningObject* iface, bool value) |
| 63 | { |
| 64 | iface->warningAlarmLow(value); |
| 65 | } |
| 66 | |
| 67 | static const char* name() |
| 68 | { |
| 69 | return "Warning"; |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | template <> |
| 74 | struct Threshold<CriticalObject> |
| 75 | { |
| 76 | public: |
| 77 | static double high(CriticalObject* iface) |
| 78 | { |
| 79 | return iface->criticalHigh(); |
| 80 | } |
| 81 | static double low(CriticalObject* iface) |
| 82 | { |
| 83 | return iface->criticalLow(); |
| 84 | } |
| 85 | |
| 86 | static bool alarmHigh(CriticalObject* iface) |
| 87 | { |
| 88 | return iface->criticalAlarmHigh(); |
| 89 | } |
| 90 | |
| 91 | static bool alarmLow(CriticalObject* iface) |
| 92 | { |
| 93 | return iface->criticalAlarmLow(); |
| 94 | } |
| 95 | |
| 96 | static void alarmHigh(CriticalObject* iface, bool value) |
| 97 | { |
| 98 | iface->criticalAlarmHigh(value); |
| 99 | } |
| 100 | |
| 101 | static void alarmLow(CriticalObject* iface, bool value) |
| 102 | { |
| 103 | iface->criticalAlarmLow(value); |
| 104 | } |
| 105 | |
| 106 | static const char* name() |
| 107 | { |
| 108 | return "Critical"; |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | template <> |
| 113 | struct Threshold<SoftShutdownObject> |
| 114 | { |
| 115 | public: |
| 116 | static double high(SoftShutdownObject* iface) |
| 117 | { |
| 118 | return iface->softShutdownHigh(); |
| 119 | } |
| 120 | static double low(SoftShutdownObject* iface) |
| 121 | { |
| 122 | return iface->softShutdownLow(); |
| 123 | } |
| 124 | |
| 125 | static bool alarmHigh(SoftShutdownObject* iface) |
| 126 | { |
| 127 | return iface->softShutdownAlarmHigh(); |
| 128 | } |
| 129 | |
| 130 | static bool alarmLow(SoftShutdownObject* iface) |
| 131 | { |
| 132 | return iface->softShutdownAlarmLow(); |
| 133 | } |
| 134 | |
| 135 | static void alarmHigh(SoftShutdownObject* iface, bool value) |
| 136 | { |
| 137 | iface->softShutdownAlarmHigh(value); |
| 138 | } |
| 139 | |
| 140 | static void alarmLow(SoftShutdownObject* iface, bool value) |
| 141 | { |
| 142 | iface->softShutdownAlarmLow(value); |
| 143 | } |
| 144 | |
| 145 | static const char* name() |
| 146 | { |
| 147 | return "SoftShutdown"; |
| 148 | } |
| 149 | }; |
| 150 | |
| 151 | template <> |
| 152 | struct Threshold<HardShutdownObject> |
| 153 | { |
| 154 | public: |
| 155 | static double high(HardShutdownObject* iface) |
| 156 | { |
| 157 | return iface->hardShutdownHigh(); |
| 158 | } |
| 159 | static double low(HardShutdownObject* iface) |
| 160 | { |
| 161 | return iface->hardShutdownLow(); |
| 162 | } |
| 163 | |
| 164 | static bool alarmHigh(HardShutdownObject* iface) |
| 165 | { |
| 166 | return iface->hardShutdownAlarmHigh(); |
| 167 | } |
| 168 | |
| 169 | static bool alarmLow(HardShutdownObject* iface) |
| 170 | { |
| 171 | return iface->hardShutdownAlarmLow(); |
| 172 | } |
| 173 | |
| 174 | static void alarmHigh(HardShutdownObject* iface, bool value) |
| 175 | { |
| 176 | iface->hardShutdownAlarmHigh(value); |
| 177 | } |
| 178 | |
| 179 | static void alarmLow(HardShutdownObject* iface, bool value) |
| 180 | { |
| 181 | iface->hardShutdownAlarmLow(value); |
| 182 | } |
| 183 | |
| 184 | static const char* name() |
| 185 | { |
| 186 | return "HardShutdown"; |
| 187 | } |
| 188 | }; |
| 189 | |
| 190 | } // namespace phosphor::virtualSensor |