将数据从 LabView 发送到 Python 并返回
如何将数据从 LabView 发送到 Python 并返回结果?
How do I send data from LabView to Python and get a result back?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何将数据从 LabView 发送到 Python 并返回结果?
How do I send data from LabView to Python and get a result back?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(9)
另一种解决方案是使用智能消息传递库 ZeroMQ,它附带了很多绑定,几乎适用于所有主要语言。
对于 Python/Labview 案例,sourceforge 上有一个很好的演示项目:
Python-LabVIEW Communication
客户端 ~LabVIEW
+
服务器端部分(示例)
One other solution is using the smart messaging library ZeroMQ, which comes with a lot of bindings, almost for all major languages.
For the Python/Labview case there is a nice demo project on sourceforge:
Python-LabVIEW Communication
Client-side ~LabVIEW
+
Server-side part (example)
LabView 允许您用多种语言编写扩展,目前的主要技术是使用网络连接。避免在 Labview 进程本身内部运行本机语言工具包。
这里似乎有一个Python Labview 工具包,但它不再起作用了。
使用套接字服务器和套接字客户端在 Labview 和 python 之间进行通信。 (大多数跨平台解决方案,现在您不必让 python 和 labview 在同一台 PC 上或同一进程中运行)。
不幸的是,目前我无法提供示例,因为我没有安装labview,但我已经完成了从LabView到两三种语言的数十个应用程序的基于ole自动化的集成,但那是很多年前的事了。这些天我会使用网络套接字技术。
LabView allows you to write extensions in several languages, the primary technique these days is to use a network connection. Native language toolkits that run inside the labview process itself are avoided.
It seems there is a Python Labview toolkit here but it no longer works.
Use a socket server and socket client to talk between Labview and python. (Most cross-platform solution, and now you don't have to have your python and labview running on the same PC, or in the same process).
Unfortunately a sample is beyond me at the moment as I don't have labview installed, but I have done ole automation based integrations from LabView to dozens of apps in two or three languages, but that was many years ago. These days I would use the network socket technique.
LabVIEW 2018 现在提供了一个“本机”解决方案,可以通过来回“发送数据”来从 LabVIEW 调用 Python 代码:
参考:LabVIEW 2018 功能和变更
Python 节点提供了模块路径、函数名称、输入参数和返回值的预期数据类型。这些输入和输出支持许多基本数据类型:数字、(多维)数组、字符串、簇;自动转换为相应的数据类型,即LabVIEW数组转换为Python列表,簇转换为元组(返回值反之亦然)。
LabVIEW 2018 now offers a "native" solution to calling Python code from LabVIEW with "sending data" back and forth:
Reference: LabVIEW 2018 Features and Changes
The Python Node is provided with the module path, function name, input parameters, and the expected data type of the return value. These inputs and output support a number of basic data types: numerics, (multi-dimensional) arrays, strings, clusters; with automatic conversion to corresponding data types, i.e. LabVIEW arrays are converted to Python lists, and clusters to tuples (and vice versa for the return value).
我使用 stdio 与 Python 进程进行通信有一段时间了,最近注意到 Python for .Net ( http://pythonnet.github. io/ )这对我有用。
只需将 .dll 复制到 LabVIEW 项目中,创建 .Net 构造函数,然后使用 LabVIEW .Net,您就可以快速了解如何使用该库,它基本上为您提供了非托管 Python 共享库,并封装了 .Net 的优点。
I was using stdio communication with a Python process for a while and recently noticed Python for .Net ( http://pythonnet.github.io/ ) which works for me.
Just copy the .dll in your LabVIEW project, create .Net constructors, and using the LabVIEW .Net you can quickly figure out how to use this library, which basically provides you with the unmanaged Python shared library, wrapped with .Net goodness.
使用 Python 的服务器端
Labview 客户端
Server side with Python
Labview Client Side
有一个新的 Python/LabVIEW 连接器,主要由您真正构建,称为 TestScript 。它是一个免费的、源代码发布的完全双向的 Python/LabVIEW 连接器。您可以在Python脚本中控制LabVIEW,也可以从LabVIEW调用Python脚本。它附带了几个示例,说明如何将数据从 LabVIEW 发送到 Python 并返回结果。特别是,简单脚本示例 - Add on Python Side.vi 展示了 TestScript 如何完成您的需要。
享受!
There is a new Python/LabVIEW connector out, built mostly by yours truly, called TestScript. It's a free, source-released Python/LabVIEW connector that is fully bidirectional. You can control LabVIEW from within a Python script, and you can call Python scripts from LabVIEW. It ships with several examples illustrating how you can send data from LabVIEW to Python and get a result back. In particular, the Simple Scripting Example - Add on Python Side.vi shows how TestScript accomplishes what you need.
Enjoy!
Python-LabVIEW-Interface (PyLVi) 是一个基于 ZeroMQ 库调用 Python 函数并将结果读回 LabVIEW。
它支持类方法和属性的调用,并且可以处理结构化数据类型(例如Python字典映射到LabVIEW集群)以及numpy数组。
Python-LabVIEW-Interface (PyLVi) is an open-source project based on the ZeroMQ library to call Python functions and read the results back to LabVIEW.
It supports call of class methods and properties, and can handle structured datatypes (e.g. Python dictionaries are mapped to LabVIEW clusters) as well as numpy arrays.
您可以尝试以下操作: https:// /forums.ni.com/t5/LabVIEW-APIs-Documents/Open-Python-Interface/ta-p/3612981
它是 LabVIEW 的开放式 Python 接口工具包。
You can try this: https://forums.ni.com/t5/LabVIEW-APIs-Documents/Open-Python-Interface/ta-p/3612981
Its an Open Python Interface toolkit for LabVIEW.
这是一个很好的快速解决方案,但有点不优雅。只需使用 labview 和 python 都可以读取/写入的文本文件。 Labview 将命令写入文本文件,而 python 等待读取命令,反之亦然。您可以同时拥有一个读取文本文件和一个写入文本文件。然而,这是一个较慢的解决方案,因为读取和写入需要时间。
Here is a good quick solution but kind of unelegant. Just use a text file that both labview and python can read/write from. Labview writes commands to text file and python waits until a command is read or vice versa. you can have a read text file and a write text file at the same time. However this is a slower solution as it takes time to read and write.