Skip to content

Commit 92734b9

Browse files
texasaggie97-zzmarcoskirsch
authored andcommitted
Disable nifgen get_fir_filter_coefficients() (#891)
* Add specific implementation for get_fir_filter_coefficients() Is not like the rest of the ivi-dance functions Not worth torqueing the code generator around to support this one use case * Enable and fix get_fir_filter_coefficients test * Don't try to use generated documentation * Don't ise generated documentation * Update generated files * Update changelog * Disable get_fir_filter_coefficients() * Update changelog * Update generated files * Disable get_fir_filter_coefficients() test * Update comments to be explicit about applying only once OSP supported
1 parent 434b281 commit 92734b9

File tree

9 files changed

+106
-157
lines changed

9 files changed

+106
-157
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ All notable changes to this project will be documented in this file.
8282
* `configure_digital_edge_script_trigger()` - use `session.digital_edge_script_trigger_source` & `session.digital_edge_script_trigger_edge`
8383
* `configure_digital_level_script_trigger()` - use `session.digital_level_script_trigger_source` & `session.digital_level_script_trigger_active_level`
8484
* `configure_digital_edge_start_trigger()` - use `session.digital_edge_start_trigger_source` & `session.digital_edge_start_trigger_edge`
85-
* Removed `send_software_edge_trigger()` - [#850](https://github.com/ni/nimi-python/issues/850)
85+
* Removed `get_fir_filter_coefficients()` - [#535](https://github.com/ni/nimi-python/issues/535), [#596](https://github.com/ni/nimi-python/issues/596)
8686
* ### NI-SCOPE
8787
* #### Added
8888
* `niscope_fetch_forever.py` example

docs/nifgen/class.rst

-57
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ nifgen.Session
434434
+-----------------------------------------------------+
435435
| :py:func:`get_ext_cal_recommended_interval` |
436436
+-----------------------------------------------------+
437-
| :py:func:`get_fir_filter_coefficients` |
438-
+-----------------------------------------------------+
439437
| :py:func:`get_hardware_state` |
440438
+-----------------------------------------------------+
441439
| :py:func:`get_self_cal_last_date_and_time` |
@@ -5656,59 +5654,6 @@ get_ext_cal_recommended_interval
56565654
56575655
56585656
5659-
get_fir_filter_coefficients
5660-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5661-
5662-
.. py:currentmodule:: nifgen.Session
5663-
5664-
.. py:method:: get_fir_filter_coefficients()
5665-
5666-
| Returns the FIR filter coefficients used by the onboard signal
5667-
processing block. These coefficients are determined by NI-FGEN and
5668-
based on the FIR filter type and corresponding property (Alpha,
5669-
Passband, BT) unless you are using the custom filter. If you are using
5670-
a custom filter, the coefficients returned are those set with the
5671-
:py:meth:`nifgen.Session.configure_custom_fir_filter_coefficients` method coerced to the
5672-
quantized values used by the device.
5673-
| To use this method, first call an instance of the
5674-
:py:meth:`nifgen.Session.get_fir_filter_coefficients` method with the
5675-
**coefficientsArray** parameter set to VI_NULL. Calling the method
5676-
in this state returns the current size of the **coefficientsArray** as
5677-
the value of the **numberOfCoefficientsRead** parameter. Create an
5678-
array of this size, and call the :py:meth:`nifgen.Session.get_fir_filter_coefficients`
5679-
method a second time, passing the new array as the
5680-
**coefficientsArray** parameter and the size as the **arraySize**
5681-
parameter. This second method call populates the array with the FIR
5682-
filter coefficients.
5683-
| Refer to the FIR Filter topic for your device in the *NI Signal
5684-
Generators Help* for more information about FIR filter coefficients.
5685-
This method is supported only for the NI 5441.
5686-
| **Default Value**: None
5687-
5688-
5689-
5690-
5691-
.. tip:: This method requires repeated capabilities (channels). If called directly on the
5692-
nifgen.Session object, then the method will use all repeated capabilities in the session.
5693-
You can specify a subset of repeated capabilities using the Python index notation on an
5694-
nifgen.Session repeated capabilities container, and calling this method on the result.:
5695-
5696-
.. code:: python
5697-
5698-
session.channels[0,1].get_fir_filter_coefficients()
5699-
5700-
5701-
:rtype: int
5702-
:return:
5703-
5704-
5705-
Specifies the array of data containing the number of coefficients you
5706-
want to read.
5707-
5708-
5709-
5710-
5711-
57125657
get_hardware_state
57135658
~~~~~~~~~~~~~~~~~~
57145659

@@ -6730,8 +6675,6 @@ Methods
67306675
+--------------------------------------------------------------------+
67316676
| :py:func:`nifgen.Session.get_ext_cal_recommended_interval` |
67326677
+--------------------------------------------------------------------+
6733-
| :py:func:`nifgen.Session.get_fir_filter_coefficients` |
6734-
+--------------------------------------------------------------------+
67356678
| :py:func:`nifgen.Session.get_hardware_state` |
67366679
+--------------------------------------------------------------------+
67376680
| :py:func:`nifgen.Session.get_self_cal_last_date_and_time` |

generated/nifgen/_library.py

-9
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def __init__(self, ctypes_library):
5050
self.niFgen_GetExtCalLastDateAndTime_cfunc = None
5151
self.niFgen_GetExtCalLastTemp_cfunc = None
5252
self.niFgen_GetExtCalRecommendedInterval_cfunc = None
53-
self.niFgen_GetFIRFilterCoefficients_cfunc = None
5453
self.niFgen_GetHardwareState_cfunc = None
5554
self.niFgen_GetLastExtCalLastDateAndTime_cfunc = None
5655
self.niFgen_GetLastSelfCalLastDateAndTime_cfunc = None
@@ -350,14 +349,6 @@ def niFgen_GetExtCalRecommendedInterval(self, vi, months): # noqa: N802
350349
self.niFgen_GetExtCalRecommendedInterval_cfunc.restype = ViStatus # noqa: F405
351350
return self.niFgen_GetExtCalRecommendedInterval_cfunc(vi, months)
352351

353-
def niFgen_GetFIRFilterCoefficients(self, vi, channel_name, array_size, coefficients_array, number_of_coefficients_read): # noqa: N802
354-
with self._func_lock:
355-
if self.niFgen_GetFIRFilterCoefficients_cfunc is None:
356-
self.niFgen_GetFIRFilterCoefficients_cfunc = self._library.niFgen_GetFIRFilterCoefficients
357-
self.niFgen_GetFIRFilterCoefficients_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar), ViInt32, ctypes.POINTER(ViReal64), ctypes.POINTER(ViInt32)] # noqa: F405
358-
self.niFgen_GetFIRFilterCoefficients_cfunc.restype = ViStatus # noqa: F405
359-
return self.niFgen_GetFIRFilterCoefficients_cfunc(vi, channel_name, array_size, coefficients_array, number_of_coefficients_read)
360-
361352
def niFgen_GetHardwareState(self, vi, state): # noqa: N802
362353
with self._func_lock:
363354
if self.niFgen_GetHardwareState_cfunc is None:

generated/nifgen/session.py

-53
Original file line numberDiff line numberDiff line change
@@ -2124,59 +2124,6 @@ def _get_error(self):
21242124
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=True)
21252125
return int(error_code_ctype.value), error_description_ctype.value.decode(self._encoding)
21262126

