public void set(SimulatedTag tag, PlcValue value) {
        LOGGER.debug("setting tag {} to {}", tag, value);
        Objects.requireNonNull(tag);
        switch (tag.getType()) {
            case STATE:
                changeOfStateSubscriptions.values().stream()
                    .filter(pair -> pair.getKey().equals(tag))
                    .map(Pair::getValue)
                    .peek(plcValueConsumer -> LOGGER.debug("{} is getting notified with {}", plcValueConsumer, value))
                    .forEach(baseDefaultPlcValueConsumer -> baseDefaultPlcValueConsumer.accept(value));
                state.put(tag, value);
                return;
            case STDOUT:
                LOGGER.info("TEST PLC STDOUT [{}]: {}", tag.getName(), value.toString());
                return;
            case RANDOM:
                switch (tag.getPlcValueType()) {
                    case STRING:
                    case WSTRING:
                        break;
                    default:
                        try {
                            final int lengthInBits = DataItem.getLengthInBits(value, tag.getPlcValueType().name(), (tag.getArrayInfo().isEmpty()) ? 1 : tag.getArrayInfo().get(0).getSize());
                            final WriteBufferByteBased writeBuffer = new WriteBufferByteBased((int) Math.ceil(((float) lengthInBits) / 8.0f));
                            DataItem.staticSerialize(writeBuffer, value, tag.getPlcValueType().name(), (tag.getArrayInfo().isEmpty()) ? 1 : tag.getArrayInfo().get(0).getSize(), ByteOrder.BIG_ENDIAN);
                        } catch (SerializationException e) {
                            LOGGER.info("Write failed");
                        }
                }
                LOGGER.info("TEST PLC RANDOM [{}]: {}", tag.getName(), value);
                return;
        }
        throw new IllegalArgumentException("Unsupported tag type: " + tag.getType().name());
    }
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