Commit 67742d12 authored by Carla Guillen Carias's avatar Carla Guillen Carias
Browse files

setting publish to false for sensors which get aggregated to another sensor...

setting publish to false for sensors which get aggregated to another sensor (they shouldn't be published).
parent 25a15890
...@@ -81,6 +81,14 @@ void MSRSensorGroup::groupInBins() { ...@@ -81,6 +81,14 @@ void MSRSensorGroup::groupInBins() {
} }
_sensorBins.shrink_to_fit(); _sensorBins.shrink_to_fit();
if (_htAggregation) {
for (unsigned int cpu = _htAggregation; cpu < _total_number_cpus; ++cpu) {
for (unsigned int m = 0; m < _sensorBins[cpu].sensors.size(); ++m) {
_sensorBins[cpu].sensors[m]->setPublish(false);
}
}
}
} }
bool MSRSensorGroup::execOnStart() { bool MSRSensorGroup::execOnStart() {
...@@ -102,7 +110,6 @@ bool MSRSensorGroup::execOnStart() { ...@@ -102,7 +110,6 @@ bool MSRSensorGroup::execOnStart() {
} }
_sensorBins[cpu].setFd(handle); _sensorBins[cpu].setFd(handle);
} }
program_fixed(); program_fixed();
return true; return true;
...@@ -134,23 +141,18 @@ void MSRSensorGroup::read() { ...@@ -134,23 +141,18 @@ void MSRSensorGroup::read() {
} }
if (_htAggregation) { if (_htAggregation) {
for (unsigned int cpu = 0; cpu < _htAggregation; ++cpu) { for (unsigned int cpu = 0; cpu < _htAggregation; ++cpu) { // loop through all cpus until the aggregation
for (unsigned int m = 0; m < _sensorBins[cpu].sensors.size(); ++m) { for (unsigned int m = 0; m < _sensorBins[cpu].sensors.size(); ++m) { //loop through the group's sensors
reading_t aggregation; reading_t aggregation;
aggregation.value = 0; aggregation.value = 0;
aggregation.timestamp = reading.timestamp; aggregation.timestamp = reading.timestamp;
unsigned int mincpu = _total_number_cpus; // starting at the cpu we find all the cpus which will be aggregated here
for (unsigned int agg = cpu; agg + _htAggregation < _total_number_cpus; agg += _htAggregation) { for (unsigned int agg = cpu; agg + _htAggregation < _total_number_cpus; agg += _htAggregation) {
if (_sensorBins[agg].isActive()) { if (_sensorBins[agg].isActive()) {
aggregation.value += _sensorBins[agg].sensors[m]->getLatestValue().value; aggregation.value += _sensorBins[agg].sensors[m]->getLatestValue().value;
if (agg < mincpu) { // store reading for aggregation in the minimum active cpu
mincpu = agg;
}
} }
} }
if (mincpu != _total_number_cpus) { _sensorBins[cpu].sensors[m]->storeReadingGlobal(aggregation);
_sensorBins[mincpu].sensors[m]->storeReadingGlobal(aggregation); //, 1, MSR_MAXIMUM_SIZE, _htAggregation);
}
} }
} }
} }
......
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