Search in sources :

Example 46 with PlcValue

use of org.apache.plc4x.java.api.value.PlcValue in project plc4x by apache.

the class DefaultPlcReadResponse method getAllDoubles.

@Override
@JsonIgnore
public Collection<Double> getAllDoubles(String name) {
    PlcValue fieldInternal = getFieldInternal(name);
    if (fieldInternal instanceof PlcList) {
        PlcList plcList = (PlcList) fieldInternal;
        List<Double> items = new ArrayList<>(plcList.getLength());
        for (PlcValue plcValue : plcList.getList()) {
            items.add(plcValue.getDouble());
        }
        return items;
    }
    return Collections.singletonList(fieldInternal.getDouble());
}
Also used : PlcList(org.apache.plc4x.java.spi.values.PlcList) PlcValue(org.apache.plc4x.java.api.value.PlcValue)

Example 47 with PlcValue

use of org.apache.plc4x.java.api.value.PlcValue in project plc4x by apache.

the class DefaultPlcReadResponse method getAllBigIntegers.

@Override
@JsonIgnore
public Collection<BigInteger> getAllBigIntegers(String name) {
    PlcValue fieldInternal = getFieldInternal(name);
    if (fieldInternal instanceof PlcList) {
        PlcList plcList = (PlcList) fieldInternal;
        List<BigInteger> items = new ArrayList<>(plcList.getLength());
        for (PlcValue plcValue : plcList.getList()) {
            items.add(plcValue.getBigInteger());
        }
        return items;
    }
    return Collections.singletonList(fieldInternal.getBigInteger());
}
Also used : PlcList(org.apache.plc4x.java.spi.values.PlcList) PlcValue(org.apache.plc4x.java.api.value.PlcValue) BigInteger(java.math.BigInteger)

Example 48 with PlcValue

use of org.apache.plc4x.java.api.value.PlcValue in project plc4x by apache.

the class DefaultPlcReadResponse method getAllLongs.

@Override
@JsonIgnore
public Collection<Long> getAllLongs(String name) {
    PlcValue fieldInternal = getFieldInternal(name);
    if (fieldInternal instanceof PlcList) {
        PlcList plcList = (PlcList) fieldInternal;
        List<Long> items = new ArrayList<>(plcList.getLength());
        for (PlcValue plcValue : plcList.getList()) {
            items.add(plcValue.getLong());
        }
        return items;
    }
    return Collections.singletonList(fieldInternal.getLong());
}
Also used : PlcList(org.apache.plc4x.java.spi.values.PlcList) PlcValue(org.apache.plc4x.java.api.value.PlcValue)

Example 49 with PlcValue

use of org.apache.plc4x.java.api.value.PlcValue in project plc4x by apache.

the class DefaultPlcReadResponse method getAllIntegers.

@Override
@JsonIgnore
public Collection<Integer> getAllIntegers(String name) {
    PlcValue fieldInternal = getFieldInternal(name);
    if (fieldInternal instanceof PlcList) {
        PlcList plcList = (PlcList) fieldInternal;
        List<Integer> items = new ArrayList<>(plcList.getLength());
        for (PlcValue plcValue : plcList.getList()) {
            items.add(plcValue.getInteger());
        }
        return items;
    }
    return Collections.singletonList(fieldInternal.getInteger());
}
Also used : PlcList(org.apache.plc4x.java.spi.values.PlcList) BigInteger(java.math.BigInteger) PlcValue(org.apache.plc4x.java.api.value.PlcValue)

Example 50 with PlcValue

use of org.apache.plc4x.java.api.value.PlcValue in project plc4x by apache.

the class DefaultPlcReadResponse method getAllShorts.

@Override
@JsonIgnore
public Collection<Short> getAllShorts(String name) {
    PlcValue fieldInternal = getFieldInternal(name);
    if (fieldInternal instanceof PlcList) {
        PlcList plcList = (PlcList) fieldInternal;
        List<Short> items = new ArrayList<>(plcList.getLength());
        for (PlcValue plcValue : plcList.getList()) {
            items.add(plcValue.getShort());
        }
        return items;
    }
    return Collections.singletonList(fieldInternal.getShort());
}
Also used : PlcList(org.apache.plc4x.java.spi.values.PlcList) PlcValue(org.apache.plc4x.java.api.value.PlcValue)

Aggregations

PlcValue (org.apache.plc4x.java.api.value.PlcValue)53 PlcResponseCode (org.apache.plc4x.java.api.types.PlcResponseCode)19 PlcList (org.apache.plc4x.java.spi.values.PlcList)19 ResponseItem (org.apache.plc4x.java.spi.messages.utils.ResponseItem)18 CompletableFuture (java.util.concurrent.CompletableFuture)15 PlcRuntimeException (org.apache.plc4x.java.api.exceptions.PlcRuntimeException)15 PlcField (org.apache.plc4x.java.api.model.PlcField)12 DefaultPlcReadResponse (org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse)12 RequestTransactionManager (org.apache.plc4x.java.spi.transaction.RequestTransactionManager)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Duration (java.time.Duration)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)10 DefaultPlcWriteResponse (org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse)10 Consumer (java.util.function.Consumer)9 HasConfiguration (org.apache.plc4x.java.spi.configuration.HasConfiguration)8 BigInteger (java.math.BigInteger)7 Map (java.util.Map)7 PlcWriteResponse (org.apache.plc4x.java.api.messages.PlcWriteResponse)7 ConversationContext (org.apache.plc4x.java.spi.ConversationContext)7