Search in sources :

Example 1 with StatusCodes

use of org.eclipse.milo.opcua.stack.core.StatusCodes in project milo by eclipse.

the class ManagedItem method setTimestampsToReturnAsync.

/**
 * Set a new {@link TimestampsToReturn} parameter on this item.
 * <p>
 * This call completes asynchronously.
 *
 * @param timestamps a new {@link TimestampsToReturn} parameter.
 * @return a {@link CompletableFuture} that completes successfully if the item was modified and completes
 * exceptionally if an operation- or service-level error occurs.
 */
public CompletableFuture<Unit> setTimestampsToReturnAsync(TimestampsToReturn timestamps) {
    MonitoringParameters parameters = new MonitoringParameters(monitoredItem.getClientHandle(), monitoredItem.getRevisedSamplingInterval(), monitoredItem.getMonitoringFilter(), monitoredItem.getRevisedQueueSize(), monitoredItem.getDiscardOldest());
    MonitoredItemModifyRequest modifyRequest = new MonitoredItemModifyRequest(monitoredItem.getMonitoredItemId(), parameters);
    CompletableFuture<List<StatusCode>> future = subscription.getSubscription().modifyMonitoredItems(timestamps, singletonList(modifyRequest));
    return future.thenApply(statusCodes -> statusCodes.get(0)).thenCompose(statusCode -> {
        if (statusCode.isGood()) {
            return completedFuture(Unit.VALUE);
        } else {
            return failedUaFuture(statusCode);
        }
    });
}
Also used : MonitoringMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) ModifyMonitoredItemResult(org.eclipse.milo.opcua.sdk.client.subscriptions.BatchModifyMonitoredItems.ModifyMonitoredItemResult) SetMonitoringModeResult(org.eclipse.milo.opcua.sdk.client.subscriptions.BatchSetMonitoringMode.SetMonitoringModeResult) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) FutureUtils.failedUaFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture) OpcUaClient(org.eclipse.milo.opcua.sdk.client.OpcUaClient) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) CompletableFuture(java.util.concurrent.CompletableFuture) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) Collections.singletonList(java.util.Collections.singletonList) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) UaException(org.eclipse.milo.opcua.stack.core.UaException) Optional(java.util.Optional) UaMonitoredItem(org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaMonitoredItem) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List)

Example 2 with StatusCodes

use of org.eclipse.milo.opcua.stack.core.StatusCodes in project milo by eclipse.

the class SessionFsmFactory method transferSubscriptions.

