简体   繁体   English

如何在 Eclipse Milo 中获取 OPC UA 节点名称?

[英]How can I get OPC UA node name in Eclipse Milo?

I followed ManagedSubscriptionDataExample.java ( https://github.com/eclipse/milo/blob/master/milo-examples/client-examples/src/main/java/org/eclipse/milo/examples/client/ManagedSubscriptionDataExample.java ) example on github page to read OPC nodes from PLC S7-1200.我跟着 ManagedSubscriptionDataExample.java ( https://github.com/eclipse/milo/blob/master/milo-examples/client-examples/src/main/java/org/eclipse/milo/examples/client/ManagedSubscriptionDataExample.java ) github 页面上的示例,用于从 PLC S7-1200 读取 OPC 节点。

Value for nodes are getting updated but I can't get name.节点的值正在更新,但我无法获得名称。

For code:对于代码:

subscription.addDataChangeListener((items, values) -> {
                for (int i = 0; i < items.size(); i++) {
                    logger.info(
                            "subscription value received: item={}, value={}, valueID={}",
                            items.get(i).getNodeId(), values.get(i).getValue(), items.get(i).getReadValueId());
                }

I get response:我得到回应:

INFO: subscription value received: item=NodeId{ns=4, id=4}, value=Variant{value=false}, valueID=ReadValueId(nodeId=NodeId{ns=4, id=4}, attributeId=13, indexRange=null, dataEncoding=QualifiedName{name=null, namespaceIndex=0})信息:收到的订阅值:item=NodeId{ns=4, id=4}, value=Variant{value=false}, valueID=ReadValueId(nodeId=NodeId{ns=4, id=4}, attributeId=13, indexRange =null, dataEncoding=QualifiedName{name=null, namespaceIndex=0})

I see that name is null and that there is no method to get name for node.我看到该名称为空,并且没有方法可以获取节点名称。 But if I use OPC client "OPC Expert" I can also get names for nodes as they are on PLC:但是如果我使用 OPC 客户端“OPC Expert”,我也可以获得节点的名称,就像它们在 PLC 上一样: 在此处输入图片说明

Is there any other option to get name of the variable?还有其他选项可以获取变量的名称吗?

UaExpert is doing more bookkeeping than you are doing. UaExpert 做的记账比你做的多。 You should have knowledge of which Nodes you have created MonitoredItems for and be able to get the BrowseName or DisplayName attribute from those Nodes.您应该知道您为哪些节点创建了 MonitoredItems,并且能够从这些节点获取 BrowseName 或 DisplayName 属性。

Inside that callback you have access to the NodeId - that should be your key to get to the Node and any attributes you are interested in.在该回调中,您可以访问 NodeId - 这应该是您访问 Node 和您感兴趣的任何属性的关键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM