欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 创投人物 > org.eclipse.milo opcua库浏览所有节点,部分节点查看不到

org.eclipse.milo opcua库浏览所有节点,部分节点查看不到

2024/10/25 1:27:30 来源:https://blog.csdn.net/h4241778/article/details/139748930  浏览:    关键词:org.eclipse.milo opcua库浏览所有节点,部分节点查看不到

   
    org.eclipse.milo opcua库浏览所有节点,部分节点查看不到,并没有报错
    
    前提:使用pom
    
      <dependency>
         <groupId>org.eclipse.milo</groupId>
         <artifactId>sdk-client</artifactId>
         <version>0.xx.xx</version>
    </dependency>
    
    原因:
    
    请求节点时,当节点个数过多时;服务端是按照多个报文返回的。现有方法browse(NodeId nodeId)并不支持。针对现有browse方法源码进行改造,代码如下:

    

@Overridepublic CompletableFuture<List<Node>> browse(NodeId nodeId) {UInteger nodeClassMask = uint(NodeClass.Method.getValue() |NodeClass.Object.getValue() |NodeClass.Variable.getValue());UInteger resultMask = uint(BrowseResultMask.All.getValue());CompletableFuture<BrowseResult> future = client.browse(new BrowseDescription(nodeId,BrowseDirection.Forward,Identifiers.HierarchicalReferences,true,nodeClassMask,resultMask));List<Node> allNode = new ArrayList<>();try {BrowseResult result = future.get();extracted(result, allNode);List<ReferenceDescription> references = l(result.getReferences());List<Node> list2 = references.stream().flatMap(r -> opt2stream(r.getNodeId().local(client.getNamespaceTable()).map(id -> createNode(id, r.getNodeClass())))).collect(toList());allNode.addAll(list2);CompletableFuture<List<Node>> finalRes = CompletableFuture.supplyAsync(() -> {return allNode;});return finalRes;} catch (Exception e) {throw new RuntimeException(e);}}private void extracted(BrowseResult result, List<Node> allNode) {try {if (result.getContinuationPoint().isNotNull()) {BrowseResult br = client.browseNext(false, result.getContinuationPoint()).get();List<ReferenceDescription> references = l(br.getReferences());List<Node> list1 = references.stream().flatMap(r -> opt2stream(r.getNodeId().local(client.getNamespaceTable()).map(id -> createNode(id, r.getNodeClass())))).collect(toList());allNode.addAll(list1);extracted(br, allNode);}} catch (Exception e) {throw new RuntimeException(e);}}


  
   

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com