LabView使用属性节点的Value传输数据和局部变量的区别
(2010-06-01 00:38:08)
标签:
杂谈 |
There are some
subtle differences that are detailed here.
它们之间有一些微妙的差别,如下所述。
The property node allows the reading and writing of a single control within a cluster whereas a local variable and terminal will always refer to the entire cluster. A property
node can update the value from a remote location, not on the
diagram associated with the panel. If you are
using a non-strict control reference, then the data type of the
value may be a variant rather than the actual data type of the
control.
属性节点允许读写一个簇中的单个控制量而局部变量和端口往往指向整个簇。一个属性节点可以不在与前面板相关的程序框图中远程更新数据。如果你使用一个非严格的control reference, 则数值的数据类型可能是一个变量而不是控制量的实际数据类型。
Due to these differences, there are also some performance differences. If updating something like a graph, you would sometimes need to position two cursors, change some colors, and write the data to the graph. In the past this
would require two nodes, one for properties and another (terminal
or local) for the value. This resulted in two
graph redraws. Adding the value property to the
existing node and not using the terminal or local will result in
one less graph redraw, which may or may not be important for your
application.
由于这些不同,也会有一些性能(表现)上的差异。如果更新一些像图表(graph)的端口,有时你将需要定位两次光标,用以改变颜色,和写入数据到图表中。在过去这需要两个节点,一个用于属性,另一个(端口或局部变量)用于数值。这导致了两次图表的重绘。添加一个数值属性到一个已经存在在节点而不是用端口或者局部变量可以减少一次图表重绘,这对你的应用来说也许重要或者不重要。
On the other hand, because they can update a subset of the data, property nodes do not implement the same shortcuts that the locals and terminals do. When updated with the same
value over and over, a local and terminal will not redraw the
control, but the value property will.
Additionally, for controls that are updated very quickly i.e. more
than 50 times a second, terminals and locals have the option to
amortize the redisplays and save CPU cycles that would otherwise be
spent redrawing things you wouldn't see anyway.
There is the option to synchronize the display with the diagram
updates, and the value property is basically stuck using this
synchronized version each time. This is identical
to how controls and indicators updated before LabVIEW 5, and it is
still how the displays are done on single threaded systems such as
any Macintosh with OS 9.x or previous.
另一方面,用于它们可以更新数据的一个子集,属性节点不采用与局部或者端口变量同样的快捷方式。当采用同一个数值重复更新时,一个局部或者端口变量将不会重写控制变量,但是数值属性会。另外地,对于更新非常快的控制变量来说,例如,每秒超过50次,端口和局部变量有分摊(amortize)重复显示的选项,并且节省CPU循环时间,否则这些将会花费在你不管怎样也不需要看到的数值重写过程中。这里有一个选项可以将显示与程序框图更新同步,数值属性基本上每次都固定在使用这种同步方式。这与LabVIEW 5之前控制和指示变量更新数据采用的方式是同样的,这仍然是单线程系统像任何具有0S 9.x或之前版本的Mcintosh中显示怎样完成的。
To see this, drop a for loop, wire i to an indicator and have the loop execute 1,000,000 times. Initially, update
the indicator with the terminal. Run the program and it will take a
fraction of a second. The indicator will display
0, a few numbers in between, then 999,999. Move
the terminal out of the loop and update with a
local. You will see the same.
Now popup on the indicator and choose synchronous display -- it is
in the Advanced option in LabVIEW 6.x and 7.x.
Now you will probably need to abort the VI because it will take
several minutes to run because it is drawing every single number to
the screen making a nice blur of digits for you to look
at. Now, delete the local and use a property node
instead. Regardless of the setting of the
synchronous display, you will see the display is showing each and
every one of the updates.
为了理解这一点,放置一个for循环框,将循环次数i连到一个指示变量,将循环执行1,000,000次。开始,用端口更新指示变量。执行程序,它将花费几分之一秒。指示变量将显示0,之间的一些数值,然后999,999。将端口移出循环,用局部变量来更新指示变量。你将会看到同样的情况。现在右键单击指示变量,在弹出的菜单中选择同步显示,在LabVIEW6.x或7.x版本中在高级选项里。现在你大概需要中止VI,因为这将要花费数分钟的时间去运行,因为程序将在屏幕上显示每个单个数值以使你能看清每一个数值。现在,删去局部变量而使用属性节点代替。不管有没有设定同步显示,你将可以看见每次更新的每一个数值。
The fact that the value can be set from subVIs is a great feature, but it will make your diagrams more difficult to debug if you make a mistake. When a string or the indicator has the
wrong value being displayed, you need to find the code that did the
update. If only using the terminal, there is only
one place the indicator is updated, and you can work backwards from
the terminal. If using locals, then you have a
list of places to work backwards from. If you are passing the
control reference to the indicator to some number of subVIs, then
you can have many potential "updaters", including dynamic
ones. So, while this is a nice feature for
modularizing code and separating it from the display, be careful or
it will have debugging expenses that you may not want.
The following link details LabVIEW performance and memory management. It includes descriptions of tools for profiling your VIs to see changes in memory and running time.
它们之间有一些微妙的差别,如下所述。
The property node allows the reading and writing of a single control within a cluster whereas a local variable and terminal will always refer to the entire cluster.
属性节点允许读写一个簇中的单个控制量而局部变量和端口往往指向整个簇。一个属性节点可以不在与前面板相关的程序框图中远程更新数据。如果你使用一个非严格的control reference, 则数值的数据类型可能是一个变量而不是控制量的实际数据类型。
Due to these differences, there are also some performance differences. If updating something like a graph, you would sometimes need to position two cursors, change some colors, and write the data to the graph.
由于这些不同,也会有一些性能(表现)上的差异。如果更新一些像图表(graph)的端口,有时你将需要定位两次光标,用以改变颜色,和写入数据到图表中。在过去这需要两个节点,一个用于属性,另一个(端口或局部变量)用于数值。这导致了两次图表的重绘。添加一个数值属性到一个已经存在在节点而不是用端口或者局部变量可以减少一次图表重绘,这对你的应用来说也许重要或者不重要。
On the other hand, because they can update a subset of the data, property nodes do not implement the same shortcuts that the locals and terminals do.
另一方面,用于它们可以更新数据的一个子集,属性节点不采用与局部或者端口变量同样的快捷方式。当采用同一个数值重复更新时,一个局部或者端口变量将不会重写控制变量,但是数值属性会。另外地,对于更新非常快的控制变量来说,例如,每秒超过50次,端口和局部变量有分摊(amortize)重复显示的选项,并且节省CPU循环时间,否则这些将会花费在你不管怎样也不需要看到的数值重写过程中。这里有一个选项可以将显示与程序框图更新同步,数值属性基本上每次都固定在使用这种同步方式。这与LabVIEW 5之前控制和指示变量更新数据采用的方式是同样的,这仍然是单线程系统像任何具有0S 9.x或之前版本的Mcintosh中显示怎样完成的。
To see this, drop a for loop, wire i to an indicator and have the loop execute 1,000,000 times.
为了理解这一点,放置一个for循环框,将循环次数i连到一个指示变量,将循环执行1,000,000次。开始,用端口更新指示变量。执行程序,它将花费几分之一秒。指示变量将显示0,之间的一些数值,然后999,999。将端口移出循环,用局部变量来更新指示变量。你将会看到同样的情况。现在右键单击指示变量,在弹出的菜单中选择同步显示,在LabVIEW6.x或7.x版本中在高级选项里。现在你大概需要中止VI,因为这将要花费数分钟的时间去运行,因为程序将在屏幕上显示每个单个数值以使你能看清每一个数值。现在,删去局部变量而使用属性节点代替。不管有没有设定同步显示,你将可以看见每次更新的每一个数值。
The fact that the value can be set from subVIs is a great feature, but it will make your diagrams more difficult to debug if you make a mistake.
The following link details LabVIEW performance and memory management. It includes descriptions of tools for profiling your VIs to see changes in memory and running time.

加载中…