Labview:创建子VI使程序框图得以扩展 [英] Labview: creating subVIs makes the Block Diagram expand

查看:422
本文介绍了Labview:创建子VI使程序框图得以扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Labview中编写了一段相当复杂的代码(具有许多循环和其他序列).因此,我想创建许多子VI来使我的代码更清晰.

I wrote a rather complicated piece of code in Labview (with many loops and other sequences). Therefore I want to create many subVIs to make my code more clear.

当我要在子VI中包含代码的循环中时,新创建的子VI的图标与我的原始代码相距很远,从而导致了程序框图的扩展.

When I have a loop in the code I want to have in a subVI, the icon of the newly created subVI appears far away form my original piece of code, causing my Block Diagram to expand.

为什么会发生这种情况,我该如何避免呢?

Why does it happen and how can I avoid it?

我想转成subVI的那段代码:

The piece of code I want to turn into a subVI:

创建子VI后,框图的相同片段:

The same fragment of my Block Diagram after I created the subVI:

这是我新创建的subVI-与第一段代码相比,向右下方1 m处大约1 m:

And here is my newly created subVI - approximately 1 m to the right at 1 m down in comparison with the first piece of code:

推荐答案

感谢添加图像-这是对框图的充实.

Thanks for adding images -- that is quite an inflation of the block diagram.

我不知道为什么LabVIEW会采用这种方式,但是我的猜测是控件和指示器的引用正在发挥作用.

I don't know why LabVIEW is behaving that way, but my guess is that the control and indicator references are contributing.

关于防止这种情况发生的方法,除了重构代码(反正很有可能是必要的)之外,您可以尝试关闭自动布线:工具»选项»框图»取消选中启用自动布线" .

As for ways to prevent it from happening, aside from refactoring the code (which is likely necessary anyway), you can try turning off automatic wire routing: Tools » Options » Block Diagram » Uncheck 'Enable automatic wire routing'.

但是,要将框图的复杂性移到子VI中,将需要进行一些重构,因为您希望包含一个while循环,该循环可根据前面板输入更改行为(例如 stop abs 2 布尔按钮) ).否则,执行新的子VI时, stop abs 2 的值将不会改变.

However, to move the block diagram's complexity into a sub VI will require some refactoring because you want to include a while loop that changes behavior based on front panel input (like the stop abs 2 boolean button). Otherwise, whatever value stop abs 2 has when the new sub VI executes will not change while it's running.

LabVIEW帮助重申了这一点.点:由于端子仍保留在原始框图上,并且端子已连接至新的子VI,因此子VI不会在子VI内的每次循环中更新端子的值."

The LabVIEW Help reiterates this point: "Because the terminal remains on the original block diagram and the terminal is wired to the new subVI, the subVI does not update the value of the terminal on every iteration of the loop inside the subVI."

这是插图.

在执行过程中,要从子VI 发送输入和接收输出,需要一些数据同步,例如队列或通知程序.典型的设计模式包括:

To send input and receive output from a sub VI while it is executing requires some data synchronization like queues or notifiers. Typical design patterns for this include:

  • Producer/Consumer on the targeted and simple side, to
  • Queued Message Handler in the middle, to
  • Actor Framework on the general and complex side.

这篇关于Labview:创建子VI使程序框图得以扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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