Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
1 rating:
 1 out of 5     Rate this Document

Migrating to Measurement Studio Network Variable from DataSocket

Primary Software: Measurement Studio>>Enterprise Edition (Full Development System)
Primary Software Version: 8.1
Primary Software Fixed Version: 8.1
Secondary Software: N/A

Problem:
How can I migrate to Measurement Studio Network Variable from DataSocket?

Solution:
You can use the NetworkVariable class library or the DataSocket class library to transfer live measurement data between applications and servers over the network. You can use NetworkVariable or DataSocket 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 and DataSocket 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. Use DataSocket to communicate directly with an OPC server.

The benefits to using NetworkVariable is that it provides server-side buffering, a more elegant API, no COM interop, and higher throughput. The benefit to using DataSocket is that you can connect directly to the OPC data point without going through the Shared Variable Engine as an intermediary, including the implied manual configuration in the Variable Manager, or purchasing the LabVIEW DSC Runtime.

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.

Note     For more detailed information about network variable, refer to Key Measurement Studio Network Variable .NET Library Features in the NI Measurement Studio Help.

Network Variable Readers

NetworkVariableReader<TValue>

This 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<TValue>

This class reads network variable data from a client side buffer.

 

DataSocket Equivalent:

[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.Asynchronous
socket.AccessMode = AccessMode.ReadBufferedAutoUpdate

[C#]

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

NetworkVariableSubscriber<TValue>

This class subscribes to network variable data and receives update notifications.

 

DataSocket Equivalent:

[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;

Network Variable Writers

NetworkVariableWriter<TValue>

This class writes network variable data on demand.

 

DataSocket Equivalent:

[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<TValue>

This 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.

 



Related Links:

Attachments:





Report Date: 02/16/2007
Last Updated: 01/25/2008
Document ID: 46FFG05E

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit