Search in sources :

Example 1 with DiagnosticInfo

use of org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo in project milo by eclipse.

the class SubscriptionManager method modifyMonitoredItems.

public void modifyMonitoredItems(ServiceRequest service) throws UaException {
    ModifyMonitoredItemsRequest request = (ModifyMonitoredItemsRequest) service.getRequest();
    UInteger subscriptionId = request.getSubscriptionId();
    Subscription subscription = subscriptions.get(subscriptionId);
    TimestampsToReturn timestamps = request.getTimestampsToReturn();
    List<MonitoredItemModifyRequest> itemsToModify = l(request.getItemsToModify());
    if (subscription == null) {
        throw new UaException(StatusCodes.Bad_SubscriptionIdInvalid);
    }
    if (timestamps == null) {
        throw new UaException(StatusCodes.Bad_TimestampsToReturnInvalid);
    }
    if (itemsToModify.isEmpty()) {
        throw new UaException(StatusCodes.Bad_NothingToDo);
    }
    List<NodeId> distinctNodeIds = itemsToModify.stream().map(item -> {
        UInteger itemId = item.getMonitoredItemId();
        BaseMonitoredItem<?> monitoredItem = subscription.getMonitoredItems().get(itemId);
        return monitoredItem != null ? monitoredItem.getReadValueId().getNodeId() : NodeId.NULL_VALUE;
    }).filter(NodeId::isNotNull).distinct().collect(toList());
    CompletableFuture<Map<NodeId, AttributeGroup>> attributesFuture = readMonitoringAttributes(distinctNodeIds);
    attributesFuture.thenAccept(attributeGroups -> {
        MonitoredItemModifyResult[] modifyResults = new MonitoredItemModifyResult[itemsToModify.size()];
        List<BaseMonitoredItem<?>> monitoredItems = new ArrayList<>();
        for (int i = 0; i < itemsToModify.size(); i++) {
            MonitoredItemModifyRequest modifyRequest = itemsToModify.get(i);
            try {
                BaseMonitoredItem<?> monitoredItem = modifyMonitoredItem(modifyRequest, timestamps, subscription, attributeGroups);
                monitoredItems.add(monitoredItem);
                modifyResults[i] = new MonitoredItemModifyResult(StatusCode.GOOD, monitoredItem.getSamplingInterval(), uint(monitoredItem.getQueueSize()), monitoredItem.getFilterResult());
            } catch (UaException e) {
                modifyResults[i] = new MonitoredItemModifyResult(e.getStatusCode(), 0.0, UInteger.MIN, null);
            }
        }
        subscription.resetLifetimeCounter();
        /*
             * Notify AddressSpaces of the items we just modified.
             */
        byMonitoredItemType(monitoredItems, dataItems -> server.getAddressSpaceManager().onDataItemsModified(dataItems), eventItems -> server.getAddressSpaceManager().onEventItemsModified(eventItems));
        /*
             * AddressSpaces have been notified; send response.
             */
        ResponseHeader header = service.createResponseHeader();
        ModifyMonitoredItemsResponse response = new ModifyMonitoredItemsResponse(header, modifyResults, new DiagnosticInfo[0]);
        service.setResponse(response);
    });
}
Also used : AttributeKey(io.netty.util.AttributeKey) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) ReadContext(org.eclipse.milo.opcua.sdk.server.api.services.AttributeServices.ReadContext) DeadbandType(org.eclipse.milo.opcua.stack.core.types.enumerated.DeadbandType) DataItem(org.eclipse.milo.opcua.sdk.server.api.DataItem) LoggerFactory(org.slf4j.LoggerFactory) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) PublishRequest(org.eclipse.milo.opcua.stack.core.types.structured.PublishRequest) MonitoredItemCreateRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemCreateRequest) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) Map(java.util.Map) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) CreateSubscriptionResponse(org.eclipse.milo.opcua.stack.core.types.structured.CreateSubscriptionResponse) ModifySubscriptionRequest(org.eclipse.milo.opcua.stack.core.types.structured.ModifySubscriptionRequest) EnumSet(java.util.EnumSet) Reference(org.eclipse.milo.opcua.sdk.core.Reference) EventItem(org.eclipse.milo.opcua.sdk.server.api.EventItem) DataChangeFilter(org.eclipse.milo.opcua.stack.core.types.structured.DataChangeFilter) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UByte(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte) ModifyMonitoredItemsRequest(org.eclipse.milo.opcua.stack.core.types.structured.ModifyMonitoredItemsRequest) NumericRange(org.eclipse.milo.opcua.sdk.core.NumericRange) MonitoringFilter(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringFilter) RepublishResponse(org.eclipse.milo.opcua.stack.core.types.structured.RepublishResponse) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) SetPublishingModeResponse(org.eclipse.milo.opcua.stack.core.types.structured.SetPublishingModeResponse) SubscriptionAcknowledgement(org.eclipse.milo.opcua.stack.core.types.structured.SubscriptionAcknowledgement) DiagnosticInfo(org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) SetMonitoringModeRequest(org.eclipse.milo.opcua.stack.core.types.structured.SetMonitoringModeRequest) Stream(java.util.stream.Stream) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) StreamUtil.opt2stream(org.eclipse.milo.opcua.sdk.core.util.StreamUtil.opt2stream) DeleteSubscriptionsResponse(org.eclipse.milo.opcua.stack.core.types.structured.DeleteSubscriptionsResponse) CreateSubscriptionRequest(org.eclipse.milo.opcua.stack.core.types.structured.CreateSubscriptionRequest) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) MonitoringMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode) State(org.eclipse.milo.opcua.sdk.server.subscriptions.Subscription.State) SetMonitoringModeResponse(org.eclipse.milo.opcua.stack.core.types.structured.SetMonitoringModeResponse) EventFilter(org.eclipse.milo.opcua.stack.core.types.structured.EventFilter) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) NotificationMessage(org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage) MonitoredEventItem(org.eclipse.milo.opcua.sdk.server.items.MonitoredEventItem) CreateMonitoredItemsResponse(org.eclipse.milo.opcua.stack.core.types.structured.CreateMonitoredItemsResponse) RepublishRequest(org.eclipse.milo.opcua.stack.core.types.structured.RepublishRequest) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ModifyMonitoredItemsResponse(org.eclipse.milo.opcua.stack.core.types.structured.ModifyMonitoredItemsResponse) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Session(org.eclipse.milo.opcua.sdk.server.Session) ArrayList(java.util.ArrayList) AccessLevel(org.eclipse.milo.opcua.sdk.core.AccessLevel) Lists(com.google.common.collect.Lists) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) ServiceRequest(org.eclipse.milo.opcua.stack.server.services.ServiceRequest) ConversionUtil.l(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l) DeleteSubscriptionsRequest(org.eclipse.milo.opcua.stack.core.types.structured.DeleteSubscriptionsRequest) SetTriggeringResponse(org.eclipse.milo.opcua.stack.core.types.structured.SetTriggeringResponse) DeleteMonitoredItemsRequest(org.eclipse.milo.opcua.stack.core.types.structured.DeleteMonitoredItemsRequest) DeleteMonitoredItemsResponse(org.eclipse.milo.opcua.stack.core.types.structured.DeleteMonitoredItemsResponse) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) Logger(org.slf4j.Logger) Lists.newArrayListWithCapacity(com.google.common.collect.Lists.newArrayListWithCapacity) Iterator(java.util.Iterator) MonitoredDataItem(org.eclipse.milo.opcua.sdk.server.items.MonitoredDataItem) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) MonitoredItemModifyResult(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyResult) UaSerializationException(org.eclipse.milo.opcua.stack.core.UaSerializationException) SetTriggeringRequest(org.eclipse.milo.opcua.stack.core.types.structured.SetTriggeringRequest) Maps(com.google.common.collect.Maps) Unsigned.ubyte(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ubyte) MonitoredItemCreateResult(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemCreateResult) Consumer(java.util.function.Consumer) MonitoredItem(org.eclipse.milo.opcua.sdk.server.api.MonitoredItem) CreateMonitoredItemsRequest(org.eclipse.milo.opcua.stack.core.types.structured.CreateMonitoredItemsRequest) AtomicLong(java.util.concurrent.atomic.AtomicLong) BaseMonitoredItem(org.eclipse.milo.opcua.sdk.server.items.BaseMonitoredItem) SetPublishingModeRequest(org.eclipse.milo.opcua.stack.core.types.structured.SetPublishingModeRequest) Collectors.toList(java.util.stream.Collectors.toList) ModifySubscriptionResponse(org.eclipse.milo.opcua.stack.core.types.structured.ModifySubscriptionResponse) UaException(org.eclipse.milo.opcua.stack.core.UaException) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) BaseMonitoredItem(org.eclipse.milo.opcua.sdk.server.items.BaseMonitoredItem) MonitoredItemModifyResult(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyResult) UaException(org.eclipse.milo.opcua.stack.core.UaException) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) ArrayList(java.util.ArrayList) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) ModifyMonitoredItemsRequest(org.eclipse.milo.opcua.stack.core.types.structured.ModifyMonitoredItemsRequest) ModifyMonitoredItemsResponse(org.eclipse.milo.opcua.stack.core.types.structured.ModifyMonitoredItemsResponse) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with DiagnosticInfo

