References 與 Property Node?

最近在看Labview style book,擷取部分不懂的片段。

 

Some applications require large numbers of Property Nodes for controlling GUI behavior.

 

Most Property Node read and write operations are triggered by GUI events. Consequently, the Event structure is an ideal construct for handling Property Nodes.

 

Because the Event structure contains separate subdiagrams for each event case, it is uncommon to run out of space.

 

However, it is common to have multiple event cases that require many of the same Property Nodes, with different values read or written to them in each.

 

Modularize these common Property Nodes into subVIs, and pass the Control References and property values to the subVI in each location.

 

Each instance of the subVI refers to the same collection of Property Nodes in memory. This substantially reduces memory use and diagram complexity.

 

 

目前看到第四章,這段講到控制元件使用References和Property Node傳遞到子VI中。每個子VI代表在記憶體中同一份Property Node的備份。大幅減少記憶體的使用和程式複雜性。

 

有點難領悟,不知道有沒有大大可以舉個實例解釋一下,這樣的做法要如何實踐,為何可以減少暫存的使用呢?

你可以試試用以下的方式讓labview自動幫你生成使用reference的寫法。


1. 先建立以下這一個簡單的程式,其實動點是那個local variable,你可以寫其他的程式,但要有local variable


2. 用滑鼠把local variable框起來後,點選「edit」>「create SubVI」


3. 接下來labview就會把你所框選的區域包成subVI,注意:reference已經自動生成了


4. 點進去看看subVI的內容,看看程式的寫法

大大您好,非常感謝您的回覆。

這個功能我會了,非常感謝。
但是疑惑更多了~

1.請問這樣傳Reference跟直接使用區域變數哪個比較好?
2.我看到一篇文章說,使用property node會讓程式效率降低,據說是跟UI線程的切換有關?
也看到有人說全域變數與區域變數其實現在的電腦等級都能應付,但是當我看到我的程式累積幾十個區域變數和全域變數的時候,

有種感覺像是在用Labview實踐C語言,所以想嘗試練習不使用區域變數來寫程式看看,因此開始找相關資料,不知道大大們有什麼好的建議?

借個版面請教一下,

當我創建SubVI時常會出現以下警告,
到底是甚麼原因呢?
(此例只選取local variable部分來創建subVI)
tingway40716.4379976852

請問這兩種在執行上有甚麼差別呢?
一般推薦使用因素是怎樣?
亦或者都不建議使用?能避免則避免?

就References與Property Node比較References較優,但是要拉線.下面文章參考看看.

http://it360.tw/forum/forum_posts.asp?TID=13267&KW=local

![](upload://jzGOiAiXnjBJwHi9tlB57hVLhlQ.jpeg)

[QUOTE=DonWang]

<span =lgtext=“”><font =forumsubject=“” size=“3” face=“verdana”>就References與Property Node比較References較優,但是要拉線.下面文章參考看看.

http://it360.tw/forum/forum_posts.asp?TID=13267&KW=local

[/QUOTE]

感謝大大的回覆

這部分真的很特別,所以如果只針對值得操作,還是直接用區域變數比較好囉?
需要改到屬性才來決定要用References還是Property Node


最近看到一個程式,程式開始的時候把UI所有個元件建立一個Reference綁起來到一個VI裡面集中管哩,然後把所有值龜0,控制那些東西一開始要顯示,一開始要隱藏,哪些要Disable,大概是所謂的初始化處理。

結果剛執行就非常頓,這時候去操作UI就很容易死當,但程式卻不會出現無回應!!
但最嚴重一次還是電腦直接重開機....真誇張...

Referencesc還是Property Node感覺都要謹慎使用!!