MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / __init__

Method __init__

examples/simple-client-server-xml/server.py:48–69  ·  view source on GitHub ↗
(self, endpoint, name, model_filepath)

Source from the content-addressed store, hash-verified

46
47class HelloServer:
48 def __init__(self, endpoint, name, model_filepath):
49 self.server = Server()
50
51 # This need to be imported at the start or else it will overwrite the data
52 self.server.import_xml(model_filepath)
53
54 self.server.set_endpoint(endpoint)
55 self.server.set_server_name(name)
56
57 objects = self.server.get_objects_node()
58
59 freeopcua_namespace = self.server.get_namespace_index("urn:freeopcua:python:server")
60 hellower = objects.get_child("0:Hellower")
61 hellower_say_hello = hellower.get_child("0:SayHello")
62
63 self.server.link_method(hellower_say_hello, say_hello_xml)
64
65 hellower.add_method(
66 freeopcua_namespace, "SayHello2", say_hello, [ua.VariantType.Boolean], [ua.VariantType.String])
67
68 hellower.add_method(
69 freeopcua_namespace, "SayHelloArray", say_hello_array, [ua.VariantType.Boolean], [ua.VariantType.String])
70
71 def __enter__(self):
72 self.server.start()

Callers

nothing calls this directly

Calls 9

ServerClass · 0.90
set_endpointMethod · 0.80
set_server_nameMethod · 0.80
get_childMethod · 0.80
link_methodMethod · 0.80
import_xmlMethod · 0.45
get_objects_nodeMethod · 0.45
get_namespace_indexMethod · 0.45
add_methodMethod · 0.45

Tested by

no test coverage detected