Class S7HMuxImpl

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler, S7HMux

    @Sharable
    public class S7HMuxImpl
    extends io.netty.handler.codec.MessageToMessageCodec<io.netty.buffer.ByteBuf,​io.netty.buffer.ByteBuf>
    implements S7HMux
    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.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Constructor Summary

      Constructors 
      Constructor Description
      S7HMuxImpl()  
    • Field Detail

      • embeded_channel

        protected io.netty.channel.Channel embeded_channel
      • tcp_channel

        protected io.netty.channel.Channel tcp_channel
      • primary_channel

        protected io.netty.channel.Channel primary_channel
      • secondary_channel

        protected io.netty.channel.Channel secondary_channel
    • Constructor Detail

      • S7HMuxImpl

        public S7HMuxImpl()
    • Method Detail

      • encode

        protected void encode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf outbb,
                              List<Object> list)
        Specified by:
        encode in class io.netty.handler.codec.MessageToMessageCodec<io.netty.buffer.ByteBuf,​io.netty.buffer.ByteBuf>
      • decode

        protected void decode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf inbb,
                              List<Object> list)
                       throws Exception
        Specified by:
        decode in class io.netty.handler.codec.MessageToMessageCodec<io.netty.buffer.ByteBuf,​io.netty.buffer.ByteBuf>
        Throws:
        Exception
      • channelRegistered

        public void channelRegistered​(io.netty.channel.ChannelHandlerContext ctx)
                               throws Exception
        Specified by:
        channelRegistered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRegistered in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    Throwable cause)
                             throws Exception
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelWritabilityChanged

        public void channelWritabilityChanged​(io.netty.channel.ChannelHandlerContext ctx)
                                       throws Exception
        Specified by:
        channelWritabilityChanged in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelWritabilityChanged in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • userEventTriggered

        public void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx,
                                       Object evt)
                                throws Exception
        Specified by:
        userEventTriggered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelReadComplete

        public void channelReadComplete​(io.netty.channel.ChannelHandlerContext ctx)
                                 throws Exception
        Specified by:
        channelReadComplete in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelInactive

        public void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)
                             throws Exception
        Specified by:
        channelInactive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelActive

        public void channelActive​(io.netty.channel.ChannelHandlerContext ctx)
                           throws Exception
        Specified by:
        channelActive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelUnregistered

        public void channelUnregistered​(io.netty.channel.ChannelHandlerContext ctx)
                                 throws Exception
        Specified by:
        channelUnregistered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelUnregistered in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • setPrimaryChannel

        public void setPrimaryChannel​(io.netty.channel.Channel primary_channel)
        Specified by:
        setPrimaryChannel in interface S7HMux
      • setSecondaryChannel

        public void setSecondaryChannel​(io.netty.channel.Channel secondary_channel)
        Specified by:
        setSecondaryChannel in interface S7HMux
      • getTCPChannel

        public io.netty.channel.Channel getTCPChannel()
        Specified by:
        getTCPChannel in interface S7HMux