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

[RFC] Add NI-TClk support #1005

Closed
wants to merge 71 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b18af88
Intermediate change
texasaggie97-zz Feb 20, 2019
c954ae1
flake8 has gotten stricter
texasaggie97-zz Mar 26, 2019
d5921de
Additional infomarion when error or abnormal condition
texasaggie97-zz Mar 26, 2019
8748c4d
Need to merge config as well
texasaggie97-zz Mar 26, 2019
b01b135
Use actual booleans instead of a string that looks like a boolean
texasaggie97-zz Mar 26, 2019
90f3290
Since we now merge config, not all top level items are a dictionary
texasaggie97-zz Mar 26, 2019
71b62f2
Update generated files
texasaggie97-zz Mar 26, 2019
6cd180e
Only build nifake for now. Others will be added over time
texasaggie97-zz Mar 26, 2019
deabe38
Update metadata
texasaggie97-zz Mar 26, 2019
85b071e
Make naming consistent with other drivers
texasaggie97-zz Mar 26, 2019
f546b25
Enable ModInst
texasaggie97-zz Apr 3, 2019
42f263e
Disable testing drivers we are building yet
texasaggie97-zz Apr 3, 2019
c8664b5
Add config_addon
texasaggie97-zz Apr 3, 2019
d7cf40b
Update metadata
texasaggie97-zz Apr 3, 2019
5f3e841
Handle minor change in metadata format (now booleans instead of strings)
texasaggie97-zz Apr 3, 2019
2167adf
Update generated files
texasaggie97-zz Apr 3, 2019
f6a7677
Internal/add nidmm (#970)
texasaggie97-zz May 15, 2019
371f2e1
See if this fixes pypy3 build/test breakage
texasaggie97-zz May 15, 2019
29f6e4c
Merge branch 'master' into internal/metadata_updates
texasaggie97-zz May 15, 2019
d6b71cd
Allow pypy3 to fail for now
texasaggie97-zz May 15, 2019
a4331a2
Simple change to force rebuild
texasaggie97-zz May 16, 2019
bb27b00
Try to fix the build
texasaggie97-zz May 16, 2019
109157f
Change how filtering configuration dictionary is declared
texasaggie97-zz May 17, 2019
68d192a
Try to fix error on travis ci
texasaggie97-zz May 17, 2019
0db7bec
Need enum34 for Python 2.7
texasaggie97-zz May 17, 2019
aa82685
Update niscope metadata to new extraction type (#980)
texasaggie97-zz May 17, 2019
a2fc7cf
Internal/niswitch (#971)
texasaggie97-zz May 21, 2019
61cc777
Merge branch 'internal/metadata_updates' into bug293/add_tclk
texasaggie97-zz May 22, 2019
93aecb6
Update for new metadata
texasaggie97-zz May 24, 2019
d668ee9
Differentiate between tested with version and api version (#983)
texasaggie97-zz May 24, 2019
4ad0793
Internal/nidcpower (#982)
texasaggie97-zz May 24, 2019
47ed789
Internal/add fgen (#972)
texasaggie97-zz May 24, 2019
e3c59e5
Merge branch 'master' into internal/metadata_updates
texasaggie97-zz May 28, 2019
23a769f
Internal/fix build (#987)
texasaggie97-zz May 28, 2019
3de5c32
Merge branch 'internal/metadata_updates' of https://github.com/ni/nim…
texasaggie97-zz May 28, 2019
ac08812
Update nifake metadata (#988)
texasaggie97-zz May 30, 2019
07d02d4
Add behavior type ivi-dance-with-a-twist (#989)
texasaggie97-zz May 30, 2019
845fab2
Merge branch 'internal/metadata_updates' into bug293/add_tclk
texasaggie97-zz May 30, 2019
10d0e19
Updates needed for new format
texasaggie97-zz May 30, 2019
418a107
Merge branch 'master' into bug293/add_tclk
texasaggie97-zz Jun 13, 2019
723d18d
Update generated files
texasaggie97-zz Jun 13, 2019
b957c06
nitclk doesn't have enums so don't build files
texasaggie97-zz Jun 14, 2019
abcfa2c
single session, not multiple sessions
texasaggie97-zz Jun 14, 2019
d5c857d
Tell codegen sessions is not a session handle - we want them passes i…
texasaggie97-zz Jun 14, 2019
d696180
Fix codegen_method for get/set functions - should be 'private'
texasaggie97-zz Jun 14, 2019
bcd7ab1
Fix type from extraction
texasaggie97-zz Jun 14, 2019
4c5c6ee
Clean up print()'s left over from debugging
texasaggie97-zz Jun 14, 2019
cec97de
Add nitclk-isms
texasaggie97-zz Jun 14, 2019
c69eced
nitclk specific session.py
texasaggie97-zz Jun 14, 2019
6ed9fab
Update nitclk generated files
texasaggie97-zz Jun 14, 2019
69dd627
Add nitclk to documentation
texasaggie97-zz Jun 14, 2019
28c531a
Rename Properties to SessionReference
texasaggie97-zz Jun 21, 2019
fd4c00d
Reorder parameters
texasaggie97-zz Jun 21, 2019
f720e86
Don't hardcode implementation of _get_extended_error_info(), instead …
texasaggie97-zz Jun 21, 2019
7db2059
Update generated files
texasaggie97-zz Jun 21, 2019
9e04a5e
Add converter for session reference
texasaggie97-zz Jun 24, 2019
b88cd05
Add support for SessionReference type attributes
texasaggie97-zz Jun 24, 2019
285b80f
Move nitclk specific converter to _converters.py
texasaggie97-zz Jun 24, 2019
02ad648
Add converter for list
texasaggie97-zz Jun 24, 2019
d6ec4f4
Move nitclk specific attribute to _attributes.py
texasaggie97-zz Jun 24, 2019
acc3bde
Add codegen case for buffer with converter
texasaggie97-zz Jun 24, 2019
36da561
Add converter for sessions parameters
texasaggie97-zz Jun 24, 2019
fd77470
Need to generate _attributes.py
texasaggie97-zz Jun 24, 2019
feae6b0
We now need to import _converters
texasaggie97-zz Jun 24, 2019
6a8a285
Update generated files
texasaggie97-zz Jun 24, 2019
fd406a0
Fix typo in name
texasaggie97-zz Jun 26, 2019
efec7a3
Change min_time to min_tclk_period, add default value and add support…
texasaggie97-zz Jun 26, 2019
490def9
Import datetime in tclk session
texasaggie97-zz Jun 26, 2019
7b49668
Merge branch 'master' into bug293/add_tclk
marcoskirsch Jul 24, 2019
eec1e0e
Remove spurious extra lines
texasaggie97-zz Aug 29, 2019
cabe80f
Update CHANGELOG.md
texasaggie97-zz Aug 29, 2019
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
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ All notable changes to this project will be documented in this file.
* `runt_high_threshold`, `runt_low_threshold`, `runt_polarity`, `runt_condition`, `runt_time_high_limit`, `runt_time_low_limit` properties and associated enums
* `width_condition`, `width_high_threshold`, `width_low_threshold`, `width_polarity` properties and associated enums
* #### Changed
* Fixed enum values for `TIME_HISTOGRAM_MEAN_PLUS_STDEV`, `TIME_HISTOGRAM_MEAN_PLUS_2_STDEV`, `HF_REJECT` and `LF_REJECT`
* #### Removed
* ### NI Switch Executive
* #### Added
Expand Down Expand Up @@ -78,8 +79,12 @@ All notable changes to this project will be documented in this file.
`get_number_of_vectors()`, `get_pattern_file_path()`, `get_pin_type()`, `get_time_set_compare_edges()`, `get_time_set_drive_edges()`,
`is_pattern_file_modified_since_load()`, `load_levels_internal()`, `load_pattern_internal()`, `load_timing_internal()`, `uncommit()`
* Need to determine how to generate this function - `fetch_capture_waveform_u32()`


* ### NI-TClk
* #### Added
* Initial support
* #### Changed
* #### Removed

## 1.1.2 - 2019-06-06
* ### ALL
* #### Changed
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# In alphabetical order except put nifake first and nimodinst last
# - nifake first to get the most code generator coverage
# - nimodinst last so that the version from nimodinst is used for any global versions (docs/conf.py)
ALL_DRIVERS := nifake nidcpower nidigital nidmm nifgen niscope niswitch nise nimodinst
ALL_DRIVERS := nifake nitclk nidcpower nidigital nidmm nifgen niscope niswitch nise nimodinst
DRIVERS ?= $(ALL_DRIVERS)

ROOT_DIR := $(abspath .)
Expand Down
41 changes: 41 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,47 @@ NI-SWITCH Python API Status
:target: https://github.com/ni/nimi-python/pulls?q=is%3Aopen+is%3Aissue+label%3Aniswitch



NI-TClk Python API Status
-------------------------

+-------------------------------+-----------------------+
| NI-TClk (nitclk) | |
+===============================+=======================+
| Driver Version Tested Against | 18.0.0 |
+-------------------------------+-----------------------+
| Driver API Version | 255.0.0d0 |
+-------------------------------+-----------------------+
| PyPI Version | |nitclkLatestVersion| |
+-------------------------------+-----------------------+
| Supported Python Version | |nitclkPythonVersion| |
+-------------------------------+-----------------------+
| Open Issues | |nitclkOpenIssues| |
+-------------------------------+-----------------------+
| Open Pull Requests | |nitclkOpenPRs| |
+-------------------------------+-----------------------+


.. |nitclkLatestVersion| image:: http://img.shields.io/pypi/v/nitclk.svg
:alt: Latest NI-TClk Version
:target: http://pypi.python.org/pypi/nitclk


.. |nitclkPythonVersion| image:: http://img.shields.io/pypi/pyversions/nitclk.svg
:alt: NI-TClk supported Python versions
:target: http://pypi.python.org/pypi/nitclk


.. |nitclkOpenIssues| image:: https://img.shields.io/github/issues/ni/nimi-python/nitclk.svg
:alt: Open Issues + Pull Requests for NI-TClk
:target: https://github.com/ni/nimi-python/issues?q=is%3Aopen+is%3Aissue+label%3Anitclk


.. |nitclkOpenPRs| image:: https://img.shields.io/github/issues-pr/ni/nimi-python/nitclk.svg
:alt: Pull Requests for NI-TClk
:target: https://github.com/ni/nimi-python/pulls?q=is%3Aopen+is%3Aissue+label%3Anitclk


.. _installation-section:

Installation
Expand Down
26 changes: 20 additions & 6 deletions build/helper/codegen_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ def _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi
for p in corresponding_buffer_parameters:
assert p['direction'] == 'out'
assert p['size']['mechanism'] != 'fixed-size'
definition = '{0}.{1}({2}) # case S190'.format(module_name, parameter['ctypes_type'], parameter['python_name'])
definition = '{0}.{1}({2}) # case S210'.format(module_name, parameter['ctypes_type'], parameter['python_name'])
else:
assert parameter['direction'] == 'out'
definition = '{0}.{1}() # case S200'.format(module_name, parameter['ctypes_type'])
definition = '{0}.{1}() # case S220'.format(module_name, parameter['ctypes_type'])

if definition is not None:
definitions.append(parameter['ctypes_variable_name'] + ' = ' + definition)
Expand All @@ -348,6 +348,7 @@ def _get_ctype_variable_definition_snippet_for_buffers(parameter, parameters, iv
B600. Output buffer with mechanism passed-in: get_ctypes_pointer_for_buffer(value-array.array('d', [0] * buffer_size, library_type=ViInt32)
B610. Output buffer with mechanism ivi-dance-with-a-twist, QUERY_SIZE: None
B620. Output buffer with mechanism ivi-dance-with-a-twist, GET_DATA: get_ctypes_pointer_for_buffer(value=array.array('d', [0] * buffer_size_ctype.value, library_type=ViInt32)
B630. Input buffer of simple types with converter: get_ctypes_pointer_for_buffer(value=convert(array.array('d', list)), library_type=visatype.ViReal64)

Return Value (list): each item in the list will be one line needed for the declaration of that parameter

Expand All @@ -360,6 +361,19 @@ def _get_ctype_variable_definition_snippet_for_buffers(parameter, parameters, iv

if parameter['numpy'] is True and use_numpy_array is True:
definition = 'get_ctypes_pointer_for_buffer(value={0}) # case B510'.format(parameter['python_name'])
elif parameter['direction'] == 'in' and 'python_api_converter_name' in parameter:
if custom_type is not None:
assert False, 'Custom type {} is not supported with converters'.format(custom_type)
else:
if parameter['use_array']:
# If the incoming type is array.array, we can just use that, otherwise we need to create an array.array that is initialized with the passed in value, which must be iterable
array_declaration = '{0}_array = get_ctypes_and_array(value=_converters.{2}({0}), array_type="{1}") # case B630'.format(parameter['python_name'], get_array_type_for_api_type(parameter['ctypes_type'], parameter['python_api_converter_name']))
definitions.append(array_declaration)
definition = 'get_ctypes_pointer_for_buffer(value={0}_array, library_type={1}.{2}) # case B630'.format(parameter['python_name'], module_name, parameter['ctypes_type'])
elif parameter['use_list']:
definition = 'get_ctypes_pointer_for_buffer(value=_converters.{3}({0}), library_type={1}.{2}) # case B630'.format(parameter['python_name'], module_name, parameter['ctypes_type'], parameter['python_api_converter_name'])
else:
assert False, "Expected either 'use_array' or 'use_list' to be True. Both False."
elif parameter['direction'] == 'in':
if custom_type is not None:
definition = 'get_ctypes_pointer_for_buffer([{0}.{1}(c) for c in {2}], library_type={0}.{1}) # case B540'.format(module_name, parameter['ctypes_type'], parameter['python_name'], parameter['python_name'])
Expand Down Expand Up @@ -1257,14 +1271,14 @@ def test_get_ctype_variable_declaration_snippet_case_s180():
assert snippet == ["string_size_ctype = _visatype.ViInt32(error_code) # case S180"]


def test_get_ctype_variable_declaration_snippet_case_s190():
def test_get_ctype_variable_declaration_snippet_case_s210():
snippet = get_ctype_variable_declaration_snippet(parameters_for_testing[4], parameters_for_testing, IviDanceStep.NOT_APPLICABLE, config_for_testing, use_numpy_array=False)
assert snippet == ["number_of_elements_ctype = _visatype.ViInt32(number_of_elements) # case S190"]
assert snippet == ["number_of_elements_ctype = _visatype.ViInt32(number_of_elements) # case S210"]


def test_get_ctype_variable_declaration_snippet_case_s200():
def test_get_ctype_variable_declaration_snippet_case_s220():
snippet = get_ctype_variable_declaration_snippet(parameters_for_testing[1], parameters_for_testing, IviDanceStep.NOT_APPLICABLE, config_for_testing, use_numpy_array=False)
assert snippet == ["output_ctype = _visatype.ViInt64() # case S200"]
assert snippet == ["output_ctype = _visatype.ViInt64() # case S220"]


def test_get_ctype_variable_declaration_snippet_case_s210():
Expand Down
4 changes: 2 additions & 2 deletions build/helper/metadata_add_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _add_is_session_handle(parameter):

def _fix_type(parameter):
'''Replace any spaces in the parameter type with an underscore.'''
parameter['type'] = parameter['type'].replace('[ ]', '[]').replace(' ', '_')
parameter['type'] = parameter['type'].replace('[ ]', '[]').replace(' []', '[]').replace(' ', '_')


def _add_use_in_python_api(p, parameters):
Expand All @@ -314,7 +314,7 @@ def _setup_init_function(functions, config):
# Change the init_function information for generating the docstring
# We are assuming the last parameter is vi out
for p in init_function['parameters']:
if p['name'] == 'vi':
if p['name'] == config['session_handle_parameter_name']:
p['documentation']['description'] = session_return_text
p['type_in_documentation'] = config['module_name'] + '.Session'
p['python_name'] = 'session'
Expand Down
18 changes: 18 additions & 0 deletions build/templates/__init__.py.mako
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
${template_parameters['encoding_tag']}
# This file was generated
<%
import build.helper as helper

enums = template_parameters['metadata'].enums
functions = helper.filter_codegen_functions(template_parameters['metadata'].functions)
config = template_parameters['metadata'].config
module_name = config['module_name']
registry_name = config['driver_registry'] if 'driver_registry' in config else config['driver_name']
Expand All @@ -14,7 +17,22 @@ from ${module_name}.enums import * # noqa: F403,F401,H303
% endif
from ${module_name}.errors import DriverWarning # noqa: F401
from ${module_name}.errors import Error # noqa: F401
<%
# nitclk is different. It does not have a session class that we open a session on
# Instead it is a bunch of stateless function calls. So if we are NOT building for
# nitclk, we import the Session class like before. If it is nitclk then we will
# import each function and the SessionReference class
%>\
% if config['module_name'] != 'nitclk':
from ${module_name}.session import Session # noqa: F401
% else:
from ${module_name}.session import SessionReference # noqa: F401

# Function imports
% for func_name in sorted([functions[k]['python_name'] for k in functions if not functions[k]['render_in_session_base']]):
from ${module_name}.session import ${func_name} # noqa: F401
% endfor
% endif
<%
# Blank lines are to make each import separate so that they do not need to be sorted
# Otherwise flake8 test fails
Expand Down
15 changes: 15 additions & 0 deletions build/templates/_attributes.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ${template_parameters['encoding_tag']}
# This file was generated
<%
module_name = template_parameters['metadata'].config['module_name']
config = template_parameters['metadata'].config
%>\
import ${module_name}._converters as _converters

Expand Down Expand Up @@ -112,4 +113,18 @@ class AttributeEnum(object):
return self._underlying_attribute.__set__(session, value.value)


% if config['module_name'] == 'nitclk':
# nitclk specific attribute type
class AttributeViInt32SessionReference(Attribute):

def __get__(self, session, session_type):
# Import here to avoid a circular dependency when initial import happens
from ${module_name}.session import SessionReference
return SessionReference(session._get_attribute_vi_int32(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_to_nitclk_session_num(value))


% endif

30 changes: 30 additions & 0 deletions build/templates/_converters.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,36 @@ def convert_init_with_options_dictionary(values, encoding):
return init_with_options_string


% if config['module_name'] == 'nitclk':
# nitclk specific converters
def convert_to_nitclk_session_num(item):
'''Convert from supported objects to NI-TClk Session Num

Supported objects are:
- class with .tclk object of type nitclk.SessionReference
- nitclk.SessionReference
- NI-TClk Session Num
'''
try:
return item.tclk.get_session_number()
except KeyError:
pass

try:
return item.get_session_number()
except KeyError:
pass

# If we haven't gotten a SessionReference, we assume the item is the actual nitclk session num and return it
return item


def convert_to_nitclk_session_num_list(item_list):
'''Converts a list of items to nitclk session nums'''
return [convert_to_nitclk_session_num(i) for i in item_list]


% endif
# Let's run some tests
def test_convert_init_with_options_dictionary():
assert convert_init_with_options_dictionary('', 'ascii') == ''
Expand Down
13 changes: 13 additions & 0 deletions docs/_static/nitclk_usage.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Usage
------

The following is a basic example of using the **nitclk** module to TBD.

.. code-block:: python

import nitclk
# Configure the session.


Additional examples for NI-TClk are located in src/nitclk/examples/ directory.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = '0.1.1.dev0'
release = '0.1.0.dev0'
# The short X.Y version.
version = release[:3]

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Refer to your driver documentation for device-specific information and detailed
niswitch
nimodinst
nise
nitclk

Indices and tables
==================
Expand Down
10 changes: 10 additions & 0 deletions docs/nitclk.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
nitclk module
=============================================================

.. include:: nitclk/installation.inc

.. include:: _static/nitclk_usage.inc

.. include:: nitclk/toc.inc


Loading