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

Update burst_pattern method to return pass/fail results if wait_until_done is True #1336

Merged
merged 8 commits into from
Mar 25, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ All notable changes to this project will be documented in this file.
* #### Changed
* Change the type of applicable method parameters and properties to enums - [#1066](https://github.com/ni/nimi-python/issues/1066)
* `get_site_pass_fail` returns dictionary where each key is a site number and value is a bool indicating pass/fail - [#1297](https://github.com/ni/nimi-python/issues/1297)
* `burst_pattern` returns dictionary where each key is a site number and value is a bool indicating pass/fail, if `wait_until_done` is specified as `True` - [#1296](https://github.com/ni/nimi-python/issues/1296)
* #### Removed
* `get_pattern_pin_list`, `get_pattern_pin_indexes` and `get_pin_name` - [#1292](https://github.com/ni/nimi-python/issues/1292)
* ### NI-DMM
Expand Down
17 changes: 16 additions & 1 deletion docs/nidigital/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ burst_pattern

.. py:method:: burst_pattern(start_label, select_digital_function=True, wait_until_done=True, timeout=datetime.timedelta(seconds=10.0))

TBD
Uses the start_label you specify to burst the pattern on the sites you specify. If you
specify wait_until_done as True, waits for the burst to complete, and returns comparison results for each site.

Digital pins retain their state at the end of a pattern burst until the first vector of the pattern burst, a call to
:py:meth:`nidigital.Session.write_static`, or a call to :py:meth:`nidigital.Session.apply_levels_and_timing`.



Expand Down Expand Up @@ -228,6 +232,17 @@ burst_pattern

:type timeout: float in seconds or datetime.timedelta

:rtype: { int: bool, int: bool, ... }
:return:


Dictionary where each key is a site number and value is pass/fail,
if wait_until_done is specified as True. Else, None.





clear_error
-----------

Expand Down
42 changes: 40 additions & 2 deletions generated/nidigital/nidigital/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ def apply_tdr_offsets(self, offsets):
return

@ivi_synchronized
def burst_pattern(self, start_label, select_digital_function=True, wait_until_done=True, timeout=datetime.timedelta(seconds=10.0)):
r'''burst_pattern
def _burst_pattern(self, start_label, select_digital_function=True, wait_until_done=True, timeout=datetime.timedelta(seconds=10.0)):
r'''_burst_pattern

TBD

Expand Down Expand Up @@ -1170,6 +1170,44 @@ def enable_sites(self):
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return

@ivi_synchronized
def burst_pattern(self, start_label, select_digital_function=True, wait_until_done=True, timeout=datetime.timedelta(seconds=10.0)):
'''burst_pattern

Uses the start_label you specify to burst the pattern on the sites you specify. If you
specify wait_until_done as True, waits for the burst to complete, and returns comparison results for each site.

Digital pins retain their state at the end of a pattern burst until the first vector of the pattern burst, a call to
write_static, or a call to apply_levels_and_timing.

Tip:
This method requires repeated capabilities. If called directly on the
nidigital.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
nidigital.Session repeated capabilities container, and calling this method on the result.

Args:
start_label (str):

select_digital_function (bool):

wait_until_done (bool):

timeout (float in seconds or datetime.timedelta):


Returns:
pass_fail ({ int: bool, int: bool, ... }): Dictionary where each key is a site number and value is pass/fail,
if wait_until_done is specified as True. Else, None.

'''
self._burst_pattern(start_label, select_digital_function, wait_until_done, timeout)

if wait_until_done:
return self.get_site_pass_fail()
else:
return None

@ivi_synchronized
def _fetch_capture_waveform(self, waveform_name, samples_to_read, timeout):
# This is slightly modified codegen from the function
Expand Down
1 change: 1 addition & 0 deletions src/nidigital/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
'returns': 'ViStatus'
},
'BurstPattern': {
'codegen_method': 'private',
'documentation': {
'description': 'TBD'
},
Expand Down
75 changes: 75 additions & 0 deletions src/nidigital/metadata/functions_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,81 @@
functions_override_metadata = {
}

functions_additional_burst_pattern = {
'FancyBurstPattern': {
'python_name': 'burst_pattern',
'codegen_method': 'python-only',
'method_templates': [
{
'documentation_filename': 'default_method',
'method_python_name_suffix': '',
'session_filename': 'fancy_burst_pattern',
}
],
'documentation': {
'description': """\nUses the start_label you specify to burst the pattern on the sites you specify. If you
specify wait_until_done as True, waits for the burst to complete, and returns comparison results for each site.

Digital pins retain their state at the end of a pattern burst until the first vector of the pattern burst, a call to
niDigital_WriteStatic, or a call to niDigital_ApplyLevelsAndTiming.

"""
},
'parameters': [
{
'direction': 'in',
'name': 'vi',
'type': 'ViSession'
},
{
'direction': 'in',
'is_repeated_capability': True,
'repeated_capability_type': 'sites',
'name': 'siteList',
'type': 'ViConstString'
},
{
'direction': 'in',
'name': 'startLabel',
'type': 'ViConstString'
},
{
'default_value': True,
'direction': 'in',
'name': 'selectDigitalFunction',
'type': 'ViBoolean'
},
{
'default_value': True,
'direction': 'in',
'name': 'waitUntilDone',
'type': 'ViBoolean'
},
{
'default_value': 'datetime.timedelta(seconds=10.0)',
'direction': 'in',
'name': 'timeout',
'python_api_converter_name': 'convert_timedelta_to_seconds_real64',
'type': 'ViReal64',
'type_in_documentation': 'float in seconds or datetime.timedelta'
},
{
'direction': 'out',
'documentation': {
'description': '\nDictionary where each key is a site number and value is pass/fail,\nif wait_until_done is specified as True. Else, None.\n'
},
'name': 'passFail',
'size': {
'mechanism': 'python-code',
'value': None
},
'type': 'ViBoolean',
'type_in_documentation': '{ int: bool, int: bool, ... }',
},
],
},
}

functions_additional_write_source_waveform_site_unique = {
'FancyWriteSourceWaveformSiteUnique': {
'python_name': 'write_source_waveform_site_unique',
Expand Down
24 changes: 21 additions & 3 deletions src/nidigital/system_tests/test_system_nidigital.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ def test_tdr_some_channels(multi_instrument_session):
assert fetched_offsets == applied_offsets


def test_burst_pattern_burst_only(multi_instrument_session):
test_files_folder = 'simple_pattern'
configure_session(multi_instrument_session, test_files_folder)

multi_instrument_session.load_pattern(get_test_file_path(test_files_folder, 'pattern.digipat'))

result = multi_instrument_session.burst_pattern(start_label='new_pattern', wait_until_done=False)
assert result is None


def test_burst_pattern_pass_fail(multi_instrument_session):
test_files_folder = 'simple_pattern'
configure_session(multi_instrument_session, test_files_folder)

multi_instrument_session.load_pattern(get_test_file_path(test_files_folder, 'pattern.digipat'))

result = multi_instrument_session.burst_pattern(start_label='new_pattern', wait_until_done=True)
assert result == {0: True, 1: True, 2: True, 3: True}


def test_source_waveform_parallel_broadcast(multi_instrument_session):
test_name = test_source_waveform_parallel_broadcast.__name__
configure_session(multi_instrument_session, test_name)
Expand All @@ -123,9 +143,7 @@ def test_source_waveform_parallel_broadcast(multi_instrument_session):
waveform_name='src_wfm',
waveform_data=[i for i in range(4)])

multi_instrument_session.burst_pattern(start_label='new_pattern')

pass_fail = multi_instrument_session.get_site_pass_fail()
pass_fail = multi_instrument_session.burst_pattern(start_label='new_pattern')
assert pass_fail == {0: True, 1: True}


Expand Down
18 changes: 18 additions & 0 deletions src/nidigital/templates/session.py/fancy_burst_pattern.py.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<%page args="f, config, method_template"/>\
<%
'''Forwards to _burst_pattern(). If wait_until_done is True, calls get_site_pass_fail() to obtain the pass/fail
results and returns it to the caller.'''
import build.helper as helper
%>\
def ${f['python_name']}(${helper.get_params_snippet(f, helper.ParameterUsageOptions.SESSION_METHOD_DECLARATION)}):
'''${f['python_name']}

${helper.get_function_docstring(f, False, config, indent=8)}
'''
self._burst_pattern(start_label, select_digital_function, wait_until_done, timeout)

if wait_until_done:
return self.get_site_pass_fail()
else:
return None