tags:

views:

98

answers:

2

I'm writing opc client, using .NET API from opc foundation.

In samples I only see, where item's names are hardcoded like:

items[0] = new Opc.Da.Item();
items[0].ItemName = "blahblahblah";

What I want, is not to write names of all items by my hands. I want to load all items from server, into tree for example. How can I do it?

A: 

Well, I'm not familiar with your opc client library, but you should be able to browse the servers items. This is a common feature used by many standalone OPC-Clients.

PVitt
+1  A: 

You can browse the server with the following construct:

using Opc.Da;
using Server=Opc.Da.Server;
using Factory=OpcCom.Factory;

string urlstring = string.Format("opcda://{0}/{1}/{{{2}}}", _hostName, _serverName, serverid);
Server s = new Server(new Factory(), new URL(urlstring));
ItemIdentifier itemId = null;
BrowsePosition position;
BrowseFilters filters = new BrowseFilters() {BrowseFilter = browseFilter.item};
BrowseElement[] elements = s.Browse(itemId, filters, out position);

The tags are in elements[i].Name.

yes. i used same code. but. i have folders on server... and your code doesnt show them
eba