2127-
@ivi_synchronized
2128-
def get_fir_filter_coefficients(self):
2129-
'''get_fir_filter_coefficients
2130-
2131-
| Returns the FIR filter coefficients used by the onboard signal
2132-
processing block. These coefficients are determined by NI-FGEN and
2133-
based on the FIR filter type and corresponding property (Alpha,
2134-
Passband, BT) unless you are using the custom filter. If you are using
2135-
a custom filter, the coefficients returned are those set with the
2136-
configure_custom_fir_filter_coefficients method coerced to the
2137-
quantized values used by the device.
2138-
| To use this method, first call an instance of the
2139-
get_fir_filter_coefficients method with the
2140-
**coefficientsArray** parameter set to VI_NULL. Calling the method
2141-
in this state returns the current size of the **coefficientsArray** as
2142-
the value of the **numberOfCoefficientsRead** parameter. Create an
2143-
array of this size, and call the get_fir_filter_coefficients
2144-
method a second time, passing the new array as the
2145-
**coefficientsArray** parameter and the size as the **arraySize**
2146-
parameter. This second method call populates the array with the FIR
2147-
filter coefficients.
2148-
| Refer to the FIR Filter topic for your device in the *NI Signal
2149-
Generators Help* for more information about FIR filter coefficients.
2150-
This method is supported only for the NI 5441.
2151-
| **Default Value**: None
2152-
2153-
Tip:
2154-
This method requires repeated capabilities (channels). If called directly on the
2155-
nifgen.Session object, then the method will use all repeated capabilities in the session.
2156-
You can specify a subset of repeated capabilities using the Python index notation on an
2157-
nifgen.Session repeated capabilities container, and calling this method on the result.:
2158-
2159-
session.channels[0,1].get_fir_filter_coefficients()
2160-
2161-
Returns:
2162-
number_of_coefficients_read (int): Specifies the array of data containing the number of coefficients you
2163-
want to read.
2164-
2165-
'''
2166-
vi_ctype = _visatype.ViSession(self._vi) # case S110
2167-
channel_name_ctype = ctypes.create_string_buffer(self._repeated_capability.encode(self._encoding)) # case C010
2168-
array_size_ctype = _visatype.ViInt32() # case S170
2169-
coefficients_array_ctype = None # case B580
2170-
number_of_coefficients_read_ctype = _visatype.ViInt32() # case S200
2171-
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)))
2172-
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False)
2173-
array_size_ctype = _visatype.ViInt32(error_code) # case S180
2174-
coefficients_array_size = array_size_ctype.value # case B590
2175-
coefficients_array_ctype = get_ctypes_pointer_for_buffer(library_type=_visatype.ViReal64, size=coefficients_array_size) # case B590
2176-
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)))
2177-
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
2178-
return [float(coefficients_array_ctype[i]) for i in range(array_size_ctype.value)], int(number_of_coefficients_read_ctype.value)
2179-
21802127
def lock(self):
21812128
'''lock
21822129

generated/nifgen/unit_tests/_mock_helper.py

-26
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ def __init__(self):
103103
self._defaults['GetExtCalRecommendedInterval'] = {}
104104
self._defaults['GetExtCalRecommendedInterval']['return'] = 0
105105
self._defaults['GetExtCalRecommendedInterval']['Months'] = None
106-
self._defaults['GetFIRFilterCoefficients'] = {}
107-
self._defaults['GetFIRFilterCoefficients']['return'] = 0
108-
self._defaults['GetFIRFilterCoefficients']['numberOfCoefficientsRead'] = None
109-
self._defaults['GetFIRFilterCoefficients']['coefficientsArray'] = None
110106
self._defaults['GetHardwareState'] = {}
111107
self._defaults['GetHardwareState']['return'] = 0
112108
self._defaults['GetHardwareState']['state'] = None
@@ -495,26 +491,6 @@ def niFgen_GetExtCalRecommendedInterval(self, vi, months): # noqa: N802
495491
months.contents.value = self._defaults['GetExtCalRecommendedInterval']['Months']
496492
return self._defaults['GetExtCalRecommendedInterval']['return']
497493

498-
def niFgen_GetFIRFilterCoefficients(self, vi, channel_name, array_size, coefficients_array, number_of_coefficients_read): # noqa: N802
499-
if self._defaults['GetFIRFilterCoefficients']['return'] != 0:
500-
return self._defaults['GetFIRFilterCoefficients']['return']
501-
# number_of_coefficients_read
502-
if self._defaults['GetFIRFilterCoefficients']['numberOfCoefficientsRead'] is None:
503-
raise MockFunctionCallError("niFgen_GetFIRFilterCoefficients", param='numberOfCoefficientsRead')
504-
if number_of_coefficients_read is not None:
505-
number_of_coefficients_read.contents.value = self._defaults['GetFIRFilterCoefficients']['numberOfCoefficientsRead']
506-
if self._defaults['GetFIRFilterCoefficients']['coefficientsArray'] is None:
507-
raise MockFunctionCallError("niFgen_GetFIRFilterCoefficients", param='coefficientsArray')
508-
if array_size.value == 0:
509-
return len(self._defaults['GetFIRFilterCoefficients']['coefficientsArray'])
510-
try:
511-
coefficients_array_ref = coefficients_array.contents
512-
except AttributeError:
513-
coefficients_array_ref = coefficients_array
514-
for i in range(len(self._defaults['GetFIRFilterCoefficients']['coefficientsArray'])):
515-
coefficients_array_ref[i] = self._defaults['GetFIRFilterCoefficients']['coefficientsArray'][i]
516-
return self._defaults['GetFIRFilterCoefficients']['return']
517-
518494
def niFgen_GetHardwareState(self, vi, state): # noqa: N802
519495
if self._defaults['GetHardwareState']['return'] != 0:
520496
return self._defaults['GetHardwareState']['return']
@@ -921,8 +897,6 @@ def set_side_effects_and_return_values(self, mock_library):
921897
mock_library.niFgen_GetExtCalLastTemp.return_value = 0
922898
mock_library.niFgen_GetExtCalRecommendedInterval.side_effect = MockFunctionCallError("niFgen_GetExtCalRecommendedInterval")
923899
mock_library.niFgen_GetExtCalRecommendedInterval.return_value = 0
924-
mock_library.niFgen_GetFIRFilterCoefficients.side_effect = MockFunctionCallError("niFgen_GetFIRFilterCoefficients")
925-
mock_library.niFgen_GetFIRFilterCoefficients.return_value = 0
926900
mock_library.niFgen_GetHardwareState.side_effect = MockFunctionCallError("niFgen_GetHardwareState")
927901
mock_library.niFgen_GetHardwareState.return_value = 0
928902
mock_library.niFgen_GetLastExtCalLastDateAndTime.side_effect = MockFunctionCallError("niFgen_GetLastExtCalLastDateAndTime")

src/nifgen/metadata/functions_addon.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
'revision_query': { 'codegen_method': 'no', },
6161
'.+Complex.+': { 'codegen_method': 'no', },
6262
'GetStreamEndpointHandle': { 'codegen_method': 'no', },
63+
'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
6364
'AdjustSampleClockRelativeDelay': { 'codegen_method': 'no', }, # This is used internally by NI-TClk, but not by end users.
6465
'.etAttributeViInt64': { 'codegen_method': 'no', }, # NI-FGEN has no ViInt64 attributes.
6566
'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 @@
102103
'SendSoftwareEdgeTrigger': { 'parameters': { 1: { 'enum': 'Trigger', }, }, }, # TODO: issue #538
103104
}
104105

105-
functions_issues = {
106-
'GetFIRFilterCoefficients': { 'parameters': { 3: { 'direction':'out'}, # TODO(marcoskirsch): Remove when #534 solved
107-
4: { 'direction':'out', 'is_buffer': False, 'type':'ViInt32', }, }, },
108-
}
109-
110106
# This is the additional metadata needed by the code generator in order create code that can properly handle buffer allocation.
111107
functions_buffer_info = {
112108
'GetError': { 'parameters': { 3: { 'size': {'mechanism':'ivi-dance', 'value':'errorDescriptionBufferSize'}, }, }, },
@@ -117,7 +113,6 @@
117113
'ConfigureCustomFIRFilterCoefficients': { 'parameters': { 3: { 'size': {'mechanism':'len', 'value':'numberOfCoefficients'}, }, }, },
118114
'CreateWaveform(I16|F64)': { 'parameters': { 3: { 'size': {'mechanism':'len', 'value':'waveformSize'}, }, }, },
119115
'DefineUserStandardWaveform': { 'parameters': { 3: { 'size': {'mechanism':'len', 'value':'waveformSize'}, }, }, },
120-
'GetFIRFilterCoefficients': { 'parameters': { 3: { 'size': {'mechanism':'ivi-dance', 'value':'arraySize'}, }, }, }, # TODO(marcoskirsch): #537
121116
'Write.*Waveform': { 'parameters': { 4: { 'size': {'mechanism':'len', 'value':'Size'}, }, }, },
122117
'CreateAdvancedArbSequence': { 'parameters': { 2: { 'size': {'mechanism':'len', 'value':'sequenceLength'}, },
123118
3: { 'size': {'mechanism':'len', 'value':'sequenceLength'}, },
@@ -504,6 +499,11 @@
504499
], },
505500
}
506501

502+
# We keep this information because we will need it again if we ever enable OSP and need this function
503+
# 'GetFIRFilterCoefficients': { 'method_templates': [
504+
# { 'session_filename': 'get_fir_filter_coefficients', 'documentation_filename': 'get_fir_filter_coefficients', 'method_python_name_suffix': '', },
505+
# ], },
506+
507507
functions_numpy = {
508508
'CreateWaveformF64': { 'parameters': { 3: { 'numpy': True, }, }, },
509509
'CreateWaveformI16': { 'parameters': { 3: { 'numpy': True, }, }, },

src/nifgen/system_tests/test_system_nifgen.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,17 @@ def test_user_standard_waveform(session):
388388
session.clear_user_standard_waveform()
389389

390390

391-
# TODO(bhaswath): Doesn't work, issue #596
392-
'''
391+
''' Removed due to OSP disabled - #891
393392
def test_fir_filter_coefficients():
394393
with nifgen.Session('', '0', False, 'Simulate=1, DriverSetup=Model:5441;BoardType:PXI') as session:
395-
coeff_array = [1, 0, -1]
394+
coeff_array = [0 for i in range(95)]
395+
coeff_array[0] = -1.0
396+
coeff_array[2] = 1.0
396397
session.configure_custom_fir_filter_coefficients(coeff_array)
397398
session.commit()
398-
array, size = session.get_fir_filter_coefficients()
399-
assert size == len(coeff_array)
399+
array = session.get_fir_filter_coefficients()
400+
assert len(array) == len(coeff_array)
401+
assert array == coeff_array
400402
'''
401403

