name=Bad_NodeIdUnknown, value=0x80340000, quality=bad (opc ua milo WriteExample 关于 NodeId)
name=Bad_NodeIdUnknown, value=0x80340000, quality=bad (opc ua milo WriteExample about the NodeId)
我想做一个测试,通过 opc ua milo 客户端将“1”写入 kepware(PLC) 地址。我从 GitHub 获得客户端, URL 是 https://github.com/eclipse/milo 。但是我总是得到不准确的信息,像这样:
[main] INFO o.e.m.examples.client.WriteExample -
StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad}
同时,我可以成功读取kepware(PLC)的数据。
我的 opc 标记名是“AFSM010_WriteRFID”,通道名是“FE6”,设备名是“AFSM”。那么,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);
}
}
我建议您使用 UaExpert 等客户端连接到 Kepware 并浏览地址 space,找到您感兴趣的节点,然后查看 Kepware 如何格式化NodeIds.
每台服务器都有自己的“规则”来制作 NodeId。在不知道该服务器的规则的情况下,您不能仅通过知道“标签名称”来派生 NodeId。
希望您通过浏览或通过某种您已经知道格式的带外机制发现节点和 NodeId。
我想做一个测试,通过 opc ua milo 客户端将“1”写入 kepware(PLC) 地址。我从 GitHub 获得客户端, URL 是 https://github.com/eclipse/milo 。但是我总是得到不准确的信息,像这样:
[main] INFO o.e.m.examples.client.WriteExample - StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad}
同时,我可以成功读取kepware(PLC)的数据。
我的 opc 标记名是“AFSM010_WriteRFID”,通道名是“FE6”,设备名是“AFSM”。那么,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);
}
}
我建议您使用 UaExpert 等客户端连接到 Kepware 并浏览地址 space,找到您感兴趣的节点,然后查看 Kepware 如何格式化NodeIds.
每台服务器都有自己的“规则”来制作 NodeId。在不知道该服务器的规则的情况下,您不能仅通过知道“标签名称”来派生 NodeId。
希望您通过浏览或通过某种您已经知道格式的带外机制发现节点和 NodeId。