use of org.apache.plc4x.java.canopen.field.CANOpenField in project plc4x by apache.
the class CANOpenProtocolLogic method read.
public CompletableFuture<PlcReadResponse> read(PlcReadRequest readRequest) {
CompletableFuture<PlcReadResponse> response = new CompletableFuture<>();
if (readRequest.getFieldNames().size() != 1) {
response.completeExceptionally(new IllegalArgumentException("SDO requires single field to be read"));
return response;
}
PlcField field = readRequest.getFields().get(0);
if (!(field instanceof CANOpenField)) {
response.completeExceptionally(new IllegalArgumentException("Only CANOpenField instances are supported"));
return response;
}
if (!(field instanceof CANOpenSDOField)) {
response.completeExceptionally(new IllegalArgumentException("Only CANOpenSDOField instances are supported"));
return response;
}
;
readInternally(readRequest, (CANOpenSDOField) field, response);
return response;
}
use of org.apache.plc4x.java.canopen.field.CANOpenField in project plc4x by apache.
the class CANOpenProtocolLogic method write.
public CompletableFuture<PlcWriteResponse> write(PlcWriteRequest writeRequest) {
CompletableFuture<PlcWriteResponse> response = new CompletableFuture<>();
if (writeRequest.getFieldNames().size() != 1) {
response.completeExceptionally(new IllegalArgumentException("You can write only one field at the time"));
return response;
}
PlcField field = writeRequest.getFields().get(0);
if (!(field instanceof CANOpenField)) {
response.completeExceptionally(new IllegalArgumentException("Only CANOpenField instances are supported"));
return response;
}
if (field instanceof CANOpenSDOField) {
writeInternally((DefaultPlcWriteRequest) writeRequest, (CANOpenSDOField) field, response);
return response;
}
if (field instanceof CANOpenPDOField) {
writeInternally((DefaultPlcWriteRequest) writeRequest, (CANOpenPDOField) field, response);
return response;
}
response.completeExceptionally(new IllegalArgumentException("Only CANOpenSDOField instances are supported"));
return response;
}
Aggregations