DataSocket Migration

Measurement Studio 2019 Help

Edition Date: May 2019

Part Number: 375857B-01

»View Product Info
Download Help (Windows Only)
Note Note   The DataSocket class library has been deprecated for Measurement Studio 2019, and is no longer supported. However, you can migrate your DataSocket data exchange applications to use Network Variable using the process below.
Note Note   This topic applies to the following editions: Enterprise, Professional.

You can use NetworkVariable to exchange different types of data between Measurement Studio, LabVIEW, LabWindows/CVI, and other applications that support NI-Publish Subscribe Protocol (psp:). NetworkVariable is the preferred method for transferring data between these applications, and, in these cases, NetworkVariable supersedes DataSocket. You can also use NetworkVariable to exchange different types of data between OLE for Process Control (opc:) servers. Exchanging data between Measurement Studio applications and OPC servers with NetworkVariable requires LabVIEW DSC Run-Time System.

The NetworkVariable .NET class library includes five classes that create the core network variable read and write functionality. The NetworkVariable library includes three readers, NetworkVariableReader<TValue>, NetworkVariableBufferedSubscriber<TValue>, and NetworkVariableSubscriber<TValue> and two writers, NetworkVariableWriter<TValue> and NetworkVariableBufferedWriter<TValue>. The DataSocket .NET class library consists of one core class, the DataSocket class, for read and write functionality. You use AccessMode to determine whether DataSocket reads or writes. The following paragraphs compare the core read and write NetworkVariable classes to DataSocket read and write functionality, and the following paragraphs explain how to migrate existing DataSocket code to achieve the same functionality in NetworkVariable.

NetworkVariableReader Generic Class

The NetworkVariableReader<TValue> class reads network variable on demand. NetworkVariableReader<TValue> has no direct equivalent in DataSocket. You can duplicate NetworkVariableReader<TValue> functionality in DataSocket by creating a manual reader, such as Read, calling Update, and then blocking for IsDataUpdated to become true within a certain time limit.

NetworkVariableBufferedSubscriber Generic Class

The NetworkVariableBufferedSubscriber<TValue> class reads network variable data from a client side buffer.

DataSocket equivalents:

VB.NET

Dim socket As DataSocket = New DataSocket()
socket.ReadMode = ReadMode.Synchronous
socket.AccessMode = AccessMode.ReadBuffered
socket.Update()
socket.SyncRead(1000)
C#

DataSocket socket = new DataSocket();
socket.ReadMode = ReadMode.Synchronous;
socket.AccessMode = AccessMode.ReadBuffered;
socket.Update();
socket.SyncRead(1000);
//Call Update and SyncRead for socket.Data to update
VB.NET

Dim socket As DataSocket = New DataSocket()
socket.ReadMode = ReadMode.Synchronous
socket.AccessMode = AccessMode.ReadBufferedAutoUpdate
socket.SyncRead(1000)
C#

DataSocket socket = new DataSocket();
socket.ReadMode = ReadMode.Synchronous;
socket.AccessMode = AccessMode.ReadBufferedAutoUpdate;
socket.SyncRead(1000);
//Call SyncRead for socket.Data to update
NetworkVariableSubscriber Generic Class

NetworkVariableSubscriber Generic Class

The NetworkVariableSubscriber<TValue> class subscribes to network variable data and receives update notifications.

DataSocket equivalents:
VB.NET

Dim socket As DataSocket = New DataSocket()
socket.ReadMode = ReadMode.Asynchronous
socket.AccessMode = AccessMode.ReadAutoUpdate
C#

DataSocket socket = new DataSocket();
socket.ReadMode = ReadMode.Asynchronous;
socket.AccessMode = AccessMode.ReadAutoUpdate;
VB.NET

Dim socket As DataSocket = New DataSocket()
socket.ReadMode = ReadMode.Asynchronous
socket.AccessMode = AccessMode.ReadBufferedAutoUpdate
C#

DataSocket socket = new DataSocket();
socket.ReadMode = ReadMode.Asynchronous;
socket.AccessMode = AccessMode.ReadBufferedAutoUpdate;

NetworkVariableWriter Generic Class

The NetworkVariableWriter<TValue> class writes network variable data on demand.

DataSocket equivalents:
VB.NET

Dim socket As DataSocket = New DataSocket()
socket.AccessMode = AccessMode.Write
socket.SyncWrite(2.34, 1000) 
C#

DataSocket socket = new DataSocket();
socket.AccessMode = AccessMode.Write;
socket.SyncWrite(2.34, 1000);

NetworkVariableBufferedWriter Generic Class

The NetworkVariableBufferedWriter<TValue> class writes network variable data to a client side buffer. DataSocket does not include a direct equivalent to NetworkVariableBufferedWriter<TValue> because DataSocket does not have a writer buffer. However, you can use NetworkVariableBufferedWriter<TValue> for all DataSocket writes, except when you use SyncWrite.

WAS THIS ARTICLE HELPFUL?

Not Helpful