Skip to content
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 @@ -48,6 +48,7 @@ All notable changes to this project will be documented in this file.
* Update the names of many enum types. See [#1330](https://github.com/ni/nimi-python/issues/1330) for the full list.
* Added `WriteStaticPinState` enum type and changed the parameter type of `write_static` method to the newly added enum.
* Added `SoftwareTrigger` enum type and changed the parameter type of `send_software_edge_trigger` method to the newly added enum.
* Update `fetch_history_ram_cycle_information`, `get_history_ram_sample_count`, and `is_site_enabled` to use `sites` repeated capability - [#1337](https://github.com/ni/nimi-python/issues/1337)
* #### Removed
* `get_pattern_pin_list`, `get_pattern_pin_indexes` and `get_pin_name` - [#1292](https://github.com/ni/nimi-python/issues/1292)
* `get_site_results_site_numbers` method and `SiteResultType` enum - [#1298](https://github.com/ni/nimi-python/issues/1298)
Expand Down
118 changes: 68 additions & 50 deletions build/templates/_converters.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ${module_name}._visatype as _visatype
import ${module_name}.errors as errors

import array
import collections
import datetime
import numbers

Expand Down Expand Up @@ -117,7 +118,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''):
prefix (str) - common prefix for all strings

Returns:
rep_cal_list (list of str) - list of each repeated capability item with ranges expanded and prefix added
rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added
'''
# We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions
if repeated_capability is None:
Expand All @@ -135,7 +136,7 @@ def convert_repeated_capabilities_from_init(repeated_capability):
repeated_capability (str, list, tuple, slice, None) -

Returns:
rep_cal (str) - comma delimited string of each repeated capability item with ranges expanded
rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded
'''
return ','.join(convert_repeated_capabilities(repeated_capability, ''))

Expand Down Expand Up @@ -215,6 +216,54 @@ def convert_init_with_options_dictionary(values):
return init_with_options_string


# convert value to bytes
@singledispatch
def _convert_to_bytes(value): # noqa: F811
pass


@_convert_to_bytes.register(list) # noqa: F811
@_convert_to_bytes.register(bytes) # noqa: F811
@_convert_to_bytes.register(bytearray) # noqa: F811
@_convert_to_bytes.register(array.array) # noqa: F811
def _(value):
return value


@_convert_to_bytes.register(str) # noqa: F811
def _(value):
return value.encode()


def convert_to_bytes(value): # noqa: F811
return bytes(_convert_to_bytes(value))


def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


def convert_chained_repeated_capability_to_parts(chained_repeated_capability):
'''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string.

Converter assumes that the input contains the full cartesian product of its parts.
e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB',
['site0,site1', 'PinA,PinB'] is returned.

Args:
chained_repeated_capability (str) - comma-delimited repeated capabilities string where each
item is a chain of slash-delimited repeated capabilities

Returns:
rep_cap_list (list of str) - list of comma-delimited repeated capabilities string
'''
chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability)
repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)]
for item in chained_repeated_capability_items:
repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))]
return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists]


<%
# Beginning of module-specific converters
%>\
Expand Down Expand Up @@ -259,53 +308,6 @@ def convert_double_each_element(numbers):


% endif
<%
# There are some parameters in nidigital that cannot be made into a repeated capability because the
# methods already have a repeated capability (pins), and we want the parameter to behave similarly
# to repeated capabilities.
%>\
% if config['module_name'] == 'nidigital':
def convert_site_to_string(site):
if isinstance(site, str):
if site.startswith('site'):
return site
else:
return convert_site_to_string(int(site))
else:
if type(site) != int:
# Don't use assert here since this comes from the user
raise TypeError('site must be a string or an integer. Actual: {}'.format(type(site)))
return 'site' + str(site)


% endif
# convert value to bytes
@singledispatch
def _convert_to_bytes(value): # noqa: F811
pass


def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


@_convert_to_bytes.register(list) # noqa: F811
@_convert_to_bytes.register(bytes) # noqa: F811
@_convert_to_bytes.register(bytearray) # noqa: F811
@_convert_to_bytes.register(array.array) # noqa: F811
def _(value):
return value


@_convert_to_bytes.register(str) # noqa: F811
def _(value):
return value.encode()


def convert_to_bytes(value): # noqa: F811
return bytes(_convert_to_bytes(value))


# Let's run some tests
def test_convert_init_with_options_dictionary():
assert convert_init_with_options_dictionary('') == ''
Expand Down Expand Up @@ -535,6 +537,23 @@ def test_repeated_capabilies_from_init():
assert test_result == '0,2,4,5,6,7,8,9,11,12,13,14,16,17'


def test_convert_chained_repeated_capability_to_parts_three_parts():
chained_rep_cap = ('site0/test/PinA,site0/test/PinB,site0/test/PinC,'
'site1/test/PinA,site1/test/PinB,site1/test/PinC')
rep_cap_list = convert_chained_repeated_capability_to_parts(chained_rep_cap)
assert rep_cap_list == ['site0,site1', 'test', 'PinA,PinB,PinC']


def test_convert_chained_repeated_capability_to_parts_single_part():
rep_cap_list = convert_chained_repeated_capability_to_parts('site0, site1')
assert rep_cap_list == ['site0,site1']


def test_convert_chained_repeated_capability_to_parts_empty_string():
rep_cap_list = convert_chained_repeated_capability_to_parts('')
assert rep_cap_list == ['']


% endif
def test_string_to_list_channel():
test_result = _convert_repeated_capabilities('r0', '')
Expand Down Expand Up @@ -563,4 +582,3 @@ def test_string_to_list_prefix():
def test_convert_comma_separated_string_to_list():
out_list = convert_comma_separated_string_to_list(' PinA , PinB , PinC ')
assert out_list == ['PinA', 'PinB', 'PinC']

