Search in sources :

Example 11 with DefaultPlcWriteResponse

use of org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse in project plc4x by apache.

the class SimulatedConnection method write.

@Override
public CompletableFuture<PlcWriteResponse> write(PlcWriteRequest writeRequest) {
    Map<String, PlcResponseCode> fields = new HashMap<>();
    for (String fieldName : writeRequest.getFieldNames()) {
        SimulatedField field = (SimulatedField) writeRequest.getField(fieldName);
        PlcValue value = writeRequest.getPlcValue(fieldName);
        device.set(field, value);
        fields.put(fieldName, PlcResponseCode.OK);
    }
    PlcWriteResponse response = new DefaultPlcWriteResponse(writeRequest, fields);
    return CompletableFuture.completedFuture(response);
}
Also used : PlcValue(org.apache.plc4x.java.api.value.PlcValue) DefaultPlcWriteResponse(org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PlcWriteResponse(org.apache.plc4x.java.api.messages.PlcWriteResponse) DefaultPlcWriteResponse(org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse) SimulatedField(org.apache.plc4x.java.simulated.field.SimulatedField) PlcResponseCode(org.apache.plc4x.java.api.types.PlcResponseCode)

Aggregations

DefaultPlcWriteResponse (org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse)11 PlcResponseCode (org.apache.plc4x.java.api.types.PlcResponseCode)10 CompletableFuture (java.util.concurrent.CompletableFuture)7 PlcValue (org.apache.plc4x.java.api.value.PlcValue)7 DefaultPlcReadResponse (org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse)6 ResponseItem (org.apache.plc4x.java.spi.messages.utils.ResponseItem)6 RequestTransactionManager (org.apache.plc4x.java.spi.transaction.RequestTransactionManager)6 Duration (java.time.Duration)5 PlcRuntimeException (org.apache.plc4x.java.api.exceptions.PlcRuntimeException)5 HasConfiguration (org.apache.plc4x.java.spi.configuration.HasConfiguration)5 DefaultPlcReadRequest (org.apache.plc4x.java.spi.messages.DefaultPlcReadRequest)5 DefaultPlcWriteRequest (org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest)5 Collections (java.util.Collections)4 PlcField (org.apache.plc4x.java.api.model.PlcField)4 org.apache.plc4x.java.modbus.readwrite (org.apache.plc4x.java.modbus.readwrite)4 HashMap (java.util.HashMap)3 PlcReadRequest (org.apache.plc4x.java.api.messages.PlcReadRequest)3 PlcWriteResponse (org.apache.plc4x.java.api.messages.PlcWriteResponse)3 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2