Search in sources :

Example 11 with ReadRequest

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

the class ClientServerTest method setReadRequestHandler.

private void setReadRequestHandler(Variant variant) {
    server.addServiceHandler("/test", ReadRequest.TYPE_ID, service -> {
        ReadRequest request = (ReadRequest) service.getRequest();
        ResponseHeader header = new ResponseHeader(DateTime.now(), request.getRequestHeader().getRequestHandle(), StatusCode.GOOD, null, null, null);
        List<ReadValueId> nodesToRead = l(request.getNodesToRead());
        List<DataValue> results = Collections.nCopies(nodesToRead.size(), new DataValue(variant));
        ReadResponse response = new ReadResponse(header, a(results, DataValue.class), null);
        service.setResponse(response);
    });
}
Also used : ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) ReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest)

Aggregations

ReadRequest (org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest)11 ReadValueId (org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId)11 RequestHeader (org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader)8 UaStackClient (org.eclipse.milo.opcua.stack.client.UaStackClient)5 UaResponseMessage (org.eclipse.milo.opcua.stack.core.serialization.UaResponseMessage)5 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)5 EndpointDescription (org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription)5 ReadResponse (org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse)4 Test (org.testng.annotations.Test)4 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 NamespaceTable (org.eclipse.milo.opcua.stack.core.NamespaceTable)2 UaException (org.eclipse.milo.opcua.stack.core.UaException)2 Unsigned.uint (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint)2 Lists.newCopyOnWriteArrayList (com.google.common.collect.Lists.newCopyOnWriteArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 ExecutionException (java.util.concurrent.ExecutionException)1