use of org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo in project milo by eclipse.

the class DefaultSubscriptionServiceSet method onTransferSubscriptions.

@Override
public void onTransferSubscriptions(ServiceRequest service) throws UaException {
    TransferSubscriptionsRequest request = (TransferSubscriptionsRequest) service.getRequest();
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
    Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
    List<UInteger> subscriptionIds = l(request.getSubscriptionIds());
    if (subscriptionIds.isEmpty()) {
        throw new UaException(StatusCodes.Bad_NothingToDo);
    }
    List<TransferResult> results = Lists.newArrayList();
    for (UInteger subscriptionId : subscriptionIds) {
        Subscription subscription = server.getSubscriptions().get(subscriptionId);
        if (subscription == null) {
            results.add(new TransferResult(new StatusCode(StatusCodes.Bad_SubscriptionIdInvalid), new UInteger[0]));
        } else {
            Session otherSession = subscription.getSession();
            if (!sessionsHaveSameUser(session, otherSession)) {
                results.add(new TransferResult(new StatusCode(StatusCodes.Bad_UserAccessDenied), new UInteger[0]));
            } else {
                UInteger[] availableSequenceNumbers;
                synchronized (subscription) {
                    otherSession.getSubscriptionManager().sendStatusChangeNotification(subscription, new StatusCode(StatusCodes.Good_SubscriptionTransferred));
                    otherSession.getSubscriptionManager().removeSubscription(subscriptionId);
                    subscription.setSubscriptionManager(session.getSubscriptionManager());
                    subscriptionManager.addSubscription(subscription);
                    subscription.getMonitoredItems().values().forEach(item -> item.setSession(session));
                    availableSequenceNumbers = subscription.getAvailableSequenceNumbers();
                    if (request.getSendInitialValues()) {
                        subscription.getMonitoredItems().values().stream().filter(item -> item instanceof MonitoredDataItem).map(item -> (MonitoredDataItem) item).forEach(MonitoredDataItem::maybeSendLastValue);
                    }
                }
                subscription.getSubscriptionDiagnostics().getTransferRequestCount().increment();
                ApplicationDescription toClient = session.getClientDescription();
                ApplicationDescription fromClient = otherSession.getClientDescription();
                if (Objects.equals(toClient, fromClient)) {
                    subscription.getSubscriptionDiagnostics().getTransferredToSameClientCount().increment();
                } else {
                    subscription.getSubscriptionDiagnostics().getTransferredToAltClientCount().increment();
                }
                results.add(new TransferResult(StatusCode.GOOD, availableSequenceNumbers));
            }
        }
    }
    TransferSubscriptionsResponse response = new TransferSubscriptionsResponse(service.createResponseHeader(), a(results, TransferResult.class), new DiagnosticInfo[0]);
    service.setResponse(response);
}
Also used : StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) MonitoredDataItem(org.eclipse.milo.opcua.sdk.server.items.MonitoredDataItem) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) Subscription(org.eclipse.milo.opcua.sdk.server.subscriptions.Subscription) TransferResult(org.eclipse.milo.opcua.stack.core.types.structured.TransferResult) TransferSubscriptionsResponse(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsResponse) Session(org.eclipse.milo.opcua.sdk.server.Session) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) ConversionUtil.a(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.a) Objects(java.util.Objects) DiagnosticInfo(org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo) List(java.util.List) Lists(com.google.common.collect.Lists) ServiceRequest(org.eclipse.milo.opcua.stack.server.services.ServiceRequest) ConversionUtil.l(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) ApplicationDescription(org.eclipse.milo.opcua.stack.core.types.structured.ApplicationDescription) UaException(org.eclipse.milo.opcua.stack.core.UaException) SubscriptionManager(org.eclipse.milo.opcua.sdk.server.subscriptions.SubscriptionManager) SubscriptionServiceSet(org.eclipse.milo.opcua.stack.server.services.SubscriptionServiceSet) TransferSubscriptionsRequest(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsRequest) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) TransferSubscriptionsRequest(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsRequest) UaException(org.eclipse.milo.opcua.stack.core.UaException) TransferResult(org.eclipse.milo.opcua.stack.core.types.structured.TransferResult) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) ApplicationDescription(org.eclipse.milo.opcua.stack.core.types.structured.ApplicationDescription) MonitoredDataItem(org.eclipse.milo.opcua.sdk.server.items.MonitoredDataItem) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) TransferSubscriptionsResponse(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsResponse) Subscription(org.eclipse.milo.opcua.sdk.server.subscriptions.Subscription) Session(org.eclipse.milo.opcua.sdk.server.Session)

