Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""This module wraps the calls to the Power Interface."""
CALIBRATING, DONE, IDLE, OVERFLOWED, RUNNING, XAM, CHANNEL_A, POWER_CURRENT) PowerReadError, PowerStatusError, InterfaceNotAvailableError)
"""Wraps the calls to the Power interface."""
"""Instantiate DGILibInterfacePower object.""" # Set default values for attributes # Instantiate base class # Parse arguments
"""get_config
Get the power config options.
Returns ------- list(dict) Power buffers configuration list of dictionaries like ``[{"channel": CHANNEL_A, "power_type": POWER_CURRENT}]``. """ # Return the configuration return self.power_buffers
"""set_config
Set the power config options.
Register buffers inside the library for the buffers specified in power_buffers and removes ones that are not present.
Parameters ---------- power_buffers: list(dict) Power buffers configuration list of dictionaries like ``[{"channel": CHANNEL_A, "power_type": POWER_CURRENT}]``. """ # Parse arguments "power_buffers", [{"channel": CHANNEL_A, "power_type": POWER_CURRENT}],)
# Initialize the power handle if it is None self.dgilib_extra.auxiliary_power_initialize()
# Enable the configurations that are in the new config and not in # self.power_buffers # BUG: This probably needs multiple power handles channel=power_buffer["channel"], power_type=power_buffer["power_type"])
# Disable the configurations that are not in the new config and remove # them from self.power_buffers channel=power_buffer["channel"], power_type=power_buffer["power_type"],)
# Uninitialize the power handle if there are no power buffers left self.dgilib_extra.auxiliary_power_uninitialize()
"""enable
Enable the interface. """ raise InterfaceNotAvailableError( f"Interface {self.interface_id} not available. Available " + f"interfaces: {self.dgilib_extra.available_interfaces}") # Check if calibration is valid and trigger calibration if it is not
"""disable
Disable the interface. """ # NOTE: This currently also removes the configuration!!! # TODO # BUG
"""read
Read data from the interface.
Returns ------- InterfaceData Interface data """ # Return the data
"""read_buffer
Read power data of the specified buffer.
Returns ------- tuple(list(float), list(float)) Tuple of list of power samples in Ampere and list of timestamps in seconds. """ # TODO: Copies parsed power data into the specified buffer. Remember to # lock the buffers first. If the count parameter is the same as # max_count there is probably more data to be read. Do another read to # get the remaining data.
# Check if power_buffer is in self.power_buffers f"Power Buffer {power_buffer} does not exist in " f"self.power_buffers: {self.power_buffers}.")
# Check if auxiliary_power_get_status() is in # - IDLE = 0x00, # - RUNNING = 0x01, # - DONE = 0x02 or # - OVERFLOWED = 0x11 # and raise PowerStatusError if it is. # if power_status <= DONE or power_status == OVERFLOWED: f"BUFFER OVERFLOW, call this function more frequently or " f"increase the buffer size.")
# Create variables to the store data in
# TODO: Check implementation in case of buffer overflow. # Should auxiliary_power_lock_data_for_reading() be inside the loop # or before?
# Get the data from the buffer in the library power_buffer["channel"], power_buffer["power_type"]) # BUG: This probably clears all channels! (channels might not be # working on XAM anyway) # Repeat the loop until there is no buffer overflow (which should # always be avoided.)
"""calibrate
Calibrate the Auxiliary Power interface of the device.
Check if calibration is valid and trigger calibration if it is not.
Parameters ---------- force : bool Force calibration, even if it is valid (default: `False`)
Raises ------ PowerReadError `No description given.`
PowerStatusError `No description given.` """ # TODO: Give descriptions to the exceptions under 'Raises' above.
self.auxiliary_power_calibration()
"""auxiliary_power_calibration
Calibrate the Auxiliary Power interface of the device.
Parameters ---------- circuit_type : int Type of calibration to trigger(defaults to XAM)
""" self.dgilib_extra.auxiliary_power_trigger_calibration(circuit_type) while self.dgilib_extra.auxiliary_power_get_status() == CALIBRATING: sleep(0.1) |