Sensor.Threshold.*: use PDI constants
Use PDI constants instead of local definitions.
Tested: Inspection only.
Change-Id: Ibb878bc15ac7fa5ec2cae45c5327d2a396e435a0
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index e7f6566..6065edb 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -20,6 +20,8 @@
#include <nlohmann/json.hpp>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/ObjectMapper/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
#include <xyz/openbmc_project/Sensor/Value/common.hpp>
#include <fstream>
@@ -28,6 +30,10 @@
using ObjectMapper = sdbusplus::common::xyz::openbmc_project::ObjectMapper;
using SensorValue = sdbusplus::common::xyz::openbmc_project::sensor::Value;
+using SensorThresholdWarning =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
+using SensorThresholdCritical =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
#ifdef FEATURE_HYBRID_SENSORS
@@ -173,8 +179,7 @@
// Add sensors to SensorTree
static constexpr const std::array sensorInterfaces = {
SensorValue::interface, "xyz.openbmc_project.Sensor.ValueMutability",
- "xyz.openbmc_project.Sensor.Threshold.Warning",
- "xyz.openbmc_project.Sensor.Threshold.Critical"};
+ SensorThresholdWarning::interface, SensorThresholdCritical::interface};
static constexpr const std::array vrInterfaces = {
"xyz.openbmc_project.Control.VoltageRegulatorMode"};
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 1c4930f..6d03468 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -31,6 +31,8 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <user_channel/channel_layer.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
#include <xyz/openbmc_project/Sensor/Value/common.hpp>
#include <algorithm>
@@ -47,6 +49,10 @@
#include <variant>
using SensorValue = sdbusplus::common::xyz::openbmc_project::sensor::Value;
+using SensorThresholdWarning =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
+using SensorThresholdCritical =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
#ifdef FEATURE_HYBRID_SENSORS
@@ -259,10 +265,8 @@
min = -128;
auto sensorObject = sensorMap.find(SensorValue::interface);
- auto critical =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical");
- auto warning =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning");
+ auto critical = sensorMap.find(SensorThresholdCritical::interface);
+ auto warning = sensorMap.find(SensorThresholdWarning::interface);
if (sensorObject != sensorMap.end())
{
@@ -282,8 +286,10 @@
}
if (critical != sensorMap.end())
{
- auto lower = critical->second.find("CriticalLow");
- auto upper = critical->second.find("CriticalHigh");
+ auto lower = critical->second.find(
+ SensorThresholdCritical::property_names::critical_low);
+ auto upper = critical->second.find(
+ SensorThresholdCritical::property_names::critical_high);
if (lower != critical->second.end())
{
double value = std::visit(VariantToDoubleVisitor(), lower->second);
@@ -303,8 +309,10 @@
}
if (warning != sensorMap.end())
{
- auto lower = warning->second.find("WarningLow");
- auto upper = warning->second.find("WarningHigh");
+ auto lower = warning->second.find(
+ SensorThresholdWarning::property_names::warning_low);
+ auto upper = warning->second.find(
+ SensorThresholdWarning::property_names::warning_high);
if (lower != warning->second.end())
{
double value = std::visit(VariantToDoubleVisitor(), lower->second);
@@ -1050,12 +1058,13 @@
uint8_t thresholds = 0;
- auto warningObject =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning");
+ auto warningObject = sensorMap.find(SensorThresholdWarning::interface);
if (warningObject != sensorMap.end())
{
- auto alarmHigh = warningObject->second.find("WarningAlarmHigh");
- auto alarmLow = warningObject->second.find("WarningAlarmLow");
+ auto alarmHigh = warningObject->second.find(
+ SensorThresholdWarning::property_names::warning_alarm_high);
+ auto alarmLow = warningObject->second.find(
+ SensorThresholdWarning::property_names::warning_alarm_low);
if (alarmHigh != warningObject->second.end())
{
if (std::get<bool>(alarmHigh->second))
@@ -1074,12 +1083,13 @@
}
}
- auto criticalObject =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical");
+ auto criticalObject = sensorMap.find(SensorThresholdCritical::interface);
if (criticalObject != sensorMap.end())
{
- auto alarmHigh = criticalObject->second.find("CriticalAlarmHigh");
- auto alarmLow = criticalObject->second.find("CriticalAlarmLow");
+ auto alarmHigh = criticalObject->second.find(
+ SensorThresholdCritical::property_names::critical_alarm_high);
+ auto alarmLow = criticalObject->second.find(
+ SensorThresholdCritical::property_names::critical_alarm_low);
if (alarmHigh != criticalObject->second.end())
{
if (std::get<bool>(alarmHigh->second))
@@ -1187,60 +1197,66 @@
// verifiy all needed fields are present
if (lowerCriticalThreshMask || upperCriticalThreshMask)
{
- auto findThreshold =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical");
+ auto findThreshold = sensorMap.find(SensorThresholdCritical::interface);
if (findThreshold == sensorMap.end())
{
return ipmi::responseInvalidFieldRequest();
}
if (lowerCriticalThreshMask)
{
- auto findLower = findThreshold->second.find("CriticalLow");
+ auto findLower = findThreshold->second.find(
+ SensorThresholdCritical::property_names::critical_low);
if (findLower == findThreshold->second.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("CriticalLow", lowerCritical,
- findThreshold->first);
+ thresholdsToSet.emplace_back(
+ SensorThresholdCritical::property_names::critical_low,
+ lowerCritical, findThreshold->first);
}
if (upperCriticalThreshMask)
{
- auto findUpper = findThreshold->second.find("CriticalHigh");
+ auto findUpper = findThreshold->second.find(
+ SensorThresholdCritical::property_names::critical_high);
if (findUpper == findThreshold->second.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("CriticalHigh", upperCritical,
- findThreshold->first);
+ thresholdsToSet.emplace_back(
+ SensorThresholdCritical::property_names::critical_high,
+ upperCritical, findThreshold->first);
}
}
if (lowerNonCriticalThreshMask || upperNonCriticalThreshMask)
{
- auto findThreshold =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning");
+ auto findThreshold = sensorMap.find(SensorThresholdWarning::interface);
if (findThreshold == sensorMap.end())
{
return ipmi::responseInvalidFieldRequest();
}
if (lowerNonCriticalThreshMask)
{
- auto findLower = findThreshold->second.find("WarningLow");
+ auto findLower = findThreshold->second.find(
+ SensorThresholdWarning::property_names::warning_low);
if (findLower == findThreshold->second.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("WarningLow", lowerNonCritical,
- findThreshold->first);
+ thresholdsToSet.emplace_back(
+ SensorThresholdWarning::property_names::warning_low,
+ lowerNonCritical, findThreshold->first);
}
if (upperNonCriticalThreshMask)
{
- auto findUpper = findThreshold->second.find("WarningHigh");
+ auto findUpper = findThreshold->second.find(
+ SensorThresholdWarning::property_names::warning_high);
if (findUpper == findThreshold->second.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("WarningHigh", upperNonCritical,
- findThreshold->first);
+ thresholdsToSet.emplace_back(
+ SensorThresholdWarning::property_names::warning_high,
+ upperNonCritical, findThreshold->first);
}
}
for (const auto& property : thresholdsToSet)
@@ -1259,10 +1275,8 @@
IPMIThresholds getIPMIThresholds(const DbusInterfaceMap& sensorMap)
{
IPMIThresholds resp;
- auto warningInterface =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning");
- auto criticalInterface =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical");
+ auto warningInterface = sensorMap.find(SensorThresholdWarning::interface);
+ auto criticalInterface = sensorMap.find(SensorThresholdCritical::interface);
if ((warningInterface != sensorMap.end()) ||
(criticalInterface != sensorMap.end()))
@@ -1294,8 +1308,10 @@
{
auto& warningMap = warningInterface->second;
- auto warningHigh = warningMap.find("WarningHigh");
- auto warningLow = warningMap.find("WarningLow");
+ auto warningHigh = warningMap.find(
+ SensorThresholdWarning::property_names::warning_high);
+ auto warningLow = warningMap.find(
+ SensorThresholdWarning::property_names::warning_low);
if (warningHigh != warningMap.end())
{
@@ -1322,8 +1338,10 @@
{
auto& criticalMap = criticalInterface->second;
- auto criticalHigh = criticalMap.find("CriticalHigh");
- auto criticalLow = criticalMap.find("CriticalLow");
+ auto criticalHigh = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_high);
+ auto criticalLow = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_low);
if (criticalHigh != criticalMap.end())
{
@@ -1497,10 +1515,8 @@
return ipmi::responseResponseError();
}
- auto warningInterface =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning");
- auto criticalInterface =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical");
+ auto warningInterface = sensorMap.find(SensorThresholdWarning::interface);
+ auto criticalInterface = sensorMap.find(SensorThresholdCritical::interface);
if ((warningInterface != sensorMap.end()) ||
(criticalInterface != sensorMap.end()))
{
@@ -1510,8 +1526,10 @@
{
auto& warningMap = warningInterface->second;
- auto warningHigh = warningMap.find("WarningHigh");
- auto warningLow = warningMap.find("WarningLow");
+ auto warningHigh = warningMap.find(
+ SensorThresholdWarning::property_names::warning_high);
+ auto warningLow = warningMap.find(
+ SensorThresholdWarning::property_names::warning_low);
if (warningHigh != warningMap.end())
{
double value =
@@ -1545,8 +1563,10 @@
{
auto& criticalMap = criticalInterface->second;
- auto criticalHigh = criticalMap.find("CriticalHigh");
- auto criticalLow = criticalMap.find("CriticalLow");
+ auto criticalHigh = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_high);
+ auto criticalLow = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_low);
if (criticalHigh != criticalMap.end())
{
@@ -1676,19 +1696,17 @@
deassertions);
}
- auto warningInterface =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning");
- auto criticalInterface =
- sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical");
+ auto warningInterface = sensorMap.find(SensorThresholdWarning::interface);
+ auto criticalInterface = sensorMap.find(SensorThresholdCritical::interface);
- std::optional<bool> criticalDeassertHigh =
- thresholdDeassertMap[path]["CriticalAlarmHigh"];
- std::optional<bool> criticalDeassertLow =
- thresholdDeassertMap[path]["CriticalAlarmLow"];
- std::optional<bool> warningDeassertHigh =
- thresholdDeassertMap[path]["WarningAlarmHigh"];
- std::optional<bool> warningDeassertLow =
- thresholdDeassertMap[path]["WarningAlarmLow"];
+ std::optional<bool> criticalDeassertHigh = thresholdDeassertMap
+ [path][SensorThresholdCritical::property_names::critical_alarm_high];
+ std::optional<bool> criticalDeassertLow = thresholdDeassertMap
+ [path][SensorThresholdCritical::property_names::critical_alarm_low];
+ std::optional<bool> warningDeassertHigh = thresholdDeassertMap
+ [path][SensorThresholdWarning::property_names::warning_alarm_high];
+ std::optional<bool> warningDeassertLow = thresholdDeassertMap
+ [path][SensorThresholdWarning::property_names::warning_alarm_low];
if (criticalDeassertHigh && !*criticalDeassertHigh)
{
@@ -1719,8 +1737,10 @@
{
auto& warningMap = warningInterface->second;
- auto warningHigh = warningMap.find("WarningAlarmHigh");
- auto warningLow = warningMap.find("WarningAlarmLow");
+ auto warningHigh = warningMap.find(
+ SensorThresholdWarning::property_names::warning_alarm_high);
+ auto warningLow = warningMap.find(
+ SensorThresholdWarning::property_names::warning_alarm_low);
auto warningHighAlarm = false;
auto warningLowAlarm = false;
@@ -1749,8 +1769,10 @@
{
auto& criticalMap = criticalInterface->second;
- auto criticalHigh = criticalMap.find("CriticalAlarmHigh");
- auto criticalLow = criticalMap.find("CriticalAlarmLow");
+ auto criticalHigh = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_alarm_high);
+ auto criticalLow = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_alarm_low);
auto criticalHighAlarm = false;
auto criticalLowAlarm = false;
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 6b716d5..62a4b8b 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -10,6 +10,8 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/message/types.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
#include <xyz/openbmc_project/Sensor/Value/common.hpp>
#include <cmath>
@@ -41,6 +43,10 @@
using PropertyMap = ipmi::PropertyMap;
using SensorValue = sdbusplus::common::xyz::openbmc_project::sensor::Value;
+using SensorThresholdWarning =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
+using SensorThresholdCritical =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
using namespace phosphor::logging;
@@ -298,8 +304,8 @@
{
critAlarmHigh = std::get<bool>(ipmi::getDbusProperty(
bus, service, sensorInfo.sensorPath,
- "xyz.openbmc_project.Sensor.Threshold.Critical",
- "CriticalAlarmHigh"));
+ SensorThresholdCritical::interface,
+ SensorThresholdCritical::property_names::critical_alarm_high));
}
catch (const std::exception& e)
{
@@ -310,8 +316,8 @@
{
critAlarmLow = std::get<bool>(ipmi::getDbusProperty(
bus, service, sensorInfo.sensorPath,
- "xyz.openbmc_project.Sensor.Threshold.Critical",
- "CriticalAlarmLow"));
+ SensorThresholdCritical::interface,
+ SensorThresholdCritical::property_names::critical_alarm_low));
}
catch (const std::exception& e)
{
@@ -322,8 +328,8 @@
{
warningAlarmHigh = std::get<bool>(ipmi::getDbusProperty(
bus, service, sensorInfo.sensorPath,
- "xyz.openbmc_project.Sensor.Threshold.Warning",
- "WarningAlarmHigh"));
+ SensorThresholdWarning::interface,
+ SensorThresholdWarning::property_names::warning_alarm_high));
}
catch (const std::exception& e)
{
@@ -334,7 +340,8 @@
{
warningAlarmLow = std::get<bool>(ipmi::getDbusProperty(
bus, service, sensorInfo.sensorPath,
- "xyz.openbmc_project.Sensor.Threshold.Warning", "WarningAlarmLow"));
+ SensorThresholdWarning::interface,
+ SensorThresholdWarning::property_names::warning_alarm_low));
}
catch (const std::exception& e)
{
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 1acdf7e..4e9a93a 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -14,6 +14,8 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/message/types.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
#include <xyz/openbmc_project/Sensor/Value/server.hpp>
#include <bitset>
@@ -43,6 +45,10 @@
sdbusplus::error::xyz::openbmc_project::common::InternalFailure;
using SensorValue = sdbusplus::common::xyz::openbmc_project::sensor::Value;
+using SensorThresholdCritical =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
+using SensorThresholdWarning =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
void registerNetFnSenFunctions() __attribute__((constructor));
@@ -927,11 +933,6 @@
return ipmi::responseSuccess();
}
- constexpr auto warningThreshIntf =
- "xyz.openbmc_project.Sensor.Threshold.Warning";
- constexpr auto criticalThreshIntf =
- "xyz.openbmc_project.Sensor.Threshold.Critical";
-
std::string service;
boost::system::error_code ec;
ec = ipmi::getService(ctx, info.sensorInterface, info.sensorPath, service);
@@ -951,29 +952,34 @@
{
ipmi::PropertyMap findThreshold;
ec = ipmi::getAllDbusProperties(ctx, service, info.sensorPath,
- criticalThreshIntf, findThreshold);
+ SensorThresholdCritical::interface,
+ findThreshold);
if (!ec)
{
if (lowerCriticalThreshMask)
{
- auto findLower = findThreshold.find("CriticalLow");
+ auto findLower = findThreshold.find(
+ SensorThresholdCritical::property_names::critical_low);
if (findLower == findThreshold.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("CriticalLow", lowerCritical,
- criticalThreshIntf);
+ thresholdsToSet.emplace_back(
+ SensorThresholdCritical::property_names::critical_low,
+ lowerCritical, SensorThresholdCritical::interface);
}
if (upperCriticalThreshMask)
{
- auto findUpper = findThreshold.find("CriticalHigh");
+ auto findUpper = findThreshold.find(
+ SensorThresholdCritical::property_names::critical_high);
if (findUpper == findThreshold.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("CriticalHigh", upperCritical,
- criticalThreshIntf);
+ thresholdsToSet.emplace_back(
+ SensorThresholdCritical::property_names::critical_high,
+ upperCritical, SensorThresholdCritical::interface);
}
}
}
@@ -981,29 +987,34 @@
{
ipmi::PropertyMap findThreshold;
ec = ipmi::getAllDbusProperties(ctx, service, info.sensorPath,
- warningThreshIntf, findThreshold);
+ SensorThresholdWarning::interface,
+ findThreshold);
if (!ec)
{
if (lowerNonCriticalThreshMask)
{
- auto findLower = findThreshold.find("WarningLow");
+ auto findLower = findThreshold.find(
+ SensorThresholdWarning::property_names::warning_low);
if (findLower == findThreshold.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("WarningLow", lowerNonCritical,
- warningThreshIntf);
+ thresholdsToSet.emplace_back(
+ SensorThresholdWarning::property_names::warning_low,
+ lowerNonCritical, SensorThresholdWarning::interface);
}
if (upperNonCriticalThreshMask)
{
- auto findUpper = findThreshold.find("WarningHigh");
+ auto findUpper = findThreshold.find(
+ SensorThresholdWarning::property_names::warning_high);
if (findUpper == findThreshold.end())
{
return ipmi::responseInvalidFieldRequest();
}
- thresholdsToSet.emplace_back("WarningHigh", upperNonCritical,
- warningThreshIntf);
+ thresholdsToSet.emplace_back(
+ SensorThresholdWarning::property_names::warning_high,
+ upperNonCritical, SensorThresholdWarning::interface);
}
}
}