Search in sources :

Example 1 with HistoryUpdateDetails

use of org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateDetails 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)

Example 2 with HistoryUpdateDetails

use of org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateDetails 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);
    });
}
Also used : Arrays(java.util.Arrays) BrowseNextRequest(org.eclipse.milo.opcua.stack.core.types.structured.BrowseNextRequest) WriteValue(org.eclipse.milo.opcua.stack.core.types.structured.WriteValue) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) PublishRequest(org.eclipse.milo.opcua.stack.core.types.structured.PublishRequest) WriteRequest(org.eclipse.milo.opcua.stack.core.types.structured.WriteRequest) MonitoredItemCreateRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemCreateRequest) DataTypeManager(org.eclipse.milo.opcua.stack.core.types.DataTypeManager) WriteResponse(org.eclipse.milo.opcua.stack.core.types.structured.WriteResponse) SessionInitializer(org.eclipse.milo.opcua.sdk.client.session.SessionFsm.SessionInitializer) TranslateBrowsePathsToNodeIdsRequest(org.eclipse.milo.opcua.stack.core.types.structured.TranslateBrowsePathsToNodeIdsRequest) ModifySubscriptionRequest(org.eclipse.milo.opcua.stack.core.types.structured.ModifySubscriptionRequest) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ModifyMonitoredItemsRequest(org.eclipse.milo.opcua.stack.core.types.structured.ModifyMonitoredItemsRequest) UaResponseMessage(org.eclipse.milo.opcua.stack.core.serialization.UaResponseMessage) AddReferencesItem(org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesItem) TransferSubscriptionsResponse(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsResponse) ManifestUtil(org.eclipse.milo.opcua.stack.core.util.ManifestUtil) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) SetPublishingModeResponse(org.eclipse.milo.opcua.stack.core.types.structured.SetPublishingModeResponse) SetMonitoringModeRequest(org.eclipse.milo.opcua.stack.core.types.structured.SetMonitoringModeRequest) MonitoringMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode) SetMonitoringModeResponse(org.eclipse.milo.opcua.stack.core.types.structured.SetMonitoringModeResponse) RepublishRequest(org.eclipse.milo.opcua.stack.core.types.structured.RepublishRequest) ModifyMonitoredItemsResponse(org.eclipse.milo.opcua.stack.core.types.structured.ModifyMonitoredItemsResponse) ConversionUtil.a(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.a) OpcUaClientConfigBuilder(org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfigBuilder) MonitoredItemModifyRequest(org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemModifyRequest) Stack(org.eclipse.milo.opcua.stack.core.Stack) EndpointDescription(org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription) DeleteNodesRequest(org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesRequest) HistoryUpdateRequest(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateRequest) RegisterNodesRequest(org.eclipse.milo.opcua.stack.core.types.structured.RegisterNodesRequest) UaRequestMessage(org.eclipse.milo.opcua.stack.core.serialization.UaRequestMessage) DeleteNodesItem(org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesItem) DeleteMonitoredItemsRequest(org.eclipse.milo.opcua.stack.core.types.structured.DeleteMonitoredItemsRequest) DeleteMonitoredItemsResponse(org.eclipse.milo.opcua.stack.core.types.structured.DeleteMonitoredItemsResponse) TransferSubscriptionsRequest(org.eclipse.milo.opcua.stack.core.types.structured.TransferSubscriptionsRequest) DeleteReferencesItem(org.eclipse.milo.opcua.stack.core.types.structured.DeleteReferencesItem) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) RegisterNodesResponse(org.eclipse.milo.opcua.stack.core.types.structured.RegisterNodesResponse) Lists.newCopyOnWriteArrayList(com.google.common.collect.Lists.newCopyOnWriteArrayList) OpcUaClientConfig(org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig) SessionFsm(org.eclipse.milo.opcua.sdk.client.session.SessionFsm) UaStackClient(org.eclipse.milo.opcua.stack.client.UaStackClient) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) SetTriggeringRequest(org.eclipse.milo.opcua.stack.core.types.structured.SetTriggeringRequest) ExecutionException(java.util.concurrent.ExecutionException) DeleteReferencesResponse(org.eclipse.milo.opcua.stack.core.types.structured.DeleteReferencesResponse) AddNodesResponse(org.eclipse.milo.opcua.stack.core.types.structured.AddNodesResponse) AddNodesRequest(org.eclipse.milo.opcua.stack.core.types.structured.AddNodesRequest) DiscoveryClient(org.eclipse.milo.opcua.stack.client.DiscoveryClient) Namespaces(org.eclipse.milo.opcua.stack.core.util.Namespaces) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) LoggerFactory(org.slf4j.LoggerFactory) AddNodesItem(org.eclipse.milo.opcua.stack.core.types.structured.AddNodesItem) DeleteReferencesRequest(org.eclipse.milo.opcua.stack.core.types.structured.DeleteReferencesRequest) ReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest) OpcUaSubscriptionManager(org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaSubscriptionManager) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) CreateSubscriptionResponse(org.eclipse.milo.opcua.stack.core.types.structured.CreateSubscriptionResponse) DeleteNodesResponse(org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesResponse) VariableTypeInitializer(org.eclipse.milo.opcua.sdk.client.model.VariableTypeInitializer) HistoryReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadRequest) UByte(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte) Predicate(java.util.function.Predicate) BrowsePath(org.eclipse.milo.opcua.stack.core.types.structured.BrowsePath) HistoryUpdateDetails(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateDetails) RepublishResponse(org.eclipse.milo.opcua.stack.core.types.structured.RepublishResponse) ServiceFault(org.eclipse.milo.opcua.stack.core.types.structured.ServiceFault) Objects(java.util.Objects) SubscriptionAcknowledgement(org.eclipse.milo.opcua.stack.core.types.structured.SubscriptionAcknowledgement) List(java.util.List) UnregisterNodesResponse(org.eclipse.milo.opcua.stack.core.types.structured.UnregisterNodesResponse) AddReferencesRequest(org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesRequest) AddReferencesResponse(org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesResponse) TranslateBrowsePathsToNodeIdsResponse(org.eclipse.milo.opcua.stack.core.types.structured.TranslateBrowsePathsToNodeIdsResponse) Optional(java.util.Optional) DeleteSubscriptionsResponse(org.eclipse.milo.opcua.stack.core.types.structured.DeleteSubscriptionsResponse) CreateSubscriptionRequest(org.eclipse.milo.opcua.stack.core.types.structured.CreateSubscriptionRequest) BrowseResponse(org.eclipse.milo.opcua.stack.core.types.structured.BrowseResponse) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) BrowseRequest(org.eclipse.milo.opcua.stack.core.types.structured.BrowseRequest) UnregisterNodesRequest(org.eclipse.milo.opcua.stack.core.types.structured.UnregisterNodesRequest) CallMethodRequest(org.eclipse.milo.opcua.stack.core.types.structured.CallMethodRequest) CallResponse(org.eclipse.milo.opcua.stack.core.types.structured.CallResponse) CreateMonitoredItemsResponse(org.eclipse.milo.opcua.stack.core.types.structured.CreateMonitoredItemsResponse) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) RequestHeader(org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader) NamespaceTable(org.eclipse.milo.opcua.stack.core.NamespaceTable) CallRequest(org.eclipse.milo.opcua.stack.core.types.structured.CallRequest) SerializationContext(org.eclipse.milo.opcua.stack.core.serialization.SerializationContext) UShort(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort) SessionFsmFactory(org.eclipse.milo.opcua.sdk.client.session.SessionFsmFactory) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) ServiceFaultListener(org.eclipse.milo.opcua.sdk.client.api.ServiceFaultListener) SecurityPolicy(org.eclipse.milo.opcua.stack.core.security.SecurityPolicy) BrowseNextResponse(org.eclipse.milo.opcua.stack.core.types.structured.BrowseNextResponse) DeleteSubscriptionsRequest(org.eclipse.milo.opcua.stack.core.types.structured.DeleteSubscriptionsRequest) HistoryReadDetails(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadDetails) SetTriggeringResponse(org.eclipse.milo.opcua.stack.core.types.structured.SetTriggeringResponse) HistoryReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadResponse) HistoryUpdateResponse(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateResponse) ExecutionQueue(org.eclipse.milo.opcua.stack.core.util.ExecutionQueue) Logger(org.slf4j.Logger) PublishResponse(org.eclipse.milo.opcua.stack.core.types.structured.PublishResponse) Unsigned.ushort(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort) ObjectTypeInitializer(org.eclipse.milo.opcua.sdk.client.model.ObjectTypeInitializer) UserTokenType(org.eclipse.milo.opcua.stack.core.types.enumerated.UserTokenType) UaServiceFaultException(org.eclipse.milo.opcua.stack.core.UaServiceFaultException) ViewDescription(org.eclipse.milo.opcua.stack.core.types.structured.ViewDescription) CreateMonitoredItemsRequest(org.eclipse.milo.opcua.stack.core.types.structured.CreateMonitoredItemsRequest) SetPublishingModeRequest(org.eclipse.milo.opcua.stack.core.types.structured.SetPublishingModeRequest) UaClient(org.eclipse.milo.opcua.sdk.client.api.UaClient) ModifySubscriptionResponse(org.eclipse.milo.opcua.stack.core.types.structured.ModifySubscriptionResponse) UaException(org.eclipse.milo.opcua.stack.core.UaException) HistoryReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadValueId) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) HistoryUpdateRequest(org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateRequest)

Aggregations

List (java.util.List)2 StatusCodes (org.eclipse.milo.opcua.stack.core.StatusCodes)2 HistoryReadDetails (org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadDetails)2 HistoryReadRequest (org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadRequest)2 HistoryReadResponse (org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadResponse)2 HistoryReadValueId (org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadValueId)2 HistoryUpdateDetails (org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateDetails)2 HistoryUpdateRequest (org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateRequest)2 HistoryUpdateResponse (org.eclipse.milo.opcua.stack.core.types.structured.HistoryUpdateResponse)2 ConversionUtil.a (org.eclipse.milo.opcua.stack.core.util.ConversionUtil.a)2 Lists.newCopyOnWriteArrayList (com.google.common.collect.Lists.newCopyOnWriteArrayList)1 Arrays (java.util.Arrays)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 ServiceFaultListener (org.eclipse.milo.opcua.sdk.client.api.ServiceFaultListener)1