Skip to content
Snippets Groups Projects
Commit 315c8af7 authored by Thomas Juerges's avatar Thomas Juerges
Browse files

Add quick and dirty first test

parent 1a4876ca
No related branches found
No related tags found
No related merge requests found
#! /usr/bin/env python3
import opcua
from time import sleep
port = 4840
host = "10.87.2.8"
client = opcua.Client("opc.tcp://{}:{}".format(host, port))
client.connect()
obj = client.get_objects_node()
name_space_index = 2
time_offset = obj.get_child("{}:time_offset".format(name_space_index))
time_offset_R = time_offset.get_child("{}:monitor_point".format(name_space_index))
time_offset_RW = time_offset.get_child("{}:control_point".format(name_space_index))
old_time_offset = time_offset_R.get_value()
target_time_offset = 1
new_time_offset = old_time_offset + target_time_offset
time_offset_RW.set_value(new_time_offset)
sleep(1.0)
latest_time_offset = time_offset_R.get_value()
difference_time_offset = latest_time_offset - old_time_offset
if difference_time_offset != target_time_offset:
print("ERROR: Setting and reading back time_offset. old_time_offset = %d, new_time_offset = %d, latest_time_offset = %d, target_time_offset = %d, difference_time_offset = %d." % (old_time_offset, new_time_offset, latest_time_offset, target_time_offset, difference_time_offset))
else:
print("SUCCESS: Setting and reading back time_offset.")
client.disconnect()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment