Commit 0633e3fd authored by Michael Ott's avatar Michael Ott
Browse files

Add prefix parameter for tester plugin sensors

parent e30a4c81
......@@ -43,12 +43,14 @@ void TesterConfigurator::sensorGroup(TesterSensorGroup &s, CFG_VAL config) {
s.setNumSensors(stoull(val.second.data()));
} else if (boost::iequals(val.first, "startValue")) {
s.setValue(stoi(val.second.data()));
} else if (boost::iequals(val.first, "prefix")) {
s.setPrefix(val.second.data());
}
}
std::string sTopic = "";
for (unsigned int i = 0; i < s.getNumSensors(); i++) {
sTopic = s.getGroupName() + std::to_string(i);
sTopic = s.getPrefix() + std::to_string(i);
std::shared_ptr<TesterSensorBase> sensor = std::make_shared<TesterSensorBase>(sTopic);
sensor->setMqttSuffix(sTopic);
sensor->setCacheInterval(_cacheInterval);
......
......@@ -71,4 +71,5 @@ void TesterSensorGroup::printGroupConfig(LOG_LEVEL ll, unsigned leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "Value: " << _value;
LOG_VAR(ll) << leading << "Num Sensors: " << _numSensors;
LOG_VAR(ll) << leading << "Prefix: " << _prefix;
}
......@@ -45,9 +45,11 @@ class TesterSensorGroup : public SensorGroupTemplate<TesterSensorBase> {
void setValue(long long n) { _value = n; }
void setNumSensors(unsigned int n) { _numSensors = n; }
void setPrefix(std::string s) { _prefix = s; }
long long getValue() { return _value; }
unsigned int getNumSensors() { return _numSensors; }
std::string getPrefix() { return _prefix; }
void printGroupConfig(LOG_LEVEL ll, unsigned leadingSpaces) final override;
......@@ -56,6 +58,7 @@ class TesterSensorGroup : public SensorGroupTemplate<TesterSensorBase> {
long long _value;
unsigned int _numSensors;
std::string _prefix;
};
#endif /* TESTERSENSORGROUP_H_ */
Markdown is supported
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