Anda di halaman 1dari 4

The LabWindows/CVI Network Variable Library provides a simple and robust mechanism to transfer data between programs running

on one or more machines on a network. This mechanism involves the creation and use of network variables which are similar to program variables in that they contain data but their scope extends to the entire network. A network variable is hosted by the NI Variable Manager running on one particular machine. The variable is identified by a fully qualified name that is similar to a UNC path and consists of the hosting machine name, a process name, and a variable name. Network variables are not limited to LabWindows/CVI programs but can also be used in programs written in LabVIEW and Measurement Studio. The LabWindows/CVI Network Variable Library provides many different ways to connect to network variables. In this document, we will discuss these connection types and how and when to use them. Network Variable Connection Types The LabWindows/CVI Network Variable library provides the following ways to connect to a network variable: Subscriber Buffered Subscriber Reader Asynchronous Reader Writer Buffered Writer The Subscriber, Buffered Subscriber, Reader, and Asynchronous Reader connections are used to read data from the variable. The Writer and Buffered Writer connections are used to write data to the variable. Subscriber The Subscriber connection is created by calling the CNVCreateSubscriber function. This connection is a subscription to the network variable which results in the users callback function getting called automatically when the value of the variable changes.

This is the most efficient connection to continuously read from the variable. The user callback is called on a separate library thread and this makes the data communication independent of other activities in the program. The callback function should return back to the library as soon as possible to let the library thread process and post further data updates. While the callback is running, new data updates cannot be posted and if there is more than one new update then all but the latest update will be lost. This connection type is appropriate when you want to continuously and automatically get the variable value, as and when it changes. Buffered Subscriber The Buffered Subscriber connection is created by calling the CNVCreateBufferedSubscriber function. This connection is a subscription to the network variable and results in the variables values getting sent and cached automatically in a local buffer Reader The Reader connection is created by calling the CNVCreateReader function. This connection can be used to read the next value of the variable by calling the CNVRead function Asynchronous Reader The Asynchronous Reader connection is created by calling the CNVCreateAsyncReader function. This connection is similar to the Reader connection and can be used to read the next value of the variable by calling the CNVReadAsync function Writer The Writer connection is created by calling the CNVCreateWriter function. This connection can be used to write a new value to the variable by calling the CNVWrite function. Buffered Writer The Buffered Writer connection is created by calling the CNVCreateBufferedWriter function. This connection can be used to continuously write values to the variable.

The CNVPutDataInBuffer function places the value in a local buffer and returns immediately. The library automatically writes the buffered value to the network variable without blocking the user program. The size of the buffer is specified in the CNVCreateBufferedWriter function and can be changed by calling the CNVSetConnectionAttribute function. If the buffer is full, the CNVPutDataInBuffer function waits until the interval specified by the user elapses. If the data could not be places in the buffer within the specified time, then the function fails and returns a timeout error. This connection is appropriate if you want to write values continuously and automatically to the variable. Comparison of Read and Write Connections See Table 1 for a comparison of the various read connections. In most cases, you should use the Subscriber or Buffered Subscriber for best throughput and low latency. For deterministic on-demand reading you can use the Reader model. In specific use-cases, you may want to use the Asynchronous Reader. The Reader and Asynchronous Reader have lower throughput and more latency.

Anda mungkin juga menyukai