Follow up on Todo, move path out of base sensor
Not every sensor needs a sysfs path, because of that
move it out of the base class and into the classes that
need it.
Change-Id: I62b7df681e1ee889eb66e371d1cd6094097e9f21
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/ADCSensor.hpp b/include/ADCSensor.hpp
index 539e0da..b5a9e9a 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -23,6 +23,7 @@
boost::asio::posix::stream_descriptor inputDev;
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
+ std::string path;
int errCount;
double scaleFactor;
std::optional<int> bridgeGpio;
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index 1b25518..2cac56e 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -33,6 +33,7 @@
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
std::string nameTcontrol;
+ std::string path;
double privTcontrol;
bool show;
int errCount;
diff --git a/include/HwmonTempSensor.hpp b/include/HwmonTempSensor.hpp
index 9343576..795c02d 100644
--- a/include/HwmonTempSensor.hpp
+++ b/include/HwmonTempSensor.hpp
@@ -20,6 +20,7 @@
boost::asio::posix::stream_descriptor inputDev;
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
+ std::string path;
int errCount;
void setupRead(void);
void handleResponse(const boost::system::error_code& err);
diff --git a/include/PSUSensor.hpp b/include/PSUSensor.hpp
index afc748b..370ded9 100644
--- a/include/PSUSensor.hpp
+++ b/include/PSUSensor.hpp
@@ -23,6 +23,7 @@
boost::asio::posix::stream_descriptor inputDev;
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
+ std::string path;
int errCount;
unsigned int sensorFactor;
void setupRead(void);
diff --git a/include/TachSensor.hpp b/include/TachSensor.hpp
index 2a489dc..4588653 100644
--- a/include/TachSensor.hpp
+++ b/include/TachSensor.hpp
@@ -76,6 +76,7 @@
boost::asio::posix::stream_descriptor inputDev;
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
+ std::string path;
int errCount;
void setupRead(void);
void handleResponse(const boost::system::error_code& err);
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 19c3733..29f674a 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -8,20 +8,18 @@
constexpr const char* sensorValueInterface = "xyz.openbmc_project.Sensor.Value";
struct Sensor
{
- Sensor(const std::string& name, const std::string& path,
+ Sensor(const std::string& name,
std::vector<thresholds::Threshold>&& thresholdData,
const std::string& configurationPath, const std::string& objectType,
const double max, const double min) :
name(name),
- path(path), configurationPath(configurationPath),
- objectType(objectType), thresholds(std::move(thresholdData)),
- maxValue(max), minValue(min)
+ configurationPath(configurationPath), objectType(objectType),
+ thresholds(std::move(thresholdData)), maxValue(max), minValue(min)
{
}
virtual ~Sensor() = default;
virtual void checkThresholds(void) = 0;
std::string name;
- std::string path;
std::string configurationPath;
std::string objectType;
double maxValue;
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index a8d98ae..c94f251 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -64,10 +64,10 @@
const double scaleFactor, PowerState readState,
const std::string& sensorConfiguration,
std::optional<int> bridgeGpio) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration,
"xyz.openbmc_project.Configuration.ADC", maxReading, minReading),
- objServer(objectServer), scaleFactor(scaleFactor),
+ objServer(objectServer), scaleFactor(scaleFactor), path(path),
readState(std::move(readState)), inputDev(io, open(path.c_str(), O_RDONLY)),
waitTimer(io), errCount(0), thresholdTimer(io, this), bridgeGpio(bridgeGpio)
{
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 4c5eb8b..0920754 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -34,11 +34,11 @@
std::vector<thresholds::Threshold>&& _thresholds,
const std::string& sensorConfiguration, int cpuId,
bool show) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
minReading),
objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
- waitTimer(io), show(show),
+ path(path), waitTimer(io), show(show),
privTcontrol(std::numeric_limits<double>::quiet_NaN()), errCount(0)
{
nameTcontrol = labelTcontrol;
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 8779be0..a4aba4b 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -152,9 +152,9 @@
std::vector<thresholds::Threshold>&& thresholdData,
std::shared_ptr<ExitAirTempSensor>& parent) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
- "" /* todo: remove arg from base*/, std::move(thresholdData),
- sensorConfiguration, "xyz.openbmc_project.Configuration.ExitAirTemp",
- cfmMaxReading, cfmMinReading),
+ std::move(thresholdData), sensorConfiguration,
+ "xyz.openbmc_project.Configuration.ExitAirTemp", cfmMaxReading,
+ cfmMinReading),
dbusConnection(conn), parent(parent), objServer(objectServer)
{
sensorInterface =
@@ -471,9 +471,9 @@
sdbusplus::asio::object_server& objectServer,
std::vector<thresholds::Threshold>&& thresholdData) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
- "" /* todo: remove arg from base*/, std::move(thresholdData),
- sensorConfiguration, "xyz.openbmc_project.Configuration.ExitAirTemp",
- exitAirMaxReading, exitAirMinReading),
+ std::move(thresholdData), sensorConfiguration,
+ "xyz.openbmc_project.Configuration.ExitAirTemp", exitAirMaxReading,
+ exitAirMinReading),
dbusConnection(conn), objServer(objectServer)
{
sensorInterface = objectServer.add_interface(
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 8472012..09161e4 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -40,11 +40,11 @@
boost::asio::io_service& io, const std::string& sensorName,
std::vector<thresholds::Threshold>&& _thresholds,
const std::string& sensorConfiguration) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
minReading),
- objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
- waitTimer(io), errCount(0)
+ path(path), objServer(objectServer),
+ inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index b8dd220..5c76e8b 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -57,9 +57,9 @@
std::vector<thresholds::Threshold>&& thresholdData,
uint8_t deviceAddress) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
- "" /* todo: remove arg from base*/, std::move(thresholdData),
- sensorConfiguration, "xyz.openbmc_project.Configuration.ExitAirTemp",
- ipmbMaxReading, ipmbMinReading),
+ std::move(thresholdData), sensorConfiguration,
+ "xyz.openbmc_project.Configuration.ExitAirTemp", ipmbMaxReading,
+ ipmbMinReading),
objectServer(objectServer), dbusConnection(conn), waitTimer(io),
deviceAddress(deviceAddress)
{
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index 86997d3..fdd453a 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -36,10 +36,11 @@
const std::string& sensorConfiguration,
std::string& sensorTypeName, unsigned int factor,
double max, double min) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, max, min),
- objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
- waitTimer(io), errCount(0), sensorFactor(factor)
+ path(path), objServer(objectServer),
+ inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0),
+ sensorFactor(factor)
{
std::string dbusPath = sensorPathPrefix + sensorTypeName + name;
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index bbd382f..aeef7c5 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -42,10 +42,9 @@
std::vector<thresholds::Threshold>&& _thresholds,
const std::string& sensorConfiguration,
const std::pair<size_t, size_t>& limits) :
- Sensor(boost::replace_all_copy(fanName, " ", "_"), path,
- std::move(_thresholds), sensorConfiguration, objectType,
- limits.second, limits.first),
- objServer(objectServer), presence(std::move(presenceSensor)),
+ Sensor(boost::replace_all_copy(fanName, " ", "_"), std::move(_thresholds),
+ sensorConfiguration, objectType, limits.second, limits.first),
+ path(path), objServer(objectServer), presence(std::move(presenceSensor)),
redundancy(redundancy), inputDev(io, open(path.c_str(), O_RDONLY)),
waitTimer(io), errCount(0)
{