system.opc.browseSimple
This function is used in Python Scripting.
Description​
Allows browsing of OPC servers in the runtime returning a list of tags. browseSimple() takes mandatory parameters, which can be null, while browse() uses keyword-style arguments. The spelling on the opcServer
and device
parameters must be exact.
This function performs a fully recursive browse that can't be terminated, which can be especially problematic in larger systems. It is highly advised to use system.opc.browseServer instead since recursion with that function is driven by subsequent calls.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax​
system.opc.browseSimple(opcServer, device, folderPath, opcItemPath)
Parameters​
Type | Parameter | Description |
---|---|---|
String | opcServer | The name of the OPC server to browse |
String | device | The name of the device to browse |
String | folderPath | Filters on a folder path. Use * as a wildcard for any number of characters and a ? for a single character. |
String | opcItemPath | Filters on a OPC item path. Use * as a wildcard for any number of characters and a ? for a single character. |
Returns​
OPCBrowseTag[] - An array of OPCBrowseTag objects. OPCBrowseTag has the following functions: getOpcServer(), getOpcItemPath(), getType(), getDisplayName(), getDisplayPath(), getDataType().
Scope​
Gateway, Vision Client, Perspective Session
Code Example​
# This example will print out the the OPC item path for each item in a specific folder,
# Browse Ignition's OPC UA Server. This can be changed to match any connected OPC server.
server = "Ignition OPC UA Server"
# Focus on the "SLC" device connection. This must match a valid device connection in the OPC server.
device = "SLC"
# Specify that the folder path should contain "B3".
folderPath = "*B3*"
# This example is not filtering on a specific OPCItemPath, so it pass Python's None for this parameter
opcItemPath = None
# Call browseSimple and store the results in a variable. Note that it may take some time to complete the browse.
OpcObjects = system.opc.browseSimple(server, device, folderPath, opcItemPath)
# For each returned address, print out the
for address in OpcObjects:
print address.getOpcItemPath()