@SuppressWarnings("Duplicates")
private static CompletableFuture<Unit> transferSubscriptions(FsmContext<State, Event> ctx, OpcUaClient client, OpcUaSession session) {
    UaStackClient stackClient = client.getStackClient();
    OpcUaSubscriptionManager subscriptionManager = client.getSubscriptionManager();
    ImmutableList<UaSubscription> subscriptions = subscriptionManager.getSubscriptions();
    if (subscriptions.isEmpty()) {
        return completedFuture(Unit.VALUE);
    }
    CompletableFuture<Unit> transferFuture = new CompletableFuture<>();
    UInteger[] subscriptionIdsArray = subscriptions.stream().map(UaSubscription::getSubscriptionId).toArray(UInteger[]::new);
    TransferSubscriptionsRequest request = new TransferSubscriptionsRequest(client.newRequestHeader(session.getAuthenticationToken()), subscriptionIdsArray, true);
    LOGGER.debug("[{}] Sending TransferSubscriptionsRequest...", ctx.getInstanceId());
    stackClient.sendRequest(request).thenApply(TransferSubscriptionsResponse.class::cast).whenComplete((tsr, ex) -> {
        if (tsr != null) {
            List<TransferResult> results = l(tsr.getResults());
            LOGGER.debug("[{}] TransferSubscriptions supported: {}", ctx.getInstanceId(), tsr.getResponseHeader().getServiceResult());
            if (LOGGER.isDebugEnabled()) {
                try {
                    Stream<UInteger> subscriptionIds = subscriptions.stream().map(UaSubscription::getSubscriptionId);
                    Stream<StatusCode> statusCodes = results.stream().map(TransferResult::getStatusCode);
                    // noinspection UnstableApiUsage
                    String[] ss = Streams.zip(subscriptionIds, statusCodes, (i, s) -> String.format("id=%s/%s", i, StatusCodes.lookup(s.getValue()).map(sa -> sa[0]).orElse(s.toString()))).toArray(String[]::new);
                    LOGGER.debug("[{}] TransferSubscriptions results: {}", ctx.getInstanceId(), Arrays.toString(ss));
                } catch (Throwable t) {
                    LOGGER.error("[{}] error logging TransferSubscription results", ctx.getInstanceId(), t);
                }
            }
            client.getConfig().getExecutor().execute(() -> {
                for (int i = 0; i < results.size(); i++) {
                    TransferResult result = results.get(i);
                    if (!result.getStatusCode().isGood()) {
                        UaSubscription subscription = subscriptions.get(i);
                        subscriptionManager.transferFailed(subscription.getSubscriptionId(), result.getStatusCode());
                    }
                }
            });
            transferFuture.complete(Unit.VALUE);
        } else {
            StatusCode statusCode = UaException.extract(ex).map(UaException::getStatusCode).orElse(StatusCode.BAD);
            LOGGER.debug("[{}] TransferSubscriptions not supported: {}", ctx.getInstanceId(), statusCode);
            client.getConfig().getExecutor().execute(() -> {
                // because the list from getSubscriptions() above is a copy.
                for (UaSubscription subscription : subscriptions) {
                    subscriptionManager.transferFailed(subscription.getSubscriptionId(), statusCode);
                }
            });
            // supported but server implementations interpret the spec differently.
            if (statusCode.getValue() == StatusCodes.Bad_NotImplemented || statusCode.getValue() == StatusCodes.Bad_NotSupported || statusCode.getValue() == StatusCodes.Bad_OutOfService || statusCode.getValue() == StatusCodes.Bad_ServiceUnsupported) {
                // One of the expected responses; continue moving through the FSM.
                transferFuture.complete(Unit.VALUE);
            } else {
                // An unexpected response; complete exceptionally and start over.
                // Subsequent runs through the FSM will not attempt transfer because
                // transferFailed() has been called for all the existing subscriptions.
                // This will prevent us from getting stuck in a "loop" attempting to
                // reconnect to a defective server that responds with a channel-level
                // Error message to subscription transfer requests instead of an
                // application-level ServiceFault.
                transferFuture.completeExceptionally(ex);
            }
        }
    });
    return transferFuture;
}
Also used : X509Certificate(java.security.cert.X509Certificate) KEY_CLOSE_FUTURE(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_CLOSE_FUTURE) KeyPair(java.security.KeyPair) SignedSoftwareCertificate(org.eclipse.milo.opcua.stack.core.types.structured.SignedSoftwareCertificate) Arrays(java.util.Arrays) ApplicationType(org.eclipse.milo.opcua.stack.core.types.enumerated.ApplicationType) ScheduledFuture(java.util.concurrent.ScheduledFuture) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) LoggerFactory(org.slf4j.LoggerFactory) ServerState(org.eclipse.milo.opcua.stack.core.types.enumerated.ServerState) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) ReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest) TransferResult(org.eclipse.milo.opcua.stack.core.types.structured.TransferResult) KEY_WAIT_TIME(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_WAIT_TIME) OpcUaSubscriptionManager(org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaSubscriptionManager) ByteBuffer(java.nio.ByteBuffer) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) UserIdentityToken(org.eclipse.milo.opcua.stack.core.types.structured.UserIdentityToken) SecurityAlgorithm(org.eclipse.milo.opcua.stack.core.security.SecurityAlgorithm) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) UaSubscription(org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscription) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) KEY_SESSION_INITIALIZERS(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_SESSION_INITIALIZERS) CertificateUtil(org.eclipse.milo.opcua.stack.core.util.CertificateUtil) CreateSessionRequest(org.eclipse.milo.opcua.stack.core.types.structured.CreateSessionRequest) ActivateSessionRequest(org.eclipse.milo.opcua.stack.core.types.structured.ActivateSessionRequest) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) Predicate(java.util.function.Predicate) KEY_SESSION_ACTIVITY_LISTENERS(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_SESSION_ACTIVITY_LISTENERS) TransferSubscriptionsResponse(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsResponse) Streams(com.google.common.collect.Streams) Bytes(com.google.common.primitives.Bytes) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) ServiceFault(org.eclipse.milo.opcua.stack.core.types.structured.ServiceFault) KEY_WAIT_FUTURE(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_WAIT_FUTURE) ActivateSessionResponse(org.eclipse.milo.opcua.stack.core.types.structured.ActivateSessionResponse) List(java.util.List) Stream(java.util.stream.Stream) PrivateKey(java.security.PrivateKey) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) KEY_KEEP_ALIVE_FAILURE_COUNT(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_KEEP_ALIVE_FAILURE_COUNT) EndpointUtil(org.eclipse.milo.opcua.stack.core.util.EndpointUtil) OpcUaSession(org.eclipse.milo.opcua.sdk.client.OpcUaSession) CertificateEncodingException(java.security.cert.CertificateEncodingException) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) CloseSessionRequest(org.eclipse.milo.opcua.stack.core.types.structured.CloseSessionRequest) KEY_SESSION_FUTURE(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_SESSION_FUTURE) ActionContext(com.digitalpetri.strictmachine.dsl.ActionContext) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) OpcUaClient(org.eclipse.milo.opcua.sdk.client.OpcUaClient) SignedIdentityToken(org.eclipse.milo.opcua.sdk.client.api.identity.SignedIdentityToken) CompletableFuture(java.util.concurrent.CompletableFuture) CreateSessionResponse(org.eclipse.milo.opcua.stack.core.types.structured.CreateSessionResponse) RequestHeader(org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader) ImmutableList(com.google.common.collect.ImmutableList) EndpointDescription(org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription) ConversionUtil.l(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l) SignatureData(org.eclipse.milo.opcua.stack.core.types.structured.SignatureData) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) FutureUtils.complete(org.eclipse.milo.opcua.stack.core.util.FutureUtils.complete) ServiceFaultListener(org.eclipse.milo.opcua.sdk.client.api.ServiceFaultListener) SessionFuture(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.SessionFuture) SecurityPolicy(org.eclipse.milo.opcua.stack.core.security.SecurityPolicy) TransferSubscriptionsRequest(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsRequest) KEY_SESSION(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_SESSION) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) SignatureUtil(org.eclipse.milo.opcua.stack.core.util.SignatureUtil) Fsm(com.digitalpetri.strictmachine.Fsm) Logger(org.slf4j.Logger) OpcUaClientConfig(org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig) UaStackClient(org.eclipse.milo.opcua.stack.client.UaStackClient) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) KEY_KEEP_ALIVE_SCHEDULED_FUTURE(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.KEY_KEEP_ALIVE_SCHEDULED_FUTURE) TimeUnit(java.util.concurrent.TimeUnit) NonceUtil(org.eclipse.milo.opcua.stack.core.util.NonceUtil) FsmContext(com.digitalpetri.strictmachine.FsmContext) ApplicationDescription(org.eclipse.milo.opcua.stack.core.types.structured.ApplicationDescription) FutureUtils.failedFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedFuture) UaException(org.eclipse.milo.opcua.stack.core.UaException) FsmBuilder(com.digitalpetri.strictmachine.dsl.FsmBuilder) UaSubscription(org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscription) TransferSubscriptionsRequest(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsRequest) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) TimeUnit(java.util.concurrent.TimeUnit) TransferResult(org.eclipse.milo.opcua.stack.core.types.structured.TransferResult) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) CompletableFuture(java.util.concurrent.CompletableFuture) UaStackClient(org.eclipse.milo.opcua.stack.client.UaStackClient) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) OpcUaSubscriptionManager(org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaSubscriptionManager)

