"""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 marker_search(self, selector_string, search_mode):
r"""Performs the marker search operation that you specify using Search Mode.
.. note::
Marker search operation is performed on real-valued data only. No search operation is performed on complex-valued data.
Args:
selector_string (string):
Specifies a selector string. Pass an empty string.
search_mode (enums.MarkerSearchMode, int):
This parameter specifies the search-target. If search is successful, RFmx updates the marker X and Y values to the
location at which search-target is found.
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Name (Value) | Description |
+=======================+==========================================================================================================================+
| None (0) | No search operation is performed. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Max (1) | Moves the marker to the highest measured value on the configured data source. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Min (2) | Moves the marker to the lowest measured value on the configured data source. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Peak (3) | Moves the marker to the highest peak that satisfies peak threshold and peak excursion criteria. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Next Peak (4) | Moves the marker to the next peak that satisfies peak threshold and peak excursion criteria. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Next Left Peak (5) | Moves the marker to the next left peak that satisfies peak threshold and peak excursion criteria. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Next Right Peak (6) | Moves the marker to the next right peak that satisfies peak threshold and peak excursion criteria. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Target (7) | Moves the marker to the first right target encountered from the current marker position, wraps around if no target |
| | found. If marker mode is Discrete,marker moves to the data point closest to the first right target. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Next Left Target (8) | Moves the marker to the next left target encountered from the current marker position. If marker mode is |
| | Discrete,marker moves to the data point closest to the next left target. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Next Right Target (9) | Moves the marker to the next right target encountered from the current marker position. If marker mode is |
| | Discrete,marker moves to the data point closest to the next right target. |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+
Returns:
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")
search_mode = (
search_mode.value if type(search_mode) is enums.MarkerSearchMode else search_mode
)
updated_selector_string = _helper.validate_and_update_selector_string(
selector_string, self._signal_obj
)
error_code = self._interpreter.marker_marker_search(
updated_selector_string, search_mode
)
finally:
self._session_function_lock.exit_read_lock()
return error_code
[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