Apr-24-2021, 01:09 PM
(This post was last modified: Apr-24-2021, 01:46 PM by Ultrainstinct_5.)
(Apr-24-2021, 08:29 AM)ibreeden Wrote: Well then there is only one way left: we introduce an extra parameter: "superfolder". What is a superfolder? Well everybody knows what a subfolder is: a folder below the current folder. So a superfolder is the opposite: the folder(path) above.
ServerName = "LINX-7912 Server" root = "" def BrowseServer(server,root, superfolder = ""): #print 'started BrowseServer(%s,%s)' % (server,root) path_list = [] browseServer = system.opc.browseServer(server,root) for browse_object in browseServer: nodeName = str(browse_object.getDisplayName()) nodeId = str(browse_object.getServerNodeId().getNodeId()) elementType = str(browse_object.getElementType()) if elementType == "OBJECT": fullpath = superfolder + "/" + nodeName print fullpath path_list.append(fullpath) path_list += BrowseServer(server, nodeId, fullpath) return path_list obj_list = BrowseServer(ServerName,root) print "\n" for obj in obj_list: print obj(I could not test it so I hope i made no mistakes)
This seemed to work minus the extra forward slash at the beginning, take a look at the image, once again look at the "OPC Browse" Pane towards the left to see the folder structure of the OPC Server "LINX-7912 Server!
You can see from the new image there're two root folders "Loytec ROOT" and "Server" with that said each OPC server could have a different amount of root folders? I could easily strip the first forward slash, or modify.