Example 3 with StatusCodes

use of org.eclipse.milo.opcua.stack.core.StatusCodes in project milo by eclipse.

the class ManagedDataItem method setSamplingIntervalAsync.

/**
 * Request a new sampling interval for this item.
 * <p>
 * This call completes asynchronously.
 *
 * @param samplingInterval the new sampling interval to request.
 * @return a {@link CompletableFuture} that completes successfully with the new sampling interval, possibly revised
 * by the server, or completes exceptionally if an operation- or service-level error occurs.
 */
public CompletableFuture<Double> setSamplingIntervalAsync(double samplingInterval) {
    MonitoringParameters parameters = new MonitoringParameters(monitoredItem.getClientHandle(), samplingInterval, monitoredItem.getMonitoringFilter(), // size if it was revised from the original
    monitoredItem.getRevisedQueueSize(), monitoredItem.getDiscardOldest());
    MonitoredItemModifyRequest modifyRequest = new MonitoredItemModifyRequest(monitoredItem.getMonitoredItemId(), parameters);
    CompletableFuture<List<StatusCode>> future = subscription.getSubscription().modifyMonitoredItems(subscription.getDefaultTimestamps(), singletonList(modifyRequest));
    return future.thenApply(statusCodes -> statusCodes.get(0)).thenCompose(statusCode -> {
        if (statusCode.isGood()) {
            return completedFuture(monitoredItem.getRevisedSamplingInterval());
        } else {
            return failedUaFuture(statusCode);
        }
    });
}
Also used : MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) ModifyMonitoredItemResult(org.eclipse.milo.opcua.sdk.client.subscriptions.BatchModifyMonitoredItems.ModifyMonitoredItemResult) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) FutureUtils.failedUaFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) OpcUaClient(org.eclipse.milo.opcua.sdk.client.OpcUaClient) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) CompletableFuture(java.util.concurrent.CompletableFuture) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) Collections.singletonList(java.util.Collections.singletonList) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) List(java.util.List) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) UaException(org.eclipse.milo.opcua.stack.core.UaException) Optional(java.util.Optional) UaMonitoredItem(org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaMonitoredItem) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 4 with StatusCodes

