@Override
    public void setSecondaryChannel(Channel secondary_channel) {
        if ((this.primaryChannel == null) && (tcpChannel == null)) {
            if (secondary_channel != null) {
                this.secondaryChannel = secondary_channel;
                tcpChannel = secondary_channel;
                embededChannel.attr(IS_PRIMARY).set(false);
            }

        } else if ((this.secondaryChannel == null) ||
            ((tcpChannel == primaryChannel)) && (tcpChannel.isActive())) {
            this.secondaryChannel = secondary_channel;

        } else if ((!this.secondaryChannel.isActive()) && (tcpChannel == primaryChannel)) {
            this.secondaryChannel = secondary_channel;

        } else if (((!this.secondaryChannel.isActive()) && (tcpChannel == this.secondaryChannel)) ||
            (secondary_channel.isActive())) {
            synchronized (tcpChannel) {
                tcpChannel.close();
                this.secondaryChannel = secondary_channel;
                tcpChannel = secondary_channel;
                embededChannel.attr(IS_PRIMARY).set(false);
            }
            if (tcpChannel.isActive()) {
                embedCtx.fireUserEventTriggered(new ConnectEvent());
            }
        }
    }
Implementation of a multiplexing channel, from an embedded channel to two
possible TCP connections, primary and secondary.
The objective is to allow connections to individual systems
with a two CP (PN CPUs, CP343-1, CP443-1 or similar), or H-type systems
(S7-400H or S7-1500H).
The user App must be in charge of restoring the requests or
subscriptions that it is requesting.
plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HMuxImpl.java