Example 3 with DiagnosticInfo

use of org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo in project milo by eclipse.

the class DefaultAttributeServiceSet method onRead.

@Override
public void onRead(ServiceRequest service) {
    ReadRequest request = (ReadRequest) service.getRequest();
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
    Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
    List<ReadValueId> nodesToRead = l(request.getNodesToRead());
    if (nodesToRead.isEmpty()) {
        service.setServiceFault(StatusCodes.Bad_NothingToDo);
        return;
    }
    if (nodesToRead.size() > server.getConfig().getLimits().getMaxNodesPerRead().longValue()) {
        service.setServiceFault(StatusCodes.Bad_TooManyOperations);
        return;
    }
    if (request.getMaxAge() < 0d) {
        service.setServiceFault(StatusCodes.Bad_MaxAgeInvalid);
        return;
    }
    if (request.getTimestampsToReturn() == null) {
        service.setServiceFault(StatusCodes.Bad_TimestampsToReturnInvalid);
        return;
    }
    DiagnosticsContext<ReadValueId> diagnosticsContext = new DiagnosticsContext<>();
    ReadContext context = new ReadContext(server, session, diagnosticsContext);
    server.getAddressSpaceManager().read(context, request.getMaxAge(), request.getTimestampsToReturn(), nodesToRead);
    context.getFuture().thenAccept(values -> {
        ResponseHeader header = service.createResponseHeader();
        DiagnosticInfo[] diagnosticInfos = diagnosticsContext.getDiagnosticInfos(nodesToRead);
        ReadResponse response = new ReadResponse(header, values.toArray(new DataValue[0]), diagnosticInfos);
        service.setResponse(response);
    });
}
Also used : OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) DiagnosticInfo(org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) DiagnosticsContext(org.eclipse.milo.opcua.sdk.server.DiagnosticsContext) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) ReadContext(org.eclipse.milo.opcua.sdk.server.api.services.AttributeServices.ReadContext) ReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest) Session(org.eclipse.milo.opcua.sdk.server.Session)

