Source code for nirfmxspecan.power_list_results

"""Provides methods to fetch and read the PowerList measurement results."""

import functools

import nirfmxspecan.attributes as attributes
import nirfmxspecan.errors as errors
import nirfmxspecan.internal._helper as _helper


def _raise_if_disposed(f):
    """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""

    @functools.wraps(f)
    def aux(*xs, **kws):
        meas_obj = xs[0]  # parameter 0 is 'self' which is the measurement object
        if meas_obj._signal_obj.is_disposed:
            raise Exception("Cannot access a disposed SpecAn signal configuration")
        return f(*xs, **kws)

    return aux


[docs] class PowerListResults(object): """Provides methods to fetch and read the PowerList measurement results.""" def __init__(self, signal_obj): """Provides methods to fetch and read the PowerList measurement results.""" self._signal_obj = signal_obj self._session_function_lock = signal_obj._session_function_lock self._interpreter = signal_obj._interpreter
[docs] @_raise_if_disposed def get_mean_absolute_power(self, selector_string): r"""Gets an array of mean absolute power of the signal, each corresponding to a segment. This value is expressed in dBm. You do not need to use a selector string to read this result for the default signal and result instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals and results. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns an array of mean absolute power of the signal, each corresponding to a segment. This value is expressed in dBm. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.POWERLIST_RESULTS_MEAN_ABSOLUTE_POWER.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_maximum_power(self, selector_string): r"""Gets an array of maximum power of the signal, each corresponding to a segment. This value is expressed in dBm. You do not need to use a selector string to read this result for the default signal and result instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals and results. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns an array of maximum power of the signal, each corresponding to a segment. This value is expressed in dBm. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.POWERLIST_RESULTS_MAXIMUM_POWER.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_minimum_power(self, selector_string): r"""Gets an array of minimum power of the signal, each corresponding to a segment. This value is expressed in dBm. You do not need to use a selector string to read this result for the default signal and result instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals and results. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns an array of minimum power of the signal, each corresponding to a segment. This value is expressed in dBm. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.POWERLIST_RESULTS_MINIMUM_POWER.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def fetch_mean_absolute_power_array(self, selector_string, timeout): r"""Returns the mean absolute power of all segments measured using the PowerList measurement. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (mean_absolute_power, error_code): mean_absolute_power (float): This parameter returns an array of mean absolute power, in dBm for each segment. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) mean_absolute_power, error_code = ( self._interpreter.power_list_fetch_mean_absolute_power_array( updated_selector_string, timeout ) ) finally: self._session_function_lock.exit_read_lock() return mean_absolute_power, error_code
[docs] @_raise_if_disposed def fetch_maximum_power_array(self, selector_string, timeout): r"""Returns the maximum power of all segments measured using the PowerList measurement. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (maximum_power, error_code): maximum_power (float): This parameter returns an array of maximum power in dBm for each segment. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) maximum_power, error_code = self._interpreter.power_list_fetch_maximum_power_array( updated_selector_string, timeout ) finally: self._session_function_lock.exit_read_lock() return maximum_power, error_code
[docs] @_raise_if_disposed def fetch_minimum_power_array(self, selector_string, timeout): r"""Returns the minimum power of all segments measured using the PowerList measurement. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (minimum_power, error_code): minimum_power (float): This parameter returns an array of minimum power, in dBm for each segment. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) minimum_power, error_code = self._interpreter.power_list_fetch_minimum_power_array( updated_selector_string, timeout ) finally: self._session_function_lock.exit_read_lock() return minimum_power, error_code