CVBpy 14.0
opcua/BareboneServer
1# loading cvb.opcua
2
3import cvb.opcua
4
5
6def main():
7 # create a server
8 server = cvb.opcua.Server.create(4840)
9
10 # start server
11 server.start()
12
13 # ... but this was too easy, lets add a node to the server.
14
15 # ... where to add the new node
17 cvb.opcua.Namespace0NodeID.OBJECTSFOLDER)
18
19 # create node(s)
20 node1 = cvb.opcua.FloatNode.create(0, "TestNode", loc, 7.2)
21
22 def callback(data):
23 print("callback was triggered")
24
25 readCookie = node1.register_read_callback(callback)
26
27 # add node(s)
28 server.add_node(node1)
29
30 input("Press Enter to stop\n")
31
32 node1.deregister_callback(readCookie)
33 server.stop()
34
35
36if __name__ == "__main__":
37 main()
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
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