Add to emit the threshold alarm signals
Emit the thresold alarm signals on sensor threshold interface:
https://gerrit.openbmc-project.xyz/39899
When the sensor reading exceeds the threshold, it'll send the
alarm signal with the sensor value
Tested:
Change the threshold to trigger the alarm signal:
busctl set-property xyz.openbmc_project.VirtualSensor
/xyz/openbmc_project/sensors/temperature/i2cool_0
xyz.openbmc_project.Sensor.Threshold.Critical CriticalHigh d 10
Monitor the signal by the following command:
dbus-monitor --system type=signal,member=CriticalHighAlarmAsserted
match the signal:
signal time=4282.318610 sender=:1.62 -> destination=(null destination)
serial=104431 path=/xyz/openbmc_project/sensors/temperature/i2cool_0;
interface=xyz.openbmc_project.Sensor.Threshold.Critical;
member=CriticalHighAlarmAsserted
double 22
Signed-off-by: George Hung <george.hung@quantatw.com>
Change-Id: Iac19745ac8761435ff90bf7c8f7ff1ff14f26f05
diff --git a/thresholds.hpp b/thresholds.hpp
index b01d86d..aa77f7f 100644
--- a/thresholds.hpp
+++ b/thresholds.hpp
@@ -49,6 +49,30 @@
{
return warningAlarmLow(std::forward<Args>(args)...);
}
+
+ template <typename... Args>
+ auto alarmHighSignalAsserted(Args... args)
+ {
+ return warningHighAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmHighSignalDeasserted(Args... args)
+ {
+ return warningHighAlarmDeasserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalAsserted(Args... args)
+ {
+ return warningLowAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalDeasserted(Args... args)
+ {
+ return warningLowAlarmDeasserted(std::forward<Args>(args)...);
+ }
};
template <>
@@ -77,6 +101,30 @@
{
return criticalAlarmLow(std::forward<Args>(args)...);
}
+
+ template <typename... Args>
+ auto alarmHighSignalAsserted(Args... args)
+ {
+ return criticalHighAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmHighSignalDeasserted(Args... args)
+ {
+ return criticalHighAlarmDeasserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalAsserted(Args... args)
+ {
+ return criticalLowAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalDeasserted(Args... args)
+ {
+ return criticalLowAlarmDeasserted(std::forward<Args>(args)...);
+ }
};
template <>
@@ -105,6 +153,30 @@
{
return softShutdownAlarmLow(std::forward<Args>(args)...);
}
+
+ template <typename... Args>
+ auto alarmHighSignalAsserted(Args... args)
+ {
+ return softShutdownHighAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmHighSignalDeasserted(Args... args)
+ {
+ return softShutdownHighAlarmDeasserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalAsserted(Args... args)
+ {
+ return softShutdownLowAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalDeasserted(Args... args)
+ {
+ return softShutdownLowAlarmDeasserted(std::forward<Args>(args)...);
+ }
};
template <>
@@ -133,6 +205,30 @@
{
return hardShutdownAlarmLow(std::forward<Args>(args)...);
}
+
+ template <typename... Args>
+ auto alarmHighSignalAsserted(Args... args)
+ {
+ return hardShutdownHighAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmHighSignalDeasserted(Args... args)
+ {
+ return hardShutdownHighAlarmDeasserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalAsserted(Args... args)
+ {
+ return hardShutdownLowAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalDeasserted(Args... args)
+ {
+ return hardShutdownLowAlarmDeasserted(std::forward<Args>(args)...);
+ }
};
template <>
@@ -161,6 +257,30 @@
{
return performanceLossAlarmLow(std::forward<Args>(args)...);
}
+
+ template <typename... Args>
+ auto alarmHighSignalAsserted(Args... args)
+ {
+ return performanceLossHighAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmHighSignalDeasserted(Args... args)
+ {
+ return performanceLossHighAlarmDeasserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalAsserted(Args... args)
+ {
+ return performanceLossLowAlarmAsserted(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
+ auto alarmLowSignalDeasserted(Args... args)
+ {
+ return performanceLossLowAlarmDeasserted(std::forward<Args>(args)...);
+ }
};
} // namespace phosphor::virtualSensor
diff --git a/virtualSensor.hpp b/virtualSensor.hpp
index ba802db..1d72f1e 100644
--- a/virtualSensor.hpp
+++ b/virtualSensor.hpp
@@ -142,12 +142,14 @@
constexpr auto msg =
"ASSERT: {} has exceeded the {} high threshold";
log<level::ERR>(fmt::format(msg, name, tname).c_str());
+ threshold->alarmHighSignalAsserted(value);
}
else
{
constexpr auto msg =
"DEASSERT: {} is under the {} high threshold";
log<level::INFO>(fmt::format(msg, name, tname).c_str());
+ threshold->alarmHighSignalDeasserted(value);
}
threshold->alarmHigh(!alarmHigh);
}
@@ -160,12 +162,14 @@
{
constexpr auto msg = "ASSERT: {} is under the {} low threshold";
log<level::ERR>(fmt::format(msg, name, tname).c_str());
+ threshold->alarmLowSignalAsserted(value);
}
else
{
constexpr auto msg =
"DEASSERT: {} is above the {} low threshold";
log<level::INFO>(fmt::format(msg, name, tname).c_str());
+ threshold->alarmLowSignalDeasserted(value);
}
threshold->alarmLow(!alarmLow);
}