Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

DataSocket Connect() timeout

    I'm am creating an application which uses datasockets to connect to compact FieldPoint modules.  The application works fine as long as the FieldPoint URLs used to connect the datasockets to the OPC server in the FieldPoint is correct.  However, I am working on creating a connection status/diagnostic page which will show the user which datasockets the application has successsfully established a connection with and which have issues.  I've found that there is no timeout functionality present in DataSocket.Connect().  If the URL is incorrect or the FieldPoint is not currently present the application will freeze as it searches the network for several fieldpoints and attempts to connect to the via DataSocket.   I would like to add a timeout to this connection attempt so that if the connection is not established in a few seconds the application assumes there is a connection error and proceeds.  Is there anything available which provides this functionality?  Do network variables allow for timeouts to be specified?  If so, are network variables reccommended for use with FieldPoints or should I stick with DataSocket?  Any tutorials/examples which address the issue would be much appreciated.
Thanks!
0 Kudos
Message 1 of 5
(4,964 Views)

Hi daringen,


Network variables are recommended for FieldPoint.  The Network Variable Technical Overview is a great starting point.   Also, you can find Measurement Studio specific information in the Measurement Studio help topic "Using the Measurement Studio Network Variable .NET Library".

There are network variable shipping examples that come with Measurement Studio as well.  They typically are located on your machine at the following path: C:\Documents and Settings\All Users\Documents\National Instruments\MStudioVS2005\DotNET\Examples\NetworkVariable .

 
Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 2 of 5
(4,929 Views)
Hi daringen,
 
I just wanted to add some additional information on top of what Jessica already mentioned. I would definitely encourage you to read through the tutorial that Jessica provided as well as look at the Key Measurement Studio Network Variable .NET Library Features help topic in the NI Measurement Studio Help. If you do decide to migrate to the Network Variable, check out the Migrating to Measurement Studio Network Variable From DataSocket help topic as well. 
 
You mentioned talking to OPC servers so I wanted to make clear the fact that you can use Network Variables to talk to OPC servers as long as LabVIEW DSC is in the picture.  Specifically, you need to have the LabVIEW DSC run time installed on the machine that will host the Network Variable engine that you will use to host the OPC variables.  You don't need the LabVIEW DSC development module.  If you decide not to purchase the LabVIEW DSC run time, you can still use DataSocket (i.e. like you currently are) to talk to the OPC servers. Check out the Using OPC with the Measurement Studio Network Variable Class Library help topic for more information.
 
Now, I don't want to get into to much detail about Network Variables, especially if you have never used them, but there are timeout options you can configure. For example, suppose you had a network variable reader declared as follows:

private NetworkVariableReader<double[]> _reader;

You could then say _reader.Connect(timeout) where this overload takes in a TimeSpan object.

Anyway, let me know if you have any other questions, or if something isn't clear.

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 3 of 5
(4,922 Views)

Jonathan,
Thanks for your reply.  How is the performance of talking to FieldPoint modules using OPC via network variables and the LabView DSC runtime?  My application must support real-time control and monitoring of the values on several FieldPoints at a sampling rate of about 0.25-0.5 seconds.  Also, are you suggesting that I use DataSockets in concert with Network Variables if I don't purchase the DSC Runtime or as a standalone solution?  Would you reccomend using DataSockets to perform the low level data aquisition and then publishing the data to Network Variables for use by my client application?  If so, how should DataSockets publish to the Shared Variable engine/Variable manager?  Something the approach suggested here? i.e. write the data to an existing variable like so:
psp:\\localhost\[Library]\[VariableName]  Which method would provide the best performance and reliability when communicating with FieldPoints?
Thanks for your assistance.

 
0 Kudos
Message 4 of 5
(4,889 Views)

Hi daringen,

DataSocket and Network Variable use different underlying protocols and its a known fact that the new protocol (PSP) is much faster.  I'm not an expert on OPC servers and FieldPoint and from what I understand, there is a variety of ways to connect to OPC servers.  I found several documents that discuss options (most of which are with respect to LabVIEW but they are good references) with regards to performance. If you want an exact answer on performance, you probably want to post that question either on the LabVIEW forums or FieldPoint forums.  The documents I found that might help include:

DataSocket Performance is slow - Forum post
LabVIEW DSC Module OPC Client Performance Considerations - KB

Now, I can say a few extra comments from the Measurement Studio side of things.  The NetworkVariable is the preferred method for transferring data between applications.  You can use NetworkVariable and DataSocket to exchange different types of data between 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.

There is a variety of benefits to using the NetworkVariable including the fact that it provides server-side buffering, its a more elegant API, there isn't any COM interop, and you receive 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.

You could use DataSocket to communicate to the OPC servers directly, gather the data and and then write that data to some Network Variable.  That KB you mentiond shows how to do that. 

Hope this helps!

Best Regards,

 
Jonathan N.
National Instruments
0 Kudos
Message 5 of 5
(4,886 Views)