physalia.third_party.monsoon module¶
Interface for a USB-connected Monsoon power meter (http://msoon.com/LabEquipment/PowerMonitor/).
-
class
physalia.third_party.monsoon.
Monsoon
(*args, **kwargs)[source]¶ Bases:
object
The wrapper class for test scripts to interact with monsoon.
-
attach_device
(dut)[source]¶ Attach the controller object for the Device Under Test (DUT) physically attached to the Monsoon box.
- Args:
- dut: A controller object representing the device being powered by
- this Monsoon box.
-
measure_power
(hz, duration, tag, offset=30)[source]¶ Measure power consumption of the attached device.
Because it takes some time for the device to calm down after the usb connection is cut, an offset is set for each measurement. The default is 30s. The total time taken to measure will be (duration + offset).
- Args:
- hz: Number of samples to take per second. duration: Number of seconds to take samples for in each step. offset: The number of seconds of initial data to discard. tag: A string that’s the name of the collected data group.
- Returns:
- A MonsoonData object with the measured power data.
-
set_max_init_current
(cur)[source]¶ Sets the max power-up/inital current.
- Args:
- cur: The max initial current allowed in mA.
-
set_voltage
(volt, ramp=False)[source]¶ Sets the output voltage of monsoon.
- Args:
volt: Voltage to set the output to. ramp: If true, the output voltage will be increased gradually to
prevent tripping Monsoon overvoltage.
-
status
¶ Gets the status params of monsoon.
- Returns:
- A dictionary where each key-value pair represents a monsoon status param.
-
take_samples
(sample_hz, sample_num, sample_offset=0, live=False)[source]¶ Take samples of the current value supplied by monsoon.
This is the actual measurement for power consumption. This function blocks until the number of samples requested has been fulfilled.
- Args:
hz: Number of points to take for every second. sample_num: Number of samples to take. offset: The number of initial data points to discard in MonsoonData
calculations. sample_num is extended by offset to compensate.live: Print each sample in console as measurement goes on.
- Returns:
- A MonsoonData object representing the data obtained in this sampling. None if sampling is unsuccessful.
-
usb
= <timeout_decorator.timeout_decorator._Timeout object>¶
-
-
class
physalia.third_party.monsoon.
MonsoonData
(data_points, timestamps, hz, voltage, offset=0)[source]¶ Bases:
object
A class for reporting power measurement data from monsoon.
Data means the measured current value in Amps.
-
average_current
¶ Average current in the unit of mA.
-
delimiter
= '\n\n==========\n\n'¶
-
static
from_string
(data_str)[source]¶ Creates a MonsoonData object from a string representation generated by __str__.
- Args:
- str: The string representation of a MonsoonData.
- Returns:
- A MonsoonData object.
-
static
from_text_file
(file_path)[source]¶ Load MonsoonData objects from a text file generated by MonsoonData.save_to_text_file.
- Args:
- file_path: The full path of the file load from, including the file
- name.
- Returns:
- A list of MonsoonData objects.
-
get_average_record
(n)[source]¶ Returns a list of average current numbers, each representing the average over the last n data points.
- Args:
- n: Number of data points to average over.
- Returns:
- A list of average current values.
-
get_data_with_timestamps
()[source]¶ Returns the data points with timestamps.
- Returns:
- A list of tuples in the format of (timestamp, data)
-
lr
= 8¶
-
static
save_to_text_file
(monsoon_data, file_path)[source]¶ Save multiple MonsoonData objects to a text file.
- Args:
- monsoon_data: A list of MonsoonData objects to write to a text
- file.
- file_path: The full path of the file to save to, including the file
- name.
-
sr
= 6¶
-
total_charge
¶ Total charged used in the unit of mAh.
-
total_power
¶ Total power used.
-
-
exception
physalia.third_party.monsoon.
MonsoonError
[source]¶ Bases:
mobly.signals.ControllerError
Raised for exceptions encountered in monsoon lib.
-
class
physalia.third_party.monsoon.
MonsoonProxy
(device=None, serialno=None, wait=1)[source]¶ Bases:
object
Class that directly talks to monsoon over serial.
Provides a simple class to use the power meter, e.g. mon = monsoon.Monsoon() mon.SetVoltage(3.7) mon.StartDataCollection() mydata = [] while len(mydata) < 1000:
mydata.extend(mon.CollectData())mon.StopDataCollection()