Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: client/cros/power_status.py

Issue 6800002: power_Draw/Idle/LoadTest: Support temperature sensing for x86 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/site_tests/power_Draw/power_Draw.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cros/power_status.py
diff --git a/client/cros/power_status.py b/client/cros/power_status.py
index 17a2358c357c8a8a341ee8104bd2a3238fe75cfd..e81aa846dbdbcdc6550736ea9c08a17b793d5898 100644
--- a/client/cros/power_status.py
+++ b/client/cros/power_status.py
@@ -41,6 +41,64 @@ class DevStat(object):
setattr(self, field, val)
+class ThermalStat(DevStat):
+ """
+ Thermal status.
+
+ Fields:
Duncan Laurie 2011/04/06 16:57:34 I think the list in the comments was copy+paste fr
Simon Que 2011/04/07 20:59:46 Done.
+
+ float charge_full: Last full capacity reached [Ah]
+ float charge_full_design: Full capacity by design [Ah]
+ float charge_now: Remaining charge [Ah]
+ float current_now: Battery discharge rate [A]
+ float energy: Current battery charge [Wh]
+ float energy_full: Last full capacity reached [Wh]
+ float energy_full_design: Full capacity by design [Wh]
+ float energy_rate: Battery discharge rate [W]
+ float remaining_time: Remaining discharging time [h]
+ float voltage_min_design: Minimum voltage by design [V]
+ float voltage_now: Voltage now [V]
Sameer Nanda 2011/04/06 17:53:54 comments need to fixed up to match thermal fields.
Simon Que 2011/04/07 20:59:46 Done.
+ """
+
+ thermal_fields = {
+ 'enabled': ['enabled', float],
+ 'temp': ['temp', float],
+ 'type': ['type', float],
+ 'num_points_tripped': ['', '']
+ }
+ def __init__(self, path=None):
+ # Dynamically generate the rest of the fields
+ thermal_point_strings = [ 'trip_point_%d_type',
+ 'trip_point_%d_temp',
+ 'cdev%d_trip_point' ]
+ thermal_point_types = [ str, int, int ]
+ self.num_trip_points = 0
+
+ for i in range(10):
Duncan Laurie 2011/04/06 16:57:34 10 is probably safe but it may be useful to make t
Sameer Nanda 2011/04/06 17:53:54 lets use python glob to find all matching names in
Simon Que 2011/04/07 20:59:46 Done.
+ for j in range(len(thermal_point_strings)):
+ file = thermal_point_strings[j] % i
+
+ if os.path.exists(path + file):
+ self.thermal_fields[file] = [file, thermal_point_types[j]]
+ if j == 0:
+ num_trip_points += 1
+
+ super(ThermalStat, self).__init__(self.thermal_fields, path)
+ self.update()
+
+ def update(self):
+ if not os.path.exists(self.path):
+ return
+
+ self.read_all_vals()
+ self.num_points_tripped = 0
+
+ for i in range(self.num_trip_points):
+ if self.temp > self.read_val('trip_point_%d_temp' % i, int):
+ self.num_points_tripped += 1
+
+
+
class BatteryStat(DevStat):
"""
Battery status.
@@ -135,15 +193,18 @@ class SysStat(object):
Fields:
battery: A list of BatteryStat objects.
- linepower: A list of LineStat opbjects.
+ linepower: A list of LineStat objects.
"""
def __init__(self):
power_supply_path = '/sys/class/power_supply/*'
self.battery = None
self.linepower = None
+ self.thermal = None
battery_path = None
linepower_path = None
+ thermal_path = '/sys/class/thermal/thermal_zone0'
+
power_supplies = glob.glob(power_supply_path)
for path in power_supplies:
type_path = os.path.join(path,'type')
@@ -159,7 +220,10 @@ class SysStat(object):
self.linepower_path = linepower_path
else:
raise error.TestError('Battery or Linepower path not found')
+ self.thermal_path = thermal_path
+ self.min_temp = 999999999
+ self.max_temp = -999999999
def refresh(self):
"""
@@ -168,6 +232,15 @@ class SysStat(object):
"""
self.battery = [ BatteryStat(self.battery_path) ]
self.linepower = [ LineStat(self.linepower_path) ]
+ self.thermal = [ ThermalStat(self.thermal_path) ]
+
+ try:
+ if self.thermal[0].temp < self.min_temp:
+ self.min_temp = self.thermal[0].temp
+ if self.thermal[0].temp > self.max_temp:
+ self.max_temp = self.thermal[0].temp
+ except:
+ logging.error('Could not read temperature, skipping.')
def get_status():
« no previous file with comments | « no previous file | client/site_tests/power_Draw/power_Draw.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698