#! /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.") time_offset_RW.set_value(old_time_offset) client.disconnect()