get_value()方法没有返回节点的值,节点的类型是ExtensionObject

问题描述 投票:0回答:1

使用下面的代码时,我无法获取特定节点的值。

from opcua import Client, ua
server_url = "opc.tcp://localhost:4840"
client = Client(server_url)
client.connect()
try:
    node_id = "ns=1;s=data/OpcUaServer/channels/1/0_VALUES"
    node = client.get_node(node_id)
    data_value = node.get_data_value()
    print("Node Value:", data_value)
    print("Node Value:", data_value)
finally:
    client.disconnect()

收到的输出:

Node Value: ExtensionObject(TypeId:FourByteNodeId(ns=1;i=1), Encoding:1, 5 bytes)
<class 'opcua.ua.uatypes.ExtensionObject'>
所以我的客户需要知道扩展对象。问题是我无法加载类型定义。连接并运行
client.load_type_defitnitions()
后,没有任何反应,输出也收到:
Node Value: ExtensionObject(TypeId:FourByteNodeId(ns=1;i=1), Encoding:1, 5 bytes)
。我查了很多方法,但都没有效果。如果有人可以提供帮助,请先谢谢您。

python opc-ua getvalue
1个回答
0
投票

load

load_type_defitnitions
仅适用于旧服务器。有些服务器不再公开此信息。

由于不再支持opcua库,请尝试切换到asyncua并使用syncclient。

您可以尝试使用

load_data_type_definitions
而不是
load_type_defitnitions
。如果这不起作用,请尝试在 asyncua 的 github 中打开一个 pr,我们会尽力帮助您。

© www.soinside.com 2019 - 2024. All rights reserved.