Example 4 with DiagnosticInfo

use of org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo in project milo by eclipse.

the class DefaultAttributeServiceSet method onWrite.

@Override
public void onWrite(ServiceRequest service) {
    WriteRequest request = (WriteRequest) service.getRequest();
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
    Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
    List<WriteValue> nodesToWrite = l(request.getNodesToWrite());
    if (nodesToWrite.isEmpty()) {
        service.setServiceFault(StatusCodes.Bad_NothingToDo);
        return;
    }
    if (nodesToWrite.size() > server.getConfig().getLimits().getMaxNodesPerWrite().intValue()) {
        service.setServiceFault(StatusCodes.Bad_TooManyOperations);
        return;
    }
    DiagnosticsContext<WriteValue> diagnosticsContext = new DiagnosticsContext<>();
    WriteContext context = new WriteContext(server, session, new DiagnosticsContext<>());
    server.getAddressSpaceManager().write(context, nodesToWrite);
    context.getFuture().thenAccept(values -> {
        ResponseHeader header = service.createResponseHeader();
        DiagnosticInfo[] diagnosticInfos = diagnosticsContext.getDiagnosticInfos(nodesToWrite);
        WriteResponse response = new WriteResponse(header, values.toArray(new StatusCode[0]), diagnosticInfos);
        service.setResponse(response);
    });
}
Also used : OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) WriteRequest(org.eclipse.milo.opcua.stack.core.types.structured.WriteRequest) DiagnosticInfo(org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo) WriteResponse(org.eclipse.milo.opcua.stack.core.types.structured.WriteResponse) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) WriteContext(org.eclipse.milo.opcua.sdk.server.api.services.AttributeServices.WriteContext) WriteValue(org.eclipse.milo.opcua.stack.core.types.structured.WriteValue) DiagnosticsContext(org.eclipse.milo.opcua.sdk.server.DiagnosticsContext) Session(org.eclipse.milo.opcua.sdk.server.Session)

