用于测量计算daq设备的通用库python api
uldaq的Python项目详细描述
Info | Contains a Python API for interacting with Measurement Computing’s Universal Library for Linux. |
Author | Measurement Computing |
关于
uldaqpython包包含一个api(应用程序编程接口) 用于与测量计算数据采集设备交互。包已实现 作为使用ctypespython库的ul for linux c api的面向对象包装器。
uldaq支持python 2.7、3.4+
先决条件
运行uldaqpython api需要UL for Linux C API。
- 访问uldaq on GitHub 安装最新版本的ul for linux c api。
安装uldaqpython api需要Python以及pip、setuptools和wheel包。
- 有关安装python的更多信息,请转到python.org。
- 有关使用pip安装python包的更多信息,请参见 Installing Packagespython.org上的教程。
安装
使用以下命令安装uldaqpython api:
$ pip install uldaq
Note: Installation may need to be run with sudo.
示例
源tarball中包含了一组完整的示例。 要获取并运行示例,请执行以下步骤:
在导航下单击Download files链接。
单击uldaq-1.1.1.tar.gz链接下载文件。
将文件从默认下载位置复制到所需位置。
导航到文件位置并运行:
$ tar -xvf uldaq-1.1.1.tar.gz
python示例位于examples文件夹中。运行以下命令以执行模拟输入示例:
$ cd uldaq-1.1.1/examples $ ./a_in.py
Note: For best results, run examples in a terminal window.
用法
下面是一个简单的示例,用于从中的每个通道读取单个电压值 测量计算数据采集装置的模拟输入子系统。
fromuldaqimport(get_daq_device_inventory,DaqDevice,InterfaceType,AiInputMode,Range,AInFlag)try:# Get a list of available DAQ devicesdevices=get_daq_device_inventory(InterfaceType.USB)# Create a DaqDevice Object and connect to the devicedaq_device=DaqDevice(devices[0])daq_device.connect()# Get AiDevice and AiInfo objects for the analog input subsystemai_device=daq_device.get_ai_device()ai_info=ai_device.get_info()# Read and display voltage values for all analog input channelsforchannelinrange(ai_info.get_num_chans()):data=ai_device.a_in(channel,AiInputMode.SINGLE_ENDED,Range.BIP10VOLTS,AInFlag.DEFAULT)print('Channel',channel,'Data:',data)daq_device.disconnect()daq_device.release()exceptULExceptionase:print('\n',e)# Display any error messages
使用with块的相同示例:
fromuldaqimport(get_daq_device_inventory,DaqDevice,InterfaceType,AiInputMode,Range,AInFlag)try:# Get a list of available devicesdevices=get_daq_device_inventory(InterfaceType.USB)# Create a DaqDevice Object and connect to the devicewithDaqDevice(devices[0])asdaq_device:# Get AiDevice and AiInfo objects for the analog input subsystemai_device=daq_device.get_ai_device()ai_info=ai_device.get_info()# Read and display voltage values for all analog input channelsforchannelinrange(ai_info.get_num_chans()):data=ai_device.a_in(channel,AiInputMode.SINGLE_ENDED,Range.BIP10VOLTS,AInFlag.DEFAULT)print('Channel',channel,'Data:',data)exceptULExceptionase:print('\n',e)# Display any error messages
支持/反馈
mcc支持uldaq包。有关uldaq支持,请联系技术支持 通过mccdaq.com/Support.aspx。请包括python的版本信息, 使用的uldaq c api和uldaq python api包以及有关如何复制 问题。
文档
文档可在mccdaq.com获得。
许可证
uldaq在麻省理工学院风格的许可下获得许可。其他注册项目可根据 不同的许可证。所有许可证均允许非商业和商业用途。