File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys
2+ sys .path .insert (0 , ".." )
3+ import time
4+
5+
6+ from opcua import ua , Server
7+
8+ import cProfile
9+ import re
10+
11+
12+ def mymain ():
13+
14+ # setup our server
15+ server = Server ()
16+ server .set_endpoint ("opc.tcp://0.0.0.0:4840/freeopcua/server/" )
17+
18+ # setup our own namespace, not really necessary but should as spec
19+ uri = "http://examples.freeopcua.github.io"
20+ idx = server .register_namespace (uri )
21+
22+ # get Objects node, this is where we should put our nodes
23+ objects = server .get_objects_node ()
24+
25+ # populating our address space
26+ myobj = objects .add_object (idx , "MyObject" )
27+ myvar = myobj .add_variable (idx , "MyVariable" , 6.7 )
28+ myvar .set_writable () # Set MyVariable to be writable by clients
29+
30+ # starting!
31+ server .start ()
32+ server .stop ()
33+
34+
35+ if __name__ == "__main__" :
36+ cProfile .run ('mymain()' )
You can’t perform that action at this time.
0 commit comments