Commit e992a7f1 authored by Valentin Reis's avatar Valentin Reis

Logging power, works.

parent 42999a1f
Pipeline #4560 failed with stages
in 2 minutes and 9 seconds
from __future__ import print_function
import logging
import time
logger = logging.getLogger('nrm')
logger_power = logging.getLogger('power')
class Action(object):
......@@ -55,24 +56,29 @@ class Controller(object):
def planify(self, target, machineinfo):
"""Plan the next action for the control loop."""
total_power = machineinfo['energy']['power']['total']
direction = None
if total_power < target:
direction = 'i'
elif total_power > target:
direction = 'd'
if direction:
actions = []
for act in self.actuators:
newactions = act.available_actions(direction)
actions.extend([(a, act) for a in newactions])
if actions:
# TODO: better choice
actions.sort(key=lambda x: x[0].delta)
return actions.pop(0)
else:
return (None, None)
# current_e = float(machineinfo['energy']['energy']['cumulative']['package-0'])/(1000*1000) # in joules
current_p = float(machineinfo['energy']['power']['p0'])/(1000*1000) # in joules
current_p = float(machineinfo['energy']['power']['p1'])/(1000*1000) # in joules
logger_power.info("%s %s %s" % (time.time(),current_p,current_p))
return (None,None)
# direction = None
# if total_power < target:
# direction = 'i'
# elif total_power > target:
# direction = 'd'
# if direction:
# actions = []
# for act in self.actuators:
# newactions = act.available_actions(direction)
# actions.extend([(a, act) for a in newactions])
# if actions:
# # TODO: better choice
# actions.sort(key=lambda x: x[0].delta)
# return actions.pop(0)
# else:
# return (None, None)
def execute(self, action, actuator):
"""Build the action for the appropriate manager."""
......
......@@ -20,7 +20,7 @@ RPC_MSG = MSGTYPES['up_rpc_rep']
PUB_MSG = MSGTYPES['up_pub']
logger = logging.getLogger('nrm')
logger_power = logging.getLogger('power')
class Daemon(object):
......
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