Class S7Protocol

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.apache.plc4x.java.s7.netty.S7Protocol
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

public class S7Protocol
extends io.netty.channel.ChannelDuplexHandler
Communication Layer between the Application level (Plc4XS7Protocol) and the lower level (tcp) that sends and receives S7Messages. This layer also handles the control over the "wire", i.e., the queues of incoming and outgoing messages. Furthermore, here S7Messages are marshalled and unmarshalled to ByteBufs to be send over wire. Before messages are send to the wire an optional S7MessageProcessor can be applied.
See Also:
S7MessageProcessor
  • Nested Class Summary

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

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

    Constructors 
    Constructor Description
    S7Protocol​(short requestedMaxAmqCaller, short requestedMaxAmqCallee, short requestedPduSize, S7ControllerType controllerType, S7MessageProcessor messageProcessor)  
  • Method Summary

    Modifier and Type Method Description
    void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)  
    void channelRead​(io.netty.channel.ChannelHandlerContext ctx, Object msg)  
    void channelRegistered​(io.netty.channel.ChannelHandlerContext ctx)  
    void channelUnregistered​(io.netty.channel.ChannelHandlerContext ctx)  
    protected void decode​(io.netty.channel.ChannelHandlerContext ctx, IsoTPMessage in, List<Object> out)  
    void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx, Object evt)
    If the S7 protocol layer is used over Iso TP, then after receiving a IsoTPConnectedEvent the corresponding S7 setup communication message has to be sent in order to negotiate the S7 protocol layer.
    void write​(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)  

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelReadComplete, channelWritabilityChanged, exceptionCaught

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

  • Method Details

    • channelRegistered

      public void channelRegistered​(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelRegistered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRegistered in class io.netty.channel.ChannelInboundHandlerAdapter
    • 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
    • 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
    • userEventTriggered

      public void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception
      If the S7 protocol layer is used over Iso TP, then after receiving a IsoTPConnectedEvent the corresponding S7 setup communication message has to be sent in order to negotiate the S7 protocol layer.
      Specified by:
      userEventTriggered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - the current protocol layers context
      evt - the event
      Throws:
      Exception - throws an exception if something goes wrong internally
    • write

      public void write​(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelDuplexHandler
    • channelRead

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

      protected void decode​(io.netty.channel.ChannelHandlerContext ctx, IsoTPMessage in, List<Object> out)