Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,8 @@
#### [nirfsa] Unreleased
- Added
- (Common) Added `nitlsconfig[grpc]>=1.0.0a2` to the optional gRPC dependencies.
- Added new `enable_calibration_plane` and `disable_calibration_plane` functions.
- Added `calplanes` repeated capability support for `deembedding_selected_table` attribute.
- Changed
- Removed
- Removed invalid enum value `None` from enum `LoSource`
Expand Down
13 changes: 13 additions & 0 deletions build/templates/_converters.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ ${template_parameters['encoding_tag']}
config = template_parameters['metadata'].config
module_name = config['module_name']
extra_errors_used = config['extra_errors_used']
# Drivers that have repeated capabilities but do not generate InvalidRepeatedCapabilityError pass repeated capabilities they cannot parse to the driver as-is
validate_repeated_capabilities = 'InvalidRepeatedCapabilityError' in extra_errors_used or len(config['repeated_capabilities']) == 0
enums = config['enums']
%>\
import ${module_name}._visatype as _visatype
% if any(helper.enum_uses_converter(enums[enum_name]) for enum_name in helper.filter_codegen_enums(enums)):
import ${module_name}.enums as enums
% endif
% if validate_repeated_capabilities:
import ${module_name}.errors as errors
% endif

import array
import collections
Expand Down Expand Up @@ -51,7 +55,11 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811
- (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') -->
['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17']
'''
% if validate_repeated_capabilities:
raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg))
% else:
raise TypeError('Invalid type for a repeated capability: {}'.format(type(arg)))
% endif


@_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811
Expand All @@ -77,9 +85,14 @@ def _(repeated_capability, prefix):
# We remove any prefix and change ':' to '-'
r = repeated_capability.strip().replace(prefix, '').replace(':', '-')
rc = r.split('-')
% if validate_repeated_capabilities:
if len(rc) > 1:
if len(rc) > 2:
raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability)
% else:
# Only a simple range can be expanded. Anything else, such as 'calplane::plane1/port::if1', is returned as-is
if len(rc) == 2:
% endif
try:
start = int(rc[0])
end = int(rc[1])
Expand Down
156 changes: 112 additions & 44 deletions docs/nirfsa/class.rst

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/nirfsa/enums.rst
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ DeembeddingType



De-embeds the measurement using only the gain term.
De-embeds the measurement using only the gain term at center frequency.



Expand All @@ -395,7 +395,7 @@ DeembeddingType



De-embeds the measurement using wideband amplitude flatness correction.
De-embeds the measurement using the gain term across the instantaneous bandwidth of the device.



Expand Down
10 changes: 0 additions & 10 deletions docs/nirfsa/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ DriverTooNewError

An error due to the NI-RFSA driver runtime being too new for this module.

InvalidRepeatedCapabilityError
------------------------------

.. py:currentmodule:: nirfsa.errors

.. exception:: InvalidRepeatedCapabilityError

An error due to an invalid character in a repeated capability


SelfTestError
-------------

Expand Down
26 changes: 26 additions & 0 deletions docs/nirfsa/rep_caps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,30 @@ channels
passes a string of :python:`'0, 1, 2'` to the set attribute function.


calplanes
---------

.. py:attribute:: nirfsa.Session.calplanes[]

If no prefix is added to the items in the parameter, the correct prefix will be added when
the driver function call is made.

.. code:: python

session.calplanes['0-2'].channel_enabled = True

passes a string of :python:`'calplane::0, calplane::1, calplane::2'` to the set attribute function.

If an invalid repeated capability is passed to the driver, the driver will return an error.

You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix
for the specific repeated capability.

.. code:: python

session.calplanes['calplane::0-calplane::2'].channel_enabled = True

passes a string of :python:`'calplane::0, calplane::1, calplane::2'` to the set attribute function.



8 changes: 3 additions & 5 deletions generated/nirfsa/nirfsa/_converters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# This file was generated
import nirfsa._visatype as _visatype
import nirfsa.errors as errors

import array
import collections
Expand Down Expand Up @@ -41,7 +40,7 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811
- (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') -->
['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17']
'''
raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg))
raise TypeError('Invalid type for a repeated capability: {}'.format(type(arg)))


@_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811
Expand All @@ -67,9 +66,8 @@ def _(repeated_capability, prefix):
# We remove any prefix and change ':' to '-'
r = repeated_capability.strip().replace(prefix, '').replace(':', '-')
rc = r.split('-')
if len(rc) > 1:
if len(rc) > 2:
raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability)
# Only a simple range can be expanded. Anything else, such as 'calplane::plane1/port::if1', is returned as-is
if len(rc) == 2:
try:
start = int(rc[0])
end = int(rc[1])
Expand Down
12 changes: 12 additions & 0 deletions generated/nirfsa/nirfsa/_grpc_stub_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ def disable_advance_trigger(self): # noqa: N802
grpc_types.DisableAdvanceTriggerRequest(vi=self._vi),
)

def disable_calibration_plane(self, channel_name): # noqa: N802
self._invoke(
self._client.DisableCalibrationPlane,
grpc_types.DisableCalibrationPlaneRequest(vi=self._vi, channel_name=channel_name),
)

def disable_ref_trigger(self): # noqa: N802
self._invoke(
self._client.DisableRefTrigger,
Expand All @@ -238,6 +244,12 @@ def disable_start_trigger(self): # noqa: N802
grpc_types.DisableStartTriggerRequest(vi=self._vi),
)

def enable_calibration_plane(self, channel_name): # noqa: N802
self._invoke(
self._client.EnableCalibrationPlane,
grpc_types.EnableCalibrationPlaneRequest(vi=self._vi, channel_name=channel_name),
)

