Package org.apache.plc4x.java.s7.netty
Class Plc4XS7Protocol
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.MessageToMessageCodec<INBOUND_IN,OUTBOUND_IN>
org.apache.plc4x.java.base.PlcMessageToMessageCodec<S7Message,PlcRequestContainer>
org.apache.plc4x.java.s7.netty.Plc4XS7Protocol
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public class Plc4XS7Protocol extends PlcMessageToMessageCodec<S7Message,PlcRequestContainer>
This layer transforms between
PlcRequestContainers S7Messages.
And stores all "in-flight" requests in an internal structure (requests).
While sending a request, a S7RequestMessage is generated and send downstream (to the S7Protocol.
When a S7ResponseMessage is received it takes the existing request container from its Map and finishes
the PlcRequestContainers future with the PlcResponse.
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description Plc4XS7Protocol() -
Method Summary
Modifier and Type Method Description protected voiddecode(io.netty.channel.ChannelHandlerContext ctx, S7Message msg, List<Object> out)protected voidencode(io.netty.channel.ChannelHandlerContext ctx, PlcRequestContainer msg, List<Object> out)voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)When receiving an error inside the pipeline, we have to find out whichPlcRequestContainercorrelates needs to be notified about the problem.static intgetUDIntAt(byte[] buffer, int pos)voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)If this protocol layer catches anS7ConnectedEventfrom the protocol layer beneath, the connection establishment is finished.Methods inherited from class org.apache.plc4x.java.base.PlcMessageToMessageCodec
getPrevChannelHandlerMethods inherited from class io.netty.handler.codec.MessageToMessageCodec
acceptInboundMessage, acceptOutboundMessage, channelRead, writeMethods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChangedMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Constructor Details
-
Plc4XS7Protocol
public Plc4XS7Protocol()
-
-
Method Details
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws ExceptionIf this protocol layer catches anS7ConnectedEventfrom the protocol layer beneath, the connection establishment is finished.- 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
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws ExceptionWhen receiving an error inside the pipeline, we have to find out whichPlcRequestContainercorrelates needs to be notified about the problem. If a container is found, we can relay the exception to that by calling completeExceptionally and passing in the exception.- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- the current protocol layers contextcause- the exception that was caught- Throws:
Exception- throws an exception if something goes wrong internally
-
encode
protected void encode(io.netty.channel.ChannelHandlerContext ctx, PlcRequestContainer msg, List<Object> out) throws PlcException- Specified by:
encodein classio.netty.handler.codec.MessageToMessageCodec<S7Message,PlcRequestContainer>- Throws:
PlcException
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, S7Message msg, List<Object> out) throws PlcException- Specified by:
decodein classio.netty.handler.codec.MessageToMessageCodec<S7Message,PlcRequestContainer>- Throws:
PlcException
-
getUDIntAt
public static int getUDIntAt(byte[] buffer, int pos)
-