|
@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
+import java.nio.ByteBuffer;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
@@ -175,20 +176,7 @@ public class VdsCtlrService {
|
|
|
vds.getStts().initStts(false);
|
|
|
}
|
|
|
|
|
|
- voVdsState ss = new voVdsState();
|
|
|
- ss.setCTLR_NMBR(Integer.parseInt(vds.getVDS_CTLR_NMBR()));
|
|
|
- ss.setComm(vds.getStts().getSttsComm()); //Comm
|
|
|
- ss.setVideoInput(vds.getStts().getSttsVideoInput()); //VideoInput
|
|
|
- ss.setHeater(vds.getStts().getSttsHeater()); //Heater
|
|
|
- ss.setFan(vds.getStts().getSttsFan()); //Fan
|
|
|
- ss.setBackDoorOpen(vds.getStts().getSttsBackDoor()); //BackDoorOpen
|
|
|
- ss.setFrontDoorOpen(vds.getStts().getSttsFrontDoor()); //FrontDoorOpen
|
|
|
- ss.setTemperature(vds.getStts().getSttsTemp()); //Temperature
|
|
|
- ss.setFanMode(vds.getStts().getSttsFanMode()); //FanMode
|
|
|
- ss.setFanRunTemp(vds.getStts().getSttsFanRunTemp()); //FanRunTemp
|
|
|
- ss.setHetrMode(vds.getStts().getSttsHetrMode()); //HetrMode
|
|
|
- ss.setHetrRunTemp(vds.getStts().getSttsHetrRunTemp()); //HetrRunTemp
|
|
|
-
|
|
|
+ voVdsState ss = vds.getVdsStts();
|
|
|
stts.getObjList().add(ss);
|
|
|
|
|
|
if (isRun) {
|
|
@@ -213,6 +201,9 @@ public class VdsCtlrService {
|
|
|
stts.setNormal((short)normal);
|
|
|
stts.setModule((short)0);
|
|
|
|
|
|
+ /**
|
|
|
+ * 운영단말로 상태정보 등을 전송하지 않는다.(웹 기반)
|
|
|
+ */
|
|
|
// // 제어기 상태정보 운영단말 전송
|
|
|
// CenterCommClientSender notify = (CenterCommClientSender) AppUtils.getBean(CenterCommClientSender.class);
|
|
|
// notify.run(null, 0, stts.getBuffer());
|
|
@@ -234,45 +225,44 @@ public class VdsCtlrService {
|
|
|
log.info("VdsCtlrService.updateCtlrStts: total {}, normal {}, error {}", normal + error, normal, error);
|
|
|
}
|
|
|
|
|
|
- public void requestTraffic() {
|
|
|
+ /**
|
|
|
+ * 제어기 동기화 실행
|
|
|
+ * 1. 온도정보 요청(0x1E)
|
|
|
+ * 2. 제어기 동기화(0x01)
|
|
|
+ * - 제어기 동기화 후 5초 후에 데이터를 요청한다.
|
|
|
+ */
|
|
|
+ public void requestSynchronization() {
|
|
|
long curTime = System.currentTimeMillis();
|
|
|
int min = (int)(curTime / (1000 * 60) );
|
|
|
int sec = (int)(curTime / 1000);
|
|
|
|
|
|
- TbVdsCtlr vds;
|
|
|
+ TbVdsCtlr obj;
|
|
|
/*
|
|
|
* send Synchronize
|
|
|
*/
|
|
|
- byte frameNo;
|
|
|
+ //byte frameNo;
|
|
|
for (Map.Entry<String, TbVdsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
- vds = e.getValue();
|
|
|
- MDC.put("id", vds.getLogKey());
|
|
|
- if (vds.getNetState() >= NET.LOGIN_REQ && vds.getChannel() != null) {
|
|
|
- vds.setSyncTime(curTime);
|
|
|
- frameNo = (byte)((min*60 + sec) / vds.getTRAF_CLCT_CYCL() + 1);
|
|
|
-// VDS_REQ_HEAD reqHdr = new VDS_REQ_HEAD();
|
|
|
-// byte[] headBytes = reqHdr.makeHead(VDS_HEAD.evds_Synchronize, vds, 10);
|
|
|
-// ByteBuffer sendBuff = ByteBuffer.allocate(VDS_REQ_HEAD.VDS_REQ_HEADER_SIZE + reqHdr.getLength());
|
|
|
-// sendBuff.order(ByteOrder.BIG_ENDIAN);
|
|
|
-// sendBuff.put(headBytes);
|
|
|
-// sendBuff.put(frameNo);
|
|
|
-// ChannelFuture f = vds.getChannel().writeAndFlush(sendBuff);
|
|
|
-// f.awaitUninterruptibly();
|
|
|
-// if (f.isDone() || f.isSuccess()) {
|
|
|
-// log.info("SEND_0: [{}], evds_Synchronize: {} headBytes, {} sendBytes. [{}]", vds.getVDS_CTLR_IP(), headBytes.length, sendBuff.array().length, vds.getVDS_CTLR_ID());
|
|
|
-// } else {
|
|
|
-// log.error("SEND_0: [{}], evds_Synchronize: {} headBytes, {} sendBytes, Failed. [{}]", vds.getVDS_CTLR_IP(), headBytes.length, sendBuff.array().length, vds.getVDS_CTLR_ID());
|
|
|
-// }
|
|
|
- }
|
|
|
- else {
|
|
|
- log.warn("SEND_0: [{}], evds_Synchronize: Not Connected. [{}]", vds.getVDS_CTLR_IP(), vds.getVDS_CTLR_ID());
|
|
|
+ obj = e.getValue();
|
|
|
+ MDC.put("id", obj.getLogKey());
|
|
|
+ if (obj.getChannel() != null) {
|
|
|
+ obj.setSyncTime(curTime);
|
|
|
+ //frameNo = (byte)((min*60 + sec) / obj.getTRAF_CLCT_CYCL() + 1);
|
|
|
+ ByteBuffer sendBuffer = obj.getReqTemperature().getByteBuffer();
|
|
|
+ boolean result = obj.sendData(sendBuffer, 0, "vds_Temperature");
|
|
|
+ if (result) {
|
|
|
+ log.info("[{}] [{}], vds_Temperature: Request OK.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ } else {
|
|
|
+ log.info("[{}] [{}], vds_Temperature: Request Failed.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.info("[{}] [{}], vds_Temperature: Request Failed-Not Connected.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
}
|
|
|
- MDC.remove(vds.getLogKey());
|
|
|
+ MDC.remove(obj.getLogKey());
|
|
|
MDC.clear();
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- Thread.sleep(500);
|
|
|
+ Thread.sleep(800);
|
|
|
} catch (InterruptedException e1) {
|
|
|
e1.printStackTrace();
|
|
|
}
|
|
@@ -281,54 +271,47 @@ public class VdsCtlrService {
|
|
|
* send req traffic
|
|
|
*/
|
|
|
for (Map.Entry<String, TbVdsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
- vds = e.getValue();
|
|
|
- MDC.put("id", vds.getLogKey());
|
|
|
-// if (vds.getNetState() >= NET.LOGIN_REQ && vds.getChannel() != null) {
|
|
|
-// VDS_REQ_HEAD reqHdr = new VDS_REQ_HEAD();
|
|
|
-// byte[] headBytes = reqHdr.makeHead(VDS_HEAD.evds_Traffic, vds, 9);
|
|
|
-// ByteBuffer sendBuff = ByteBuffer.allocate(VDS_REQ_HEAD.VDS_REQ_HEADER_SIZE + reqHdr.getLength());
|
|
|
-// sendBuff.order(ByteOrder.BIG_ENDIAN);
|
|
|
-// sendBuff.put(headBytes);
|
|
|
-// ChannelFuture f = vds.getChannel().writeAndFlush(sendBuff);
|
|
|
-// f.awaitUninterruptibly();
|
|
|
-// if (f.isDone() || f.isSuccess()) {
|
|
|
-// log.info("SEND_0: [{}], evds_Traffic: {} headBytes, {} sendBytes. [{}]", vds.getVDS_CTLR_IP(), headBytes.length, sendBuff.array().length, vds.getVDS_CTLR_ID());
|
|
|
-// } else {
|
|
|
-// log.error("SEND_0: [{}], evds_Traffic: {} headBytes, {} sendBytes, Failed. [{}]", vds.getVDS_CTLR_IP(), headBytes.length, sendBuff.array().length, vds.getVDS_CTLR_ID());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// log.warn("SEND_0: [{}], evds_Traffic: Not Connected. [{}]", vds.getVDS_CTLR_IP(), vds.getVDS_CTLR_ID());
|
|
|
-// }
|
|
|
- MDC.remove(vds.getLogKey());
|
|
|
+ obj = e.getValue();
|
|
|
+ MDC.put("id", obj.getLogKey());
|
|
|
+ if (obj.getChannel() != null) {
|
|
|
+ obj.setSyncTime(curTime);
|
|
|
+ ByteBuffer sendBuffer = obj.getReqSynchronize().getByteBuffer();
|
|
|
+ boolean result = obj.sendData(sendBuffer, 0, "vds_Synchronization");
|
|
|
+ if (result) {
|
|
|
+ log.info("[{}] [{}], vds_Synchronization: Request OK.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ } else {
|
|
|
+ log.info("[{}] [{}], vds_Synchronization: Request Failed.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.info("[{}] [{}], vds_Synchronization: Request Failed-Not Connected.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ }
|
|
|
+ MDC.remove(obj.getLogKey());
|
|
|
MDC.clear();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void requestVehicle() {
|
|
|
-// TbVdsCtlr vds;
|
|
|
-// for (Map.Entry<String, TbVdsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
-// vds = e.getValue();
|
|
|
-// MDC.put("id", vds.getLogKey());
|
|
|
-// if (vds.getNetState() >= NET.LOGIN_REQ && vds.getChannel() != null) {
|
|
|
-// VDS_REQ_HEAD reqHdr = new VDS_REQ_HEAD();
|
|
|
-// byte[] headBytes = reqHdr.makeHead(VDS_HEAD.evds_IndividualVehicle, vds, 9);
|
|
|
-// ByteBuffer sendBuff = ByteBuffer.allocate(VDS_REQ_HEAD.VDS_REQ_HEADER_SIZE + reqHdr.getLength());
|
|
|
-// sendBuff.order(ByteOrder.BIG_ENDIAN);
|
|
|
-// sendBuff.put(headBytes);
|
|
|
-// ChannelFuture f = vds.getChannel().writeAndFlush(sendBuff);
|
|
|
-// f.awaitUninterruptibly();
|
|
|
-// if (f.isDone() || f.isSuccess()) {
|
|
|
-// log.info("SEND_0: [{}], evds_IndividualVehicle: {} headBytes, {} sendBytes. [{}]", vds.getVDS_CTLR_IP(), headBytes.length, sendBuff.array().length, vds.getVDS_CTLR_ID());
|
|
|
-// } else {
|
|
|
-// log.error("SEND_0: [{}], evds_IndividualVehicle: {} headBytes, {} sendBytes, Failed. [{}]", vds.getVDS_CTLR_IP(), headBytes.length, sendBuff.array().length, vds.getVDS_CTLR_ID());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// log.warn("SEND_0: [{}], evds_IndividualVehicle: Not Connected. [{}]", vds.getVDS_CTLR_IP(), vds.getVDS_CTLR_ID());
|
|
|
-// }
|
|
|
-// MDC.remove(vds.getLogKey());
|
|
|
-// MDC.clear();
|
|
|
-// }
|
|
|
+ /**
|
|
|
+ * 교통 데이터 요청
|
|
|
+ * - 제어기 동기화 명령 후 5초 지난 후에 실행
|
|
|
+ */
|
|
|
+ public void requestData() {
|
|
|
+ TbVdsCtlr obj;
|
|
|
+ for (Map.Entry<String, TbVdsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ obj = e.getValue();
|
|
|
+ MDC.put("id", obj.getLogKey());
|
|
|
+ if (obj.getChannel() != null) {
|
|
|
+ ByteBuffer sendBuffer = obj.getReqData().getByteBuffer();
|
|
|
+ boolean result = obj.sendData(sendBuffer, 0, "vds_Data");
|
|
|
+ if (result) {
|
|
|
+ log.info("[{}] [{}], vds_Data: Request OK.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ } else {
|
|
|
+ log.info("[{}] [{}], vds_Data: Request Failed.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.info("[{}] [{}], vds_Data: Request Failed-Not Connected.", obj.getVDS_CTLR_ID(), obj.getVDS_CTLR_IP());
|
|
|
+ }
|
|
|
+ MDC.remove(obj.getLogKey());
|
|
|
+ MDC.clear();
|
|
|
+ }
|
|
|
}
|
|
|
}
|