|
|
|
@ -9,15 +9,20 @@ import io.netty.channel.EventLoopGroup;
|
|
|
|
import io.netty.channel.nio.NioEventLoopGroup;
|
|
|
|
import io.netty.channel.nio.NioEventLoopGroup;
|
|
|
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
|
|
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
public class KsecNettyClient {
|
|
|
|
public class KsecNettyClient {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static final Logger tcpLogger = LoggerFactory.getLogger("tcp");
|
|
|
|
private static EventLoopGroup group = new NioEventLoopGroup();
|
|
|
|
private static EventLoopGroup group = new NioEventLoopGroup();
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private PlcService plcService;
|
|
|
|
private PlcService plcService;
|
|
|
|
@ -101,6 +106,9 @@ public class KsecNettyClient {
|
|
|
|
public static void write(KsecInfo ksecInfo){
|
|
|
|
public static void write(KsecInfo ksecInfo){
|
|
|
|
if(channel != null){
|
|
|
|
if(channel != null){
|
|
|
|
channel.writeAndFlush(ksecInfo);
|
|
|
|
channel.writeAndFlush(ksecInfo);
|
|
|
|
|
|
|
|
InetSocketAddress socketAddress = (InetSocketAddress) channel.remoteAddress();
|
|
|
|
|
|
|
|
String clientIp = socketAddress.getAddress().getHostAddress();
|
|
|
|
|
|
|
|
tcpLogger.info("write kesc data:{} channel:{}",ksecInfo,clientIp);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
log.error(" no connected upPc");
|
|
|
|
log.error(" no connected upPc");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|