OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import json | 5 import json |
6 import multiprocessing | 6 import multiprocessing |
7 import tempfile | 7 import tempfile |
8 import time | 8 import time |
9 | 9 |
10 from telemetry.core import exceptions | 10 from telemetry.core import exceptions |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 class MonsoonPowerMonitor(power_monitor.PowerMonitor): | 45 class MonsoonPowerMonitor(power_monitor.PowerMonitor): |
46 def __init__(self): | 46 def __init__(self): |
47 super(MonsoonPowerMonitor, self).__init__() | 47 super(MonsoonPowerMonitor, self).__init__() |
48 self._powermonitor_process = None | 48 self._powermonitor_process = None |
49 self._powermonitor_output_file = None | 49 self._powermonitor_output_file = None |
50 self._is_collecting = None | 50 self._is_collecting = None |
51 self._monsoon = None | 51 self._monsoon = None |
52 try: | 52 try: |
53 self._monsoon = monsoon.Monsoon(wait=False) | 53 self._monsoon = monsoon.Monsoon(wait=False) |
54 self._monsoon.SetMaxCurrent(2.0) | |
55 # Nominal Li-ion voltage is 3.7V, but it puts out 4.2V at max capacity. | 54 # Nominal Li-ion voltage is 3.7V, but it puts out 4.2V at max capacity. |
56 # Use 4.0V to simulate a "~80%" charged battery. Google "li-ion voltage | 55 # Use 4.0V to simulate a "~80%" charged battery. Google "li-ion voltage |
57 # curve". This is true only for a single cell. (Most smartphones, some | 56 # curve". This is true only for a single cell. (Most smartphones, some |
58 # tablets.) | 57 # tablets.) |
59 self._monsoon.SetVoltage(4.0) | 58 self._monsoon.SetVoltage(4.0) |
60 except EnvironmentError: | 59 except EnvironmentError: |
61 self._monsoon = None | 60 self._monsoon = None |
62 | 61 |
63 def CanMonitorPowerAsync(self): | 62 def CanMonitorPowerAsync(self): |
64 return self._monsoon is not None | 63 return self._monsoon is not None |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 total_energy_consumption_mwh += energy_consumption_mw * timedelta_h | 110 total_energy_consumption_mwh += energy_consumption_mw * timedelta_h |
112 power_samples.append(energy_consumption_mw) | 111 power_samples.append(energy_consumption_mw) |
113 # -------- Collect and Process Data ------------- | 112 # -------- Collect and Process Data ------------- |
114 out_dict = {} | 113 out_dict = {} |
115 # Raw power usage samples. | 114 # Raw power usage samples. |
116 out_dict['identifier'] = 'monsoon' | 115 out_dict['identifier'] = 'monsoon' |
117 out_dict['power_samples_mw'] = power_samples | 116 out_dict['power_samples_mw'] = power_samples |
118 out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh | 117 out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh |
119 | 118 |
120 return out_dict | 119 return out_dict |
OLD | NEW |