当我通过milo向kepware服务器写入数据时,有时有些数据无法写入成功。但是服务器返回了
StatusCode{name=Good, value=0x00000000, quality=good}
服务器没有显示我写的数据。
提前感谢您的帮助
- 单线程不起作用。
- 开始写入数据时创建新客户端。
- 只有一个客户响应写作。
所有这些都失败了。
mWriteClient = new OPCUAClientRunner(KSOPCUASubscription.this).createClient();
mWriteClient.connect().get();
} catch (Exception e) {
e.printStackTrace();
logger.error("OPCUAClient connect Exception", e);
return ;
}
logger.info("Wrote identifier: " + identifier);
List<NodeId> nodeIds = ImmutableList.of(new NodeId(namespaceIndex, identifier));//Int32"t|bbb"
Variant v = new Variant(value);
// don't write status or timestamps
DataValue dv = new DataValue(v, null, null);
logger.info("OPCUAClient begin write");
// write asynchronously....
CompletableFuture<List<StatusCode>> f =
mWriteClient.writeValues(nodeIds, ImmutableList.of(dv));
// ...but block for the results so we write in order
List<StatusCode> statusCodes = null;
try {
statusCodes = f.get();
} catch (InterruptedException e) {
e.printStackTrace();
logger.error("OPCUAClient write get response Exception", e);
} catch (ExecutionException e) {
e.printStackTrace();
logger.error("OPCUAClient write get response Exception", e);
}
StatusCode status = statusCodes.get(0);
logger.info("Wrote status: " + status.toString());
if (status.isGood()) {
logger.info("Wrote '{}' to nodeId={}", v, nodeIds.get(0));
}