Sharing Live Data Programmatically

You can use the DataSocket VI and functions to programmatically configure, read, or write live data.

(Real-Time, Windows) National Instruments recommends that you wire a Shared Variable node into VIs and functions to share live data programmatically.

Note��You can create, configure, and host shared variables only on Windows or RT targets with the LabVIEW Real Time Module. Use the DataSocket VI and functions to read or write shared variables from other platforms.

Using Shared Variables

Use shared variables to share data among VIs or between locations on the block diagram that you cannot connect with wires. You can share data using shared variables with little or no block diagram programming.

For the DataSocket VI and functions, you read or write data by specifying a URL in much the same way you specify URLs in a Web browser.

Specifying a URL

URLs use communication protocols, such as opc, ftp, and http on Windows, and psp, dstp, and file on all LabVIEW-supported platforms, to transfer data. The protocol you use in a URL depends on the type of data you want to write and how you configure your network.

You can use the following protocols when you read or write data using the DataSocket VI and functions or when you enable a connection for a control:

The following table shows examples of each protocol URL.

URL Example

psp

For shared variables:

psp://computer/library/shared_variable

For NI-PSP data items, such as server and device data items:

psp://computer/process/data_item

fieldpoint://host/FP/module/channel

dstp

dstp://servername.com/numeric, where numeric is the named tag for the data

opc

opc:\National Instruments.OPCTest\item1

opc:\\computer\National Instruments.OPCModbus\Modbus Demo Box.4:0

opc:\\computer\National Instruments.OPCModbus\Modbus Demo Box.4:0?updaterate=100&deadband=0.7

ftp

ftp://ftp.ni.com/datasocket/ping.wav

ftp://ftp.ni.com/support/00README.txt[text]

file

file:ping.wav

file:c:\mydata\ping.wav

file:\\computer\mydata\ping.wav

http

http://ni.com

Use the psp, dstp, and opc URLs to share live data because these protocols can update remote and local controls and indicators. Use the ftp and file URLs to read data from files because these protocols cannot update remote and local controls and indicators.

Data Formats Supported by the DataSocket VI and Functions

You can pass data of any LabVIEW data type using the DataSocket VI and functions. You also can use the DataSocket VI and functions to read and write the following data: