-
Notifications
You must be signed in to change notification settings - Fork 670
Expand file tree
/
Copy pathtest_perf.py
More file actions
36 lines (24 loc) · 822 Bytes
/
test_perf.py
File metadata and controls
36 lines (24 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
sys.path.insert(0, "..")
import time
from opcua import ua, Server
import cProfile
import re
def mymain():
# setup our server
server = Server()
server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
# setup our own namespace, not really necessary but should as spec
uri = "http://examples.freeopcua.github.io"
idx = server.register_namespace(uri)
# get Objects node, this is where we should put our nodes
objects = server.get_objects_node()
# populating our address space
myobj = objects.add_object(idx, "MyObject")
myvar = myobj.add_variable(idx, "MyVariable", 6.7)
myvar.set_writable() # Set MyVariable to be writable by clients
# starting!
server.start()
server.stop()
if __name__ == "__main__":
cProfile.run('mymain()')