use of org.eclipse.milo.opcua.stack.core.StatusCodes in project milo by eclipse.

the class ManagedItem method setQueueSizeAsync.

/**
 * Request a new queue size for this item.
 * <p>
 * This call completes asynchronously.
 *
 * @param queueSize the new queue size to request.
 * @return a {@link CompletableFuture} that completes successfully with the new queue size, possibly revised by the
 * server, or completes exceptionally if an operation- or service-level error occurs.
 */
public CompletableFuture<UInteger> setQueueSizeAsync(UInteger queueSize) {
    MonitoringParameters parameters = new MonitoringParameters(monitoredItem.getClientHandle(), monitoredItem.getRevisedSamplingInterval(), monitoredItem.getMonitoringFilter(), queueSize, monitoredItem.getDiscardOldest());
    MonitoredItemModifyRequest modifyRequest = new MonitoredItemModifyRequest(monitoredItem.getMonitoredItemId(), parameters);
    CompletableFuture<List<StatusCode>> future = subscription.getSubscription().modifyMonitoredItems(monitoredItem.getTimestamps(), singletonList(modifyRequest));
    return future.thenApply(statusCodes -> statusCodes.get(0)).thenCompose(statusCode -> {
        if (statusCode.isGood()) {
            return completedFuture(monitoredItem.getRevisedQueueSize());
        } else {
            return failedUaFuture(statusCode);
        }
    });
}
Also used : MonitoringMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) ModifyMonitoredItemResult(org.eclipse.milo.opcua.sdk.client.subscriptions.BatchModifyMonitoredItems.ModifyMonitoredItemResult) SetMonitoringModeResult(org.eclipse.milo.opcua.sdk.client.subscriptions.BatchSetMonitoringMode.SetMonitoringModeResult) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) FutureUtils.failedUaFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture) OpcUaClient(org.eclipse.milo.opcua.sdk.client.OpcUaClient) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) CompletableFuture(java.util.concurrent.CompletableFuture) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) Collections.singletonList(java.util.Collections.singletonList) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) UaException(org.eclipse.milo.opcua.stack.core.UaException) Optional(java.util.Optional) UaMonitoredItem(org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaMonitoredItem) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List)

