private PlcValue randomValue(SimulatedTag tag) {

        short tagDataTypeSize = SimulatedDataTypeSizes.valueOf(tag.getPlcValueType().name()).getDataTypeSize();

        byte[] b = new byte[tagDataTypeSize * ((tag.getArrayInfo().isEmpty()) ? 1 : tag.getArrayInfo().get(0).getSize())];
        random.nextBytes(b);

        ReadBuffer io = new ReadBufferByteBased(b);
        try {
            return DataItem.staticParse(io, tag.getPlcValueType().name(), ((tag.getArrayInfo().isEmpty()) ? 1 : tag.getArrayInfo().get(0).getSize()));
        } catch (ParseException e) {
            return null;
        }
    }
Test device storing its state in memory.
Values are stored in a HashMap.
plc4j/drivers/simulated/src/main/java/org/apache/plc4x/java/simulated/connection/SimulatedDevice.java