Commit 2116bfbb authored by Micha Mueller's avatar Micha Mueller
Browse files

Make local- and global- storeReading public

parent b2f28aae
......@@ -216,27 +216,13 @@ public:
}
}
static std::string formatName(const std::string& name, int cpuID=-1) {return cpuID<0 ? name : "cpu" + std::to_string(cpuID) + "." + name;}
virtual void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "Sensor: " << _name;
LOG_VAR(ll) << leading << " MQTT Topic: " << _mqtt;
LOG_VAR(ll) << leading << " Sink: " << (getSinkPath() != "" ? getSinkPath() : "none");
LOG_VAR(ll) << leading << " SubSampling: " << getSubsampling();
LOG_VAR(ll) << leading << (_skipConstVal ? " Skipping constant values" : " No skipping of constant values");
LOG_VAR(ll) << leading << (_delta ? " Storing delta readings" : " Storing absolute readings");
}
protected:
/**
* Store reading within the sensor, but do not put it in the readingQueue
* so the reading does not get pushed but the caches are still updated.
*/
inline
void storeReadingLocal(reading_t reading) {
if (_sinkFile) {
/**
* Store reading within the sensor, but do not put it in the readingQueue
* so the reading does not get pushed but the caches are still updated.
*/
inline
void storeReadingLocal(reading_t reading) {
if (_sinkFile) {
try {
_sinkFile->seekp(0, std::ios::beg);
*_sinkFile << reading.value << std::endl;
......@@ -245,14 +231,14 @@ protected:
_cache->store(reading);
_latestValue = reading;
}
}
/**
* Store the reading in the readingQueue so it can get pushed.
*/
inline
void storeReadingGlobal(reading_t reading) {
if( _delta )
/**
* Store the reading in the readingQueue so it can get pushed.
*/
inline
void storeReadingGlobal(reading_t reading) {
if( _delta )
// If in delta mode, _accumulator acts as a buffer, summing all deltas for the subsampling period
_accumulator.value += reading.value;
else
......@@ -268,8 +254,22 @@ protected:
// We reset the accumulator's value for the correct accumulation of deltas
_accumulator.value = 0;
}
}
static std::string formatName(const std::string& name, int cpuID=-1) {return cpuID<0 ? name : "cpu" + std::to_string(cpuID) + "." + name;}
virtual void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "Sensor: " << _name;
LOG_VAR(ll) << leading << " MQTT Topic: " << _mqtt;
LOG_VAR(ll) << leading << " Sink: " << (getSinkPath() != "" ? getSinkPath() : "none");
LOG_VAR(ll) << leading << " SubSampling: " << getSubsampling();
LOG_VAR(ll) << leading << (_skipConstVal ? " Skipping constant values" : " No skipping of constant values");
LOG_VAR(ll) << leading << (_delta ? " Storing delta readings" : " Storing absolute readings");
}
protected:
std::string _name;
std::string _mqtt;
std::string _sinkPath;
......
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