本篇將進一步的說明動態裝載與呼叫時,會用到的 Open VI Reference元件。
Option:
1 0x0(預設值):只能只用 call by reference
2
0x08:可使用於一般執行或同行(reentrant)執行,只能使用於run vi property 執行。如果要用於同步執行,參數不需增加0x40,只需要將被呼叫的背景程式的VI Properties設定視窗,依需求要設定為 Shared clone reentrant execution或Preallocated clone reentrant execution。這邊需注意的是左圖中的Wait Until Done需設定為False,主程式才能呼叫多次背景程式,不然會在第一次呼叫時就暫停執行,並等待背景程式執行完畢。
3
0x40:啟用同步執行VI,並共享data。執行方式分為 call
by reference 和 start asynchronous call 。
3.1
Call by reference:下圖使用Parallel For Loop Iterations,由於是同步執行,所以此處的error
cluster 不需要使用 shift register。
3.2
Start asynchronous call:透過 start asynchronous call 執行的可建立背景程式,並依照是否讀取背景程式的輸出來設定Open VI Reference 的 option值。
3.2.1
如果不需要讀取背景程式的輸出值,則option設定如下圖左方,0x80為不需讀取背景程式輸出值的設定碼。右圖為被呼叫的背景程式的VI Properties設定視窗,依需求要設定為 Shared clone reentrant execution或Preallocated clone reentrant execution。
3.2.2
如果需讀取背景程式的輸出值,則option設定如下圖左方,0x100為需讀取背景程式輸出值的設定碼。右圖為被呼叫的背景程式的VI Properties設定視窗,須設定為 Shared clone reentrant execution或Preallocated clone reentrant execution。
4
0x80:並且不需要管理其運行的背景程式,不讀取背景程式的輸出數據。只能用
Start Asynchronous Call執行
5
0x100:只能用 Start Asynchronous Call執行。並且透過Wait On
Asynchronous Call讀取背景程式的輸出數據。
參考程式: labview\examples\viserver\AsynchronousCallByReference\TCPDateServerUsingStartAsynchronousCall.llb
labview\examples\viserver\AsynchronousCallByReference
labview\examples\viserver\AsynchronousCallByReference
labview\examples\viserver\AsynchronousCallByReference
labview\examples\Application Control\VI Server\Asynchronous Call By Reference\ Benchmarking Asynchronous Calls
參考程式: labview\examples\viserver\AsynchronousCallByReference\TCPDateServerUsingStartAsynchronousCall.llb
labview\examples\viserver\AsynchronousCallByReference
labview\examples\viserver\AsynchronousCallByReference
labview\examples\viserver\AsynchronousCallByReference
labview\examples\Application Control\VI Server\Asynchronous Call By Reference\ Benchmarking Asynchronous Calls