Example 5 with DiagnosticInfo

use of org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo 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);
    });
}
Also used : StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) HistoryReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadRequest) HistoryUpdateResponse(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateResponse) HistoryUpdateDetails(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateDetails) Collectors(java.util.stream.Collectors) Session(org.eclipse.milo.opcua.sdk.server.Session) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) HistoryReadContext(org.eclipse.milo.opcua.sdk.server.api.services.AttributeHistoryServices.HistoryReadContext) ConversionUtil.a(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.a) HistoryUpdateContext(org.eclipse.milo.opcua.sdk.server.api.services.AttributeHistoryServices.HistoryUpdateContext) DiagnosticInfo(org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo) List(java.util.List) ServiceRequest(org.eclipse.milo.opcua.stack.server.services.ServiceRequest) HistoryReadResult(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadResult) ConversionUtil.l(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l) HistoryUpdateRequest(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateRequest) HistoryUpdateResult(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateResult) AttributeHistoryServiceSet(org.eclipse.milo.opcua.stack.server.services.AttributeHistoryServiceSet) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) HistoryReadDetails(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadDetails) DiagnosticsContext(org.eclipse.milo.opcua.sdk.server.DiagnosticsContext) HistoryReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadResponse) HistoryReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadValueId) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) HistoryUpdateRequest(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateRequest) DiagnosticInfo(org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo) HistoryUpdateResponse(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateResponse) HistoryUpdateResult(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateResult) HistoryUpdateContext(org.eclipse.milo.opcua.sdk.server.api.services.AttributeHistoryServices.HistoryUpdateContext) DiagnosticsContext(org.eclipse.milo.opcua.sdk.server.DiagnosticsContext) HistoryUpdateDetails(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateDetails) Session(org.eclipse.milo.opcua.sdk.server.Session)

Aggregations

DiagnosticInfo (org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo)14 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)8 Session (org.eclipse.milo.opcua.sdk.server.Session)8 StatusCode (org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode)7 ResponseHeader (org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader)6 DiagnosticsContext (org.eclipse.milo.opcua.sdk.server.DiagnosticsContext)5 StatusCodes (org.eclipse.milo.opcua.stack.core.StatusCodes)4 Unsigned.uint (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint)4 List (java.util.List)3 UaException (org.eclipse.milo.opcua.stack.core.UaException)3 ConversionUtil.l (org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l)3 ServiceRequest (org.eclipse.milo.opcua.stack.server.services.ServiceRequest)3 Lists (com.google.common.collect.Lists)2 ArrayList (java.util.ArrayList)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ReadContext (org.eclipse.milo.opcua.sdk.server.api.services.AttributeServices.ReadContext)2 MonitoredDataItem (org.eclipse.milo.opcua.sdk.server.items.MonitoredDataItem)2 UaSerializationException (org.eclipse.milo.opcua.stack.core.UaSerializationException)2 ByteString (org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)2 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)2