3 from IPython
import embed
10 shell = code.InteractiveConsole(vars)
13 from opcua
import ua, uamethod, Server
18 print(
"Calling say_hello_xml")
22 result =
"I'm not happy" 32 result =
"I'm not happy" 42 result =
"I'm not happy" 44 return [result,
"Actually I am"]
48 def __init__(self, endpoint, name, model_filepath):
52 self.server.import_xml(model_filepath)
54 self.server.set_endpoint(endpoint)
55 self.server.set_server_name(name)
57 objects = self.server.get_objects_node()
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")
63 self.server.link_method(hellower_say_hello, say_hello_xml)
66 freeopcua_namespace,
"SayHello2", say_hello, [ua.VariantType.Boolean], [ua.VariantType.String])
69 freeopcua_namespace,
"SayHelloArray", say_hello_array, [ua.VariantType.Boolean], [ua.VariantType.String])
79 if __name__ ==
'__main__':
80 script_dir = os.path.dirname(__file__)
82 "opc.tcp://0.0.0.0:40840/freeopcua/server/",
83 "FreeOpcUa Example Server",
84 os.path.join(script_dir,
"test_saying.xml"))
as server:
def __exit__(self, exc_type, exc_val, exc_tb)
def say_hello_array(parent, happy)
def __init__(self, endpoint, name, model_filepath)
def say_hello(parent, happy)
def say_hello_xml(parent, happy)