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

Add simple nidigital API - no Pythonic niceties #994

Merged
merged 80 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
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
54be34a
Add nidigital metadata
texasaggie97-zz Apr 25, 2019
2aeed4c
Enable nidigital
texasaggie97-zz Apr 25, 2019
475703f
Add simple example and system_test
texasaggie97-zz Apr 25, 2019
69a27d4
nidigital doesn't have documentation but we need at least an empy dic…
texasaggie97-zz Apr 25, 2019
fdf0a5e
Move import datetime into the snippet that uses it
texasaggie97-zz Apr 25, 2019
d5e531d
Simple usage file
texasaggie97-zz Apr 25, 2019
590bb9c
Add support for ivi-dance-with-a-twist
texasaggie97-zz Apr 25, 2019
2120b50
Add/update generated files
texasaggie97-zz Apr 25, 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
e38c9bf
Merge branch 'internal/metadata_updates' into internal/add_digital
texasaggie97-zz May 21, 2019
42ea12a
Move import datetime back into session.py.mako but skip flake8 error
texasaggie97-zz May 21, 2019
3f51ebd
Update generated files
texasaggie97-zz May 21, 2019
54d1dae
Update changelog
texasaggie97-zz May 21, 2019
a2fc7cf
Internal/niswitch (#971)
texasaggie97-zz May 21, 2019
bf7432e
Merge branch 'internal/metadata_updates' into internal/add_digital
texasaggie97-zz May 21, 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
15b079a
Update changelog per review comments
texasaggie97-zz May 28, 2019
f730070
Clean up incorrect comments per review
texasaggie97-zz May 28, 2019
7880a9e
Fix comment per review
texasaggie97-zz May 28, 2019
8678514
Update and expand on docstring per review
texasaggie97-zz May 28, 2019
888ce70
Remove reference to nidcpower per review
texasaggie97-zz May 28, 2019
952e42b
Add TODO per review
texasaggie97-zz May 28, 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
856c547
Rename and remove functionality
texasaggie97-zz May 30, 2019
bd27fb0
Update generated files
texasaggie97-zz May 30, 2019
9aa1424
Merge branch 'internal/metadata_updates' into internal/add_digital
texasaggie97-zz May 30, 2019
6634139
Update generated files
texasaggie97-zz May 30, 2019
cbda0f2
Add nidigital metadata (#991)
texasaggie97-zz May 30, 2019
edf6055
Merge branch 'internal/metadata_updates' into internal/add_digital
texasaggie97-zz May 30, 2019
9a9ed83
Add SwitchExecutive (#992)
texasaggie97-zz May 30, 2019
faf6b0d
Add missing key
texasaggie97-zz May 30, 2019
e4f7b1b
Merge branch 'internal/metadata_updates' into internal/add_digital
texasaggie97-zz May 30, 2019
38c5422
Fix key name
texasaggie97-zz May 30, 2019
8313f30
Update generated files
texasaggie97-zz May 30, 2019
58500d9
Update order and add comment
texasaggie97-zz May 30, 2019
648cdbc
Fix name
texasaggie97-zz May 30, 2019
c70a84d
Update order and add comment why
texasaggie97-zz May 30, 2019
ced4c66
Clean up addon files
texasaggie97-zz May 30, 2019
0600062
Library file name changed
texasaggie97-zz May 30, 2019
e36209d
Add missing comment with missing case
texasaggie97-zz May 30, 2019
546795b
Add some missing unit tests
texasaggie97-zz May 30, 2019
0d7ca85
Update generated files
texasaggie97-zz May 30, 2019
078ed82
Don't renumber existing cases
texasaggie97-zz May 31, 2019
29038ca
Fix incorrect case - comment was correct
texasaggie97-zz May 31, 2019
492ce77
Add some missing test cases
texasaggie97-zz May 31, 2019
74bae20
Update generated files
texasaggie97-zz May 31, 2019
d38111d
Merge branch 'internal/metadata_updates' into internal/add_digital
texasaggie97-zz May 31, 2019
4711e2b
Update generated files
texasaggie97-zz May 31, 2019
72ba2b9
Merge branch 'master' into internal/add_digital
texasaggie97-zz Jun 3, 2019
4213523
Merge branch 'master' into internal/add_digital
texasaggie97-zz Jun 6, 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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ All notable changes to this project will be documented in this file.
* #### Added
* #### Changed
* #### Removed

* ### NI-Digital Pattern Driver
* #### Added
* Initial support
* Very basic at this point and subject to change
* Looking for any testing and/or feedback
* #### Changed
* #### Removed


## 1.1.2 - 2019-06-06
* ### ALL
Expand Down Expand Up @@ -750,6 +757,10 @@ and this project adheres to [Python Versioning](http://legacy.python.org/dev/pep
* #### Added
* #### Changed
* #### Removed
* ### NI-Digital Pattern Driver
* #### Added
* #### Changed
* #### Removed
-->


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 nidmm nifgen niscope niswitch nise nimodinst
ALL_DRIVERS := nifake 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 @@ -105,6 +105,47 @@ NI-DCPower Python API Status



NI-Digital Pattern Driver Python API Status
-------------------------------------------

+---------------------------------------+--------------------------+
| NI-Digital Pattern Driver (nidigital) | |
+=======================================+==========================+
| Driver Version Tested Against | 19.1.0 |
+---------------------------------------+--------------------------+
| Driver API Version | 19.0.0d32 |
+---------------------------------------+--------------------------+
| PyPI Version | |nidigitalLatestVersion| |
+---------------------------------------+--------------------------+
| Supported Python Version | |nidigitalPythonVersion| |
+---------------------------------------+--------------------------+
| Open Issues | |nidigitalOpenIssues| |
+---------------------------------------+--------------------------+
| Open Pull Requests | |nidigitalOpenPRs| |
+---------------------------------------+--------------------------+


.. |nidigitalLatestVersion| image:: http://img.shields.io/pypi/v/nidigital.svg
:alt: Latest NI-Digital Pattern Driver Version
:target: http://pypi.python.org/pypi/nidigital


.. |nidigitalPythonVersion| image:: http://img.shields.io/pypi/pyversions/nidigital.svg
:alt: NI-Digital Pattern Driver supported Python versions
:target: http://pypi.python.org/pypi/nidigital


.. |nidigitalOpenIssues| image:: https://img.shields.io/github/issues/ni/nimi-python/nidigital.svg
:alt: Open Issues + Pull Requests for NI-Digital Pattern Driver
:target: https://github.com/ni/nimi-python/issues?q=is%3Aopen+is%3Aissue+label%3Anidigital


.. |nidigitalOpenPRs| image:: https://img.shields.io/github/issues-pr/ni/nimi-python/nidigital.svg
:alt: Pull Requests for NI-Digital Pattern Driver
:target: https://github.com/ni/nimi-python/pulls?q=is%3Aopen+is%3Aissue+label%3Anidigital



NI-DMM Python API Status
------------------------

Expand Down
2 changes: 1 addition & 1 deletion build/templates/session.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ${template_parameters['encoding_tag']}
%>\
import array # noqa: F401
import ctypes
import datetime
import datetime # noqa: F401
% if config['use_locking']:
# Used by @ivi_synchronized
from functools import wraps
Expand Down
15 changes: 15 additions & 0 deletions docs/_static/nidigital_usage.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Usage
------

The following is a basic example of using the **nidigital** module to open a session to a ....

.. code-block:: python

import nidigital
# Configure the session.

with nidigital.Session(resource_name='PXI1Slot2', channels='0') as session:
pass

Additional examples for NI-Digital are located in src/nidigital/examples/ directory.

8,256 changes: 8,256 additions & 0 deletions docs/nidigital/class.rst

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions docs/nidigital/enums.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Enums
=====

Enums used in NI-Digital Pattern Driver

.. py:currentmodule:: nidigital


TerminationMode
---------------

.. py:class:: TerminationMode

.. py:attribute:: TerminationMode.ACTIVE_LOAD



.. py:attribute:: TerminationMode.VTERM



.. py:attribute:: TerminationMode.HIGH_Z





62 changes: 62 additions & 0 deletions docs/nidigital/errors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Exceptions and Warnings
=======================

DriverError
-----------

.. py:currentmodule:: nidigital

.. exception:: DriverError

An error originating from the NI-Digital Pattern Driver driver


UnsupportedConfigurationError
-----------------------------

.. py:currentmodule:: nidigital

.. exception:: UnsupportedConfigurationError

An error due to using this module in an usupported platform.

DriverNotInstalledError
-----------------------

.. py:currentmodule:: nidigital

.. exception:: DriverNotInstalledError

An error due to using this module without the driver runtime installed.

InvalidRepeatedCapabilityError
------------------------------

.. py:currentmodule:: nidigital

.. exception:: InvalidRepeatedCapabilityError

An error due to an invalid character in a repeated capability


SelfTestError
-------------

.. py:currentmodule:: nidigital

.. exception:: SelfTestError

An error due to a failed self-test


DriverWarning
-------------

.. py:currentmodule:: nidigital

.. exception:: DriverWarning

A warning originating from the NI-Digital Pattern Driver driver



12 changes: 12 additions & 0 deletions docs/nidigital/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Examples
========

nidigital_do_nothing.py
-----------------------

.. literalinclude:: ../../src/nidigital/examples/nidigital_do_nothing.py
:language: python
:linenos:
:encoding: utf8
:caption: `(nidigital_do_nothing.py) <https://github.com/ni/nimi-python/blob/master/src/nidigital/examples/nidigital_do_nothing.py>`_

18 changes: 18 additions & 0 deletions docs/nidigital/installation.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

.. _nidigital_installation-section:

Installation
------------

As a prerequisite to using the nidigital module, you must install the NI-Digital Pattern Driver runtime on your system. Visit `ni.com/downloads <http://www.ni.com/downloads/>`_ to download the driver runtime for your devices.

The nimi-python modules (i.e. for **NI-Digital Pattern Driver**) can be installed with `pip <http://pypi.python.org/pypi/pip>`_::

$ python -m pip install nidigital~=0.1.0.dev0

Or **easy_install** from
`setuptools <http://pypi.python.org/pypi/setuptools>`_::

$ python -m easy_install nidigital


41 changes: 41 additions & 0 deletions docs/nidigital/status.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

NI-Digital Pattern Driver Python API Status
-------------------------------------------

+---------------------------------------+--------------------------+
| NI-Digital Pattern Driver (nidigital) | |
+=======================================+==========================+
| Driver Version Tested Against | 19.1.0 |
+---------------------------------------+--------------------------+
| Driver API Version | 19.0.0d32 |
+---------------------------------------+--------------------------+
| PyPI Version | |nidigitalLatestVersion| |
+---------------------------------------+--------------------------+
| Supported Python Version | |nidigitalPythonVersion| |
+---------------------------------------+--------------------------+
| Open Issues | |nidigitalOpenIssues| |
+---------------------------------------+--------------------------+
| Open Pull Requests | |nidigitalOpenPRs| |
+---------------------------------------+--------------------------+


.. |nidigitalLatestVersion| image:: http://img.shields.io/pypi/v/nidigital.svg
:alt: Latest NI-Digital Pattern Driver Version
:target: http://pypi.python.org/pypi/nidigital


.. |nidigitalPythonVersion| image:: http://img.shields.io/pypi/pyversions/nidigital.svg
:alt: NI-Digital Pattern Driver supported Python versions
:target: http://pypi.python.org/pypi/nidigital


.. |nidigitalOpenIssues| image:: https://img.shields.io/github/issues/ni/nimi-python/nidigital.svg
:alt: Open Issues + Pull Requests for NI-Digital Pattern Driver
:target: https://github.com/ni/nimi-python/issues?q=is%3Aopen+is%3Aissue+label%3Anidigital


.. |nidigitalOpenPRs| image:: https://img.shields.io/github/issues-pr/ni/nimi-python/nidigital.svg
:alt: Pull Requests for NI-Digital Pattern Driver
:target: https://github.com/ni/nimi-python/pulls?q=is%3Aopen+is%3Aissue+label%3Anidigital


11 changes: 11 additions & 0 deletions docs/nidigital/toc.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
API Reference
--------------

.. toctree::
:maxdepth: 6

nidigital/class
nidigital/enums
nidigital/errors
nidigital/examples

2 changes: 1 addition & 1 deletion generated/nidcpower/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file was generated
import array # noqa: F401
import ctypes
import datetime
import datetime # noqa: F401
# Used by @ivi_synchronized
from functools import wraps

Expand Down
96 changes: 96 additions & 0 deletions generated/nidigital/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-
# This file was generated


__version__ = '0.1.0.dev0'

from nidigital.enums import * # noqa: F403,F401,H303
from nidigital.errors import DriverWarning # noqa: F401
from nidigital.errors import Error # noqa: F401
from nidigital.session import Session # noqa: F401


def get_diagnostic_information():
'''Get diagnostic information about the system state that is suitable for printing or logging

returns: dict

note: Python bitness may be incorrect when running in a virtual environment
'''
import os
import pkg_resources
import platform
import struct
import sys

def is_python_64bit():
return (struct.calcsize("P") == 8)

def is_os_64bit():
return platform.machine().endswith('64')

def is_venv():
return 'VIRTUAL_ENV' in os.environ

info = {}
info['os'] = {}
info['python'] = {}
info['driver'] = {}
info['module'] = {}
if platform.system() == 'Windows':
try:
import winreg as winreg
except ImportError:
import _winreg as winreg

os_name = 'Windows'
try:
driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-Digital Pattern Driver\CurrentVersion")
driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0]
except WindowsError:
driver_version = 'Unknown'
elif platform.system() == 'Linux':
os_name = 'Linux'
driver_version = 'Unknown'
else:
raise SystemError('Unsupported platform: {}'.format(platform.system()))

installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]

info['os']['name'] = os_name
info['os']['version'] = platform.version()
info['os']['bits'] = '64' if is_os_64bit() else '32'
info['driver']['name'] = "NI-Digital Pattern Driver"
info['driver']['version'] = driver_version
info['module']['name'] = 'nidigital'
info['module']['version'] = "0.1.0.dev0"
info['python']['version'] = sys.version
info['python']['bits'] = '64' if is_python_64bit() else '32'
info['python']['is_venv'] = is_venv()
info['python']['packages'] = installed_packages_list

return info


def print_diagnostic_information():
'''Print diagnostic information in a format suitable for issue report

note: Python bitness may be incorrect when running in a virtual environment
'''
info = get_diagnostic_information()

row_format = ' {:<10} {}'
for type in ['OS', 'Driver', 'Module', 'Python']:
typename = type.lower()
print(type + ':')
for item in info[typename]:
if item != 'packages':
print(row_format.format(item.title() + ':', info[typename][item]))
print(' Installed Packages:')
for p in info['python']['packages']:
print((' ' * 8) + p['name'] + '==' + p['version'])

return info


Loading