简体   繁体   English

name=Bad_NodeIdUnknown, value=0x80340000, quality=bad (opc ua milo WriteExample about the NodeId)

[英]name=Bad_NodeIdUnknown, value=0x80340000, quality=bad (opc ua milo WriteExample about the NodeId)

I would like to have a test to write "1" into kepware(PLC) address through opc ua milo client.我想通过 opc ua milo 客户端将“1”写入kepware(PLC)地址进行测试。 I get the client from GitHub, the URL is https://github.com/eclipse/milo .我从 GitHub 获得客户端,URL 是https://github.com/eclipse/milo But I always got inaccurate information, like this:但我总是得到不准确的信息,像这样:

[main] INFO oemexamples.client.WriteExample - StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad} [main] INFO oemexamples.client.WriteExample - StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad}

Meanwhile, I can successfully read the data from kepware(PLC).同时,我可以成功地从kepware(PLC)读取数据。

My opc tagname is "AFSM010_WriteRFID",the channalname is "FE6" and the devicename is "AFSM".我的 opc 标记名称是“AFSM010_WriteRFID”,通道名称是“FE6”,设备名称是“AFSM”。 So, what's the second parameter of NodeId?那么,NodeId 的第二个参数是什么? ?? ??

public class WriteExample implements ClientExample {

    public static void main(String[] args) throws Exception {
        WriteExample example = new WriteExample();

        new ClientExampleRunner(example).run();
    }

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throws Exception {
        // synchronous connect
        client.connect().get();

//        List<NodeId> nodeIds = ImmutableList.of(new NodeId(2, "HelloWorld/ScalarTypes/Int32"));
//        NodeId nodeId_Tag1 = new NodeId(3, "FE6.AFSM.AFSM010_WriteRFID");
        NodeId nodeId_Tag1 = new NodeId(3, "AFSM010_WriteRFID");
        List<NodeId> nodeIds = ImmutableList.of(nodeId_Tag1);

//        for (int i = 0; i < 10; i++) {
            Variant v = new Variant(5);

            // don't write status or timestamps
            DataValue dv = new DataValue(v, null, null);

            // write asynchronously....
            CompletableFuture<List<StatusCode>> f =
                client.writeValues(nodeIds, ImmutableList.of(dv));

            // ...but block for the results so we write in order
            List<StatusCode> statusCodes = f.get();
            StatusCode status = statusCodes.get(0);

            if (status.isGood()) {
                logger.info("Wrote '{}' to nodeId={}", v, nodeIds.get(0));
            }
        logger.info("this is the end : status " + status.toString());
//        }

        future.complete(client);
    }

}

I would suggest that you connect to Kepware with a client like UaExpert and browse the address space, find the Node(s) you're interested in, and take a look at how Kepware is formatting the NodeIds.我建议您使用 UaExpert 之类的客户端连接到 Kepware 并浏览地址空间,找到您感兴趣的节点,并查看 Kepware 如何格式化 NodeId。

Every server will have its own "rules" for how it makes NodeIds.每个服务器对于如何制作 NodeId 都有自己的“规则”。 You can't derive a NodeId from just knowing the "tag name" without know the rules for that server.在不知道该服务器的规则的情况下,您无法仅从“标签名称”中派生 NodeId。

It is expected that you discover Nodes and NodeIds either by browsing or by some out-of-band mechanism where you already know the format.预计您可以通过浏览或通过一些您已经知道格式的带外机制来发现节点和 NodeId。

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

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