如何通过ActiveX调用将Labview VI作为后台任务运行? (不让ActiveX忙) [英] How can a Labview VI be run as a background task through an ActiveX call ? (without keeping ActiveX busy)

查看:308
本文介绍了如何通过ActiveX调用将Labview VI作为后台任务运行? (不让ActiveX忙)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过Matlab中的ActiveX执行Labview VI.

I would like to execute a Labview VI through ActiveX in Matlab.

我使用以下命令:

e=actxserver('LabVIEW.Application');
vipath='C:\DATA\Labview\test.vi';
vi=invoke(e,'GetVIReference',vipath);
vi.Run;

这可以正常运行,并且可以看到该VI在其前面板上执行. 但是,Matlab一直等到VI终止. 我希望Labview在不通知Matlab(通过ActiveX)等待的情况下静默运行VI.

This works correctly and the VI is seen to execute on its front panel. However, Matlab keeps waiting until the VI has terminated. I want Labview to run the VI silently, without telling Matlab (through ActiveX) to wait.

如何在不使ActiveX繁忙的情况下执行VI?有没有这样做的标准方法? (考虑到面向多任务的Labview的情况,我认为应该有这种情况-标准格式的Matlab并非如此.)

How can a VI be executed without keeping ActiveX busy ? Is there a standard way to do so ? (I assume there should be, given how multitask-oriented Labview is - which is not the case of Matlab in its standard form).

推荐答案

我终于找到了答案(感谢NI论坛上的smercurio_fc):

I finally found the answer (thanks to smercurio_fc on the NI forum):

要在后台运行VI(无需等待完成):
vi.Run(1);

要运行它并等待其执行完成:
vi.Run(0);

vi.运行;

在使用 vi.Run(1)的后台执行模式下,可以通过 vi.Abort 中断执行.在执行期间,可以使用vi.SetControlValue和vi.GetControlValue更改输入和输出值.
例如,要在执行期间获取数控"z"的值:
vi.GetControlValue('z')

To run the VI in the background (without waiting until done):
vi.Run(1);

To run it and wait until its execution is complete:
vi.Run(0);
or
vi.Run;

In the background execution mode with vi.Run(1), execution can be interrupted with vi.Abort. During execution, input and output values can be changed with vi.SetControlValue and vi.GetControlValue.
For instance, to get the value of a numerical control 'z' during execution:
vi.GetControlValue('z')

这篇关于如何通过ActiveX调用将Labview VI作为后台任务运行? (不让ActiveX忙)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