Source code for nirfmxvna.marker_results

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

import functools

import nirfmxvna.enums as enums
import nirfmxvna.errors as errors
import nirfmxvna.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 Vna signal configuration")
        return f(*xs, **kws)

    return aux


[docs] class MarkerResults(object): """Provides methods to fetch and read the Marker measurement results.""" def __init__(self, signal_obj): """Provides methods to fetch and read the Marker 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 fetch_x(self, selector_string): r"""Returns the X value of the marker. X value of the **Delta** marker is relative to its reference marker. Args: selector_string (string): Specifies a selector string. Pass an empty string. Returns: Tuple (marker_x, error_code): marker_x (float): This parameter returns the marker X value. 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 ) marker_x, error_code = self._interpreter.marker_fetch_x(updated_selector_string) finally: self._session_function_lock.exit_read_lock() return marker_x, error_code
[docs] @_raise_if_disposed def fetch_y(self, selector_string): r"""Returns the Y value of the marker. Y value of a **Delta** marker is relative to its reference marker. Y value can be a real or a complex number depending on format of the selected measurement for the configured data source. Y is a complex number for Complex, Smith and Polar formats. For all other formats, Y is a real number. If Y value is a complex number, Marker Y1 and Marker Y2 return its real and imaginary components respectively. If Y value is a real number, Marker Y1 returns the Y location and Marker Y2 returns 0. Args: selector_string (string): Specifies a selector string. Pass an empty string. Returns: Tuple (marker_y1, marker_y2, error_code): marker_y1 (float): This parameter returns the Y1 component of marker's Y value. marker_y2 (float): This parameter returns the Y2 component of marker's Y value. Y value is always returned as two components (Y1,Y2). The format of the Y value depends on the format of the selected measurement. If the format is Complex, Smith or Polar (Y1,Y2) are (Real, Imaginary). For all other formats (Y1,Y2) are (Value,0). 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 ) marker_y1, marker_y2, error_code = self._interpreter.marker_fetch_y( updated_selector_string ) finally: self._session_function_lock.exit_read_lock() return marker_y1, marker_y2, error_code