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

Minor bugfixes. Init _lastRawUValue in constructors

parent 7b842a86
......@@ -44,12 +44,14 @@ public:
_readingQueue(nullptr),
_sinkFile(nullptr) {
_lastRawUValue.timestamp = 0;
_lastRawUValue.value = 0;
_lastRawValue.timestamp = 0;
_lastRawValue.value = 0;
_latestValue.timestamp = 0;
_latestValue.value = 0;
_lastSentValue.timestamp= 0;
_lastSentValue.value = 0;
_lastRawValue.timestamp = 0;
_lastRawValue.value = 0;
_accumulator.timestamp = 0;
_accumulator.value = 0;
}
......@@ -66,8 +68,9 @@ public:
_cache(nullptr),
_delta(other._delta),
_firstReading(true),
_latestValue(other._latestValue),
_lastRawUValue(other._lastRawUValue),
_lastRawValue(other._lastRawValue),
_latestValue(other._latestValue),
_lastSentValue(other._lastSentValue),
_accumulator(other._accumulator),
_readingQueue(nullptr),
......@@ -87,10 +90,12 @@ public:
_cache.reset(nullptr);
_delta = other._delta;
_firstReading = true;
_lastRawUValue.timestamp = other._lastRawUValue.timestamp;
_lastRawUValue.value = other._lastRawUValue.value;
_lastRawValue.timestamp = other._lastRawValue.timestamp;
_lastRawValue.value = other._lastRawValue.value;
_latestValue.timestamp = other._latestValue.timestamp;
_latestValue.value = other._latestValue.value;
_lastRawValue.timestamp = other._lastRawValue.timestamp;
_lastRawValue.value = other._lastRawValue.value;
_lastSentValue.timestamp= other._lastSentValue.timestamp;
_lastSentValue.value = other._lastSentValue.value;
_accumulator.timestamp = other._accumulator.timestamp;
......@@ -220,7 +225,8 @@ public:
* delta computation to detect an overflow.
*/
void storeReading(ureading_t rawReading, double factor=1.0, unsigned long long maxValue=ULLONG_MAX) {
reading_t reading = rawReading;
reading_t reading;
reading.timestamp = rawReading.timestamp;
if( _delta ) {
if (!_firstReading) {
if (rawReading.value < _lastRawUValue.value)
......
......@@ -232,7 +232,7 @@ void PerfSensorGroup::read() {
for (unsigned j = 0; j < _sensors.size(); j++) {
if (rf->values[i].id == _ids[j]) {
#ifdef DEBUG
LOG(debug) << _groupName << "::" << _sensors[j]->getName() << " raw reading: \"" << val << "\"";
LOG(debug) << _groupName << "::" << _sensors[j]->getName() << " raw reading: \"" << reading.value << "\"";
#endif
if(_lastValid){
//storeReading takes care of delta computation and applies correction value on the result
......
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