Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Read a list of OPC Tags using .net

How can you read a list of OPC tag names from an OPC server using .net (measurement studio)?

 

I've built an application to connect to various tags via the DataSocket object in NationalInstruments.Net.  

I've seen a related post but the solution is in labview and I cannot view the VI's as I dont have labview.

http://forums.ni.com/t5/LabVIEW/OPC-Can-I-read-in-a-list-of-all-available-tag-names/m-p/1455454#M555...

0 Kudos
Message 1 of 4
(4,031 Views)

Hi blamarche,

 

If you haven't already, I would recommend checking out this manual on the use of the DataSocket library in Measurement Studio. It contains quite a bit of information that may be helpful for your application.

Using the Measurement Studio DataSocket .NET Library: http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/usingninetdatasocket/

Tom D.
Staff Software Engineer
NI
0 Kudos
Message 2 of 4
(4,005 Views)

Thanks Tom.  This is kind of what I was going after but not fully.  

 

The DataSocket.SelectUrl method brings up an interactive browser window that allows a user to select a tag from the tag list.  I want a method that returns an IEnumerable<string> or such of tag names, and not defer to an external dialog window.  So this gets me about 30% of where I want to be.  I did find another library (albeit COM based) a way to extract the names of the tags on a server, so I think I'll use that instead.

 

But brings up another question: why does Labview (or supplied VI's) provide VI's that can return a list of OPC servers installed on a machine, and their subsequent tags, while measurement studio does not?  

0 Kudos
Message 3 of 4
(4,002 Views)

Hi blamarche,

 

After reviewing the DataSocket API, I don't believe there is a simple way to grab the names of all the OPC tags with it. It is unfortunate that the API contains a function to allow the user to grab the data, but not the ability to grab all of it programmatically. Alternatives would be either...

 

1.) Using the NetworkVariable API instead of the DataSocket API. I have attached some more documentation which details how to do this--however, using the API for this example requires the use of the LabVIEW Datalogging and Supervisory Control (DSC) Run-Time System, for which you would need to purchase a license.
2.) Using LabVIEW to build the example you linked as DLL. Again, this would require a LabVIEW license.

 

Using OPC with the Measurement Studio Network Variable Class Library: http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/networkvariableopc/

Tom D.
Staff Software Engineer
NI
0 Kudos
Message 4 of 4
(3,987 Views)