|
|
@@ -1,12 +1,10 @@
|
|
|
package com.its.api.xnetudp;
|
|
|
|
|
|
import com.its.api.config.CenterCommConfig;
|
|
|
-import com.its.api.config.VmsConfig;
|
|
|
-import com.its.api.its.model.dto.vms.VmsControlDto;
|
|
|
+import com.its.api.its.global.UnitSystManager;
|
|
|
+import com.its.api.its.model.entity.unit.TbUnitSyst;
|
|
|
import com.its.api.xnetudp.codec.CenterCommServerDecoder;
|
|
|
import com.its.api.xnetudp.handler.CenterCommServerPacketHandler;
|
|
|
-import com.its.api.xnetudp.protocol.CENTER_COMM_DEFINE;
|
|
|
-import com.its.api.xnetudp.protocol.CENTER_COMM_MESSAGE;
|
|
|
import io.netty.bootstrap.Bootstrap;
|
|
|
import io.netty.channel.*;
|
|
|
import io.netty.channel.nio.NioEventLoopGroup;
|
|
|
@@ -22,8 +20,7 @@ import org.springframework.stereotype.Component;
|
|
|
@Component
|
|
|
public class CenterCommUdpServer {
|
|
|
|
|
|
- private final VmsConfig vmsConfig;
|
|
|
- private final CenterCommConfig serverConfig;
|
|
|
+ private final CenterCommConfig centerCommConfig;
|
|
|
|
|
|
private EventLoopGroup nioEventLoopGroup;
|
|
|
private Bootstrap bootstrap;
|
|
|
@@ -32,6 +29,12 @@ public class CenterCommUdpServer {
|
|
|
public void run() {
|
|
|
log.info("UdpServerCenterComm.run: Start.");
|
|
|
|
|
|
+ TbUnitSyst oper00 = UnitSystManager.get(this.centerCommConfig.getProcessId());
|
|
|
+ if (oper00 != null) {
|
|
|
+ this.centerCommConfig.setBindingPort(Integer.parseInt(oper00.getPrgmPort().trim()));
|
|
|
+ }
|
|
|
+ log.info("{}", this.centerCommConfig);
|
|
|
+
|
|
|
try {
|
|
|
this.nioEventLoopGroup = new NioEventLoopGroup();
|
|
|
this.bootstrap = new Bootstrap();
|
|
|
@@ -57,25 +60,25 @@ public class CenterCommUdpServer {
|
|
|
|
|
|
log.info("===============================================================");
|
|
|
log.info("= UDP Center Communication Server Start.......................");
|
|
|
- log.info("= bindAddress: {}", serverConfig.getBindingAddr());
|
|
|
- log.info("= bindPort: {}", serverConfig.getBindingPort());
|
|
|
+ log.info("= bindAddress: {}", this.centerCommConfig.getBindingAddr());
|
|
|
+ log.info("= bindPort: {}", this.centerCommConfig.getBindingPort());
|
|
|
log.info("===============================================================");
|
|
|
|
|
|
try {
|
|
|
- if (this.serverConfig.getBindingAddr().equals("0.0.0.0")) {
|
|
|
+ if (this.centerCommConfig.getBindingAddr().equals("0.0.0.0")) {
|
|
|
if (isThreadRunning) {
|
|
|
- this.bootstrap.bind(this.serverConfig.getBindingPort()).sync().channel().closeFuture().await();
|
|
|
+ this.bootstrap.bind(this.centerCommConfig.getBindingPort()).sync().channel().closeFuture().await();
|
|
|
}
|
|
|
else {
|
|
|
- this.bootstrap.bind(this.serverConfig.getBindingPort());
|
|
|
+ this.bootstrap.bind(this.centerCommConfig.getBindingPort());
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (isThreadRunning) {
|
|
|
- this.bootstrap.bind(this.serverConfig.getBindingAddr(), serverConfig.getBindingPort()).sync().channel().closeFuture().await();
|
|
|
+ this.bootstrap.bind(this.centerCommConfig.getBindingAddr(), centerCommConfig.getBindingPort()).sync().channel().closeFuture().await();
|
|
|
}
|
|
|
else {
|
|
|
- this.bootstrap.bind(this.serverConfig.getBindingAddr(), serverConfig.getBindingPort());
|
|
|
+ this.bootstrap.bind(this.centerCommConfig.getBindingAddr(), centerCommConfig.getBindingPort());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -94,47 +97,4 @@ public class CenterCommUdpServer {
|
|
|
log.info("UdpServerCenterComm.run: ..End. {}", toString());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * VMS 서버로 리셋 명령 전송
|
|
|
- * @param id
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean requestReset(Long id, VmsControlDto.VmsControlReq req) {
|
|
|
- byte msgSeq = (byte)0x20;
|
|
|
- int reqSize = CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME + CENTER_COMM_DEFINE.INT_VMS_MAX_ID + CENTER_COMM_DEFINE.INT_VMS_MAX_OPER_ID;
|
|
|
- int length = reqSize + 1;
|
|
|
- CENTER_COMM_MESSAGE commMsg = new CENTER_COMM_MESSAGE(CENTER_COMM_DEFINE.INT_ID_VMS_SERVER, CENTER_COMM_DEFINE.INT_OP_VMS_RESET, length, msgSeq);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * VMS 서버로 전광판 On/Off 명령 전송
|
|
|
- * @param id
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean requestPowerControl(Long id, VmsControlDto.VmsControlReq req) {
|
|
|
- byte msgSeq = (byte)0x20;
|
|
|
- int reqSize = CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME + CENTER_COMM_DEFINE.INT_VMS_MAX_ID + CENTER_COMM_DEFINE.INT_VMS_MAX_OPER_ID;
|
|
|
- int length = reqSize + 1;
|
|
|
- byte command = req.getValue() == 0 ? (byte)0x00 : (byte)0x01;
|
|
|
- CENTER_COMM_MESSAGE commMsg = new CENTER_COMM_MESSAGE(CENTER_COMM_DEFINE.INT_ID_VMS_SERVER, CENTER_COMM_DEFINE.INT_OP_VMS_POWER_CTL, length, msgSeq);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * VMS 서버로 휘도제어 명령 전송
|
|
|
- * @param id
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean controlLuminance(Long id, VmsControlDto.VmsControlReq req) {
|
|
|
- byte msgSeq = (byte)0x20;
|
|
|
- int reqSize = CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME + CENTER_COMM_DEFINE.INT_VMS_MAX_ID + CENTER_COMM_DEFINE.INT_VMS_MAX_OPER_ID;
|
|
|
- int length = reqSize + 1;
|
|
|
- byte luminance = (byte)req.getValue().intValue();
|
|
|
- CENTER_COMM_MESSAGE commMsg = new CENTER_COMM_MESSAGE(CENTER_COMM_DEFINE.INT_ID_VMS_SERVER, CENTER_COMM_DEFINE.INT_OP_VMS_LUMINANCE_CTL, length, msgSeq);
|
|
|
- return true;
|
|
|
- }
|
|
|
}
|