system.opc.getServers() returns different results Perspective v.s. Vision

I am puzzled that system.opc.getServers() in Ignition 8.0.6 Stable (b2019111216) returns different results when executed from a button in Perspective versus Vision. In perspective it does not return disabled OPC server connections. Maybe I am missing something.

# Perspective button example
headers = ["OPCServer", "ServerState"]
data = []
servers = system.opc.getServers()
if not servers:
    print "No servers found"
    data.append(['No servers found', 'unknown'])
else:
    for server in servers:
        data.append([server, system.opc.getServerState(server)])
self.getSibling("OPCServerTable").props.data = system.dataset.toDataSet(headers, data)	



# Vision button example
headers = ["OPCServer", "ServerState"]
data = []
servers = system.opc.getServers()
if not servers:
	print "No servers found"
	data.append(['No servers found'])
else:
	for server in servers:
		print server
		data.append([server, system.opc.getServerState(server)])
print data
event.source.parent.getComponent('Table').data = system.dataset.toDataSet(headers, data)	

Thanks!

Huh, yep, gateway vs client scope has different implementations (perspective is gateway scope).

The good news is this is a known bug. The bad news is that it’s on a pretty low priority backlog. I added this thread, which may help kick it to a higher priority tier.

I’m gonna bump this, as I just ran into this on 8.0.9. I have a script that checks for disabled servers and re-enables them. As you can imagine, that doesn’t work.

I worked around it by specifically naming them, but it goes against my sense of lazy. :slight_smile:

Well, the bad news is that the ticket suggests getServers shouldn’t return disabled servers in any scope, so…

If that is so, then some of the usefulness of system.opc for server information gets crippled. :man_shrugging:

1 Like

Maybe we can make it take a keyword arg parameter includeDisabled that defaults to false if not specified.

This would keep all the existing function calls working (though not how you wish), but there’d be a new parameter to let you get disabled servers as well.

1 Like

This was implemented and released in 8.0.14.

1 Like

Any chance to make it work on 7.9.17 ? we are not yet ready to move to v8 and we would like to use it our project as soon as possible

Never mind. I manage to find a solution to skip the problem. Instead of getting the list of servers by calling the system.opc.getServers() I just use this piece of code:

tags = system.tag.browseTagsSimple("[System]Gateway/OPC/Connections","ASC")
OPCServers=[]
for tag in tags:
	if tag.isFolder():
		OPCServers.append(tag.name)