Move dbus connection into base sensor object
This seems common through most sensors, might as
well move it for consistency.
Tested: sensors operational as normal
Change-Id: I4e6c55cbb7171ee51700015f8c2ef8c05c90fb4e
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/ExitAirTempSensor.hpp b/include/ExitAirTempSensor.hpp
index e3c2ef5..2d69cec 100644
--- a/include/ExitAirTempSensor.hpp
+++ b/include/ExitAirTempSensor.hpp
@@ -42,7 +42,6 @@
boost::container::flat_map<std::string, double> tachReadings;
boost::container::flat_map<std::string, std::pair<double, double>>
tachRanges;
- std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
std::shared_ptr<sdbusplus::asio::dbus_interface> pwmLimitIface;
std::shared_ptr<sdbusplus::asio::dbus_interface> cfmLimitIface;
sdbusplus::asio::object_server& objServer;
@@ -81,7 +80,6 @@
std::vector<sdbusplus::bus::match::match> matches;
double inletTemp = std::numeric_limits<double>::quiet_NaN();
- std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
sdbusplus::asio::object_server& objServer;
std::chrono::time_point<std::chrono::system_clock> lastTime;
double getTotalCFM(void);
diff --git a/include/IpmbSensor.hpp b/include/IpmbSensor.hpp
index 3b3ee15..c3e7393 100644
--- a/include/IpmbSensor.hpp
+++ b/include/IpmbSensor.hpp
@@ -107,6 +107,5 @@
private:
sdbusplus::asio::object_server& objectServer;
- std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
boost::asio::deadline_timer waitTimer;
};
diff --git a/include/MCUTempSensor.hpp b/include/MCUTempSensor.hpp
index 74ba083..2f3aef4 100644
--- a/include/MCUTempSensor.hpp
+++ b/include/MCUTempSensor.hpp
@@ -31,6 +31,5 @@
private:
int getMCURegsInfoWord(uint8_t regs, int16_t* pu16data);
sdbusplus::asio::object_server& objectServer;
- std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
boost::asio::deadline_timer waitTimer;
};
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 7fa9300..6fd7e43 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -25,13 +25,14 @@
std::vector<thresholds::Threshold>&& thresholdData,
const std::string& configurationPath, const std::string& objectType,
const double max, const double min,
+ std::shared_ptr<sdbusplus::asio::connection>& conn,
PowerState readState = PowerState::always) :
name(std::regex_replace(name, std::regex("[^a-zA-Z0-9_/]+"), "_")),
configurationPath(configurationPath), objectType(objectType),
maxValue(max), minValue(min), thresholds(std::move(thresholdData)),
hysteresisTrigger((max - min) * 0.01),
- hysteresisPublish((max - min) * 0.0001), readState(readState),
- errCount(0)
+ hysteresisPublish((max - min) * 0.0001), dbusConnection(conn),
+ readState(readState), errCount(0)
{}
virtual ~Sensor() = default;
virtual void checkThresholds(void) = 0;
@@ -53,6 +54,7 @@
bool internalSet = false;
double hysteresisTrigger;
double hysteresisPublish;
+ std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
PowerState readState;
size_t errCount;
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index aa7b50e..7afb2ab 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -56,7 +56,7 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration,
"xyz.openbmc_project.Configuration.ADC", maxReading, minReading,
- readState),
+ conn, readState),
std::enable_shared_from_this<ADCSensor>(), objServer(objectServer),
inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), path(path),
scaleFactor(scaleFactor), bridgeGpio(std::move(bridgeGpio)),
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 4377bf9..684c430 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -44,7 +44,7 @@
bool show, double dtsOffset) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
- minReading, PowerState::on),
+ minReading, conn, PowerState::on),
objServer(objectServer), inputDev(io), waitTimer(io), path(path),
privTcontrol(std::numeric_limits<double>::quiet_NaN()),
dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs),
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 7197c4a..41d9a19 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -166,9 +166,9 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", cfmMaxReading,
- cfmMinReading, PowerState::on),
+ cfmMinReading, conn, PowerState::on),
std::enable_shared_from_this<CFMSensor>(), parent(parent),
- dbusConnection(conn), objServer(objectServer)
+ objServer(objectServer)
{
sensorInterface =
objectServer.add_interface("/xyz/openbmc_project/sensors/cfm/" + name,
@@ -494,9 +494,8 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", exitAirMaxReading,
- exitAirMinReading, PowerState::on),
- std::enable_shared_from_this<ExitAirTempSensor>(), dbusConnection(conn),
- objServer(objectServer)
+ exitAirMinReading, conn, PowerState::on),
+ std::enable_shared_from_this<ExitAirTempSensor>(), objServer(objectServer)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 35dc5f3..eaaa9e8 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -48,7 +48,7 @@
const std::string& sensorConfiguration, const PowerState powerState) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
- minReading, powerState),
+ minReading, conn, powerState),
std::enable_shared_from_this<HwmonTempSensor>(), objServer(objectServer),
inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), path(path)
{
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index a7c1e09..dccdffb 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -69,9 +69,8 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", ipmbMaxReading,
- ipmbMinReading, PowerState::on),
- deviceAddress(deviceAddress), objectServer(objectServer),
- dbusConnection(conn), waitTimer(io)
+ ipmbMinReading, conn, PowerState::on),
+ deviceAddress(deviceAddress), objectServer(objectServer), waitTimer(io)
{
std::string dbusPath = sensorPathPrefix + sensorTypeName + "/" + name;
diff --git a/src/MCUTempSensor.cpp b/src/MCUTempSensor.cpp
index 69a3226..6d94bd2 100644
--- a/src/MCUTempSensor.cpp
+++ b/src/MCUTempSensor.cpp
@@ -63,9 +63,9 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", mcuTempMaxReading,
- mcuTempMinReading),
+ mcuTempMinReading, conn),
busId(busId), mcuAddress(mcuAddress), tempReg(tempReg),
- objectServer(objectServer), dbusConnection(conn), waitTimer(io)
+ objectServer(objectServer), waitTimer(io)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
diff --git a/src/NVMeSensor.cpp b/src/NVMeSensor.cpp
index cbc88ec..46b2b52 100644
--- a/src/NVMeSensor.cpp
+++ b/src/NVMeSensor.cpp
@@ -432,7 +432,7 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration,
"xyz.openbmc_project.Configuration.NVMe", maxReading, minReading,
- PowerState::on),
+ conn, PowerState::on),
objServer(objectServer), bus(busNumber)
{
sensorInterface = objectServer.add_interface(
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index f93846d..0086382 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -46,7 +46,8 @@
double max, double min, const std::string& label,
size_t tSize) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
- std::move(_thresholds), sensorConfiguration, objectType, max, min),
+ std::move(_thresholds), sensorConfiguration, objectType, max, min,
+ conn),
std::enable_shared_from_this<PSUSensor>(), objServer(objectServer),
inputDev(io), waitTimer(io), path(path), sensorFactor(factor)
{
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index acfe659..d39e92c 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -53,7 +53,7 @@
const std::pair<size_t, size_t>& limits,
const PowerState& powerState) :
Sensor(boost::replace_all_copy(fanName, " ", "_"), std::move(_thresholds),
- sensorConfiguration, objectType, limits.second, limits.first,
+ sensorConfiguration, objectType, limits.second, limits.first, conn,
powerState),
objServer(objectServer), redundancy(redundancy),
presence(std::move(presenceSensor)),