Commit eacb14fa authored by Micha Mueller's avatar Micha Mueller
Browse files

Add printConfig to PDU plugin

parent 585aa8fc
......@@ -48,3 +48,16 @@ void PDUConfigurator::setEntityForGroup(PDUUnit& e, PDUSensorGroup& g) {
void PDUConfigurator::finalizeGroup(PDUSensorGroup& g) {
//nothing to finalize
}
void PDUConfigurator::printConfiguratorConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " No other plugin specific general attributes";
LOG_VAR(ll) << " PDU Units:";
if (_sensorEntitys.size() != 0) {
for(auto e : _sensorEntitys) {
e->printConfig(ll);
}
} else {
LOG_VAR(ll) << " No PDU Units present!";
}
}
......@@ -29,6 +29,8 @@ protected:
void setEntityForGroup(PDUUnit& e, PDUSensorGroup& g) override;
void finalizeGroup(PDUSensorGroup& g) override;
void printConfiguratorConfig(LOG_LEVEL ll) override;
private:
/**
* Split the given string into multiple parts which are later required to find the sensor value in the boost property tree.
......
......@@ -9,8 +9,8 @@
#define PDU_PDUSENSORBASE_H_
#include "../../includes/SensorBase.h"
#include "PDUUnit.h"
#include <sstream>
class PDUSensorBase : public SensorBase {
public:
......@@ -31,6 +31,16 @@ public:
}
const xmlPathVector_t& getXMLPath() const { return _xmlPath; }
std::string getXMLPathString() const {
std::stringstream ss;
for (const auto& i : _xmlPath) {
ss << "." << std::get<0>(i) << "." << std::get<1>(i);
for (const auto& j : std::get<2>(i)) {
ss << "(" << j.first << "=" << j.second << ")";
}
}
return ss.str();
}
void setXMLPath(const std::string& path) {
std::vector<std::string> subStrings;
......@@ -96,6 +106,10 @@ public:
}
}
void printConfig(LOG_LEVEL ll, LOGGER& lg) {
LOG_VAR(ll) << " XML Path: " << getXMLPathString();
}
protected:
xmlPathVector_t _xmlPath;
};
......
......@@ -149,3 +149,12 @@ void PDUSensorGroup::readAsync() {
}
_pendingTasks--;
}
void PDUSensorGroup::printConfig(LOG_LEVEL ll) {
if (_pdu) {
LOG_VAR(ll) << " PDU Unit: " << _pdu->getHost();
} else {
LOG_VAR(ll) << " No Host set!";
}
LOG_VAR(ll) << " Request: " << _request;
}
......@@ -29,6 +29,8 @@ public:
const std::string& getRequest() { return _request; }
PDUUnit* const getPdu() const { return _pdu; }
void printConfig(LOG_LEVEL ll) override;
private:
void read() override;
void readAsync() override;
......
......@@ -102,4 +102,6 @@ bool PDUUnit::sendRequest(const std::string& request, std::string& response) {
return true;
}
void PDUUnit::printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " PDUUnit: " << _host;
}
......@@ -51,12 +51,14 @@ public:
*/
bool sendRequest(const std::string& request, std::string& response);
void printConfig(LOG_LEVEL ll);
private:
std::string _host;
boost::asio::io_service::strand* _strand;
boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
LOGGER lg;
};
#endif /* PDUUNIT_H_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment