Przeglądaj źródła

decompress 2010

shjung 11 miesięcy temu
rodzic
commit
178d843488

+ 2 - 0
src/main/java/com/sig/comm/server/dao/mapper/IntDbaseMapper.java

@@ -6,6 +6,8 @@ import java.util.Map;
 
 @Mapper
 public interface IntDbaseMapper {
+
+    int updateIntTodPlan(Map<String, Object> obj);
     int updateIntOperPlan(Map<String, Object> obj);
     int updateIntHolidayPlan(Map<String, Object> obj);
     int updateIntWeekdayPlan(Map<String, Object> obj);

+ 8 - 0
src/main/java/com/sig/comm/server/dao/mapper/batch/SigCommServerDao.java

@@ -42,6 +42,14 @@ public class SigCommServerDao extends BatchDaoService {
         return total;
     }
 
+    public int updateIntTodPlan(List<HashMap<String, Object>> req) {
+        log.info("{}.updateIntTodPlan: START. {} EA", this.serviceName, req.size());
+        Elapsed elapsed = new Elapsed();
+        int total = updateBatch("updateIntTodPlan", req);
+        log.info("{}.updateIntTodPlan: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
+        return total;
+    }
+
     public int updateIntOperPlan(List<HashMap<String, Object>> req) {
         log.info("{}.updateIntOperPlan: START. {} EA", this.serviceName, req.size());
         Elapsed elapsed = new Elapsed();

+ 1 - 0
src/main/java/com/sig/comm/server/process/dbms/DbmsDataProcess.java

@@ -108,6 +108,7 @@ public class DbmsDataProcess {
 
                 case DbmsData.DBMS_DATA_INT_OPER_PLAN:
                     List<HashMap<String, Object>> operPlanLists = (List<HashMap<String, Object>>)data.getData();
+                    result = this.sigCommServerDao.updateIntTodPlan(operPlanLists);
                     result = this.sigCommServerDao.updateIntOperPlan(operPlanLists);
                     break;
                 case DbmsData.DBMS_DATA_INT_HOLIDAY:

+ 1 - 0
src/main/java/com/sig/comm/server/repository/ApplicationRepository.java

@@ -55,6 +55,7 @@ public class ApplicationRepository {
             .intCount(65535)
             .netState(new NetState())
             .intMap(new HashMap<>())
+            .dump(false)
             .build();
     private final ConcurrentHashMap<String, RegionCenter> centerMap = new ConcurrentHashMap<>();
     private final ConcurrentHashMap<String, RegionCenter> ipAddrMap = new ConcurrentHashMap<>();

+ 51 - 0
src/main/java/com/sig/comm/server/xnet/server/process/protocol/SigCommPacket.java

@@ -38,6 +38,57 @@ public class SigCommPacket implements Serializable {
 
     protected boolean isValid;
 
+    public SigCommPacket(RegionCenter center, byte[] byteBuff) {
+        this.timestamp = System.currentTimeMillis();
+        this.center = center;
+
+        this.packetLength = byteBuff.length;
+        this.buffer = new byte[this.packetLength];
+        System.arraycopy(byteBuff, 0, this.buffer, 0, this.packetLength);
+
+        if (this.packetLength < (SigProtocolConst.SIG_HEAD_SIZE + SigProtocolConst.SIG_TAIL_SIZE)) {
+            this.stx        = SigProtocolConst.SIG_NULL;
+            this.opCode     = SigProtocolConst.SIG_NULL;
+            this.year       = 0;
+            this.month      = 0;
+            this.day        = 0;
+            this.hour       = 0;
+            this.min        = 0;
+            this.sec        = 0;
+            this.sequence   = 0;
+            this.regionId   = 0;
+            this.dataLength = 0;
+            this.count      = 0;
+
+            this.chkSum     = SigProtocolConst.SIG_NULL;
+            this.etx        = SigProtocolConst.SIG_NULL;
+
+            this.commDate = "20000101010000";
+            this.isValid = false;
+            return;
+        }
+
+        int idx = 0;
+        this.stx        = this.buffer[idx++];
+        this.opCode     = this.buffer[idx++];
+        this.year       = (short)(this.buffer[idx++] & 0xFF);
+        this.month      = (short)(this.buffer[idx++] & 0xFF);
+        this.day        = (short)(this.buffer[idx++] & 0xFF);
+        this.hour       = (short)(this.buffer[idx++] & 0xFF);
+        this.min        = (short)(this.buffer[idx++] & 0xFF);
+        this.sec        = (short)(this.buffer[idx++] & 0xFF);
+        this.sequence   = ((this.buffer[idx++] & 0xFF) << 8) | (this.buffer[idx++] & 0xFF);
+        this.regionId   = ((this.buffer[idx++] & 0xFF) << 8) | (this.buffer[idx++] & 0xFF);
+        this.dataLength = ((this.buffer[idx++] & 0xFF) << 8) | (this.buffer[idx++] & 0xFF);
+        this.count      = ((this.buffer[idx++] & 0xFF) << 8) | (this.buffer[idx++] & 0xFF);
+
+        this.chkSum     = byteBuff[this.packetLength-2];
+        this.etx        = byteBuff[this.packetLength-1];
+
+        this.commDate = String.format("%4d%02d%02d%02d%02d%02d", this.year+2000, this.month, this.day, this.hour, this.min, this.sec);
+        this.isValid = true;
+    }
+
     public SigCommPacket(RegionCenter center, ByteBuf byteBuf) {
         this.timestamp = System.currentTimeMillis();
         this.center = center;

+ 60 - 60
src/main/java/com/sig/comm/server/xnet/server/process/protocol/SigMapData.java

@@ -2,7 +2,9 @@ package com.sig.comm.server.xnet.server.process.protocol;
 
 import lombok.Data;
 import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
 
+@Slf4j
 @Data
 public class SigMapData {
 
@@ -19,7 +21,7 @@ public class SigMapData {
     public static final int MAXMAPDATASIZE = 608;
     public static final int MAX_VAR_CNT = 40;
 
-    public static final int SP_SIZE = 19;
+    public static final int MAX_CODE_SIZE = 19; // lcu(16) + min + max + eop
     public static final int SP_MIN = 16;
     public static final int SP_MAX = 17;
     public static final int SP_EOP = 18;
@@ -45,49 +47,44 @@ public class SigMapData {
     public static final byte DELIMITER = (byte)0xFF;
 
 
-    private SigMapInfo[] step; // signal map data - step1 ~ step32
+    public SigMapInfo[] step; // signal map data - step1 ~ step32
+
+    public SigMapData() {
+        this.step = new SigMapInfo[MAX_SIGMAP_STEP];
+        for (int ii = 0; ii < MAX_SIGMAP_STEP; ii++) {
+            this.step[ii] = new SigMapInfo();
+        }
+    }
 
-    private byte[] data;
     @Getter
     public static class SigMapInfo {
-        private byte[] lsu; // 4색등화기 또는 3색등화기에 해당하는 lsu 배열
-        private byte minTm; // 고정시간값
-        private byte maxTm; // 가변시간값
-        private byte eop; // 현시종료
+        public byte[] code; // 4색등화기 또는 3색등화기에 해당하는 lsu 배열
 
         public SigMapInfo() {
-            this.lsu = new byte[MAX_SIGMAP_LSU];
-            this.minTm = (byte)0x00;
-            this.maxTm = (byte)0x00;
-            this.eop = (byte)0x00;
+            this.code = new byte[MAX_CODE_SIZE];
+            init();
         }
         public void init() {
-            for (int ii = 0; ii < MAX_SIGMAP_LSU; ii++) {
-                this.lsu[ii] = (byte)0x00;
+            for (int ii = 0; ii < MAX_CODE_SIZE; ii++) {
+                this.code[ii] = (byte)0x00;
             }
-            this.minTm = (byte)0x00;
-            this.maxTm = (byte)0x00;
-            this.eop = (byte)0x00;
         }
     }
 
-    public SigMapData() {
-        this.data = new byte[MAX_DECOMPRESS_DATA_SIZE];
-        this.step = new SigMapInfo[MAX_SIGMAP_STEP];
+    public static class SigMapStep {
+        public int[] code;
+
+        public SigMapStep() {
+            this.code = new int[MAX_SIGMAP_LSU+3];
+        }
     }
 
     public void init() {
-        int ii;
-        for (ii = 0; ii < this.data.length; ii++) {
-            this.data[ii] = (byte)0x00;
-        }
-        for (ii = 0; ii < MAX_SIGMAP_STEP; ii++) {
+        for (int ii = 0; ii < MAX_SIGMAP_STEP; ii++) {
             this.step[ii].init();
         }
     }
 
-
-
     public static short gen16LRC(byte[] s, int size) {
         int sLrc = 0;
         for (int ii = 0; ii < size; ii++) {
@@ -152,8 +149,7 @@ public class SigMapData {
                 if ((data & (0x01 << bitCount)) > 0) {
                     inx = compData[cp];
                     inx = (inx & (0x03 << inxCount) ) >> inxCount;
-                    switch(inx)
-                    {
+                    switch(inx) {
                         case CODE_PED_GINX: deCompData[dp] = CODE_PED_GREEN; break;
                         case CODE_PED_FINX: deCompData[dp] = CODE_PED_FLASH; break;
                         case CODE_CAR_GINX: deCompData[dp] = CODE_CAR_GREEN; break;
@@ -187,22 +183,24 @@ public class SigMapData {
         return byteCount + 1;
     }
 
-    public static int signalMapDecompress2010(byte[] compData, int start, int length, byte[] deCompData) {
-        int ep = length;
-        int sp = 0;
+    public static int signalMapDecompress2010(byte[] compData, int start, int length, SigMapData result) {
+        int sp = start;
         int cnt = 0;
         int tCnt = 0;
         int data;
         int value;
-        int dp = 0;
         byte lsu;
 
-        data = compData[sp];
-        while ((sp < ep) && (data > 0)) {
-            /* LSU 코드 값이 없으면 while 문이 종료됨 */
+        while ((sp - start) < length) {
+            data = compData[sp] & 0xFF;
+            if (data == 0x00) {
+                /* LSU 코드 값이 없으면 while 문이 종료됨 */
+                break;
+            }
+
             lsu = (byte)(data & 0xE0);
             if (lsu == (byte)0xE0) {
-                cnt = (data & 0x1F) * 256 + compData[sp+1];
+                cnt = (data & 0x1F) * 256 + (compData[sp+1] & 0xFF);
                 sp++;
                 sp++;
             }
@@ -214,72 +212,74 @@ public class SigMapData {
                 cnt = 1;
             }
 
-            data = compData[sp];
-            if ((data & 0xE0) == 0xC0){
+            data = compData[sp] & 0xFF;
+            lsu = (byte)(data & 0xE0);
+            if (lsu == (byte)0xC0){
                 value = 0x00; /* 00코드가 생략되었는지 확인 */
             }
             else {
                 value = data;
                 sp++;
             }
-            /* baseStep 구조체에 저장하기(LSU 값만 저장함) */
             for (int ii = 0; ii < cnt; ii++, tCnt++) {
-                dp = (tCnt % MAX_STEP) * SP_SIZE;
-                deCompData[dp + (tCnt/MAX_STEP)] = (byte)value;
+                /* baseStep 구조체에 저장하기(LSU 값만 저장함) */
+                result.step[tCnt%MAX_STEP].code[tCnt/MAX_STEP] = (byte)value;//(value&0xFF);
             }
         }
 
-        data = compData[sp++];
-        if (data > 0) {
+        data = compData[sp] & 0xFF;
+        if (data != 0x00) {
             return 0;
         }
+        sp++;
 
         int varAttr, attr;
         varAttr = attr = sp;
-        while (varAttr < ep && compData[varAttr++] != 0x00) {
+        while ((varAttr - start) < length && compData[varAttr++] != 0x00) {
             ;   /*3초아닌 스텝시간 영역으로 이동*/
         }
-        if (varAttr >= ep) {
+        if ((varAttr - start) >= length) {
             return 0;
         }
 
-        int stepIdx;
         for (int step = 0; step < MAX_STEP; step++) {
-            if ((step > 0) && (step % 4 != 0)) {
+            if ((step > 0) && (step % 4 == 0)) {
                 attr++;
                 if (compData[attr] == 0x00) {
                     break;
                 }
             }
             value = (((compData[attr]) >> ((step%4)*2)) & 0x03);
-            stepIdx = step*SP_SIZE;
-            switch(value)
-            {
+            switch(value) {
                 case MIN_EOP3SEC:
-                    deCompData[stepIdx+SP_MIN] = 3;
-                    deCompData[stepIdx+SP_EOP] = 1;
+                    result.step[step].code[SP_MIN] = 3;
+                    result.step[step].code[SP_EOP] = 1;
                     break; /*3초인 EOP 스텝인 경우 */
                 case MIN_3SEC:
-                    deCompData[stepIdx+SP_MIN] = 3;
+                    result.step[step].code[SP_MIN] = 3;
                     break;
                 case MAX_VAR:
-                    deCompData[stepIdx+SP_MAX] = compData[varAttr++];
-                    if (deCompData[stepIdx+SP_MAX] == (byte) 0x01) {
+                    result.step[step].code[SP_MAX] = compData[varAttr++];
+                    if (result.step[step].code[SP_MAX] == (byte) 0x01) {
                         if ((compData[varAttr] & 0x80) > 0) {
-                            deCompData[stepIdx+SP_EOP] = 1;
+                            result.step[step].code[SP_EOP] = 1;
                         }
-                        deCompData[stepIdx+SP_MIN] = (byte)(compData[varAttr++] & (byte) 0x7F);
-                        deCompData[stepIdx+SP_MAX] = compData[varAttr++];
+                        result.step[step].code[SP_MIN] = (byte)(compData[varAttr++] & 0x7F);
+                        result.step[step].code[SP_MAX] = compData[varAttr++];
                     }
                     break;
                 case MIN_VAR:
-                    deCompData[stepIdx+SP_MIN] = (byte)(compData[varAttr] & (byte) 0x7F);
+                    result.step[step].code[SP_MIN] = (byte)(compData[varAttr] & (byte) 0x7F);
                     if ((compData[varAttr++] & 0x80) > 0) {
-                        deCompData[stepIdx+SP_EOP] = 1;
+                        result.step[step].code[SP_EOP] = 1;
                     }
                     break;
             }
+            if (0x00 == result.step[step].code[SP_MIN] && 0x00 == result.step[step].code[SP_MAX]) {
+                break;
+            }
         }
         return MAXMAPDATASIZE;
     }
+
 }

+ 0 - 4
src/main/java/com/sig/comm/server/xnet/server/process/response/SigFunction.java

@@ -24,10 +24,6 @@ public class SigFunction implements SigCommResponse {
         try {
             MDC.put("id", packet.getCenter().getLogKey());
             log.info("[{}], SigFunction.response.", packet.getCenter().getLogKey());
-            if (packet.getCenter().isSimulateFlag()) {
-                // 시뮬레이션 모드로 동작중이므로 상태정보를 업데이트하지 않는다.
-                return true;
-            }
 
             final int recordSize = 82; // 2+(8*10)
             if (!packet.getPacket().checkDataLength(recordSize)) {

+ 218 - 27
src/main/java/com/sig/comm/server/xnet/server/process/response/SigSignalMap.java

@@ -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());
+        }
+    }
+
 }

+ 0 - 4
src/main/java/com/sig/comm/server/xnet/server/process/response/SigWeekDayPlan.java

@@ -24,10 +24,6 @@ public class SigWeekDayPlan implements SigCommResponse {
         try {
             MDC.put("id", packet.getCenter().getLogKey());
             log.info("[{}], SigWeekDayPlan.response.", packet.getCenter().getLogKey());
-            if (packet.getCenter().isSimulateFlag()) {
-                // 시뮬레이션 모드로 동작중이므로 상태정보를 업데이트하지 않는다.
-                return true;
-            }
 
             final int recordSize = 9;
             if (!packet.getPacket().checkDataLength(recordSize)) {

+ 10 - 0
src/main/resources/mybatis/mapper/IntDbaseMapper.xml

@@ -3,6 +3,16 @@
 
 <mapper namespace="com.sig.comm.server.dao.mapper.IntDbaseMapper">
 
+    <update id="updateIntTodPlan" parameterType="java.util.Map">
+    <![CDATA[
+        UPDATE TB_INT_PLAN
+        SET UPD_DTIME = SYSDATE
+        WHERE REGION_CD   = #{REGION_CD}
+          AND INT_NO      = #{INT_NO}
+          AND INT_PLAN_NO = #{INT_PLAN_NO}
+        ]]>
+    </update>
+
     <update id="updateIntOperPlan" parameterType="java.util.Map">
     <![CDATA[
         UPDATE TB_INT_OPER_PLAN

+ 46 - 0
src/test/java/com/sig/comm/server/SigCommServerApplicationTests.java

@@ -1,10 +1,17 @@
 package com.sig.comm.server;
 
+import com.sig.app.common.utils.ByteUtils;
+import com.sig.comm.server.dto.NetState;
+import com.sig.comm.server.dto.RegionCenter;
+import com.sig.comm.server.xnet.server.process.protocol.SigCommPacket;
+import com.sig.comm.server.xnet.server.process.response.RecvPacketDto;
+import com.sig.comm.server.xnet.server.process.response.SigSignalMap;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.HashMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -14,6 +21,45 @@ import java.util.concurrent.TimeUnit;
 //@SpringBootTest
 public class SigCommServerApplicationTests {
 
+    public static final RegionCenter rCenter = RegionCenter.builder()
+            .idx(0)
+            .isDeleted(false)
+            .regionCd("L01")
+            .regionNm("UTIC SIGNAL 센터")
+            .ipAddress("127.0.0.1")
+            .loginId("")
+            .loginPswd("")
+            .fileUpdDt("")
+            .simulateFlag(false)
+            .regionId(7600)
+            .extYn(false)
+            .realtimeYn(false)
+            .dbaseYn(false)
+            .commHistYn(false)
+            .minIntNo(0)
+            .maxIntNo(65535)
+            .intCount(65535)
+            .netState(new NetState())
+            .intMap(new HashMap<>())
+            .dump(false)
+            .build();
+    @Test
+    void testPacketRecvData() {
+        //ReadableBytes: 113 Bytes
+        String data = "02C518081901061911551DB1020C000200010200030036E04BC31020DDC10105E021C11020E030C80102D8C10105C2C10105E039C8010200555C9C2503000102090F3C090F3C010C1246006C2400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010201030025E041C80102E0B7C80102E021C5102000555C9C2503000102090F3C090F3C01040546003E450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AB03";
+        byte[] inBytes = ByteUtils.hexToByteArray(data);
+        log.error("Packet Length: {}", inBytes.length);
+        SigCommPacket sigCommPacket = new SigCommPacket(rCenter, inBytes);
+        RecvPacketDto packet = RecvPacketDto.builder()
+                .recvTime(0)
+                .center(rCenter)
+                .packet(sigCommPacket)
+                .build();
+        SigSignalMap response = new SigSignalMap(null);
+        response.responseTEST(packet);
+    }
+
+
     @Test
     public void test() {
         //1720599437901