opcua/BareboneClient
1 # load cvb.opcua
2 import cvb
3 import cvb.opcua
4 
5 
6 def make_browse_filter():
7  # define parameters for browsing
8  bd = cvb.opcua.ReferenceDirection.Forward
9  relationship = cvb.opcua.ReferenceType.Hierarchical # relationship to explore
10  max_ref = 5000 # max number of references to follow
11  # allow subtype of search type
12  allow_subtype = cvb.opcua.BrowseSubType.SubTypesIncluded
13  # masked based filter for node classes based on bitwise AND of cvb.opcua.NodeClass
14  node_class_mask = 0
15 
16  # combine them in an object
17  return cvb.opcua.BrowseFilter.create(bd, relationship, max_ref, allow_subtype, node_class_mask)
18 
19 
20 def main():
21  # create client (will connect on creation, disconnect at eol)
22  client = cvb.opcua.Client.create("opc.tcp://127.0.0.1:4840")
23 
24  # thats too simple, so lets 'browse' the server objectsfolder
25 
26  # get node id of root folder
28  cvb.opcua.Namespace0NodeID.OBJECTSFOLDER)
29  obj_folder_node = client.node(obj_folder)
30 
31  # browse on object folder
32  browse_result = obj_folder_node.browse(make_browse_filter())
33 
34  # lets print the children
35  for nid in browse_result:
36  tmp = client.node(nid)
37  print("found node: '" + tmp.display_name + "'")
38 
39 
40 if __name__ == "__main__":
41  main()
Common Vision Blox OPCUA module for Python.
Definition: __init__.py:1
cvb.opcua.NodeID create_namespace0(int namespace0_node_id)
Creates an OPCUA node ID based on a pre-defined namespace 0 value.
Definition: __init__.py:439
cvb.opcua.BrowseFilter create(int direction, int reference_type, int max_references, int include_sub_types, int node_class_mask)
Creates a BrowseFilter object for browsing the OPCUA client.
Definition: __init__.py:114
cvb.opcua.Client create(str discover_url)
Creates an OPCUA client object.
Definition: __init__.py:160