Network Variable Technical Overview

Publish Date: Apr 09, 2014 | 7 Ratings | 3.29 out of 5 | Print

Table of Contents

  1. Overview
  2. Measurement-Specific Protocol
  3. What are Network Variables?
  4. Applications Using Network Variables
  5. Communication between Real-Time Applications
  6. Additional Resources

1. Overview

Linking together diverse hardware and software components can be challenging. Consider the example of porting data into and out of applications. First, you must measure the raw data using tools such as high-performance libraries for instrument control and data acquisition. Second, you must communicate between the applications using another set of technologies. Some applications save results to a file, while others use custom TCP/IP networking solutions, DDE, or ActiveX. Each I/O mechanism has unique nuances and requires certain expertise to implement.  This complexity forces a programmer to negotiate between the different protocols to transfer data, which requires a great deal of development time and resources.

As a solution, National Instruments provides network variables to simplify data exchange between applications on the same system or across the network.  You can also use the network variable application programming interface (API) to pass data between real-time systems without impacting performance. The API is designed in a way to abstract the low-level communication protocol, such as TCP/IP or DDE, while being flexible enough to support a wide variety of measurement data types, such as scalars, multidimensional arrays, and structs.

Back to Top

2. Measurement-Specific Protocol

NI designed network variable technology to meet the needs of measurement and automation engineers. With TCP/IP, you code to convert your measurement data to an unstructured stream of bytes in the broadcasting application, as well as code to parse the stream of bytes back into its original form in subscribing applications. The network variable read and write operations transparently convert your measurements to and from the underlying byte streams, eliminating the need to write complicated parsing code. Network variables transfer data in a self-describing format that can represent data in a wide array of formats, including strings, scalars, Boolean values, and waveforms. For example, your temperature measurement can include not only the acquired value, but also the timestamp of the acquisition.

Network variables use the NI Publish-Subscribe Protocol (NI-PSP) to send and receive data across a network.

Back to Top

3. What are Network Variables?

The term network variable refers to a variable that can exist on a network and can communicate between applications, remote computers, and hardware.

Figure 1. Network variables reside on a local or remote computer and have associated data types and names.

Reference a network variable using its pathname. The pathname is similar to a network file share name, such as \\machine\myprocess\item on Windows. In this example, machine is the computer name, IP address, or Fully Qualified Domain name of the server machine that is hosting the variable; myprocess contains network variable folders or variables and is referred to as a network variable process; and item is the name of the network variable. The following list shows additional examples of network variable references:

  • \\localhost\my_process\my_variable
  • \\test_machine\my_process\my_folder\my_variable
  • \\\my_process\my_variable
  • \\\my_process\my_variable
  • \\localhost\System\DAQmx\Server Polling Rate
  • \\localhost\system\my_variable

Network variable technology consists of three pieces – the Network Variable API,  the Shared Variable Engine, and the NI Variable Manager or NI Distributed System Manager.

Network Variable Library

The LabWindows/CVI Network Variable Library provides the following functionality:

  • Create connections to network variables. You can create the following types of connections:
    • Subscriber - Receive new data that is published to a network variable
    • Buffered Subscriber - Receive buffered data and check when the buffer is empty, overwritten, or stale
    • Writer - Update network variable with new data
    • Buffered Writer - Asynchronously update published data
    • Reader - Read new data stored in a network variable
    • Asynchronous Reader - Read new network variable data in an independent thread
  • Manipulate network variable data with the Network Variable Library Data Functions.
  • Automatically browse for available network variables using the NetworkVariablePopup function, available in the toolbox.fp instrument driver.
  • Create a custom interface to browse network variables using the Network Variable Library Browser Functions.
  • Create and configure network variables and network variable processes using the Network Variable Library Configuration Functions.

Shared Variable Engine

The Shared Variable Engine (SVE) is a software framework that enables a network variable to transmit live measurement data.  The shared variable engine can be hosted on Windows PCs and real-time targets. On Windows, LabWindows/CVI configures the SVE as a service and launches the SVE at system startup.  On a real-time target, the SVE is an installable startup component that loads when the system boots. 

In order to use network variables, an instance of the SVE must be running on at least one of the nodes in the distributed system. Any node on the network can read or write to network variables that the SVE publishes. You also might have multiple instances of SVEs installed on multiple systems simultaneously if you need to deploy network variables in different locations based on application requirements.

See Also: Shared Variable Engine

Managing Network Variables

You can use one of the following tools, included with your LabWindows/CVI installation, to manage network variables:

  • LabWindows/CVI 2009 and later: NI Distributed System Manager
  • LabWindows/CVI 8.1 - LabWindows/CVI 9.0: NI Variable Manager

Both the NI Distributed System Manager and the NI Variable Manager are stand-alone applications with which you can interactively configure network variables.

