import sys
sys.path.insert(0, "..")

from timeit import default_timer as timer
from opcua import Client

if __name__ == "__main__":
    #client = Client("opc.tcp://1.1.1.53:4840") # if anonymous authentication is enabled
    client = Client("opc.tcp://user:12345678@1.1.1.53:4840/") #connect using a user
    print(client.application_uri)
    try:
        client.connect()
        start = timer()
        # get a specific node knowing its node id
        temp1c_node = client.get_node('ns=3;s="storageTemperatures"."Temperature1C"')
        temp2c_node = client.get_node('ns=3;s="storageTemperatures"."Temperature2C"')
        end = timer()
        #print(var.get_data_value()) # get value of node as a DataValue object
        temp1c = float(temp1c_node.get_value())
        temp2c = float(temp2c_node.get_value())
        print("Temp1: " + str(temp1c))
        print("Temp2: " + str(temp2c))
        print("RTT: " + str(end - start))
        
    finally:
        client.disconnect()