Skip to content

Commit

Permalink
Upload First Version of nidaqmx
Browse files Browse the repository at this point in the history
Upload the First Version of the nidaqmx Package to Repository
  • Loading branch information
Wondernutz committed Mar 21, 2017
0 parents commit 0aebe0a
Show file tree
Hide file tree
Showing 157 changed files with 60,565 additions and 0 deletions.
101 changes: 101 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Contributing to nidaqmx
=======================

Contributions to **nidaqmx** are welcome from all!

**nidaqmx** is managed via [git](https://git-scm.com), with the canonical
upstream repository hosted on [GitHub](http://developercertificate.org/).

**nidaqmx** follows a pull-request model for development. If you wish to
contribute, you will need to create a GitHub account, fork this project,
push a branch with your changes to your project, and then submit a pull
request.

See [GitHub's official documentation](https://help.github.com/articles/using-pull-requests/)
for more details.

Getting Started
---------------

To contribute to this project, it is recommended that you follow these steps:

1. Fork the repository on GitHub.
2. Run the unit tests on your system (see :ref:`testing-section`). At
this point, if any tests fail, do not begin development. Try to
investigate these failures. If you're unable to do so, report an issue
through our `GitHub issues page <http://github.com/nidaqmx/issues>`_.
3. Write new tests that demonstrate your bug or feature. Ensure that these
new tests fail.
4. Make your change.
5. Run all the unit tests again (which include the tests you just added),
and confirm that they all pass.
6. Send a GitHub Pull Request to the main repository's master branch. GitHub
Pull Requests are the expected method of code collaboration on this project.

.. _testing-section:

Testing
-------

In order to be able to run the **nidaqmx** unit tests, your setup should meet
the following minimum requirements:

- Setup has a machine with NI-DAQmx or the NI-DAQmx Runtime installed.
- Machine has a supported version of CPython or PyPy installed.
- Machine has an X-Series DAQ device connected to it (we ran the tests
using a PCIe-6363 or a USB-6351).

Before running any unit tests, an NI MAX configuration needs be imported. The
MAX configuration simply contains some custom scales used during testing. The
MAX configuration file is located at
``nidaqmx\tests\max_config\nidaqmxMaxConfig.nce``. Refer to this
`KB article <http://digital.ni.com/public.nsf/allkb/0E0D3D7C4AA8903886256B29000C9D5A>`_
for details on how to import a MAX Configuration.

To run the **nidaqmx** unit tests in a specific version of Python, run
the following command in the root of the distribution::

$ <Python executable> setup.py test

To run the unit tests in all Python interpreters supported by **nidaqmx**,
run the following commands in the root of the distribution::

$ pip install tox
$ tox
This requires you to have all the Python interpreters supported by
**nidaqmx** installed on your machine.

Developer Certificate of Origin (DCO)
-------------------------------------

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

(taken from [developercertificate.org](http://developercertificate.org/))

See [LICENSE](https://github.com/ni/nidaqmx/blob/master/LICENSE)
for details about how **nidaqmx** is licensed.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2017, National Instruments Corp. NI-DAQ is a trademark of National
Instruments.

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include *.txt
recursive-include nidaqmx_examples *.py
recursive-include nidaqmx/system *.py
recursive-include nidaqmx/_task_modules *.py
recursive-include nidaqmx/tests *.py
recursive-include nidaqmx/tests/teds *.ted
recursive-include nidaqmx/tests/max_config *.nce
200 changes: 200 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
=========== =================================================================================================================================
Info Contains a Python API for interacting with NI-DAQmx. See `GitHub <https://github.com/ni/nidaqmx-python/>`_ for the latest source.
Author National Instruments
=========== =================================================================================================================================

About
=====

The **nidaqmx** package contains an API (Application Programming Interface)
for interacting with the NI-DAQmx driver. The package is implemented in Python.
This package was created and is supported by NI. The package is implemented as a
complex, highly object-oriented wrapper around the NI-DAQmx C API using the
`ctypes <https://docs.python.org/2/library/ctypes.html>`_ Python library.

**nidaqmx** 0.5 supports all versions of the NI-DAQmx driver that ships with the
C API. The C API is included in any version of the driver that supports it. The
**nidaqmx** package does not require installation of the C header files.

Some functions in the **nidaqmx** package may be unavailable with earlier
versions of the NI-DAQmx driver. Visit the
`ni.com/downloads <http://www.ni.com/downloads/>`_ to upgrade your version of
NI-DAQmx.

**nidaqmx** supports only the Windows operating system.

**nidaqmx** supports CPython 2.7, 3.4+, PyPy2, and PyPy3.

Features
========
The following represents a non-exhaustive list of supported features for **nidaqmx**:

- Fully-object oriented
- Fully-featured Task class
- Fully-featured Scale class
- Fully-featured System sub-package with System, Device, PhysicalChannel, WatchdogTask, etc. classes
- NI-DAQmx Events
- NI-DAQmx Streams
- `Enums <https://docs.python.org/3/library/enum.html>`_ support in both Python 2 and 3
- Exceptions support
- `Warnings <https://docs.python.org/2/library/warnings.html>`_ support
- Collections that emulate Python container types
- Single, dynamic read and write methods (see :ref:`usage-section`)
- Performant, NumPy-based reader and writer classes
- Optional parameters
- Implicitly verified properties
- Context managers

The following features are not yet supported by the **nidaqmx** package:

- Calibration methods
- Real-time methods

Installation
============

Running **nidaqmx** requires NI-DAQmx or NI-DAQmx Runtime. Visit the
`ni.com/downloads <http://www.ni.com/downloads/>`_ to download the latest version
of NI-DAQmx.

**nidaqmx** can be installed with `pip <http://pypi.python.org/pypi/pip>`_::

$ python -m pip install nidaqmx

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

$ python -m easy_install nidaqmx

You also can download the project source and run::

$ python setup.py install

.. _usage-section:

Usage
=====
The following is a basic example of using an :py:class:`nidaqmx.task.Task` object.
This example illustrates how the single, dynamic :py:meth:`nidaqmx.task.Task.read`
method returns the appropriate data type.

.. code-block:: python
>>> import nidaqmx
>>> with nidaqmx.Task() as task:
... task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
... task.read()
...
-0.07476920729381246
>>> with nidaqmx.Task() as task:
... task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
... task.read(number_of_samples_per_channel=2)
...
[0.26001373311970705, 0.37796597238117036]
>>> from nidaqmx.constants import LineGrouping
>>> with nidaqmx.Task() as task:
... task.di_channels.add_di_chan(
... "cDAQ2Mod4/port0/line1:3", line_grouping=LineGrouping.CHAN_PER_LINE)
... task.read(number_of_samples_per_channel=2)
...
[[False, True], [True, True]]
A single, dynamic :py:meth:`nidaqmx.task.Task.write` method also exists.

.. code-block:: python
>>> import nidaqmx
>>> from nidaqmx.types import CtrTime
>>> with nidaqmx.Task() as task:
... task.co_channels.add_co_pulse_chan_time("Dev1/ctr0")
... sample = CtrTime(high_time=0.001, low_time=0.001)
... task.write(sample)
...
1
>>> with nidaqmx.Task() as task:
... task.ao_channels.add_ao_voltage_chan("Dev1/ao0")
... task.write([1.1, 2.2, 3.3, 4.4, 5.5], auto_start=True)
...
5
Consider using the :py:mod:`nidaqmx.stream_readers` and :py:mod:`nidaqmx.stream_writers`
classes to increase the performance of your application, which accept pre-allocated
NumPy arrays.

Following is an example of using an :py:class:`nidaqmx.system.System` object.

.. code-block:: python
>>> import nidaqmx.system
>>> system = nidaqmx.system.System.local()
>>> system.driver_version
DriverVersion(major_version=16L, minor_version=0L, update_version=0L)
>>> for device in system.devices:
... print(device)
...
Device(name=Dev1)
Device(name=Dev2)
Device(name=cDAQ1)
>>> import collections
>>> isinstance(system.devices, collections.Sequence)
True
>>> device = system.devices['Dev1']
>>> device == nidaqmx.system.Device('Dev1')
True
>>> isinstance(device.ai_physical_chans, collections.Sequence)
True
>>> phys_chan = device.ai_physical_chans['ai0']
>>> phys_chan
PhysicalChannel(name=Dev1/ai0)
>>> phys_chan == nidaqmx.system.PhysicalChannel('Dev1/ai0')
True
>>> phys_chan.ai_term_cfgs
[<TerminalConfiguration.RSE: 10083>, <TerminalConfiguration.NRSE: 10078>, <TerminalConfiguration.DIFFERENTIAL: 10106>]
>>> from enum import Enum
>>> isinstance(phys_chan.ai_term_cfgs[0], Enum)
True
Support / Feedback
==================

The **nidaqmx** package is supported by NI. For support for **nidaqmx**, open
a request through the NI support portal at `ni.com <http://www.ni.com>`_.

Bugs / Feature Requests
=======================

To report a bug or submit a feature request, please use the
`GitHub issues page <https://github.com/ni/nidaqmx-python/issues>`_.

Information to Include When Asking for Help
-------------------------------------------

Please include **all** of the following information when opening an issue:

- Detailed steps on how to reproduce the problem and full traceback, if
applicable.
- The python version used::

$ python -c "import sys; print(sys.version)"

- The versions of the **nidaqmx**, numpy, six and enum34 packages used::

$ python -m pip list

- The version of the NI-DAQmx driver used. Follow
`this KB article <http://digital.ni.com/express.nsf/bycode/ex8amn>`_
to determine the version of NI-DAQmx you have installed.
- The operating system and version, for example Windows 7, CentOS 7.2, ...

Additional Documentation
========================
Refer to the `NI-DAQmx Help <http://digital.ni.com/express.nsf/bycode/exagg4>`_
for API-agnostic information about NI-DAQmx or measurement concepts.

NI-DAQmx Help installs only with the full version of NI-DAQmx.

License
=======
**nidaqmx** is licensed under an MIT-style license (see LICENSE). Other
incorporated projects may be licensed under different licenses. All licenses
allow for non-commercial and commercial use.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = NI-DAQmxPythonAPI
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading

0 comments on commit 0aebe0a

Please sign in to comment.