use of org.eclipse.milo.opcua.sdk.server.api.services.AttributeHistoryServices.HistoryUpdateContext 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