Search in sources :

Example 1 with AddNodesItem

use of org.eclipse.milo.opcua.stack.core.types.structured.AddNodesItem in project milo by eclipse.

the class DefaultNodeManagementServiceSet method onAddNodes.

@Override
public void onAddNodes(ServiceRequest service) {
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
    Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
    AddNodesRequest request = (AddNodesRequest) service.getRequest();
    List<AddNodesItem> nodesToAdd = l(request.getNodesToAdd());
    if (nodesToAdd.isEmpty()) {
        service.setServiceFault(StatusCodes.Bad_NothingToDo);
        return;
    }
    if (nodesToAdd.size() > server.getConfig().getLimits().getMaxNodesPerNodeManagement().longValue()) {
        service.setServiceFault(StatusCodes.Bad_TooManyOperations);
        return;
    }
    AddNodesContext context = new AddNodesContext(server, session, new DiagnosticsContext<>());
    server.getAddressSpaceManager().addNodes(context, nodesToAdd);
    context.getFuture().thenAccept(results -> {
        ResponseHeader header = service.createResponseHeader();
        AddNodesResponse response = new AddNodesResponse(header, a(results, AddNodesResult.class), new DiagnosticInfo[0]);
        service.setResponse(response);
    });
}
Also used : AddNodesRequest(org.eclipse.milo.opcua.stack.core.types.structured.AddNodesRequest) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) AddNodesResponse(org.eclipse.milo.opcua.stack.core.types.structured.AddNodesResponse) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) AddNodesResult(org.eclipse.milo.opcua.stack.core.types.structured.AddNodesResult) AddNodesContext(org.eclipse.milo.opcua.sdk.server.api.services.NodeManagementServices.AddNodesContext) AddNodesItem(org.eclipse.milo.opcua.stack.core.types.structured.AddNodesItem) Session(org.eclipse.milo.opcua.sdk.server.Session)

Aggregations

OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)1 Session (org.eclipse.milo.opcua.sdk.server.Session)1 AddNodesContext (org.eclipse.milo.opcua.sdk.server.api.services.NodeManagementServices.AddNodesContext)1 AddNodesItem (org.eclipse.milo.opcua.stack.core.types.structured.AddNodesItem)1 AddNodesRequest (org.eclipse.milo.opcua.stack.core.types.structured.AddNodesRequest)1 AddNodesResponse (org.eclipse.milo.opcua.stack.core.types.structured.AddNodesResponse)1 AddNodesResult (org.eclipse.milo.opcua.stack.core.types.structured.AddNodesResult)1 ResponseHeader (org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader)1