Apply LambdaBodyIndentation to dbus-sensors
Per the transform being done in bmcweb, do the same for dbus-sensors.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: If21489607759f3cdf20fad17eede50fb4e228e5e
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 58f7468..4d77ef4 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -70,25 +70,23 @@
std::function<void(sdbusplus::message::message & message)> eventHandler =
[callback{std::move(callback)}](sdbusplus::message::message& message) {
- std::string objectName;
- boost::container::flat_map<std::string,
- std::variant<double, int64_t>>
- values;
- message.read(objectName, values);
- auto findValue = values.find("Value");
- if (findValue == values.end())
- {
- return;
- }
- double value =
- std::visit(VariantToDoubleVisitor(), findValue->second);
- if (std::isnan(value))
- {
- return;
- }
+ std::string objectName;
+ boost::container::flat_map<std::string, std::variant<double, int64_t>>
+ values;
+ message.read(objectName, values);
+ auto findValue = values.find("Value");
+ if (findValue == values.end())
+ {
+ return;
+ }
+ double value = std::visit(VariantToDoubleVisitor(), findValue->second);
+ if (std::isnan(value))
+ {
+ return;
+ }
- callback(value, message);
- };
+ callback(value, message);
+ };
matches.emplace_back(connection,
"type='signal',"
"member='PropertiesChanged',interface='org."
@@ -109,48 +107,48 @@
conn->async_method_call(
[conn, value](const boost::system::error_code ec,
const GetSubTreeType& ret) {
- if (ec)
+ if (ec)
+ {
+ std::cerr << "Error calling mapper\n";
+ return;
+ }
+ for (const auto& [path, objDict] : ret)
+ {
+ if (objDict.empty())
{
- std::cerr << "Error calling mapper\n";
return;
}
- for (const auto& [path, objDict] : ret)
- {
- if (objDict.empty())
+ const std::string& owner = objDict.begin()->first;
+
+ conn->async_method_call(
+ [conn, value, owner,
+ path{path}](const boost::system::error_code ec,
+ const std::variant<std::string>& classType) {
+ if (ec)
+ {
+ std::cerr << "Error getting pid class\n";
+ return;
+ }
+ auto classStr = std::get_if<std::string>(&classType);
+ if (classStr == nullptr || *classStr != "fan")
{
return;
}
- const std::string& owner = objDict.begin()->first;
-
conn->async_method_call(
- [conn, value, owner,
- path{path}](const boost::system::error_code ec,
- const std::variant<std::string>& classType) {
- if (ec)
- {
- std::cerr << "Error getting pid class\n";
- return;
- }
- auto classStr = std::get_if<std::string>(&classType);
- if (classStr == nullptr || *classStr != "fan")
- {
- return;
- }
- conn->async_method_call(
- [](boost::system::error_code& ec) {
- if (ec)
- {
- std::cerr << "Error setting pid class\n";
- return;
- }
- },
- owner, path, "org.freedesktop.DBus.Properties",
- "Set", pidConfigurationType, "OutLimitMax",
- std::variant<double>(value));
+ [](boost::system::error_code& ec) {
+ if (ec)
+ {
+ std::cerr << "Error setting pid class\n";
+ return;
+ }
},
- owner, path, "org.freedesktop.DBus.Properties", "Get",
- pidConfigurationType, "Class");
- }
+ owner, path, "org.freedesktop.DBus.Properties", "Set",
+ pidConfigurationType, "OutLimitMax",
+ std::variant<double>(value));
+ },
+ owner, path, "org.freedesktop.DBus.Properties", "Get",
+ pidConfigurationType, "Class");
+ }
},
mapper::busName, mapper::path, mapper::interface, mapper::subtree, "/",
0, std::array<std::string, 1>{pidConfigurationType});
@@ -200,87 +198,84 @@
setupSensorMatch(
matches, *dbusConnection, "fan_tach",
[weakRef](const double& value, sdbusplus::message::message& message) {
- auto self = weakRef.lock();
- if (!self)
- {
- return;
- }
- self->tachReadings[message.get_path()] = value;
- if (self->tachRanges.find(message.get_path()) ==
- self->tachRanges.end())
- {
- // calls update reading after updating ranges
- self->addTachRanges(message.get_sender(), message.get_path());
- }
- else
- {
- self->updateReading();
- }
+ auto self = weakRef.lock();
+ if (!self)
+ {
+ return;
+ }
+ self->tachReadings[message.get_path()] = value;
+ if (self->tachRanges.find(message.get_path()) == self->tachRanges.end())
+ {
+ // calls update reading after updating ranges
+ self->addTachRanges(message.get_sender(), message.get_path());
+ }
+ else
+ {
+ self->updateReading();
+ }
});
dbusConnection->async_method_call(
[weakRef](const boost::system::error_code ec,
const std::variant<double> cfmVariant) {
- auto self = weakRef.lock();
- if (!self)
- {
- return;
- }
+ auto self = weakRef.lock();
+ if (!self)
+ {
+ return;
+ }
- uint64_t maxRpm = 100;
- if (!ec)
- {
+ uint64_t maxRpm = 100;
+ if (!ec)
+ {
- auto cfm = std::get_if<double>(&cfmVariant);
- if (cfm != nullptr && *cfm >= minSystemCfm)
- {
- maxRpm = self->getMaxRpm(*cfm);
- }
+ auto cfm = std::get_if<double>(&cfmVariant);
+ if (cfm != nullptr && *cfm >= minSystemCfm)
+ {
+ maxRpm = self->getMaxRpm(*cfm);
}
- self->pwmLimitIface->register_property("Limit", maxRpm);
- self->pwmLimitIface->initialize();
- setMaxPWM(self->dbusConnection, maxRpm);
+ }
+ self->pwmLimitIface->register_property("Limit", maxRpm);
+ self->pwmLimitIface->initialize();
+ setMaxPWM(self->dbusConnection, maxRpm);
},
settingsDaemon, cfmSettingPath, "org.freedesktop.DBus.Properties",
"Get", cfmSettingIface, "Limit");
- matches.emplace_back(
- *dbusConnection,
- "type='signal',"
- "member='PropertiesChanged',interface='org."
- "freedesktop.DBus.Properties',path='" +
- std::string(cfmSettingPath) + "',arg0='" +
- std::string(cfmSettingIface) + "'",
- [weakRef](sdbusplus::message::message& message) {
- auto self = weakRef.lock();
- if (!self)
- {
- return;
- }
- boost::container::flat_map<std::string, std::variant<double>>
- values;
- std::string objectName;
- message.read(objectName, values);
- const auto findValue = values.find("Limit");
- if (findValue == values.end())
- {
- return;
- }
- const auto reading = std::get_if<double>(&(findValue->second));
- if (reading == nullptr)
- {
- std::cerr << "Got CFM Limit of wrong type\n";
- return;
- }
- if (*reading < minSystemCfm && *reading != 0)
- {
- std::cerr << "Illegal CFM setting detected\n";
- return;
- }
- uint64_t maxRpm = self->getMaxRpm(*reading);
- self->pwmLimitIface->set_property("Limit", maxRpm);
- setMaxPWM(self->dbusConnection, maxRpm);
- });
+ matches.emplace_back(*dbusConnection,
+ "type='signal',"
+ "member='PropertiesChanged',interface='org."
+ "freedesktop.DBus.Properties',path='" +
+ std::string(cfmSettingPath) + "',arg0='" +
+ std::string(cfmSettingIface) + "'",
+ [weakRef](sdbusplus::message::message& message) {
+ auto self = weakRef.lock();
+ if (!self)
+ {
+ return;
+ }
+ boost::container::flat_map<std::string, std::variant<double>> values;
+ std::string objectName;
+ message.read(objectName, values);
+ const auto findValue = values.find("Limit");
+ if (findValue == values.end())
+ {
+ return;
+ }
+ const auto reading = std::get_if<double>(&(findValue->second));
+ if (reading == nullptr)
+ {
+ std::cerr << "Got CFM Limit of wrong type\n";
+ return;
+ }
+ if (*reading < minSystemCfm && *reading != 0)
+ {
+ std::cerr << "Illegal CFM setting detected\n";
+ return;
+ }
+ uint64_t maxRpm = self->getMaxRpm(*reading);
+ self->pwmLimitIface->set_property("Limit", maxRpm);
+ setMaxPWM(self->dbusConnection, maxRpm);
+ });
}
CFMSensor::~CFMSensor()
@@ -310,20 +305,20 @@
path](const boost::system::error_code ec,
const boost::container::flat_map<std::string, BasicVariantType>&
data) {
- if (ec)
- {
- std::cerr << "Error getting properties from " << path << "\n";
- return;
- }
- auto self = weakRef.lock();
- if (!self)
- {
- return;
- }
- double max = loadVariant<double>(data, "MaxValue");
- double min = loadVariant<double>(data, "MinValue");
- self->tachRanges[path] = std::make_pair(min, max);
- self->updateReading();
+ if (ec)
+ {
+ std::cerr << "Error getting properties from " << path << "\n";
+ return;
+ }
+ auto self = weakRef.lock();
+ if (!self)
+ {
+ return;
+ }
+ double max = loadVariant<double>(data, "MaxValue");
+ double min = loadVariant<double>(data, "MinValue");
+ self->tachRanges[path] = std::make_pair(min, max);
+ self->updateReading();
},
serviceName, path, "org.freedesktop.DBus.Properties", "GetAll",
"xyz.openbmc_project.Sensor.Value");
@@ -417,10 +412,10 @@
tachReadings.begin(), tachReadings.end(), [&](const auto& item) {
return boost::ends_with(item.first, tachName);
});
- auto findRange = std::find_if(
- tachRanges.begin(), tachRanges.end(), [&](const auto& item) {
- return boost::ends_with(item.first, tachName);
- });
+ auto findRange = std::find_if(tachRanges.begin(), tachRanges.end(),
+ [&](const auto& item) {
+ return boost::ends_with(item.first, tachName);
+ });
if (findReading == tachReadings.end())
{
if constexpr (debug)
@@ -550,97 +545,95 @@
setupSensorMatch(matches, *dbusConnection, type,
[weakRef, type](const double& value,
sdbusplus::message::message& message) {
- auto self = weakRef.lock();
- if (!self)
- {
- return;
- }
- if (type == "power")
- {
- std::string path = message.get_path();
- if (path.find("PS") != std::string::npos &&
- boost::ends_with(path, "Input_Power"))
- {
- self->powerReadings[message.get_path()] =
- value;
- }
- }
- else if (type == inletTemperatureSensor)
- {
- self->inletTemp = value;
- }
- self->updateReading();
- });
- }
- dbusConnection->async_method_call(
- [weakRef](boost::system::error_code ec,
- const std::variant<double>& value) {
- if (ec)
- {
- // sensor not ready yet
- return;
- }
auto self = weakRef.lock();
if (!self)
{
return;
}
- self->inletTemp = std::visit(VariantToDoubleVisitor(), value);
+ if (type == "power")
+ {
+ std::string path = message.get_path();
+ if (path.find("PS") != std::string::npos &&
+ boost::ends_with(path, "Input_Power"))
+ {
+ self->powerReadings[message.get_path()] = value;
+ }
+ }
+ else if (type == inletTemperatureSensor)
+ {
+ self->inletTemp = value;
+ }
+ self->updateReading();
+ });
+ }
+ dbusConnection->async_method_call(
+ [weakRef](boost::system::error_code ec,
+ const std::variant<double>& value) {
+ if (ec)
+ {
+ // sensor not ready yet
+ return;
+ }
+ auto self = weakRef.lock();
+ if (!self)
+ {
+ return;
+ }
+ self->inletTemp = std::visit(VariantToDoubleVisitor(), value);
},
"xyz.openbmc_project.HwmonTempSensor",
std::string("/xyz/openbmc_project/sensors/") + inletTemperatureSensor,
properties::interface, properties::get, sensorValueInterface, "Value");
dbusConnection->async_method_call(
[weakRef](boost::system::error_code ec, const GetSubTreeType& subtree) {
- if (ec)
+ if (ec)
+ {
+ std::cerr << "Error contacting mapper\n";
+ return;
+ }
+ auto self = weakRef.lock();
+ if (!self)
+ {
+ return;
+ }
+ for (const auto& item : subtree)
+ {
+ size_t lastSlash = item.first.rfind("/");
+ if (lastSlash == std::string::npos ||
+ lastSlash == item.first.size() || !item.second.size())
{
- std::cerr << "Error contacting mapper\n";
- return;
+ continue;
}
- auto self = weakRef.lock();
- if (!self)
+ std::string sensorName = item.first.substr(lastSlash + 1);
+ if (boost::starts_with(sensorName, "PS") &&
+ boost::ends_with(sensorName, "Input_Power"))
{
- return;
+ const std::string& path = item.first;
+ self->dbusConnection->async_method_call(
+ [weakRef, path](boost::system::error_code ec,
+ const std::variant<double>& value) {
+ if (ec)
+ {
+ std::cerr << "Error getting value from " << path
+ << "\n";
+ }
+ auto self = weakRef.lock();
+ if (!self)
+ {
+ return;
+ }
+ double reading =
+ std::visit(VariantToDoubleVisitor(), value);
+ if constexpr (debug)
+ {
+ std::cerr << path << "Reading " << reading << "\n";
+ }
+ self->powerReadings[path] = reading;
+ },
+ item.second[0].first, item.first, properties::interface,
+ properties::get, sensorValueInterface, "Value");
}
- for (const auto& item : subtree)
- {
- size_t lastSlash = item.first.rfind("/");
- if (lastSlash == std::string::npos ||
- lastSlash == item.first.size() || !item.second.size())
- {
- continue;
- }
- std::string sensorName = item.first.substr(lastSlash + 1);
- if (boost::starts_with(sensorName, "PS") &&
- boost::ends_with(sensorName, "Input_Power"))
- {
- const std::string& path = item.first;
- self->dbusConnection->async_method_call(
- [weakRef, path](boost::system::error_code ec,
- const std::variant<double>& value) {
- if (ec)
- {
- std::cerr << "Error getting value from " << path
- << "\n";
- }
- auto self = weakRef.lock();
- if (!self)
- {
- return;
- }
- double reading =
- std::visit(VariantToDoubleVisitor(), value);
- if constexpr (debug)
- {
- std::cerr << path << "Reading " << reading
- << "\n";
- }
- self->powerReadings[path] = reading;
- },
- item.second[0].first, item.first, properties::interface,
- properties::get, sensorValueInterface, "Value");
- }
- }
+ }
},
mapper::busName, mapper::path, mapper::interface, mapper::subtree,
"/xyz/openbmc_project/sensors/power", 0,
@@ -875,77 +868,74 @@
return;
}
auto getter = std::make_shared<GetSensorConfiguration>(
- dbusConnection, [&objectServer, &dbusConnection,
- &exitAirSensor](const ManagedObjectType& resp) {
- cfmSensors.clear();
- for (const auto& pathPair : resp)
+ dbusConnection,
+ [&objectServer, &dbusConnection,
+ &exitAirSensor](const ManagedObjectType& resp) {
+ cfmSensors.clear();
+ for (const auto& pathPair : resp)
+ {
+ for (const auto& entry : pathPair.second)
{
- for (const auto& entry : pathPair.second)
+ if (entry.first == exitAirIface)
{
- if (entry.first == exitAirIface)
- {
- // thresholds should be under the same path
- std::vector<thresholds::Threshold> sensorThresholds;
- parseThresholdsFromConfig(pathPair.second,
- sensorThresholds);
+ // thresholds should be under the same path
+ std::vector<thresholds::Threshold> sensorThresholds;
+ parseThresholdsFromConfig(pathPair.second,
+ sensorThresholds);
- std::string name =
- loadVariant<std::string>(entry.second, "Name");
- exitAirSensor = std::make_shared<ExitAirTempSensor>(
- dbusConnection, name, pathPair.first.str,
- objectServer, std::move(sensorThresholds));
- exitAirSensor->powerFactorMin =
- loadVariant<double>(entry.second, "PowerFactorMin");
- exitAirSensor->powerFactorMax =
- loadVariant<double>(entry.second, "PowerFactorMax");
- exitAirSensor->qMin =
- loadVariant<double>(entry.second, "QMin");
- exitAirSensor->qMax =
- loadVariant<double>(entry.second, "QMax");
- exitAirSensor->alphaS =
- loadVariant<double>(entry.second, "AlphaS");
- exitAirSensor->alphaF =
- loadVariant<double>(entry.second, "AlphaF");
- }
- else if (entry.first == cfmIface)
+ std::string name =
+ loadVariant<std::string>(entry.second, "Name");
+ exitAirSensor = std::make_shared<ExitAirTempSensor>(
+ dbusConnection, name, pathPair.first.str, objectServer,
+ std::move(sensorThresholds));
+ exitAirSensor->powerFactorMin =
+ loadVariant<double>(entry.second, "PowerFactorMin");
+ exitAirSensor->powerFactorMax =
+ loadVariant<double>(entry.second, "PowerFactorMax");
+ exitAirSensor->qMin =
+ loadVariant<double>(entry.second, "QMin");
+ exitAirSensor->qMax =
+ loadVariant<double>(entry.second, "QMax");
+ exitAirSensor->alphaS =
+ loadVariant<double>(entry.second, "AlphaS");
+ exitAirSensor->alphaF =
+ loadVariant<double>(entry.second, "AlphaF");
+ }
+ else if (entry.first == cfmIface)
- {
- // thresholds should be under the same path
- std::vector<thresholds::Threshold> sensorThresholds;
- parseThresholdsFromConfig(pathPair.second,
- sensorThresholds);
- std::string name =
- loadVariant<std::string>(entry.second, "Name");
- auto sensor = std::make_shared<CFMSensor>(
- dbusConnection, name, pathPair.first.str,
- objectServer, std::move(sensorThresholds),
- exitAirSensor);
- loadVariantPathArray(entry.second, "Tachs",
- sensor->tachs);
- sensor->maxCFM =
- loadVariant<double>(entry.second, "MaxCFM");
+ {
+ // thresholds should be under the same path
+ std::vector<thresholds::Threshold> sensorThresholds;
+ parseThresholdsFromConfig(pathPair.second,
+ sensorThresholds);
+ std::string name =
+ loadVariant<std::string>(entry.second, "Name");
+ auto sensor = std::make_shared<CFMSensor>(
+ dbusConnection, name, pathPair.first.str, objectServer,
+ std::move(sensorThresholds), exitAirSensor);
+ loadVariantPathArray(entry.second, "Tachs", sensor->tachs);
+ sensor->maxCFM =
+ loadVariant<double>(entry.second, "MaxCFM");
- // change these into percent upon getting the data
- sensor->c1 =
- loadVariant<double>(entry.second, "C1") / 100;
- sensor->c2 =
- loadVariant<double>(entry.second, "C2") / 100;
- sensor->tachMinPercent =
- loadVariant<double>(entry.second, "TachMinPercent");
- sensor->tachMaxPercent =
- loadVariant<double>(entry.second, "TachMaxPercent");
- sensor->createMaxCFMIface();
- sensor->setupMatches();
+ // change these into percent upon getting the data
+ sensor->c1 = loadVariant<double>(entry.second, "C1") / 100;
+ sensor->c2 = loadVariant<double>(entry.second, "C2") / 100;
+ sensor->tachMinPercent =
+ loadVariant<double>(entry.second, "TachMinPercent");
+ sensor->tachMaxPercent =
+ loadVariant<double>(entry.second, "TachMaxPercent");
+ sensor->createMaxCFMIface();
+ sensor->setupMatches();
- cfmSensors.emplace_back(std::move(sensor));
- }
+ cfmSensors.emplace_back(std::move(sensor));
}
}
- if (exitAirSensor)
- {
- exitAirSensor->setupMatches();
- exitAirSensor->updateReading();
- }
+ }
+ if (exitAirSensor)
+ {
+ exitAirSensor->setupMatches();
+ exitAirSensor->updateReading();
+ }
});
getter->getConfiguration(
std::vector<std::string>(monitorIfaces.begin(), monitorIfaces.end()));
@@ -968,20 +958,20 @@
std::function<void(sdbusplus::message::message&)> eventHandler =
[&](sdbusplus::message::message&) {
- configTimer.expires_from_now(boost::posix_time::seconds(1));
- // create a timer because normally multiple properties change
- configTimer.async_wait([&](const boost::system::error_code& ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- return; // we're being canceled
- }
- createSensor(objectServer, sensor, systemBus);
- if (!sensor)
- {
- std::cout << "Configuration not detected\n";
- }
- });
- };
+ configTimer.expires_from_now(boost::posix_time::seconds(1));
+ // create a timer because normally multiple properties change
+ configTimer.async_wait([&](const boost::system::error_code& ec) {
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ return; // we're being canceled
+ }
+ createSensor(objectServer, sensor, systemBus);
+ if (!sensor)
+ {
+ std::cout << "Configuration not detected\n";
+ }
+ });
+ };
for (const char* type : monitorIfaces)
{
auto match = std::make_unique<sdbusplus::bus::match::match>(