Utilizing LabVIEW Polymorphic VIs to Access Variables Directly by Name

Back to Document

For engineers who need direct access to variables by label name, LabVIEW polymorphic VIs is a method within the graphical programming language that incorporates benefits of dataflow based programming architecture with traditional text based variable accessibility. Unlike text based programming languages, LabVIEW has the power to incorporate both methods of handling variables. This document described the approach and provides an example program.

Table of Contents:
 Introduction

Traditional text based programming languages allow access to variables directly by name. When the number of variables increase to several hundreds or even thousands, it is sometimes necessary to access these variables by name to:

1. Avoid having to handle indexing of arrays or un-bundle / bundle clusters every time a variable is being accessed.
2. Avoid excessive wire clutter in the graphical program if proper bundling techniques are not utilized.

LabVIEW is a graphical programming language that typically transports data in wires of different types.
 Polymorphic VI functioning as a memory location

The basic approach described here utilizes polymorphic VIs to access variables directly by name. Two types of operation on the variables are described: Get and Set. In this example, a data array is given to the main program. This data-array is an array of clusters. Each cluster contains one of each type variable that needs to be accessed. Attached to the data-array is an index array, providing label name for every index in the array of cluster elements (Figure 1).



Figure 1: Index array, providing label name for every index in the array of cluster elements.


The memory VI stores the data in an un-initialized shift register (Figure 2):



Figure 2: Storing the initial memory data


The general operation of the polymorphic memory VI (getting and setting values) is described in Figure 3 and 4.



Figure 3: Setting the value of a memory location (Boolean data type in this example).




Figure 4: Getting the value of a memory location (Boolean data type in this example).
 Accessing the memory location

The memory elements are now accessed by calling them by name and selecting a datatype. In the Set case, the datatype wired into the polymorphic VI selects the instance of the VI that is executed. Polymorphic VIs are not intended to adapt to the type of an indicator wired to an output. Hence, it is necessary to wire a type input to the polymorphic VI that will be used in the "Get" case (see figure 5 below).




Figure 5: Example of how to get a double precision memory value, adding 5 to its value, and storing it again. As seen, access to the memory location is by name.


As with all type propagation, all information flows downstream from controls through nodes to indicators. Another way of adding the data type manually is by right clicking on the polymorphic VI and selecting type instead of automatic (for a particular instance of the Sub-VI). This can in several cases turn out to be the best choice since the number of wires are minimized.



Figure 6: The next state entered in the machine accesses the new variable value by name, and the data type is set by right-clicking on the polymorphic VI instead.

 Conclusion

It has been demonstrated that by utilizing polymorphic VIs and un-initialized shift registers, calling variables by name to and from a memory location can be simulated.

Related Links:
Accessing LabVIEW Variables Directly by Name

转载于:https://www.cnblogs.com/Qia_sky/archive/2005/09/09/233205.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值