|
@@ -1,5 +1,6 @@
|
|
|
package com.sig.comm.server.xnet.server.process.response;
|
|
|
|
|
|
+import com.sig.app.common.utils.SysUtils;
|
|
|
import com.sig.comm.server.dto.IntDto;
|
|
|
import com.sig.comm.server.process.dbms.DbmsData;
|
|
|
import com.sig.comm.server.process.dbms.DbmsDataProcess;
|
|
@@ -20,16 +21,12 @@ public class SigSignalMap implements SigCommResponse {
|
|
|
this.dbmsDataProcess = dbmsDataProcess;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public boolean response(RecvPacketDto packet) {
|
|
|
+ //@Override
|
|
|
+ public boolean responseB(RecvPacketDto packet) {
|
|
|
boolean result = true;
|
|
|
try {
|
|
|
MDC.put("id", packet.getCenter().getLogKey());
|
|
|
log.info("[{}], SigSignalMap.response.", packet.getCenter().getLogKey());
|
|
|
- if (packet.getCenter().isSimulateFlag()) {
|
|
|
- // 시뮬레이션 모드로 동작중이므로 상태정보를 업데이트하지 않는다.
|
|
|
- return true;
|
|
|
- }
|
|
|
|
|
|
final int recordSize = 262; // 2 + 1+1+1+1+1 + 255 = 262
|
|
|
if (!packet.getPacket().checkDataLength(recordSize)) {
|
|
@@ -75,14 +72,14 @@ public class SigSignalMap implements SigCommResponse {
|
|
|
res = SigMapData.signalMapDecompress(compData, idx, compSize, deCompData);
|
|
|
}
|
|
|
else {
|
|
|
- res = SigMapData.signalMapDecompress2010(compData, idx, compSize, deCompData);
|
|
|
+// res = SigMapData.signalMapDecompress2010(compData, idx, compSize, deCompData);
|
|
|
}
|
|
|
idx = idx + SigMapData.MAX_COMPRESS_DATA_SIZE;
|
|
|
|
|
|
- if (res == 0) {
|
|
|
- log.error("[{}], SigSignalMap.response: Decompress Error. INT_NO: {}, LC_TYPE: {}", packet.getCenter().getLogKey(), intNo, lcType);
|
|
|
- continue;
|
|
|
- }
|
|
|
+// if (res == 0) {
|
|
|
+// log.error("[{}], SigSignalMap.response: Decompress Error. INT_NO: {}, LC_TYPE: {}", packet.getCenter().getLogKey(), intNo, lcType);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
|
|
|
IntDto intDto = packet.getCenter().getIntMap().get(intNo);
|
|
|
if (intDto != null) {
|
|
@@ -127,22 +124,22 @@ public class SigSignalMap implements SigCommResponse {
|
|
|
param.put("EOP", deCompData[spIdx++] & 0xFF); /*현시종료여부(1:종료) */
|
|
|
|
|
|
// SigMapData.SigMapInfo mapInfo = mapData.getStep()[jj];
|
|
|
-// param.put("CAR1", mapInfo.getLsu()[ 0] & 0xFF); /*차량등 1 (2004-LSU1) */
|
|
|
-// param.put("PED1", mapInfo.getLsu()[ 1] & 0xFF); /*보행등 1 (2004-LSU2) */
|
|
|
-// param.put("CAR2", mapInfo.getLsu()[ 2] & 0xFF);
|
|
|
-// param.put("PED2", mapInfo.getLsu()[ 3] & 0xFF);
|
|
|
-// param.put("CAR3", mapInfo.getLsu()[ 4] & 0xFF);
|
|
|
-// param.put("PED3", mapInfo.getLsu()[ 5] & 0xFF);
|
|
|
-// param.put("CAR4", mapInfo.getLsu()[ 6] & 0xFF);
|
|
|
-// param.put("PED4", mapInfo.getLsu()[ 7] & 0xFF);
|
|
|
-// param.put("CAR5", mapInfo.getLsu()[ 8] & 0xFF);
|
|
|
-// param.put("PED5", mapInfo.getLsu()[ 9] & 0xFF);
|
|
|
-// param.put("CAR6", mapInfo.getLsu()[10] & 0xFF);
|
|
|
-// param.put("PED6", mapInfo.getLsu()[11] & 0xFF);
|
|
|
-// param.put("CAR7", mapInfo.getLsu()[12] & 0xFF);
|
|
|
-// param.put("PED7", mapInfo.getLsu()[13] & 0xFF);
|
|
|
-// param.put("CAR8", mapInfo.getLsu()[14] & 0xFF); /*차량등 8 (2004-LSU15) */
|
|
|
-// param.put("PED8", mapInfo.getLsu()[15] & 0xFF); /*보행등 8 (2004-LSU16) */
|
|
|
+// param.put("CAR1", mapData.step[jj][ 0] & 0xFF); /*차량등 1 (2004-LSU1) */
|
|
|
+// param.put("PED1", mapData.step[jj][ 1] & 0xFF); /*보행등 1 (2004-LSU2) */
|
|
|
+// param.put("CAR2", mapData.step[jj][ 2] & 0xFF);
|
|
|
+// param.put("PED2", mapData.step[jj][ 3] & 0xFF);
|
|
|
+// param.put("CAR3", mapData.step[jj][ 4] & 0xFF);
|
|
|
+// param.put("PED3", mapData.step[jj][ 5] & 0xFF);
|
|
|
+// param.put("CAR4", mapData.step[jj][ 6] & 0xFF);
|
|
|
+// param.put("PED4", mapData.step[jj][ 7] & 0xFF);
|
|
|
+// param.put("CAR5", mapData.step[jj][ 8] & 0xFF);
|
|
|
+// param.put("PED5", mapData.step[jj][ 9] & 0xFF);
|
|
|
+// param.put("CAR6", mapData.step[jj][10] & 0xFF);
|
|
|
+// param.put("PED6", mapData.step[jj][11] & 0xFF);
|
|
|
+// param.put("CAR7", mapData.step[jj][12] & 0xFF);
|
|
|
+// param.put("PED7", mapData.step[jj][13] & 0xFF);
|
|
|
+// param.put("CAR8", mapData.step[jj][14] & 0xFF); /*차량등 8 (2004-LSU15) */
|
|
|
+// param.put("PED8", mapData.step[jj][15] & 0xFF); /*보행등 8 (2004-LSU16) */
|
|
|
// param.put("MIN_TM", mapInfo.getMinTm() & 0xFF); /*최소시간 */
|
|
|
// param.put("MAX_TM", mapInfo.getMaxTm() & 0xFF); /*최대시간 */
|
|
|
// param.put("EOP", mapInfo.getEop() & 0xFF); /*현시종료여부(1:종료) */
|
|
@@ -166,4 +163,198 @@ public class SigSignalMap implements SigCommResponse {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean response(RecvPacketDto packet) {
|
|
|
+ boolean result = true;
|
|
|
+ try {
|
|
|
+ MDC.put("id", packet.getCenter().getLogKey());
|
|
|
+ log.info("[{}], SigSignalMap.response.", packet.getCenter().getLogKey());
|
|
|
+
|
|
|
+ final int recordSize = 262; // 2 + 1+1+1+1+1 + 255 = 262
|
|
|
+ if (!packet.getPacket().checkDataLength(recordSize)) {
|
|
|
+ log.error("[{}], SigPhaseChange.response: Data Length Error: Req({}), Cur({}). will be closed.",
|
|
|
+ packet.getCenter().getLogKey(), packet.getPacket().getReqDataLength(recordSize), packet.getPacket().getCurDataLength());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+// #define MAX_COMPRESSDATA_SIZE 255
|
|
|
+// typedef struct _pktSignalMap
|
|
|
+// {
|
|
|
+// byte int_no [2]; /* 교차로 번호 */
|
|
|
+// byte lcType [1]; /* SIGNAL Controller protocol type, ESIGMAP_LC_TYPE_2004 or ESIGMAP_LC_TYPE_2010 */
|
|
|
+// byte ringNo [1]; /* ring no, 0: Aring, 1: Bring */
|
|
|
+// byte lampTp [1]; /* 등화기 유형 */
|
|
|
+// byte planTp [1]; /* map 계획구분, 0:일반제, 1~5:시차제, 6:보행맵 */
|
|
|
+// byte compSize[1]; /* 압축된 signal map data size */
|
|
|
+// byte compData[MAX_COMPRESSDATA_SIZE]; /* 압축된 signal map data */
|
|
|
+// } pkt_signalmap, *pkt_signalmapp; /* 2 + 1+1+1+1+1 + 255 bytes = 262 */
|
|
|
+
|
|
|
+ int res;
|
|
|
+ SigMapData mapData = new SigMapData();
|
|
|
+ List<HashMap<String, Object>> typeLists = new ArrayList<>();
|
|
|
+ List<HashMap<String, Object>> lists = new ArrayList<>();
|
|
|
+ String regionCd = packet.getCenter().getRegionCd();
|
|
|
+ int idx;
|
|
|
+ byte[] buffer = packet.getPacket().getBuffer();
|
|
|
+ for (int ii = 0; ii < packet.getPacket().getCount(); ii++) {
|
|
|
+ idx = SigProtocolConst.SIG_HEAD_SIZE + (ii * (7 + SigMapData.MAX_COMPRESS_DATA_SIZE));
|
|
|
+
|
|
|
+ int intNo = ((buffer[idx++] & 0xFF) << 8) | (buffer[idx++] & 0xFF);
|
|
|
+ int lcType = (buffer[idx++] & 0xFF); /* 제어기유형(1:2004년형, 2:2010년형) */
|
|
|
+ int ringNo = (buffer[idx++] & 0xFF); /* 링번호(0:A링,1:B링) */
|
|
|
+ int lampTp = (buffer[idx++] & 0xFF); /* 등화기유형(3:3색등화기, 4:4색등화기) */
|
|
|
+ int planTp = (buffer[idx++] & 0xFF); /* map 계획구분, 0:일반제, 1~5:시차제, 6:보행맵 */
|
|
|
+ int compSize = (buffer[idx++] & 0xFF);
|
|
|
+
|
|
|
+ byte[] compData = new byte[SigMapData.MAX_COMPRESS_DATA_SIZE];
|
|
|
+// byte[] deCompData = new byte[SigMapData.MAX_DECOMPRESS_DATA_SIZE];
|
|
|
+ System.arraycopy(buffer, idx, compData, 0, compData.length);
|
|
|
+
|
|
|
+ mapData.init();
|
|
|
+
|
|
|
+ if (lcType == SigMapData.ESIGMAP_LC_TYPE_2004) {
|
|
|
+ continue;
|
|
|
+ //res = SigMapData.signalMapDecompress(compData, idx, compSize, deCompData);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ log.info("INT_NO: {}, RING_NO: {}, PLAN_TP: {}", intNo, ringNo, planTp);
|
|
|
+ res = SigMapData.signalMapDecompress2010(buffer, idx, compSize, mapData);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (res == 0 && res == -999) {
|
|
|
+ log.error("[{}], SigSignalMap.response: Decompress Error. INT_NO: {}, LC_TYPE: {}", packet.getCenter().getLogKey(), intNo, lcType);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ IntDto intDto = packet.getCenter().getIntMap().get(intNo);
|
|
|
+ if (intDto != null) {
|
|
|
+ if (intDto.getIntLcType() != lcType || intDto.getIntLampType() != lampTp) {
|
|
|
+ HashMap<String, Object> intParam = new HashMap<>();
|
|
|
+ intParam.put("REGION_CD", regionCd);
|
|
|
+ intParam.put("INT_NO", intNo);
|
|
|
+ intParam.put("INT_LCTYPE", lcType);
|
|
|
+ intParam.put("INT_LAMP-TYPE", lampTp);
|
|
|
+ typeLists.add(intParam);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int jj = 0; jj < SigMapData.MAX_SIGMAP_STEP; jj++) {
|
|
|
+ HashMap<String, Object> param = new HashMap<>();
|
|
|
+
|
|
|
+ param.put("REGION_CD", regionCd); /*지역센터코드 */
|
|
|
+ param.put("INT_NO", intNo); /*교차로 번호 */
|
|
|
+ param.put("RING_NO", ringNo); /*링번호(0:A링,1:B링) */
|
|
|
+ param.put("PLAN_TP", planTp); /*계획구분(0:일반제, 1:시차제, 2:시차제, 3:시차제, 4:시차제, 5:시차제, 6:보행맵) */
|
|
|
+ param.put("STEP_NO", jj+1); /*스텝번호(1~32) */
|
|
|
+
|
|
|
+ param.put("CAR1", mapData.step[jj].code[ 0] & 0xFF); /*차량등 1 (2004-LSU1) */
|
|
|
+ param.put("PED1", mapData.step[jj].code[ 1] & 0xFF); /*보행등 1 (2004-LSU2) */
|
|
|
+ param.put("CAR2", mapData.step[jj].code[ 2] & 0xFF);
|
|
|
+ param.put("PED2", mapData.step[jj].code[ 3] & 0xFF);
|
|
|
+ param.put("CAR3", mapData.step[jj].code[ 4] & 0xFF);
|
|
|
+ param.put("PED3", mapData.step[jj].code[ 5] & 0xFF);
|
|
|
+ param.put("CAR4", mapData.step[jj].code[ 6] & 0xFF);
|
|
|
+ param.put("PED4", mapData.step[jj].code[ 7] & 0xFF);
|
|
|
+ param.put("CAR5", mapData.step[jj].code[ 8] & 0xFF);
|
|
|
+ param.put("PED5", mapData.step[jj].code[ 9] & 0xFF);
|
|
|
+ param.put("CAR6", mapData.step[jj].code[10] & 0xFF);
|
|
|
+ param.put("PED6", mapData.step[jj].code[11] & 0xFF);
|
|
|
+ param.put("CAR7", mapData.step[jj].code[12] & 0xFF);
|
|
|
+ param.put("PED7", mapData.step[jj].code[13] & 0xFF);
|
|
|
+ param.put("CAR8", mapData.step[jj].code[14] & 0xFF); /*차량등 8 (2004-LSU15) */
|
|
|
+ param.put("PED8", mapData.step[jj].code[15] & 0xFF); /*보행등 8 (2004-LSU16) */
|
|
|
+ param.put("MIN_TM", mapData.step[jj].code[16] & 0xFF); /*최소시간 */
|
|
|
+ param.put("MAX_TM", mapData.step[jj].code[17] & 0xFF); /*최대시간 */
|
|
|
+ param.put("EOP", mapData.step[jj].code[18] & 0xFF); /*현시종료여부(1:종료) */
|
|
|
+
|
|
|
+ lists.add(param);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!lists.isEmpty()) {
|
|
|
+ this.dbmsDataProcess.add(new DbmsData(DbmsData.DBMS_DATA_INT_SIGNALMAP, packet.getCenter(), false, lists));
|
|
|
+ }
|
|
|
+ if (!typeLists.isEmpty()) {
|
|
|
+ this.dbmsDataProcess.add(new DbmsData(DbmsData.DBMS_DATA_INT_TYPE, packet.getCenter(), false, typeLists));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ log.error("[{}], SigSignalMap.response: Exception. will be closed. {}", packet.getCenter().getLogKey(), e.getMessage());
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ MDC.remove(packet.getCenter().getLogKey());
|
|
|
+ MDC.clear();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void responseTEST(RecvPacketDto packet) {
|
|
|
+ try {
|
|
|
+ final int recordSize = 262; // 2 + 1+1+1+1+1 + 255 = 262
|
|
|
+ if (!packet.getPacket().checkDataLength(recordSize)) {
|
|
|
+ log.error("[{}], SigPhaseChange.response: Data Length Error: Req({}), Cur({}). will be closed.",
|
|
|
+ packet.getCenter().getLogKey(), packet.getPacket().getReqDataLength(recordSize), packet.getPacket().getCurDataLength());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int res;
|
|
|
+ List<HashMap<String, Object>> typeLists = new ArrayList<>();
|
|
|
+ List<HashMap<String, Object>> lists = new ArrayList<>();
|
|
|
+ String regionCd = packet.getCenter().getRegionCd();
|
|
|
+ int idx = SigProtocolConst.SIG_HEAD_SIZE;
|
|
|
+ byte[] buffer = packet.getPacket().getBuffer();
|
|
|
+ for (int ii = 0; ii < packet.getPacket().getCount(); ii++) {
|
|
|
+ idx = SigProtocolConst.SIG_HEAD_SIZE + (ii * (7 + SigMapData.MAX_COMPRESS_DATA_SIZE));
|
|
|
+ int intNo = ((buffer[idx++] & 0xFF) << 8) | (buffer[idx++] & 0xFF);
|
|
|
+ int lcType = (buffer[idx++] & 0xFF); /* 제어기유형(1:2004년형, 2:2010년형) */
|
|
|
+ int ringNo = (buffer[idx++] & 0xFF); /* 링번호(0:A링,1:B링) */
|
|
|
+ int lampTp = (buffer[idx++] & 0xFF); /* 등화기유형(3:3색등화기, 4:4색등화기) */
|
|
|
+ int planTp = (buffer[idx++] & 0xFF); /* map 계획구분, 0:일반제, 1~5:시차제, 6:보행맵 */
|
|
|
+ int compSize = (buffer[idx++] & 0xFF);
|
|
|
+
|
|
|
+ log.info("{}, {}, {}, {}, {}, {}", intNo, lcType, ringNo, lampTp, planTp, compSize);
|
|
|
+
|
|
|
+ byte[] compData = new byte[SigMapData.MAX_COMPRESS_DATA_SIZE];
|
|
|
+ byte[] deCompData = new byte[SigMapData.MAX_DECOMPRESS_DATA_SIZE];
|
|
|
+ System.arraycopy(buffer, idx, compData, 0, compData.length);
|
|
|
+
|
|
|
+ log.info("{} Bytes. {}", deCompData.length, SysUtils.byteArrayToHex(compData));
|
|
|
+ if (lcType == SigMapData.ESIGMAP_LC_TYPE_2004) {
|
|
|
+ //res = SigMapData.signalMapDecompress(compData, idx, compSize, deCompData);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+// res = SigMapData.signalMapDecompress2010(compData, idx, compSize, deCompData);
|
|
|
+ }
|
|
|
+ idx = idx + SigMapData.MAX_COMPRESS_DATA_SIZE;
|
|
|
+
|
|
|
+// if (res == 0) {
|
|
|
+// log.error("[{}], SigSignalMap.response: Decompress Error. INT_NO: {}, LC_TYPE: {}", packet.getCenter().getLogKey(), intNo, lcType);
|
|
|
+// }
|
|
|
+
|
|
|
+// param.put("CAR1", deCompData[spIdx++] & 0xFF); /*차량등 1 (2004-LSU1) */
|
|
|
+// param.put("PED1", deCompData[spIdx++] & 0xFF); /*보행등 1 (2004-LSU2) */
|
|
|
+// param.put("CAR2", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("PED2", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("CAR3", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("PED3", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("CAR4", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("PED4", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("CAR5", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("PED5", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("CAR6", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("PED6", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("CAR7", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("PED7", deCompData[spIdx++] & 0xFF);
|
|
|
+// param.put("CAR8", deCompData[spIdx++] & 0xFF); /*차량등 8 (2004-LSU15) */
|
|
|
+// param.put("PED8", deCompData[spIdx++] & 0xFF); /*보행등 8 (2004-LSU16) */
|
|
|
+// param.put("MIN_TM", deCompData[spIdx++] & 0xFF); /*최소시간 */
|
|
|
+// param.put("MAX_TM", deCompData[spIdx++] & 0xFF); /*최대시간 */
|
|
|
+// param.put("EOP", deCompData[spIdx++] & 0xFF); /*현시종료여부(1:종료) */
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ log.error("[{}], SigSignalMap.response: Exception. will be closed. {}", packet.getCenter().getLogKey(), e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|