Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable nifgen get_fir_filter_coefficients() #891

Merged
merged 13 commits into from
Jun 8, 2018
Merged
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: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 0 additions & 57 deletions docs/nifgen/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down Expand Up @@ -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
~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -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` |
Expand Down
9 changes: 0 additions & 9 deletions generated/nifgen/_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
53 changes: 0 additions & 53 deletions generated/nifgen/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 0 additions & 26 deletions generated/nifgen/unit_tests/_mock_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 6 additions & 6 deletions src/nifgen/metadata/functions_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'}, }, }, },
Expand All @@ -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'}, },
Expand Down Expand Up @@ -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, }, }, },
Expand Down
12 changes: 7 additions & 5 deletions src/nifgen/system_tests/test_system_nifgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should error because the device expected symmetrical coefficients.
I think you need to also enable OSP so that the OSP configuration gets validated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test disabled since OSP disabled, can't check this.

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
'''


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<%page args="function, config, method_template, indent"/>\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you keeping these on purpose because they may be useful in the future?
I'm not sure what the proper way of handling this sort of thing is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am keeping this on purpose. I mentioned that in the PR description. I don't want to lose this knowledge since it isn't obvious how this needs to work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just seems like dead code so there's a risk of it being removed in the future too.

How about removing it but in the issue recording the last commit that contained it to show a solution?

<%
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.





Expand Down
Loading