Commit 0016f807 authored by tonyg@chromium.org's avatar tonyg@chromium.org

[Telemetry] Allow the Monsoon to power the device under test.

The monsoon provides power for the device, so for devices with no
real battery, we need a chance to turn them on after the monsoon
enables voltage output to the device.

BUG=

Review URL: https://codereview.chromium.org/400863002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285005 0039d316-1c4b-4281-b951-d872f2087c98
parent de212233
......@@ -18,6 +18,7 @@ from telemetry.core import util
from telemetry.core.backends import adb_commands
from telemetry.core.backends.chrome import android_browser_backend
from telemetry.core.platform import android_platform_backend
from telemetry.core.platform.profiler import monsoon
CHROME_PACKAGE_NAMES = {
......@@ -176,6 +177,7 @@ def CanFindAvailableBrowsers(logging=real_logging):
adb_works = False
return adb_works
def FindAllAvailableBrowsers(finder_options, logging=real_logging):
"""Finds all the desktop browsers available on this machine."""
if not CanFindAvailableBrowsers(logging=logging):
......@@ -183,15 +185,38 @@ def FindAllAvailableBrowsers(finder_options, logging=real_logging):
'Will not try searching for Android browsers.')
return []
device = None
if finder_options.android_device:
devices = [finder_options.android_device]
else:
devices = adb_commands.GetAttachedDevices()
def _GetDevices():
if finder_options.android_device:
return [finder_options.android_device]
else:
return adb_commands.GetAttachedDevices()
if len(devices) == 0:
logging.info('No android devices found.')
return []
devices = _GetDevices()
if not devices:
try:
m = monsoon.Monsoon(wait=False)
m.SetUsbPassthrough(1)
m.SetVoltage(3.8)
m.SetMaxCurrent(8)
logging.warn("""
Monsoon power monitor detected, but no Android devices.
The Monsoon's power output has been enabled. Please now ensure that:
1. The Monsoon's front and back USB are connected to the host.
2. The Device is connected to the Monsoon's main and USB channels.
3. The Device is turned on.
Waiting for device...
""")
util.WaitFor(_GetDevices, 600)
devices = _GetDevices()
if not devices:
raise IOError()
except IOError:
logging.info('No android devices found.')
return []
if len(devices) > 1:
logging.warn(
......
......@@ -103,15 +103,16 @@ class MonsoonPowerMonitor(power_monitor.PowerMonitor):
"""
power_samples = []
total_energy_consumption_mwh = 0
result = json.loads(powermonitor_output)
timedelta_h = result['duration_s'] / len(result['samples']) / 3600
for (current_a, voltage_v) in result['samples']:
energy_consumption_mw = current_a * voltage_v * 10**3
total_energy_consumption_mwh += energy_consumption_mw * timedelta_h
power_samples.append(energy_consumption_mw)
# -------- Collect and Process Data -------------
if result['samples']:
timedelta_h = result['duration_s'] / len(result['samples']) / 3600
for (current_a, voltage_v) in result['samples']:
energy_consumption_mw = current_a * voltage_v * 10**3
total_energy_consumption_mwh += energy_consumption_mw * timedelta_h
power_samples.append(energy_consumption_mw)
out_dict = {}
# Raw power usage samples.
out_dict['identifier'] = 'monsoon'
out_dict['power_samples_mw'] = power_samples
out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh
......
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