Package org.apache.plc4x.java.s7.netty
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
-
Constructor Summary
Constructors Constructor Description S7Protocol(short requestedMaxAmqCaller, short requestedMaxAmqCallee, short requestedPduSize, S7ControllerType controllerType, S7MessageProcessor messageProcessor) -
Method Summary
Modifier and Type Method Description voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)voidchannelRegistered(io.netty.channel.ChannelHandlerContext ctx)voidchannelUnregistered(io.netty.channel.ChannelHandlerContext ctx)protected voiddecode(io.netty.channel.ChannelHandlerContext ctx, IsoTPMessage in, List<Object> out)voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)If the S7 protocol layer is used over Iso TP, then after receiving aIsoTPConnectedEventthe corresponding S7 setup communication message has to be sent in order to negotiate the S7 protocol layer.voidwrite(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, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelWritabilityChanged, exceptionCaughtMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Constructor Details
-
S7Protocol
public S7Protocol(short requestedMaxAmqCaller, short requestedMaxAmqCallee, short requestedPduSize, S7ControllerType controllerType, S7MessageProcessor messageProcessor)
-
-
Method Details
-
channelRegistered
public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx)- Specified by:
channelRegisteredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelRegisteredin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelUnregistered
- Specified by:
channelUnregisteredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelUnregisteredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws ExceptionIf the S7 protocol layer is used over Iso TP, then after receiving aIsoTPConnectedEventthe corresponding S7 setup communication message has to be sent in order to negotiate the S7 protocol layer.- Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- the current protocol layers contextevt- 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:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelDuplexHandler
-
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, IsoTPMessage in, List<Object> out)
-