Figure 2. NI Distributed System Manager

Figure 3. NI Variable Manager

Differences between the System Manager and the Variable Manager

You can complete most of the same tasks in both the System Manager and the Variable Manager. However, the menu items and context menus you use to complete certain tasks vary between the tools. For example, to customize the alarms columns that appear in the Variable Manager, select Edit»Preferences. In the System Manager, click the Columns button in the Alarms and Events view. The System Manager provides windows called views, and you can customize what views to display and what to include in the views. For more information about the tasks you can complete in each tool, refer to the NI Distributed System Manager Help or the Variable Manager Help, which you can access from the System Manager and the Variable Manager, respectively.

To access the System Manager, select Start»All Programs»National Instruments»Distributed System Manager. To access the Variable Manager, select Start»All Programs»National Instruments»Variable Manager»Variable Manager.

Creating Network Variables

You can create network variables either explicitly or implicitly.

Explicitly Created Network Variables

You can create and configure network variables explicitly using the System Manager or Variable Manager. You can use these applications to create new processes and variables, delete existing processes and variables, start and stop processes, create variables with specific data types or the variant data type, allow multiple writers or restrict write access to a single client, configure server buffering, and so on. For more information, refer to the NI Distributed System Manager Help or the Variable Manager Help, which you can access from the System Manager and the Variable Manager, respectively.

Figure 4. Configuring a network variable with the System Manager

Figure 5. Configuring a network variable with the Variable Manager

Starting with LabWindows/CVI 8.5, you can also programmatically create and configure network variables explicitly using the Configuration Functions in the Network Variable Library. For more information, refer to the Library Reference»Network Variable Library section of the LabWindows/CVI Help.

Implicitly Created Network Variables

You can implicitly create network variables in the system process: a new variable is created automatically when you connect to it, if the process name is system and the variable name you specify does not already exist in the system process. For example, \\localhost\system\test implicitly creates a variable called test in the system process on your local computer. If the variable already exists, then your program connects to the existing variable and does not create a new variable. An implicitly created variable is automatically deleted by the server when all of its clients have disconnected. Implicit variables have no concrete data type and can hold values of any type. They always have the single-writer restriction and their values are not buffered on the server, but their values can be buffered on the client.

Back to Top

4. Applications Using Network Variables

Because network variables are a general-purpose programming tool for enhancing measurement applications, you can use them in a variety of different applications. The following section describes an example application.

Using Network Variables to Monitor Process Variables

Imagine a data acquisition board production factory that makes several different types of acquisition boards. Each type of board has its own production line, and each line has a computer that monitors the process variables. You are a systems engineer writing a LabWindows/CVI application that continuously monitors each of the process variables. Your application writes the live data to the central office over the local network. A computer in the central office gathers data and displays a live summary by production line and by process variable so that factory managers have an up-to-date picture of factory performance.

Without network variables, you would have to write a TCP/IP server and client application to transfer the data from the factory floor to the central office. The server application would acquire the process data, flatten the data into a bit stream, and transfer the data to the client.

The client reads, unflattens, and displays the data. In addition to the code required to read information from the server, the client application must also contain the code required to manage multiple connections—one connection for each process line. Writing all the low-level TCP/IP code to handle such data transfers would add a significant amount of overhead to the development process.

With network variables, you can easily handle the network communication required to move data from the factory floor to the central office. In LabWindows/CVI, use the CNVCreateBufferedSubscriber, CNVCreateBufferedWriter, CNVPutDataInBufferand CNVFinish functions to write and read process variable data. Because data is managed by the Shared Variable Engine, the central office application does not need to implement extra code to handle the additional connections of multiple production lines. It simply reads the data item for each line.

This example illustrates how to broadcast data over a local network. You could expand upon the acquisition board scenario by passing process control information from the central office back to the production lines. Because network communication can span Windows or real-time systems, your central office could be accessing diverse hardware and test systems around the world.

Back to Top

5. Communication between Real-Time Applications

The Shared Variable Engine can be accessed from NI LabVIEW, LabWindows/CVI, and Measurement Studio. With network variables in LabWindows/CVI and Measurement Studio for Visual Studio and shared variables in LabVIEW, you can easily perform cross-platform communication among several applications written in various languages.  The LabWindows/CVI Real-Time Module also expands the functionality of network variables. With LabWindows/CVI Real-Time, you can configure a network variable in conjunction with a thread-safe queue when handling data. Using thread-safe queues ensures that passing data between tasks or over the network does not add jitter to an application.

Back to Top

6. Additional Resources

LabWindows/CVI provides access to a wide array of technologies for creating distributed applications. The network variable introduced in LabWindows/CVI 8.1 is a major step forward in simplifying the programming necessary for such applications.


Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No