我正在尝试从OPC UA服务器设备调用一个方法。这就是方法:StartScan法
它包含两个参数:InputArguments OutputArguments
我不能用我的密码:
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)
有人能帮我吗?我是OPC UA的新成员。谢谢。
发布于 2022-04-06 09:50:08
您必须获取父对象并从它中使用call_method。第一个参数是您的方法。这应该能行。
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)
https://stackoverflow.com/questions/71753040
复制相似问题