【问题标题】:Read function are not called in the ExampleNamespace code在 ExampleNamespace 代码中未调用读取函数
【发布时间】:2018-04-09 22:30:18
【问题描述】:

我运行了 ExampleNamespace 示例。我可以浏览节点并正确返回所有节点。 我可以运行客户端读取示例。

但是当我运行客户端读取HelloWorld.Dynamic.Double的值时,它超时,并且没有调用ExampleNamespace中的覆盖读取函数。

// synchronous read request via VariableNode
NodeId nodeId = new NodeId(2, "HellowWorld.Dynamic.Double");

VariableNode node= client.getAddressSpace().createVariableNode(nodeId);

CompletableFuture<DataValue> datavalue = client.readValue(1.0, TimestampsToReturn.Source, nodeId);

DataValue value = datavalue.get();

我是不是忘了做点什么?

【问题讨论】:

    标签: opc-ua milo node-opcua


    【解决方案1】:

    在代码的第二行,通过client 对象进行调用,将node 变量的实例设置为VariableNode 类型,看起来是正确的。

    但是,您以后永远不会使用新的node 变量。下一行代码仍然尝试通过相同的client 对象readValue。我可以建议您将client 替换为node 变量,如下所示:

    CompletableFuture<DataValue> datavalue = node.readValue(1.0, TimestampsToReturn.Source, nodeId);
    

    进行相同读取操作的更简单方法可能如下:

        // synchronous read request via VariableNode object (node)
        VariableNode node = client.getAddressSpace().createVariableNode(nodeId);
        DataValue datavalue = node.readValue().get();
    

    【讨论】:

    • 思南,感谢您的回复...我按照您建议的方式做了...我仍然有超时,ExampleNamespace 服务器示例仍然没有调用“读取”函数...任何其他建议?
    • 我还注意到,在您的代码的第一行有一个额外的 'w' 字符。你会检查一下吗? NodeId nodeId = new NodeId(2, "HellowWorld.Dynamic.Double"); 这可能会导致用错误的值实例化 nodeId 对象。
    猜你喜欢
    • 1970-01-01
    • 2018-06-12
    • 2020-11-05
    • 1970-01-01
    • 2015-08-12
    • 2017-04-22
    • 2012-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多