49 changes: 20 additions & 29 deletions docs/nidigital/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1142,17 +1142,24 @@ fetch_history_ram_cycle_information

.. py:currentmodule:: nidigital.Session

.. py:method:: fetch_history_ram_cycle_information(site, position, samples_to_read)
.. py:method:: fetch_history_ram_cycle_information(position, samples_to_read)

Returns the pattern information acquired for the specified cycles.

If the pattern is using the edge multiplier feature, cycle numbers represent tester cycles, each of which may
consist of multiple DUT cycles. When using pins with mixed edge multipliers, pins may return
:py:data:`~nidigital.PinState.PIN_STATE_NOT_ACQUIRED` for DUT cycles where those pins do not have edges defined.

Site number on which to retrieve pattern information must be specified via sites repeated capability.
The method returns an error if more than one site is specified.

Pins for which to retrieve pattern information must be specified via pins repeated capability.
If pins are not specified, pin list from the pattern containing the start label is used. Call
:py:meth:`nidigital.Session.get_pattern_pin_names` with the start label to retrieve the pins
associated with the pattern burst.
:py:meth:`nidigital.Session.get_pattern_pin_names` with the start label to retrieve the pins associated with the pattern burst:

.. code:: python

session.sites[0].pins['PinA', 'PinB'].fetch_history_ram_cycle_information(0, -1)



Expand All @@ -1163,16 +1170,6 @@ fetch_history_ram_cycle_information
nidigital.Session repeated capabilities container, and calling this method on the result.


:param site:


Site on which to retrieve History RAM data. Specify site as a string in the form of siteN,
where N is the site number. The VI returns an error if more than one site is specified.




:type site: str or int
:param position:


Expand Down Expand Up @@ -1342,21 +1339,18 @@ get_history_ram_sample_count

.. py:currentmodule:: nidigital.Session

.. py:method:: get_history_ram_sample_count(site)
.. py:method:: get_history_ram_sample_count()

TBD




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

:param site:





:type site: str or int

:rtype: int
:return:
Expand Down Expand Up @@ -1698,21 +1692,18 @@ is_site_enabled

.. py:currentmodule:: nidigital.Session

.. py:method:: is_site_enabled(site)
.. py:method:: is_site_enabled()

TBD




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

:param site:





:type site: str or int

:rtype: bool
:return:
Expand Down
52 changes: 45 additions & 7 deletions generated/nidcpower/nidcpower/_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import nidcpower.errors as errors

import array
import collections
import datetime
import numbers

Expand Down Expand Up @@ -112,7 +113,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''):
prefix (str) - common prefix for all strings

Returns:
rep_cal_list (list of str) - list of each repeated capability item with ranges expanded and prefix added
rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added
'''
# We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions
if repeated_capability is None:
Expand All @@ -130,7 +131,7 @@ def convert_repeated_capabilities_from_init(repeated_capability):
repeated_capability (str, list, tuple, slice, None) -

Returns:
rep_cal (str) - comma delimited string of each repeated capability item with ranges expanded
rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded
'''
return ','.join(convert_repeated_capabilities(repeated_capability, ''))

Expand Down Expand Up @@ -216,10 +217,6 @@ def _convert_to_bytes(value): # noqa: F811
pass


def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


@_convert_to_bytes.register(list) # noqa: F811
@_convert_to_bytes.register(bytes) # noqa: F811
@_convert_to_bytes.register(bytearray) # noqa: F811
Expand All @@ -237,6 +234,31 @@ def convert_to_bytes(value): # noqa: F811
return bytes(_convert_to_bytes(value))


def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


def convert_chained_repeated_capability_to_parts(chained_repeated_capability):
'''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string.

Converter assumes that the input contains the full cartesian product of its parts.
e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB',
['site0,site1', 'PinA,PinB'] is returned.

Args:
chained_repeated_capability (str) - comma-delimited repeated capabilities string where each
item is a chain of slash-delimited repeated capabilities

Returns:
rep_cap_list (list of str) - list of comma-delimited repeated capabilities string
'''
chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability)
repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)]
for item in chained_repeated_capability_items:
repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))]
return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists]


# Let's run some tests
def test_convert_init_with_options_dictionary():
assert convert_init_with_options_dictionary('') == ''
Expand Down Expand Up @@ -461,6 +483,23 @@ def test_repeated_capabilies_from_init():
assert test_result == '0,2,4,5,6,7,8,9,11,12,13,14,16,17'


def test_convert_chained_repeated_capability_to_parts_three_parts():
chained_rep_cap = ('site0/test/PinA,site0/test/PinB,site0/test/PinC,'
'site1/test/PinA,site1/test/PinB,site1/test/PinC')
rep_cap_list = convert_chained_repeated_capability_to_parts(chained_rep_cap)
assert rep_cap_list == ['site0,site1', 'test', 'PinA,PinB,PinC']


def test_convert_chained_repeated_capability_to_parts_single_part():
rep_cap_list = convert_chained_repeated_capability_to_parts('site0, site1')
assert rep_cap_list == ['site0,site1']


def test_convert_chained_repeated_capability_to_parts_empty_string():
rep_cap_list = convert_chained_repeated_capability_to_parts('')
assert rep_cap_list == ['']


def test_string_to_list_channel():
test_result = _convert_repeated_capabilities('r0', '')
assert test_result == ['r0']
Expand Down Expand Up @@ -488,4 +527,3 @@ def test_string_to_list_prefix():
def test_convert_comma_separated_string_to_list():
out_list = convert_comma_separated_string_to_list(' PinA , PinB , PinC ')
assert out_list == ['PinA', 'PinB', 'PinC']

Loading