use of org.apache.plc4x.simulator.server.s7.protocol.S7Step7ServerAdapter in project plc4x by apache.
the class S7ServerModule method start.
@Override
public void start() throws SimulatorExcepiton {
if (loopGroup != null) {
return;
}
try {
loopGroup = new NioEventLoopGroup();
workerGroup = new NioEventLoopGroup();
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(loopGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel channel) {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(new GeneratedProtocolMessageCodec<>(TPKTPacket.class, TPKTPacket::staticParse, ByteOrder.BIG_ENDIAN, null, new S7Driver.ByteLengthEstimator(), new S7Driver.CorruptPackageCleaner()));
pipeline.addLast(new S7Step7ServerAdapter(context));
}
}).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.SO_KEEPALIVE, true);
bootstrap.bind(ISO_ON_TCP_PORT).sync();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new SimulatorExcepiton(e);
}
}
Aggregations