def enable_session_access(self, enable): # noqa: N802
self._invoke(
self._client.EnableSessionAccess,
Expand Down
18 changes: 18 additions & 0 deletions generated/nirfsa/nirfsa/_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ def __init__(self, ctypes_library):
self.niRFSA_DeleteAllDeembeddingTables_cfunc = None
self.niRFSA_DeleteDeembeddingTable_cfunc = None
self.niRFSA_DisableAdvanceTrigger_cfunc = None
self.niRFSA_DisableCalibrationPlane_cfunc = None
self.niRFSA_DisableRefTrigger_cfunc = None
self.niRFSA_DisableStartTrigger_cfunc = None
self.niRFSA_EnableCalibrationPlane_cfunc = None
self.niRFSA_EnableSessionAccess_cfunc = None
self.niRFSA_ErrorMessage_cfunc = None
self.niRFSA_FetchIQMultiRecordComplexF32_cfunc = None
Expand Down Expand Up @@ -292,6 +294,14 @@ def niRFSA_DisableAdvanceTrigger(self, vi): # noqa: N802
self.niRFSA_DisableAdvanceTrigger_cfunc.restype = ViStatus # noqa: F405
return self.niRFSA_DisableAdvanceTrigger_cfunc(vi)

def niRFSA_DisableCalibrationPlane(self, vi, channel_name): # noqa: N802
with self._func_lock:
if self.niRFSA_DisableCalibrationPlane_cfunc is None:
self.niRFSA_DisableCalibrationPlane_cfunc = self._get_library_function('niRFSA_DisableCalibrationPlane')
self.niRFSA_DisableCalibrationPlane_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar)] # noqa: F405
self.niRFSA_DisableCalibrationPlane_cfunc.restype = ViStatus # noqa: F405
return self.niRFSA_DisableCalibrationPlane_cfunc(vi, channel_name)

def niRFSA_DisableRefTrigger(self, vi): # noqa: N802
with self._func_lock:
if self.niRFSA_DisableRefTrigger_cfunc is None:
Expand All @@ -308,6 +318,14 @@ def niRFSA_DisableStartTrigger(self, vi): # noqa: N802
self.niRFSA_DisableStartTrigger_cfunc.restype = ViStatus # noqa: F405
return self.niRFSA_DisableStartTrigger_cfunc(vi)

def niRFSA_EnableCalibrationPlane(self, vi, channel_name): # noqa: N802
with self._func_lock:
if self.niRFSA_EnableCalibrationPlane_cfunc is None:
self.niRFSA_EnableCalibrationPlane_cfunc = self._get_library_function('niRFSA_EnableCalibrationPlane')
self.niRFSA_EnableCalibrationPlane_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar)] # noqa: F405
self.niRFSA_EnableCalibrationPlane_cfunc.restype = ViStatus # noqa: F405
return self.niRFSA_EnableCalibrationPlane_cfunc(vi, channel_name)

def niRFSA_EnableSessionAccess(self, vi, enable): # noqa: N802
with self._func_lock:
if self.niRFSA_EnableSessionAccess_cfunc is None:
Expand Down
14 changes: 14 additions & 0 deletions generated/nirfsa/nirfsa/_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ def disable_advance_trigger(self): # noqa: N802
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return

def disable_calibration_plane(self, channel_name): # noqa: N802
vi_ctype = _visatype.ViSession(self._vi) # case S110
channel_name_ctype = ctypes.create_string_buffer(channel_name.encode(self._encoding)) # case C010
error_code = self._library.niRFSA_DisableCalibrationPlane(vi_ctype, channel_name_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return

def disable_ref_trigger(self): # noqa: N802
vi_ctype = _visatype.ViSession(self._vi) # case S110
error_code = self._library.niRFSA_DisableRefTrigger(vi_ctype)
Expand All @@ -290,6 +297,13 @@ def disable_start_trigger(self): # noqa: N802
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return

def enable_calibration_plane(self, channel_name): # noqa: N802
vi_ctype = _visatype.ViSession(self._vi) # case S110
channel_name_ctype = ctypes.create_string_buffer(channel_name.encode(self._encoding)) # case C010
error_code = self._library.niRFSA_EnableCalibrationPlane(vi_ctype, channel_name_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return

def enable_session_access(self, enable): # noqa: N802
vi_ctype = _visatype.ViSession(self._vi) # case S110
enable_ctype = _visatype.ViBoolean(enable) # case S150
Expand Down
4 changes: 2 additions & 2 deletions generated/nirfsa/nirfsa/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ class DeembeddingType(Enum):
'''
SCALAR = 3901
r'''
De-embeds the measurement using only the gain term.
De-embeds the measurement using only the gain term at center frequency.
'''
VECTOR = 3902
r'''
De-embeds the measurement using the gain term and the reflection term.
'''
AMPLITUDE_FLATNESS = 3903
r'''
De-embeds the measurement using wideband amplitude flatness correction.
De-embeds the measurement using the gain term across the instantaneous bandwidth of the device.
'''


Expand Down
7 changes: 0 additions & 7 deletions generated/nirfsa/nirfsa/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ def __init__(self):
super(DriverTooNewError, self).__init__('The NI-RFSA runtime returned an unexpected value. This can occur if it is too new for the nirfsa Python module. Upgrade the nirfsa Python module.')


class InvalidRepeatedCapabilityError(Error):
'''An error due to an invalid character in a repeated capability'''

def __init__(self, invalid_character, invalid_string):
super(InvalidRepeatedCapabilityError, self).__init__('An invalid character ({}) was found in repeated capability string ({})'.format(invalid_character, invalid_string))


class SelfTestError(Error):
'''An error due to a failed self-test'''

Expand Down
Loading
Loading