package com.its.vds.entity; import com.its.app.utils.SysUtils; import com.its.vds.domain.NET; import com.its.vds.xnettcp.vds.protocol.VdsReqData; import com.its.vds.xnettcp.vds.protocol.VdsReqSynchronize; import com.its.vds.xnettcp.vds.protocol.VdsReqTemperature; import io.netty.channel.Channel; import lombok.Getter; import lombok.Setter; import lombok.ToString; import java.net.InetSocketAddress; import java.util.Collections; import java.util.HashMap; import java.util.Map; @Getter @Setter @ToString public class TbVdsCtlr { private String VDS_CTLR_NMBR; private String VDS_CTLR_ID; private String VDS_NM; private String VDS_TYPE_CD; private String VDS_CTLR_IP; private int VDS_CTLR_PORT; private int GROUP_NO; private int VDS_CTLR_LOCAL_NO; private int FAN_MODE; private int FAN_RUN_TMPR; private int HETR_MODE; private int HETR_RUN_TMPR; private int DETECT_LANES; private int TRAF_CLCT_CYCL; private int STTS_CLCT_CYCL; private String VALD_YN; private String DEL_YN; private Map vdsDtctMap; private int netState; private boolean isDupCon; private boolean isDupLogin; private String dstIpAddr; private TbVdsCtlrStts stts; private Channel channel; private Channel dupChannel; private long syncTime; private InetSocketAddress cliReq; private int connectCount; private String connectTm; private String disConnectTm; VdsReqSynchronize reqSynchronize = null; VdsReqData reqData = null; VdsReqTemperature reqTemperature = null; public TbVdsCtlr() { this.vdsDtctMap = Collections.synchronizedMap(new HashMap()); this.stts = new TbVdsCtlrStts(); this.connectCount = 0; this.connectTm = ""; this.disConnectTm = ""; initNet(); } public String getLogKey() { return this.VDS_CTLR_ID; } public void resetConnectCount() { if (this.netState == NET.CLOSED) this.connectCount = 0; else this.connectCount = 1; } public void setConnectTm() { this.connectTm = SysUtils.getSysTimeStr(); this.connectCount++; } public void setDisConnectTm() { this.disConnectTm = SysUtils.getSysTimeStr(); } void initNet() { this.netState = NET.CLOSED; this.isDupCon = false; this.isDupLogin = false; this.dstIpAddr = ""; this.channel = null; this.dupChannel = null; this.cliReq = null; this.syncTime = 0; } public synchronized void channelOpen(Channel channel) { this.netState = NET.LOGIN_REQ; this.channel = channel; getStts().initStts(true); setConnectTm(); } public synchronized void channelLogin(Channel channel) { this.netState = NET.LOGINED; this.channel = channel; getStts().initStts(true); setConnectTm(); } public synchronized void channelClosed() { this.netState = NET.CLOSED; this.channel = null; getStts().initStts(false); setDisConnectTm(); } /** * 통신 패킷 초기화 */ public void initReqPacket() { if (this.reqSynchronize == null) { this.reqSynchronize = new VdsReqSynchronize((short)this.GROUP_NO, (short)this.VDS_CTLR_LOCAL_NO); this.reqData.makeCRC(); } if (this.reqData == null) { this.reqData = new VdsReqData((short)this.GROUP_NO, (short)this.VDS_CTLR_LOCAL_NO); this.reqData.makeCRC(); } if (this.reqTemperature == null) { this.reqTemperature = new VdsReqTemperature((short)this.GROUP_NO, (short)this.VDS_CTLR_LOCAL_NO); this.reqData.makeCRC(); } } }