Is there any way to get the OPC connection names dynamically

Is there any way to get the OPC connection names dynamically, i didn’t see any functions in the manual. Thanks

Try the IALabs Scripting Module: system.opc.browse

That’s awesome, just what i thought I needed!

I need a list of OPC Server names, any suggestions where or if I can get those? Thanks again

FWIW, the IALabs Scripting Module functions are built in to Ignition 7.7.

Hi kathy,

Is there a way I could get the OPC server names dynamically? Thanks

Seems like example 1 in the docs for system.opc.browse() does this…

you have to specify the OPC server to browse with system.opc.browse(opcServer, device, folderPath, opcItemPath) according to the docs. I wanted a list of all current OPC Servers available. Thanks

Sometimes parameters to a function or method in computer programming are optional. While the documentation may be a little lacking in saying that it is optional, you can easily see in the first example that it is optional. Just try it out:

Example 1: Browse every OPC server

tags = system.opc.browse()
for row in tags:
    print row.getOpcServer(), row.getOpcItemPath(), row.getType(), row.getDisplayName(), row.getDisplayPath(), row.getDataType()

UPDATE: Here’s the code to get the list of unique servers:

tags = system.opc.browse()
servers = []
for row in tags:
    server = row.getOpcServer()
    if server not in servers:
print servers

I saw that thanks, but when i try example 1 i get an error: CANNOT BROWSE, SERVER IS FAULTED. The problem is, none of my OPC servers are faulted.

pretty weird

I had no problem copy/pasting example 1 this morning. You might try contacting tech support to see why you’re having issues.