Example 5 with StatusCodes

use of org.eclipse.milo.opcua.stack.core.StatusCodes in project milo by eclipse.

the class ManagedItem method setDiscardOldestAsync.

/**
 * Set this item's discard policy.
 * <p>
 * This call completes asynchronously.
 *
 * @param discardOldest {@code true} if the oldest are discarded when the queue is full.
 * @return a {@link CompletableFuture} that completes successfully if the item was modified and completes
 * exceptionally if an operation- or service-level error occurs.
 */
public CompletableFuture<Unit> setDiscardOldestAsync(boolean discardOldest) {
    MonitoringParameters parameters = new MonitoringParameters(monitoredItem.getClientHandle(), monitoredItem.getRevisedSamplingInterval(), monitoredItem.getMonitoringFilter(), monitoredItem.getRevisedQueueSize(), discardOldest);
    MonitoredItemModifyRequest modifyRequest = new MonitoredItemModifyRequest(monitoredItem.getMonitoredItemId(), parameters);
    CompletableFuture<List<StatusCode>> future = subscription.getSubscription().modifyMonitoredItems(monitoredItem.getTimestamps(), singletonList(modifyRequest));
    return future.thenApply(statusCodes -> statusCodes.get(0)).thenCompose(statusCode -> {
        if (statusCode.isGood()) {
            return completedFuture(Unit.VALUE);
        } else {
            return failedUaFuture(statusCode);
        }
    });
}
Also used : MonitoringMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) ModifyMonitoredItemResult(org.eclipse.milo.opcua.sdk.client.subscriptions.BatchModifyMonitoredItems.ModifyMonitoredItemResult) SetMonitoringModeResult(org.eclipse.milo.opcua.sdk.client.subscriptions.BatchSetMonitoringMode.SetMonitoringModeResult) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) FutureUtils.failedUaFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture) OpcUaClient(org.eclipse.milo.opcua.sdk.client.OpcUaClient) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) CompletableFuture(java.util.concurrent.CompletableFuture) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) Collections.singletonList(java.util.Collections.singletonList) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) UaException(org.eclipse.milo.opcua.stack.core.UaException) Optional(java.util.Optional) UaMonitoredItem(org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaMonitoredItem) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) MonitoringParameters(org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List)

Aggregations

List (java.util.List)6 StatusCodes (org.eclipse.milo.opcua.stack.core.StatusCodes)6 UaException (org.eclipse.milo.opcua.stack.core.UaException)6 CompletableFuture (java.util.concurrent.CompletableFuture)5 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)5 OpcUaClient (org.eclipse.milo.opcua.sdk.client.OpcUaClient)5 StatusCode (org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode)5 ReadValueId (org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId)5 Unit (org.eclipse.milo.opcua.stack.core.util.Unit)5 Collections.singletonList (java.util.Collections.singletonList)4 Optional (java.util.Optional)4 ExecutionException (java.util.concurrent.ExecutionException)4 UaMonitoredItem (org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaMonitoredItem)4 ModifyMonitoredItemResult (org.eclipse.milo.opcua.sdk.client.subscriptions.BatchModifyMonitoredItems.ModifyMonitoredItemResult)4 UInteger (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger)4 TimestampsToReturn (org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn)4 MonitoredItemModifyRequest (org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest)4 MonitoringParameters (org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters)4 FutureUtils.failedUaFuture (org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture)4 SetMonitoringModeResult (org.eclipse.milo.opcua.sdk.client.subscriptions.BatchSetMonitoringMode.SetMonitoringModeResult)3