简体   繁体   English

使用 Eclipse Milo JAva 客户端从 Rockwell OPC UA 服务器获取数据时出错

[英]Error fetching data from Rockwell OPC UA Server using Eclipse Milo JAva Client

I have built a Java Application to fetch data from OPC UA Server.我已经构建了一个 Java 应用程序来从 OPC UA 服务器获取数据。 I have used Eclipse Milo UA Client SDK to build the client.我已经使用 Eclipse Milo UA Client SDK 来构建客户端。 I am facing a problem in OpcUaClient.readValues method.我在 OpcUaClient.readValues 方法中遇到问题。 I am passing a list of NodeId created from Tags defined and if I traverse the DataValue array returned by readValues method, I get follwing error for some of the elements我正在传递从定义的标签创建的 NodeId 列表,如果我遍历 readValues 方法返回的 DataValue 数组,我会收到一些元素的以下错误

DataValue{value=Variant{value=null}, status=StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad},

Sudo code looks like须藤代码看起来像

List<NodeId> nodeIds = new ArrayList<NodeId>();
List<Parameter> parameters = device.getParameters();
for (int i = 0; i < parameters.size(); i++) {
    Parameter parameter = parameters.get(i);
                            
    nodeIds.add(new NodeId(device.getNsID(),  parameter.getTagName()));
                            
}
List<DataValue> values = client.readValues( 0.0, TimestampsToReturn.Both, nodeIds).get();
for (int i = 0; i < values .size(); i++) {
    DataValue dvalue = values.get(i);
    if( dvalue.getValue().getValue() != null) {
        Integer intValue =  (Integer) values.get(i).getValue().getValue();
                            
        logger.info("captured Value is  {}", value);
                                        
    }
    else
    {
       logger.error("Error fetching value for {} , {}", parameter.getName(),dvalue.toString());
    }
}

The error is flagged from else clause.错误是从 else 子句标记的。

My application is running on a separate computer than the SCADA Server ( OPC UA).我的应用程序运行在与 SCADA 服务器 (OPC UA) 不同的计算机上。 A peculiar behavior observed is, If I use ProSys Client to check value of failing tag, and if I re-run my application, data is fetched correctly.观察到的一个特殊行为是,如果我使用 ProSys 客户端检查失败标签的值,并且如果我重新运行我的应用程序,则可以正确获取数据。 I am completely clueless about how ProSys client and my application is related.我完全不知道 ProSys 客户端和我的应用程序是如何相关的。 Is prosys client triggering something on the server side to load the tags in some cache... Any clues/pointers will help. prosys客户端是否在服务器端触发某些东西以将标签加载到某个缓存中...任何线索/指针都会有所帮助。 Thanks in advance.提前致谢。

It sure sounds like the Rockwell server doesn't actually "build" the Node instances until you've browsed it first.听起来 Rockwell 服务器在您首先浏览它之前并没有真正“构建” Node 实例。

You aren't doing anything wrong in the client;您在客户端没有做错任何事情; this is stupid behavior on the server's part.这是服务器方面的愚蠢行为。 You may have to program your client to recursively browse the hierarchy you're interested in before reading or creating monitored items.在读取或创建受监控项之前,您可能必须对客户端进行编程以递归浏览您感兴趣的层次结构。

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

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