简体   繁体   English

如何在linux上从python控制labview中的实验?

[英]How to control experiment in labview from python on linux?

I need to open labview experiment (.vi file) from python, pass parameters to it and start experiment.我需要从python打开labview实验(.vi文件),将参数传递给它并开始实验。 Everything should be done on ubuntu 20.4.一切都应该在 ubuntu 20.4 上完成。 I found out it can be done with tcp communication, but it's quite complicated, is there any easier way ?我发现它可以通过tcp通信来完成,但是它很复杂,有没有更简单的方法? For example on windows you can do it very easily when you import win32com.client :例如在 Windows 上,当你导入 win32com.client 时,你可以很容易地做到这一点:

labview = \win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference("Example.vi")
VI.setcontrolvalue('Period', 1.5)
VI.setcontrolvalue('file_path', "C:\\new.txt")

try:  # have to do this,otherwise: TypeError: 'NoneType' object is not callable
    VI.Run(False)  # False=wait until vi finishes, True=don't wait

except:
    print("Exception")
    pass

Take a look at the python_labview_automation package .看看python_labview_automation 包 While I have not tested it myself it looks as if it does exactly what you want.虽然我没有亲自测试过它,但它看起来好像完全符合您的要求。

It only depends on Windows to start the actual LabView instance and run the server-side VI that is contained in the package.它仅依赖于 Windows 来启动实际的 LabView 实例并运行包中包含的服务器端 VI。 So you can either start LabView yourself or modify the package to know how to start LabView under linux.所以你可以自己启动LabView,也可以修改包来了解linux下如何启动LabView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM