Commit cde97b35 authored by Ivan Tyagov's avatar Ivan Tyagov

Extend test.

parent 1b812226
""" """
OPC-UA test agent used for testing of PLC program here: https://lab.nexedi.com/nexedi/osie/tree/master/Beremiz/beremiz_test_opc_ua OPC-UA test agent used for testing of PLC program here: https://lab.nexedi.com/nexedi/osie/tree/master/Beremiz/beremiz_test_opc_ua
XXX:
- add asserts
""" """
from opcua import Client from opcua import Client
import time import time
client = Client("opc.tcp://k2-osie:4840/") TIMEOUT = 5 # seconds to wait between checks
NUMBER_OF_CHECKS = 10 # number of times we check the server
OPC_UA_ADDRESS = "opc.tcp://k2-osie:4840/"
OPC_UA_IDENTIFIER = "ns=1;s=i2c0.relay0"
# connect to a session at OPC-UA server
client = Client(OPC_UA_ADDRESS)
try: try:
client.connect() client.connect()
...@@ -14,13 +19,17 @@ try: ...@@ -14,13 +19,17 @@ try:
# Client has a few methods to get proxy to UA nodes that should always be in address space such as Root or Objects # Client has a few methods to get proxy to UA nodes that should always be in address space such as Root or Objects
root = client.get_root_node() root = client.get_root_node()
children_list = root.get_children() children_list = root.get_children()
for i in range (0,10): var = client.get_node(OPC_UA_IDENTIFIER)
var = client.get_node("ns=1;s=i2c0.relay0")
i2c0_relay0 = var.get_value() for i in range (0, NUMBER_OF_CHECKS):
# XXX: do asserts here i2c0_relay0_before = var.get_value()
print i2c0_relay0 print "\ni2c0_relay0 (before) = ", i2c0_relay0_before
print "sleep" print "sleep ..."
time.sleep(5) time.sleep(TIMEOUT)
i2c0_relay0_after = var.get_value()
print "i2c0_relay0 (after) = ", i2c0_relay0_after
# for the wait timeout runtime should have increased the value
assert i2c0_relay0_after > i2c0_relay0_before
finally: finally:
client.disconnect() client.disconnect()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment