3

I'm Trying to call a method from a OPC UA server device. this is the method: StartScan Method

It contains Two Arguments: InputArguments OutputArguments

I'm not able with my code:

from opcua import Client, ua

url = "opc.tcp://10.239.37.236:4840"
client = Client(url)
#client.set_user = "user"
#client.set_password = "pw"
client.connect()

print("client connected")

while True:
    lsd = client.get_node("ns=4; i=6013")
    LastScanData = lsd.get_value()
    print(LastScanData)

    start = client.get_node("ns=3; i=7009")
    input_Arg = client.get_node("ns=3, i=6051")

    res = start.call_method(input_Arg,  ua.Variant(5, ua.VariantType.UInt32), ua.Variant(99, ua.VariantType.UInt32))
    time.sleep(1)

Can someone help me? I'm new in OPC UA. Thanks.

Kevin Herron
  • 6,500
  • 3
  • 26
  • 35

1 Answers1

1

You have to get the parent object and use call_method from it. The first parameter is then your method. This should work.

method = client.get_node("ns=3; i=7009")
parent_obj = "ns=3; i=xxxx" # Nodeid of the object
obj = client.get_node(parent_obj)
inp1 = ua.Variant(5, ua.VariantType.UInt32)
out = obj.call_method(method, inp1)
Schroeder
  • 749
  • 4
  • 10