7test_node_name =
"TestNode"
13def read_callback(data):
14 print(
"callback: reading")
17def write_callback(data):
18 print(
"callback: writing")
34 ns_index = server.add_namespace(
"StemmerNamespace")
38 cvb.opcua.Namespace0NodeID.FOLDERTYPE)
40 cvb.opcua.Namespace0NodeID.OBJECTSFOLDER)
42 ns_index,
"StemmerFolder", loc, folder_type)
43 server.add_node(folder)
47 ns_index, test_node_name, folder.node_id(), 1.111)
48 server.add_node(var_node)
51 readCookie = var_node.register_read_callback(read_callback)
52 writeCookie = var_node.register_write_callback(write_callback)
60 var_node.deregister_callback(readCookie)
61 var_node.deregister_callback(writeCookie)
69def make_browse_filter():
70 bd = cvb.opcua.ReferenceDirection.Forward
71 relationship = cvb.opcua.ReferenceType.Hierarchical
74 allow_subtype = cvb.opcua.BrowseSubType.SubTypesIncluded
80 bd, relationship, max_ref, allow_subtype, node_class_mask)
102 root_folder = client.root_node()
105 result = root_folder.browse(make_browse_filter())
109 node_extracted = client.node(nid)
111 print(
"found: " + node_extracted.display_name)
114 if(node_extracted.display_name == test_node_name):
116 print(
"value access: "+str(node_extracted.value()))
118 node_extracted.set_value(2.2)
119 print(
"value access: "+str(node_extracted.value()))
124server_thread = threading.Thread(target=start_server)
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
cvb.opcua.FloatNode create(int namespace_index, str name, cvb.opcua.NodeID parent_node_id, float value)
Creates an OPCUA variable with the specified parameter, data type, and its floating-point value.
Definition: __init__.py:222
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
None create_from_type(int namespace_index, str name, cvb.opcua.NodeID parent_node_id, cvb.opcua.NodeID type_def_node_id)
Creates an OPCUA object with a given type definition.
Definition: __init__.py:480
cvb.opcua.Server create(int port)
Creates an OPCUA server with the specified port number.
Definition: __init__.py:527
Common Vision Blox OPCUA module for Python.
Definition: __init__.py:1