system.opc.browseSimple time out error

Here’s some code you can use as a springboard for playing with system.opc.browseServer and figuring out how it works. Be careful when increasing the maxDepth parameter, especially if you’re starting at or near the root, there’s no way to stop the browse once it starts!

import system
from functools import partial

maxDepth = 1
serverName = 'Ignition OPC-UA Server'

def browse(nodeId, depth = 0):
	children = system.opc.browseServer(serverName, nodeId)
	
	for child in children:
		elementType = str(child.getElementType())
		childNodeId = child.getServerNodeId().getNodeId()
		
		print '%s%s' % (depth*'    ', childNodeId)
		
		# this is where you might check to see if child is one of the
		# tags you're looking for. you might also use additional criteria
		# to determine if you should continue browsing underneath 
		# this child in addition to elementType and maxDepth...
		
		if (elementType == 'FOLDER' and depth < maxDepth):
			browse(childNodeId, depth + 1)
			
root = '[logix57]'

system.util.invokeAsynchronous(partial(browse, root))
1 Like