tests/ide_tests/opcua_browse.sikuli/opcua_service.bash
author Edouard Tisserant <edouard.tisserant@gmail.com>
Thu, 10 Nov 2022 19:41:31 +0100
branchwxPython4
changeset 3672 230c8b90f3dc
parent 3549 tests/cli_tests/opcua_test.bash@0af7b6a96c53
child 3718 7841b651d601
permissions -rw-r--r--
Tests: Add OPC-UA server browsing and veriable picking UI test.
#!/bin/bash

echo "Instant OPC-UA server for test"

# Run server
exec $BEREMIZPYTHONPATH - << EOF

import sys
import time

from opcua import ua, Server

server = Server()
server.set_endpoint("opc.tcp://127.0.0.1:4840/freeopcua/server/")

uri = "http://beremiz.github.io"
idx = server.register_namespace(uri)

objects = server.get_objects_node()

testobj = objects.add_object(idx, "TestObject")
testvarout = testobj.add_variable(idx, "TestOut", 1.2)
testvar = testobj.add_variable(idx, "TestIn", 5.6)
testvar.set_writable()

server.start()

try:
    while True:
        time.sleep(1)
        inval=testvar.get_value()
        print inval
        testvarout.set_value(inval*2)
        sys.stdout.flush()
finally:
    server.stop()
EOF