mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-05 17:46:29 +02:00
Debug power state plugin
This commit is contained in:
parent
f165afac6e
commit
e93546e0f3
2 changed files with 7 additions and 6 deletions
|
@ -41,7 +41,7 @@ class PowerStates(NodePlugin):
|
|||
"""
|
||||
def __init__(self,node,power_init):
|
||||
self.node=node
|
||||
self.clock=self.node.clock()
|
||||
self.clock=self.node.read("clock")
|
||||
self.energy=0
|
||||
self.power=power_init
|
||||
self.power_changes=dict()
|
||||
|
@ -50,7 +50,7 @@ class PowerStates(NodePlugin):
|
|||
|
||||
|
||||
def set_power(self,power_watt):
|
||||
cur_clock=self.node.clock()
|
||||
cur_clock=self.node.read("clock")
|
||||
self.energy+=self.power*(cur_clock-self.clock)
|
||||
self.clock=cur_clock
|
||||
if self.power != power_watt:
|
||||
|
@ -113,17 +113,17 @@ class PowerStatesComms(NodePlugin):
|
|||
self.energy_dynamic=0.0 # Store the dynamic part of the energy consumption
|
||||
self.power=dict() # Store the power states
|
||||
self.tx_clock=0 # Dynamic clock (store the time at which a the last tx starts
|
||||
self.idle_clock=api.clock() # Store the start time (to compute the idle part of the energy consumption)
|
||||
self.idle_clock=api.read("clock") # Store the start time (to compute the idle part of the energy consumption)
|
||||
|
||||
def on_receive_return(self,interface,data,start_at,end_at):
|
||||
duration=float(end_at)-float(start_at)
|
||||
self.energy_dynamic+=self.power[interface]["rx"]*duration
|
||||
|
||||
def on_send_call(self,interface,data,datasize,dst):
|
||||
self.tx_clock=self.api.clock()
|
||||
self.tx_clock=self.api.read("clock")
|
||||
|
||||
def on_send_return(self,interface,data,datasize,dst,code):
|
||||
clock=self.api.clock()
|
||||
clock=self.api.read("clock")
|
||||
duration=(clock-float(self.tx_clock))
|
||||
self.energy_dynamic+=self.power[interface]["tx"]*duration
|
||||
self.tx_clock=clock # Any value could be use here
|
||||
|
@ -135,7 +135,7 @@ class PowerStatesComms(NodePlugin):
|
|||
self.power[interface]["tx"]=tx
|
||||
|
||||
def get_idle(self):
|
||||
clock=self.api.clock()
|
||||
clock=self.api.read("clock")
|
||||
idle=0
|
||||
for interface in self.power.keys():
|
||||
idle+=(clock-self.idle_clock)*self.power[interface]["idle"]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import math
|
||||
import numpy as np
|
||||
|
||||
# This plugin is outdated
|
||||
class WirelessArea:
|
||||
|
||||
def __init__(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue