ni-daqmx python api
nidaqmx的Python项目详细描述
Info | Contains a Python API for interacting with NI-DAQmx. See GitHub for the latest source. |
Author | National Instruments |
关于
nidaqmx包包含一个api(应用程序编程接口) 用于与ni daqmx驱动程序交互。这个包是用python实现的。 这个包是由ni创建并支持的。该包实现为 使用 ctypespython库。
ni daqmx0.5支持随 C API。C API包含在任何支持它的驱动程序版本中。这个 nidaqmx包不需要安装C头文件。
nidaqmx包中的某些函数可能在早期版本中不可用 NI DAQMX驱动程序的版本。参观 ni.com/downloads升级您的版本 我是达克斯。
nidaqmx仅支持Windows操作系统。
nidaqmx支持cpython 2.7、3.4+、pypypy2和pypy3。
安装
运行ni daqmx需要ni-daqmx或ni-daqmx运行时。参观 ni.com/downloads下载最新版本 我是尼达克斯。
nidaqmx可以与pip:
一起安装$ python -m pip install nidaqmx
或easy_安装 setuptools:
$ python -m easy_install nidaqmx
您还可以下载项目源并运行:
$ python setup.py install
用法
下面是使用nidaqmx.task.task对象的基本示例。 此示例演示了单个动态nidaqmx.task.task.read如何 方法返回适当的数据类型。
>>>importnidaqmx>>>withnidaqmx.Task()astask:...task.ai_channels.add_ai_voltage_chan("Dev1/ai0")...task.read()...-0.07476920729381246>>>withnidaqmx.Task()astask:...task.ai_channels.add_ai_voltage_chan("Dev1/ai0")...task.read(number_of_samples_per_channel=2)...[0.26001373311970705,0.37796597238117036]>>>fromnidaqmx.constantsimportLineGrouping>>>withnidaqmx.Task()astask:...task.di_channels.add_di_chan(..."cDAQ2Mod4/port0/line0:1",line_grouping=LineGrouping.CHAN_PER_LINE)...task.read(number_of_samples_per_channel=2)...[[False,True],[True,True]]
一个动态的^ {STR 1 } $NIDAQMX.Task.Task.Wrord方法也存在。
>>>importnidaqmx>>>fromnidaqmx.typesimportCtrTime>>>withnidaqmx.Task()astask:...task.co_channels.add_co_pulse_chan_time("Dev1/ctr0")...sample=CtrTime(high_time=0.001,low_time=0.001)...task.write(sample)...1>>>withnidaqmx.Task()astask:...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
考虑使用nidaqmx.stream\u readers和nidaqmx.stream\u writers 类以提高应用程序的性能,这些类接受预先分配的 numpy数组。
下面是使用nidaqmx.system.system对象的示例。
>>>importnidaqmx.system>>>system=nidaqmx.system.System.local()>>>system.driver_versionDriverVersion(major_version=16L,minor_version=0L,update_version=0L)>>>fordeviceinsystem.devices:...print(device)...Device(name=Dev1)Device(name=Dev2)Device(name=cDAQ1)>>>importcollections>>>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_chanPhysicalChannel(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>]>>>fromenumimportEnum>>>isinstance(phys_chan.ai_term_cfgs[0],Enum)True
支持/反馈
ni支持nidaqmx包。要支持nidaqmx,请打开 通过位于ni.com的ni支持门户的请求。
错误/功能请求
若要报告错误或提交功能请求,请使用 GitHub issues page。
请求帮助时要包含的信息
打开问题时,请包含以下信息中的all:
关于如何重现问题和完整回溯的详细步骤,如果 适用。
使用的python版本:
$ python -c "import sys; print(sys.version)"
使用的nidaqmx、numpy、six和enum34包的版本:
$ python -m pip list
使用的NI DAQMX驱动程序的版本。跟随 this KB article 以确定已安装的ni-daqmx的版本。
操作系统和版本,例如Windows 7、CentOS 7.2,…
文档
文档可用here。
许可证
nidaqmx在麻省理工学院风格的许可下获得许可(请参见 LICENSE)。 其他注册项目可根据不同的许可证获得许可。全部 许可证允许非商业和商业用途。