Commit 90efdac3 authored by Swann Perarnau's avatar Swann Perarnau

[refactor] Use actual sensor info in control loop

This patch is the last link between coolr and the daemon. We now create
a dictionary of machine information inside the sensor manager, and give
this dictionary back to the daemon. The daemon can then use the real
data for control.

We still need to receive the target power from somewhere, and that will
come later.
parent be8dab11
......@@ -97,11 +97,11 @@ class Daemon(object):
application.state)
def do_sensor(self):
self.sensor_state = self.sensor.do_update()
self.logger.info("current state: %r" % self.sensor_state)
self.machine_info = self.sensor.do_update()
self.logger.info("current state: %r" % self.machine_info)
def do_control(self):
total_power = self.sensor_state['total_power']
total_power = self.machine_info['energy']['power']['total']
self.target = random.randrange(0, 34)
self.logger.info("target measure: " + str(self.target))
......@@ -142,7 +142,7 @@ class Daemon(object):
# create sensor manager and make first measurement
self.sensor = sensor.SensorManager()
self.sensor.start()
self.sensor_state = self.sensor.do_update()
self.machine_info = self.sensor.do_update()
# setup periodic sensor updates
self.sensor_cb = ioloop.PeriodicCallback(self.do_sensor, 1000)
......
......@@ -6,7 +6,6 @@
This module should be the only one interfacing with coolr.
"""
from __future__ import print_function
import random
import coolr
import coolr.clr_rapl
import coolr.clr_hwmon
......@@ -31,8 +30,7 @@ class SensorManager:
self.rapl.stop_energy_counter()
def do_update(self):
rapl_data = self.rapl.sample(accflag=True)
print(repr(rapl_data))
hwmon_data = self.coretemp.sample()
print(repr(hwmon_data))
return {'total_power': random.randrange(0, 34)}
machine_info = dict()
machine_info['energy'] = self.rapl.sample(accflag=True)
machine_info['temperature'] = self.coretemp.sample()
return machine_info
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