diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ec40abd..f65db60c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,7 +82,7 @@ All notable changes to this project will be documented in this file. * `configure_digital_edge_script_trigger()` - use `session.digital_edge_script_trigger_source` & `session.digital_edge_script_trigger_edge` * `configure_digital_level_script_trigger()` - use `session.digital_level_script_trigger_source` & `session.digital_level_script_trigger_active_level` * `configure_digital_edge_start_trigger()` - use `session.digital_edge_start_trigger_source` & `session.digital_edge_start_trigger_edge` - * Removed `send_software_edge_trigger()` - [#850](https://github.com/ni/nimi-python/issues/850) + * Removed `get_fir_filter_coefficients()` - [#535](https://github.com/ni/nimi-python/issues/535), [#596](https://github.com/ni/nimi-python/issues/596) * ### NI-SCOPE * #### Added * `niscope_fetch_forever.py` example diff --git a/docs/nifgen/class.rst b/docs/nifgen/class.rst index fcf47e044..d329bb64c 100644 --- a/docs/nifgen/class.rst +++ b/docs/nifgen/class.rst @@ -434,8 +434,6 @@ nifgen.Session +-----------------------------------------------------+ | :py:func:`get_ext_cal_recommended_interval` | +-----------------------------------------------------+ - | :py:func:`get_fir_filter_coefficients` | - +-----------------------------------------------------+ | :py:func:`get_hardware_state` | +-----------------------------------------------------+ | :py:func:`get_self_cal_last_date_and_time` | @@ -5656,59 +5654,6 @@ get_ext_cal_recommended_interval -get_fir_filter_coefficients -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - .. py:currentmodule:: nifgen.Session - - .. py:method:: get_fir_filter_coefficients() - - | Returns the FIR filter coefficients used by the onboard signal - processing block. These coefficients are determined by NI-FGEN and - based on the FIR filter type and corresponding property (Alpha, - Passband, BT) unless you are using the custom filter. If you are using - a custom filter, the coefficients returned are those set with the - :py:meth:`nifgen.Session.configure_custom_fir_filter_coefficients` method coerced to the - quantized values used by the device. - | To use this method, first call an instance of the - :py:meth:`nifgen.Session.get_fir_filter_coefficients` method with the - **coefficientsArray** parameter set to VI_NULL. Calling the method - in this state returns the current size of the **coefficientsArray** as - the value of the **numberOfCoefficientsRead** parameter. Create an - array of this size, and call the :py:meth:`nifgen.Session.get_fir_filter_coefficients` - method a second time, passing the new array as the - **coefficientsArray** parameter and the size as the **arraySize** - parameter. This second method call populates the array with the FIR - filter coefficients. - | Refer to the FIR Filter topic for your device in the *NI Signal - Generators Help* for more information about FIR filter coefficients. - This method is supported only for the NI 5441. - | **Default Value**: None - - - - - .. tip:: This method requires repeated capabilities (channels). If called directly on the - nifgen.Session object, then the method will use all repeated capabilities in the session. - You can specify a subset of repeated capabilities using the Python index notation on an - nifgen.Session repeated capabilities container, and calling this method on the result.: - - .. code:: python - - session.channels[0,1].get_fir_filter_coefficients() - - - :rtype: int - :return: - - - Specifies the array of data containing the number of coefficients you - want to read. - - - - - get_hardware_state ~~~~~~~~~~~~~~~~~~ @@ -6730,8 +6675,6 @@ Methods +--------------------------------------------------------------------+ | :py:func:`nifgen.Session.get_ext_cal_recommended_interval` | +--------------------------------------------------------------------+ -| :py:func:`nifgen.Session.get_fir_filter_coefficients` | -+--------------------------------------------------------------------+ | :py:func:`nifgen.Session.get_hardware_state` | +--------------------------------------------------------------------+ | :py:func:`nifgen.Session.get_self_cal_last_date_and_time` | diff --git a/generated/nifgen/_library.py b/generated/nifgen/_library.py index 7b837beef..a7c107ae0 100644 --- a/generated/nifgen/_library.py +++ b/generated/nifgen/_library.py @@ -50,7 +50,6 @@ def __init__(self, ctypes_library): self.niFgen_GetExtCalLastDateAndTime_cfunc = None self.niFgen_GetExtCalLastTemp_cfunc = None self.niFgen_GetExtCalRecommendedInterval_cfunc = None - self.niFgen_GetFIRFilterCoefficients_cfunc = None self.niFgen_GetHardwareState_cfunc = None self.niFgen_GetLastExtCalLastDateAndTime_cfunc = None self.niFgen_GetLastSelfCalLastDateAndTime_cfunc = None @@ -350,14 +349,6 @@ def niFgen_GetExtCalRecommendedInterval(self, vi, months): # noqa: N802 self.niFgen_GetExtCalRecommendedInterval_cfunc.restype = ViStatus # noqa: F405 return self.niFgen_GetExtCalRecommendedInterval_cfunc(vi, months) - def niFgen_GetFIRFilterCoefficients(self, vi, channel_name, array_size, coefficients_array, number_of_coefficients_read): # noqa: N802 - with self._func_lock: - if self.niFgen_GetFIRFilterCoefficients_cfunc is None: - self.niFgen_GetFIRFilterCoefficients_cfunc = self._library.niFgen_GetFIRFilterCoefficients - self.niFgen_GetFIRFilterCoefficients_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar), ViInt32, ctypes.POINTER(ViReal64), ctypes.POINTER(ViInt32)] # noqa: F405 - self.niFgen_GetFIRFilterCoefficients_cfunc.restype = ViStatus # noqa: F405 - return self.niFgen_GetFIRFilterCoefficients_cfunc(vi, channel_name, array_size, coefficients_array, number_of_coefficients_read) - def niFgen_GetHardwareState(self, vi, state): # noqa: N802 with self._func_lock: if self.niFgen_GetHardwareState_cfunc is None: diff --git a/generated/nifgen/session.py b/generated/nifgen/session.py index 2ef3b03d9..1bc002f4d 100644 --- a/generated/nifgen/session.py +++ b/generated/nifgen/session.py @@ -2124,59 +2124,6 @@ def _get_error(self): errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=True) return int(error_code_ctype.value), error_description_ctype.value.decode(self._encoding) - @ivi_synchronized - def get_fir_filter_coefficients(self): - '''get_fir_filter_coefficients - - | Returns the FIR filter coefficients used by the onboard signal - processing block. These coefficients are determined by NI-FGEN and - based on the FIR filter type and corresponding property (Alpha, - Passband, BT) unless you are using the custom filter. If you are using - a custom filter, the coefficients returned are those set with the - configure_custom_fir_filter_coefficients method coerced to the - quantized values used by the device. - | To use this method, first call an instance of the - get_fir_filter_coefficients method with the - **coefficientsArray** parameter set to VI_NULL. Calling the method - in this state returns the current size of the **coefficientsArray** as - the value of the **numberOfCoefficientsRead** parameter. Create an - array of this size, and call the get_fir_filter_coefficients - method a second time, passing the new array as the - **coefficientsArray** parameter and the size as the **arraySize** - parameter. This second method call populates the array with the FIR - filter coefficients. - | Refer to the FIR Filter topic for your device in the *NI Signal - Generators Help* for more information about FIR filter coefficients. - This method is supported only for the NI 5441. - | **Default Value**: None - - Tip: - This method requires repeated capabilities (channels). If called directly on the - nifgen.Session object, then the method will use all repeated capabilities in the session. - You can specify a subset of repeated capabilities using the Python index notation on an - nifgen.Session repeated capabilities container, and calling this method on the result.: - - session.channels[0,1].get_fir_filter_coefficients() - - Returns: - number_of_coefficients_read (int): Specifies the array of data containing the number of coefficients you - want to read. - - ''' - vi_ctype = _visatype.ViSession(self._vi) # case S110 - channel_name_ctype = ctypes.create_string_buffer(self._repeated_capability.encode(self._encoding)) # case C010 - array_size_ctype = _visatype.ViInt32() # case S170 - coefficients_array_ctype = None # case B580 - number_of_coefficients_read_ctype = _visatype.ViInt32() # case S200 - error_code = self._library.niFgen_GetFIRFilterCoefficients(vi_ctype, channel_name_ctype, array_size_ctype, coefficients_array_ctype, None if number_of_coefficients_read_ctype is None else (ctypes.pointer(number_of_coefficients_read_ctype))) - errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False) - array_size_ctype = _visatype.ViInt32(error_code) # case S180 - coefficients_array_size = array_size_ctype.value # case B590 - coefficients_array_ctype = get_ctypes_pointer_for_buffer(library_type=_visatype.ViReal64, size=coefficients_array_size) # case B590 - error_code = self._library.niFgen_GetFIRFilterCoefficients(vi_ctype, channel_name_ctype, array_size_ctype, coefficients_array_ctype, None if number_of_coefficients_read_ctype is None else (ctypes.pointer(number_of_coefficients_read_ctype))) - errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) - return [float(coefficients_array_ctype[i]) for i in range(array_size_ctype.value)], int(number_of_coefficients_read_ctype.value) - def lock(self): '''lock diff --git a/generated/nifgen/unit_tests/_mock_helper.py b/generated/nifgen/unit_tests/_mock_helper.py index a9cc57c7d..f93d189c1 100644 --- a/generated/nifgen/unit_tests/_mock_helper.py +++ b/generated/nifgen/unit_tests/_mock_helper.py @@ -103,10 +103,6 @@ def __init__(self): self._defaults['GetExtCalRecommendedInterval'] = {} self._defaults['GetExtCalRecommendedInterval']['return'] = 0 self._defaults['GetExtCalRecommendedInterval']['Months'] = None - self._defaults['GetFIRFilterCoefficients'] = {} - self._defaults['GetFIRFilterCoefficients']['return'] = 0 - self._defaults['GetFIRFilterCoefficients']['numberOfCoefficientsRead'] = None - self._defaults['GetFIRFilterCoefficients']['coefficientsArray'] = None self._defaults['GetHardwareState'] = {} self._defaults['GetHardwareState']['return'] = 0 self._defaults['GetHardwareState']['state'] = None @@ -495,26 +491,6 @@ def niFgen_GetExtCalRecommendedInterval(self, vi, months): # noqa: N802 months.contents.value = self._defaults['GetExtCalRecommendedInterval']['Months'] return self._defaults['GetExtCalRecommendedInterval']['return'] - def niFgen_GetFIRFilterCoefficients(self, vi, channel_name, array_size, coefficients_array, number_of_coefficients_read): # noqa: N802 - if self._defaults['GetFIRFilterCoefficients']['return'] != 0: - return self._defaults['GetFIRFilterCoefficients']['return'] - # number_of_coefficients_read - if self._defaults['GetFIRFilterCoefficients']['numberOfCoefficientsRead'] is None: - raise MockFunctionCallError("niFgen_GetFIRFilterCoefficients", param='numberOfCoefficientsRead') - if number_of_coefficients_read is not None: - number_of_coefficients_read.contents.value = self._defaults['GetFIRFilterCoefficients']['numberOfCoefficientsRead'] - if self._defaults['GetFIRFilterCoefficients']['coefficientsArray'] is None: - raise MockFunctionCallError("niFgen_GetFIRFilterCoefficients", param='coefficientsArray') - if array_size.value == 0: - return len(self._defaults['GetFIRFilterCoefficients']['coefficientsArray']) - try: - coefficients_array_ref = coefficients_array.contents - except AttributeError: - coefficients_array_ref = coefficients_array - for i in range(len(self._defaults['GetFIRFilterCoefficients']['coefficientsArray'])): - coefficients_array_ref[i] = self._defaults['GetFIRFilterCoefficients']['coefficientsArray'][i] - return self._defaults['GetFIRFilterCoefficients']['return'] - def niFgen_GetHardwareState(self, vi, state): # noqa: N802 if self._defaults['GetHardwareState']['return'] != 0: return self._defaults['GetHardwareState']['return'] @@ -921,8 +897,6 @@ def set_side_effects_and_return_values(self, mock_library): mock_library.niFgen_GetExtCalLastTemp.return_value = 0 mock_library.niFgen_GetExtCalRecommendedInterval.side_effect = MockFunctionCallError("niFgen_GetExtCalRecommendedInterval") mock_library.niFgen_GetExtCalRecommendedInterval.return_value = 0 - mock_library.niFgen_GetFIRFilterCoefficients.side_effect = MockFunctionCallError("niFgen_GetFIRFilterCoefficients") - mock_library.niFgen_GetFIRFilterCoefficients.return_value = 0 mock_library.niFgen_GetHardwareState.side_effect = MockFunctionCallError("niFgen_GetHardwareState") mock_library.niFgen_GetHardwareState.return_value = 0 mock_library.niFgen_GetLastExtCalLastDateAndTime.side_effect = MockFunctionCallError("niFgen_GetLastExtCalLastDateAndTime") diff --git a/src/nifgen/metadata/functions_addon.py b/src/nifgen/metadata/functions_addon.py index 1813a5db3..9a230a2bb 100644 --- a/src/nifgen/metadata/functions_addon.py +++ b/src/nifgen/metadata/functions_addon.py @@ -60,6 +60,7 @@ 'revision_query': { 'codegen_method': 'no', }, '.+Complex.+': { 'codegen_method': 'no', }, 'GetStreamEndpointHandle': { 'codegen_method': 'no', }, + 'GetFIRFilterCoefficients': { 'codegen_method': 'no', }, # Removed - applies to OSP only #596 - If this is removed, the commented out snippet below needs to be added back to templates to use 'AdjustSampleClockRelativeDelay': { 'codegen_method': 'no', }, # This is used internally by NI-TClk, but not by end users. '.etAttributeViInt64': { 'codegen_method': 'no', }, # NI-FGEN has no ViInt64 attributes. 'GetExtCalLastDateAndTime': { 'codegen_method': 'private', 'method_name_for_documentation': 'get_ext_cal_last_date_and_time', }, # 'GetLastExtCalLastDateAndTime' Public wrapper to allow datetime @@ -102,11 +103,6 @@ 'SendSoftwareEdgeTrigger': { 'parameters': { 1: { 'enum': 'Trigger', }, }, }, # TODO: issue #538 } -functions_issues = { - 'GetFIRFilterCoefficients': { 'parameters': { 3: { 'direction':'out'}, # TODO(marcoskirsch): Remove when #534 solved - 4: { 'direction':'out', 'is_buffer': False, 'type':'ViInt32', }, }, }, -} - # This is the additional metadata needed by the code generator in order create code that can properly handle buffer allocation. functions_buffer_info = { 'GetError': { 'parameters': { 3: { 'size': {'mechanism':'ivi-dance', 'value':'errorDescriptionBufferSize'}, }, }, }, @@ -117,7 +113,6 @@ 'ConfigureCustomFIRFilterCoefficients': { 'parameters': { 3: { 'size': {'mechanism':'len', 'value':'numberOfCoefficients'}, }, }, }, 'CreateWaveform(I16|F64)': { 'parameters': { 3: { 'size': {'mechanism':'len', 'value':'waveformSize'}, }, }, }, 'DefineUserStandardWaveform': { 'parameters': { 3: { 'size': {'mechanism':'len', 'value':'waveformSize'}, }, }, }, - 'GetFIRFilterCoefficients': { 'parameters': { 3: { 'size': {'mechanism':'ivi-dance', 'value':'arraySize'}, }, }, }, # TODO(marcoskirsch): #537 'Write.*Waveform': { 'parameters': { 4: { 'size': {'mechanism':'len', 'value':'Size'}, }, }, }, 'CreateAdvancedArbSequence': { 'parameters': { 2: { 'size': {'mechanism':'len', 'value':'sequenceLength'}, }, 3: { 'size': {'mechanism':'len', 'value':'sequenceLength'}, }, @@ -504,6 +499,11 @@ ], }, } +# We keep this information because we will need it again if we ever enable OSP and need this function +# 'GetFIRFilterCoefficients': { 'method_templates': [ +# { 'session_filename': 'get_fir_filter_coefficients', 'documentation_filename': 'get_fir_filter_coefficients', 'method_python_name_suffix': '', }, +# ], }, + functions_numpy = { 'CreateWaveformF64': { 'parameters': { 3: { 'numpy': True, }, }, }, 'CreateWaveformI16': { 'parameters': { 3: { 'numpy': True, }, }, }, diff --git a/src/nifgen/system_tests/test_system_nifgen.py b/src/nifgen/system_tests/test_system_nifgen.py index 0a889bf05..ed3a55bc2 100644 --- a/src/nifgen/system_tests/test_system_nifgen.py +++ b/src/nifgen/system_tests/test_system_nifgen.py @@ -388,15 +388,17 @@ def test_user_standard_waveform(session): session.clear_user_standard_waveform() -# TODO(bhaswath): Doesn't work, issue #596 -''' +''' Removed due to OSP disabled - #891 def test_fir_filter_coefficients(): with nifgen.Session('', '0', False, 'Simulate=1, DriverSetup=Model:5441;BoardType:PXI') as session: - coeff_array = [1, 0, -1] + coeff_array = [0 for i in range(95)] + coeff_array[0] = -1.0 + coeff_array[2] = 1.0 session.configure_custom_fir_filter_coefficients(coeff_array) session.commit() - array, size = session.get_fir_filter_coefficients() - assert size == len(coeff_array) + array = session.get_fir_filter_coefficients() + assert len(array) == len(coeff_array) + assert array == coeff_array ''' diff --git a/src/nifgen/templates/functions.rst/get_fir_filter_coefficients.rst.mako b/src/nifgen/templates/functions.rst/get_fir_filter_coefficients.rst.mako new file mode 100644 index 000000000..9da3f6274 --- /dev/null +++ b/src/nifgen/templates/functions.rst/get_fir_filter_coefficients.rst.mako @@ -0,0 +1,43 @@ +<%page args="function, config, method_template, indent"/>\ +<% + import build.helper as helper + # This file is not currently used - will be enabled when OSP is enabled. +%>\ + .. py:method:: get_fir_filter_coefficients() + + | Returns the FIR filter coefficients used by the onboard signal + processing block. These coefficients are determined by NI-FGEN and + based on the FIR filter type and corresponding property (Alpha, + Passband, BT) unless you are using the custom filter. If you are using + a custom filter, the coefficients returned are those set with the + :py:meth:`nifgen.Session.configure_custom_fir_filter_coefficients` method coerced to the + quantized values used by the device. + | Refer to the FIR Filter topic for your device in the *NI Signal + Generators Help* for more information about FIR filter coefficients. + This method is supported only for the NI 5441. + + + .. tip:: This method requires repeated capabilities (channels). If called directly on the + nifgen.Session object, then the method will use all repeated capabilities in the session. + You can specify a subset of repeated capabilities using the Python index notation on an + nifgen.Session instance, and calling this method on the result.: + + .. code:: python + + session.channels[0,1].get_fir_filter_coefficients(array_size, number_of_coefficients_read) + + + :rtype: list of float + :return: + + + Specifies the array of data the onboard signal processor uses for the + FIR filter coefficients. For the NI 5441, provide a symmetric array of + 95 coefficients to this parameter. + + The coefficients should range between -1.00 and +1.00. + + + + + diff --git a/src/nifgen/templates/session.py/get_fir_filter_coefficients.py.mako b/src/nifgen/templates/session.py/get_fir_filter_coefficients.py.mako new file mode 100644 index 000000000..1b8f5f7a6 --- /dev/null +++ b/src/nifgen/templates/session.py/get_fir_filter_coefficients.py.mako @@ -0,0 +1,49 @@ +<%page args="f, config"/>\ +<% + '''Special implementation of get_fir_filter_coefficients(). Not quite IVI-dance since the size is returned in an out parameter instead of the error_code''' + import build.helper as helper + # This file is not currently used - will be enabled when OSP is enabled. +%>\ + def get_fir_filter_coefficients(self): + '''get_fir_filter_coefficients + + | Returns the FIR filter coefficients used by the onboard signal + processing block. These coefficients are determined by NI-FGEN and + based on the FIR filter type and corresponding property (Alpha, + Passband, BT) unless you are using the custom filter. If you are using + a custom filter, the coefficients returned are those set with the + configure_custom_fir_filter_coefficients method coerced to the + quantized values used by the device. + | Refer to the FIR Filter topic for your device in the *NI Signal + Generators Help* for more information about FIR filter coefficients. + This method is supported only for the NI 5441. + + Tip: + This method requires repeated capabilities (channels). If called directly on the + nifgen.Session object, then the method will use all repeated capabilities in the session. + You can specify a subset of repeated capabilities using the Python index notation on an + nifgen.Session instance, and calling this method on the result.: + + session.channels[0,1].get_fir_filter_coefficients() + + Returns: + coefficients_array (list of float): Specifies the array of data the onboard signal processor uses for the + FIR filter coefficients. For the NI 5441, provide a symmetric array of + 95 coefficients to this parameter. + + The coefficients should range between -1.00 and +1.00. + ''' + vi_ctype = _visatype.ViSession(self._vi) # case S110 + channel_name_ctype = ctypes.create_string_buffer(self._repeated_capability.encode(self._encoding)) # case C010 + array_size_ctype = _visatype.ViInt32() # case S170 + coefficients_array_ctype = None # case B580 + number_of_coefficients_read_ctype = _visatype.ViInt32() # case S200 + error_code = self._library.niFgen_GetFIRFilterCoefficients(vi_ctype, channel_name_ctype, array_size_ctype, coefficients_array_ctype, ctypes.pointer(number_of_coefficients_read_ctype)) + errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) + array_size_ctype = _visatype.ViInt32(number_of_coefficients_read_ctype.value) # special case + coefficients_array_size = array_size_ctype.value # case B590 + coefficients_array_ctype = get_ctypes_pointer_for_buffer(library_type=_visatype.ViReal64, size=coefficients_array_size) # case B590 + error_code = self._library.niFgen_GetFIRFilterCoefficients(vi_ctype, channel_name_ctype, array_size_ctype, coefficients_array_ctype, ctypes.pointer(number_of_coefficients_read_ctype)) + errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) + return [float(coefficients_array_ctype[i]) for i in range(array_size_ctype.value)] +