402404

src/nifgen/templates/functions.rst/get_fir_filter_coefficients.rst.mako

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<%page args="function, config, method_template, indent"/>\
2+
<%
3+
import build.helper as helper
4+
# This file is not currently used - will be enabled when OSP is enabled.
5+
%>\
6+
.. py:method:: get_fir_filter_coefficients()
7+
8+
| Returns the FIR filter coefficients used by the onboard signal
9+
processing block. These coefficients are determined by NI-FGEN and
10+
based on the FIR filter type and corresponding property (Alpha,
11+
Passband, BT) unless you are using the custom filter. If you are using
12+
a custom filter, the coefficients returned are those set with the
13+
:py:meth:`nifgen.Session.configure_custom_fir_filter_coefficients` method coerced to the
14+
quantized values used by the device.
15+
| Refer to the FIR Filter topic for your device in the *NI Signal
16+
Generators Help* for more information about FIR filter coefficients.
17+
This method is supported only for the NI 5441.
18+
19+
20+
.. tip:: This method requires repeated capabilities (channels). If called directly on the
21+
nifgen.Session object, then the method will use all repeated capabilities in the session.
22+
You can specify a subset of repeated capabilities using the Python index notation on an
23+
nifgen.Session instance, and calling this method on the result.:
24+
25+
.. code:: python
26+
27+
session.channels[0,1].get_fir_filter_coefficients(array_size, number_of_coefficients_read)
28+
29+
30+
:rtype: list of float
31+
:return:
32+
33+
34+
Specifies the array of data the onboard signal processor uses for the
35+
FIR filter coefficients. For the NI 5441, provide a symmetric array of
36+
95 coefficients to this parameter.
37+
38+
The coefficients should range between -1.00 and +1.00.
39+
40+
41+
42+
43+

0 commit comments

Comments
 (0)