use of org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateRequest in project milo by eclipse.
the class OpcUaClient method historyUpdate.
@Override
public CompletableFuture<HistoryUpdateResponse> historyUpdate(List<HistoryUpdateDetails> historyUpdateDetails) {
return getSession().thenCompose(session -> {
ExtensionObject[] details = historyUpdateDetails.stream().map(hud -> ExtensionObject.encode(getStaticSerializationContext(), hud)).toArray(ExtensionObject[]::new);
HistoryUpdateRequest request = new HistoryUpdateRequest(newRequestHeader(session.getAuthenticationToken()), details);
return sendRequest(request);
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateRequest in project milo by eclipse.
the class DefaultAttributeHistoryServiceSet method onHistoryUpdate.
@Override
public void onHistoryUpdate(ServiceRequest service) {
historyUpdateMetric.record(service);
HistoryUpdateRequest request = (HistoryUpdateRequest) service.getRequest();
OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
List<HistoryUpdateDetails> historyUpdateDetailsList = l(request.getHistoryUpdateDetails()).stream().map(e -> (HistoryUpdateDetails) e.decode(server.getSerializationContext())).collect(Collectors.toList());
if (historyUpdateDetailsList.isEmpty()) {
service.setServiceFault(StatusCodes.Bad_NothingToDo);
return;
}
if (historyUpdateDetailsList.size() > server.getConfig().getLimits().getMaxNodesPerWrite().intValue()) {
service.setServiceFault(StatusCodes.Bad_TooManyOperations);
return;
}
DiagnosticsContext<HistoryUpdateDetails> diagnosticsContext = new DiagnosticsContext<>();
HistoryUpdateContext context = new HistoryUpdateContext(server, session, diagnosticsContext);
server.getAddressSpaceManager().historyUpdate(context, historyUpdateDetailsList);
context.getFuture().thenAccept(values -> {
ResponseHeader header = service.createResponseHeader();
DiagnosticInfo[] diagnosticInfos = diagnosticsContext.getDiagnosticInfos(historyUpdateDetailsList);
HistoryUpdateResponse response = new HistoryUpdateResponse(header, a(values, HistoryUpdateResult.class), diagnosticInfos);
service.setResponse(response);
});
}
Aggregations