|
@@ -13,7 +13,6 @@ import com.tsi.comm.server.repository.TsiNodeAddManager;
|
|
|
import com.tsi.comm.server.vo.TsiNodeAddDetailVo;
|
|
import com.tsi.comm.server.vo.TsiNodeAddDetailVo;
|
|
|
import com.tsi.comm.server.vo.TsiNodeAddVo;
|
|
import com.tsi.comm.server.vo.TsiNodeAddVo;
|
|
|
import com.tsi.comm.server.vo.TsiNodeVo;
|
|
import com.tsi.comm.server.vo.TsiNodeVo;
|
|
|
-import com.tsi.common.spring.SpringUtils;
|
|
|
|
|
import com.tsi.common.utils.ByteUtils;
|
|
import com.tsi.common.utils.ByteUtils;
|
|
|
import com.tsi.common.utils.CRC16Utils;
|
|
import com.tsi.common.utils.CRC16Utils;
|
|
|
import io.netty.channel.Channel;
|
|
import io.netty.channel.Channel;
|
|
@@ -26,158 +25,36 @@ import java.nio.ByteOrder;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
+import static com.tsi.comm.server.protocol.TsiCvibProtocolSpec.*;
|
|
|
|
|
+
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Getter
|
|
@Getter
|
|
|
@Setter
|
|
@Setter
|
|
|
public class TsiCpuPacket extends AbstractTsiPacket {
|
|
public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
|
|
|
|
|
- // 헤더(10), 상태헤더(8), 상태정보(5)*상태정보건수, 체크섬(2)
|
|
|
|
|
- // CVIB Protocol Format(CPU-->CENTER)
|
|
|
|
|
- //TYPE STX1 STX2 LEN OPCODE DataVer NodeID DATA CHKSUM
|
|
|
|
|
- //Size Byte Byte 2Byte Byte 1Byte 4Byte NByte 2Byte
|
|
|
|
|
- //Value 0x7E 0x7E Size(LEN…CHKSUM) 0x13 0x01 … CRC16
|
|
|
|
|
- //- LEN : LEN∼CHKSUM data length
|
|
|
|
|
- // - OPCODE: 0x13, 신호상태정보전송
|
|
|
|
|
- // - NodeID: Node ID
|
|
|
|
|
- //- DATA : Opcode에 따른 데이터 영역
|
|
|
|
|
- //- CRC16 : CCITT / ITU / CRC - 16, bits shift right, final little(x) big(o) endian encoding.from LEN to DATA
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
- // 10 byte
|
|
|
|
|
- uint8_t stx1; // stx 0x7E
|
|
|
|
|
- uint8_t stx2; // stx 0x7E
|
|
|
|
|
- uint8_t length[2]; // length, length byte ~ check sum
|
|
|
|
|
- uint8_t opcode; // op code, 0x13
|
|
|
|
|
- uint8_t dataVer; // Data Version
|
|
|
|
|
- uint8_t nodeid[4]; // signal node id
|
|
|
|
|
- // 8 byte
|
|
|
|
|
- tsc_cvim_hdr_t hdr; // 8 byte, cvim signal status header
|
|
|
|
|
- // 5 byte * count
|
|
|
|
|
- tsc_cvim_stts_t stts[MAX_CVIM_STTS]; // 5 byte * 127 = 635 byte
|
|
|
|
|
- */
|
|
|
|
|
- // cvim-raw packet header
|
|
|
|
|
- /*
|
|
|
|
|
-#define TIMESPEC_SIZE (sizeof(struct timespec)) // 16 bytes
|
|
|
|
|
- uint8_t pktTm[TIMESPEC_SIZE]; // little endian
|
|
|
|
|
- uint8_t ipaddr[4]; // big endian
|
|
|
|
|
- uint8_t port[2]; // big endian
|
|
|
|
|
- uint8_t connect;
|
|
|
|
|
- uint8_t nodeid[4]; // big endian
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
-//typedef struct _tsc_cvim_hdr_s
|
|
|
|
|
-//{
|
|
|
|
|
-// uint8_t manual : 1; /* 수동, 1: 이상, 0: 정상 */
|
|
|
|
|
-// uint8_t blink : 1; /* 점멸, 1: 점멸, 0: 정상 */
|
|
|
|
|
-// uint8_t turnOff : 1; /* 소등, 1: 소등, 0: 정상 */
|
|
|
|
|
-// uint8_t response : 1; /* 감응, 1: 감응, 0: 정상 */
|
|
|
|
|
-// uint8_t trans : 1; /* 전이, 1: 전이중, 0: 전이완료 */
|
|
|
|
|
-// uint8_t byte1Res0 : 3; /* 예약, bit 7 ~ 5 */
|
|
|
|
|
-//
|
|
|
|
|
-// uint8_t conflict : 1; /* 모순 이상, 1 : 이상, 0 : 정상 */
|
|
|
|
|
-// uint8_t centerComm : 1; /* 센터 통신 이상, 1: 센터 통신이상, 0 : 정상 */
|
|
|
|
|
-// uint8_t scuComm : 1; /* SCU 통신 이상, 1: MCU <--> SCU 통신 이상, 0: 정상 */
|
|
|
|
|
-// uint8_t byte2Res0 : 5; /* 예약, bit 7 ~ 3 */
|
|
|
|
|
-//
|
|
|
|
|
-// uint8_t cycleCounter; /* 주기 카운터, 초 */
|
|
|
|
|
-//
|
|
|
|
|
-// uint8_t sttsCount : 7; /* 총 신호상태정보의 개수, N 개 */
|
|
|
|
|
-// uint8_t splitFlag : 1; /* 데이터를 분할하여 전송할 경우 마지막 정보임을 나타내는 플래그(분할 패킷의 처음과 중간:0, 단일 또는 마지막 패킷:1) */
|
|
|
|
|
-//
|
|
|
|
|
-// uint8_t currTime[4]; /* 현재시간, time_t형, Big Endian */
|
|
|
|
|
-//} tsc_cvim_hdr_t, *ptsc_cvim_hdr_t;
|
|
|
|
|
-//
|
|
|
|
|
-//typedef struct _tsc_cvim_stts_s
|
|
|
|
|
-//{
|
|
|
|
|
-// uint8_t dirAdd : 4; /* 3 ~ 0, 방향추가정보, 해당 방향에 연등지 없음(0), 해당 방향의 첫번째 연등지(1), 해당 방향의 두번째 연등지(2) */
|
|
|
|
|
-// uint8_t lightInfo : 4; /* 7 ~ 4, 신호등 정보, ■ 미지정(0), 직진(1), 좌회전(2), 보행자(3), 자전거(4), 우회전(5), 버스(6), 유턴(7) */
|
|
|
|
|
-//
|
|
|
|
|
-// uint8_t lighting : 3; /* 2 ~ 0, 신호등 상태, ■ 소등(0), 적색점등(1), 황색점등(2), 녹색점등(3), 적색점멸(4), 황색점멸(5), 녹색점멸(6) */
|
|
|
|
|
-// uint8_t unprotect : 1; /* 3, 비보호 상태, ■ 신호등 정보 유턴/좌회전에 대한 비보호 여부, ■ 비보호 아님(0), 비보호(1) */
|
|
|
|
|
-// uint8_t Reserved0 : 2; /* 5 ~ 4, 예비, ■ 예비 */
|
|
|
|
|
-// uint8_t walkerPush : 1; /* 6, 보행자(푸쉬 또는 자동검지), ■ 없음(0), 버튼 눌림 or 자동검지(1) */
|
|
|
|
|
-// uint8_t timeFlag : 1; /* 7, 시간 정보 신뢰성, ■ 고정신호시간(0), 가변신호시간(1) */
|
|
|
|
|
-//
|
|
|
|
|
-// uint8_t displayTm; /* 표출 시간, ■ 초 */
|
|
|
|
|
-// uint8_t remainTm; /* 잔여 시간, ■ 초 */
|
|
|
|
|
-// uint8_t dirCode; /* 방향 코드, ■ 출력지정 테이블에 지정된 방향코드 */
|
|
|
|
|
-//} tsc_cvim_stts_t, *ptsc_cvim_stts_t;
|
|
|
|
|
-
|
|
|
|
|
- // TODO: 20240722 Protocol R28 Added
|
|
|
|
|
- public static final byte PROTOCOL_R27 = 0x01;
|
|
|
|
|
- public static final byte PROTOCOL_R28 = 0x1C; // 28
|
|
|
|
|
-
|
|
|
|
|
- public static final byte STX1 = 0x7E;
|
|
|
|
|
- public static final byte STX2 = 0x7E;
|
|
|
|
|
-
|
|
|
|
|
- public static final int SIZE_HEAD = 10;
|
|
|
|
|
- public static final int SIZE_STX1 = 1;
|
|
|
|
|
- public static final int SIZE_STX2 = 1;
|
|
|
|
|
- public static final int SIZE_LENGTH = 2;
|
|
|
|
|
- public static final int SIZE_OPCODE = 1;
|
|
|
|
|
- public static final int SIZE_VERSION = 1;
|
|
|
|
|
- public static final int SIZE_NODE_ID = 4;
|
|
|
|
|
- public static final int SIZE_STATUS_HDR = 8;
|
|
|
|
|
- public static final int SIZE_STATUS_DATA = 5;
|
|
|
|
|
- public static final int SIZE_CHECKSUM = 2;
|
|
|
|
|
- public static final int SIZE_PACKET_DATA = 18; // length, opcode, version, node_id, status_hdr, checksum
|
|
|
|
|
-
|
|
|
|
|
- public static final int INDEX_STX1 = 0; // 0
|
|
|
|
|
- public static final int INDEX_STX2 = 1; // 1
|
|
|
|
|
- public static final int INDEX_LENGTH = 2; // 2,3
|
|
|
|
|
- public static final int INDEX_OPCODE = 4; // 4
|
|
|
|
|
- public static final int INDEX_VERSION = 5; // 5
|
|
|
|
|
- public static final int INDEX_NODE_ID = 6; // 6,7,8,9
|
|
|
|
|
- public static final int INDEX_STATUS_HDR = 10; // 10,11,12,13,14,15,16,17
|
|
|
|
|
- public static final int INDEX_STATUS_DATA = 18; // 18,19,20,21,22
|
|
|
|
|
- public static final int INDEX_STATUS_DIR_ADD = 0; // 상태정보내 방향 추가 정보 인덱스
|
|
|
|
|
- public static final int INDEX_STATUS_DIRECTION = 4; // 상태정보내 방향코드
|
|
|
|
|
-
|
|
|
|
|
- public static final int SIZE_NODE_DUMMY = 1+1+2+1+1+2; // stx1, stx1, length(2), opcode, version, checksum(2)
|
|
|
|
|
- public static final int SIZE_NODE_HEAD = SIZE_NODE_ID + SIZE_STATUS_HDR;
|
|
|
|
|
- public static final int POS_NODE_HEAD_NODEID = 0; // node(4),
|
|
|
|
|
- public static final int POS_NODE_HEAD_COUNT = 7; // node(4),
|
|
|
|
|
-
|
|
|
|
|
- public static final int SIZE_IPC_SIZE = 27;
|
|
|
|
|
- public static final int SIZE_TIMESPEC = 16;
|
|
|
|
|
- public static final int POS_IPC_TIMESPEC = 0;
|
|
|
|
|
- public static final int POS_IPC_IPADDR = 16;
|
|
|
|
|
- public static final int POS_IPC_PORT = 20;
|
|
|
|
|
- public static final int POS_IPC_CONNECT = 22;
|
|
|
|
|
- public static final int POS_IPC_NODEID = 23;
|
|
|
|
|
- public static final int POS_IPC_PACKET = SIZE_IPC_SIZE;
|
|
|
|
|
- public static final byte CONNECT = 0x01;
|
|
|
|
|
- public static final byte DISCONNECT = 0x00;
|
|
|
|
|
-
|
|
|
|
|
- // FOR Netty LengthFieldBasedFrameDecoder
|
|
|
|
|
- public static final int MAX_FRAME_LENGTH = 2048;
|
|
|
|
|
- public static final int LENGTH_FIELD_OFFSET = 2; // 길이 필드가 2번 인덱스에서 시작
|
|
|
|
|
- public static final int LENGTH_FIELD_LENGTH = 2; // 길이 필드의 크기는 2바이트
|
|
|
|
|
- public static final int LENGTH_ADJUSTMENT = -2; // 길이 필드 값에 더해야 할 조정값 (길이 필드 자체의 크기를 빼줌)
|
|
|
|
|
- public static final int INITIAL_BYTES_TO_STRIP = 0; // 프레임에서 제거할 초기 바이트 수
|
|
|
|
|
-
|
|
|
|
|
|
|
+ protected static TsiNodeAddManager nodeAddManager;
|
|
|
|
|
|
|
|
private Object obj;
|
|
private Object obj;
|
|
|
private int length;
|
|
private int length;
|
|
|
private byte dataVer;
|
|
private byte dataVer;
|
|
|
private int count;
|
|
private int count;
|
|
|
- private int checkSum;
|
|
|
|
|
|
|
+
|
|
|
protected byte[] cvimData; // for cvim-raw topic
|
|
protected byte[] cvimData; // for cvim-raw topic
|
|
|
protected byte[] nodeData; // for node topic
|
|
protected byte[] nodeData; // for node topic
|
|
|
|
|
|
|
|
protected List<TsiCpuAddPacket> addNodes;
|
|
protected List<TsiCpuAddPacket> addNodes;
|
|
|
|
|
|
|
|
- private final TsiNodeAddManager nodeAddManager;
|
|
|
|
|
- private int calcCheckSum;
|
|
|
|
|
|
|
+ public static void setNodeAddManager(TsiNodeAddManager nodeAddManager) {
|
|
|
|
|
+ TsiCpuPacket.nodeAddManager = nodeAddManager;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public TsiCpuPacket(long nodeId, long msec, long nsec, Channel channel) {
|
|
public TsiCpuPacket(long nodeId, long msec, long nsec, Channel channel) {
|
|
|
super(nodeId, msec, nsec, NettyUtils.getRemoteIpAddressToLong(channel), NettyUtils.getRemotePort(channel));
|
|
super(nodeId, msec, nsec, NettyUtils.getRemoteIpAddressToLong(channel), NettyUtils.getRemotePort(channel));
|
|
|
setOpCode(eOpCode.TSI_CPU_SIGNAL_NOTIFY.getValue());
|
|
setOpCode(eOpCode.TSI_CPU_SIGNAL_NOTIFY.getValue());
|
|
|
- this.nodeAddManager = SpringUtils.getBean(TsiNodeAddManager.class);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public TsiCpuPacket(long nodeId, long msec, long nsec, long remoteIpAddressToLong, int remotePort) {
|
|
public TsiCpuPacket(long nodeId, long msec, long nsec, long remoteIpAddressToLong, int remotePort) {
|
|
|
super(nodeId, msec, nsec, remoteIpAddressToLong, remotePort);
|
|
super(nodeId, msec, nsec, remoteIpAddressToLong, remotePort);
|
|
|
- this.nodeAddManager = SpringUtils.getBean(TsiNodeAddManager.class);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// FOR CVIM packet
|
|
// FOR CVIM packet
|
|
@@ -261,8 +138,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
|
|
|
|
|
// 0 단계. STX1, STX2 체크
|
|
// 0 단계. STX1, STX2 체크
|
|
|
if (this.buf[INDEX_STX1] != STX1 || this.buf[INDEX_STX2] != STX2) {
|
|
if (this.buf[INDEX_STX1] != STX1 || this.buf[INDEX_STX2] != STX2) {
|
|
|
-// log.info("Node: {}, STX Error: {}, {}", nodeId, this.buf[INDEX_STX1], this.buf[INDEX_STX2]);
|
|
|
|
|
-// log.error("{}", HexString.fromBytes(this.buf));
|
|
|
|
|
|
|
+ log.error("parsing: errno(-1), NodeId: {}, stx1: {}, stx2: {}", this.nodeId, this.buf[INDEX_STX1], this.buf[INDEX_STX2]);
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -273,24 +149,19 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
// reqLength = SIZE_PACKET_DATA + (SIZE_STATUS_DATA * this.count) + 1; // ADD CPU byte packet
|
|
// reqLength = SIZE_PACKET_DATA + (SIZE_STATUS_DATA * this.count) + 1; // ADD CPU byte packet
|
|
|
// }
|
|
// }
|
|
|
// if (this.length != reqLength ) {
|
|
// if (this.length != reqLength ) {
|
|
|
-// log.info("Node: {}, Length Error: {}, Version: {}, status count: {}, {}", nodeId, this.length, this.buf[INDEX_VERSION],
|
|
|
|
|
-// this.count, reqLength);
|
|
|
|
|
-// log.error("{}", HexString.fromBytes(this.buf));
|
|
|
|
|
// return false;
|
|
// return false;
|
|
|
// }
|
|
// }
|
|
|
- int reqLength = SIZE_PACKET_DATA + (SIZE_STATUS_DATA * this.count);
|
|
|
|
|
|
|
+ final int reqLength = SIZE_PACKET_DATA + (SIZE_STATUS_DATA * this.count);
|
|
|
if (this.length < reqLength ) {
|
|
if (this.length < reqLength ) {
|
|
|
-// log.info("Node: {}, Length Error: {}, Version: {}, status count: {}, {}", nodeId, this.length, this.buf[INDEX_VERSION],
|
|
|
|
|
-// this.count, reqLength);
|
|
|
|
|
-// log.error("{}", HexString.fromBytes(this.buf));
|
|
|
|
|
|
|
+ log.error("parsing: errno(-2), NodeId: {}, reqLength: {}, recvLength: {}", this.nodeId, reqLength, this.length);
|
|
|
return -2;
|
|
return -2;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 2단계. 체크섬
|
|
// 2단계. 체크섬
|
|
|
- this.checkSum = ByteUtils.getUnsignedShort(this.buf, this.buf.length-2);
|
|
|
|
|
- this.calcCheckSum = CRC16Utils.CRC16_ccitt_cvim(this.buf, INDEX_LENGTH, this.length-2); // 시작인덱스가 있으므로 전체길이로 계산
|
|
|
|
|
- if (this.checkSum != this.calcCheckSum) {
|
|
|
|
|
-// log.error("Node: {}, Check Sum Error: Version: {}, recv: {}, calc: {}", nodeId, this.buf[INDEX_VERSION], this.checkSum, this.calcCheckSum);
|
|
|
|
|
-// log.error("{}", HexString.fromBytes(this.buf));
|
|
|
|
|
|
|
+ final int receivedCrc = ByteUtils.getUnsignedShort(this.buf, this.buf.length-2);
|
|
|
|
|
+ final int calculatedCrc = CRC16Utils.CRC16_ccitt_cvim(this.buf, INDEX_LENGTH, this.length-2); // 시작인덱스가 있으므로 전체길이로 계산
|
|
|
|
|
+ if (receivedCrc != calculatedCrc) {
|
|
|
|
|
+ log.error("parsing: errno(-3), NodeId: {}, crc(recv/calc): {}/{}", this.nodeId, receivedCrc, calculatedCrc);
|
|
|
return -3;
|
|
return -3;
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
@@ -299,6 +170,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
public int parsing(TsiNodeVo obj, boolean isCheckPacket) {
|
|
public int parsing(TsiNodeVo obj, boolean isCheckPacket) {
|
|
|
|
|
|
|
|
if (this.buf == null || this.buf.length < INDEX_STATUS_HDR+3) {
|
|
if (this.buf == null || this.buf.length < INDEX_STATUS_HDR+3) {
|
|
|
|
|
+ log.error("parsing: errno(-4), NodeId: {}, buf: {}, length: {}", this.nodeId, this.buf == null, this.buf == null ? 0 : this.buf.length);
|
|
|
return -4;
|
|
return -4;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -323,7 +195,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- TsiNodeAddVo tsiNodeAddVo = this.nodeAddManager.get(this.nodeId);
|
|
|
|
|
|
|
+ TsiNodeAddVo tsiNodeAddVo = TsiCpuPacket.nodeAddManager.get(this.nodeId);
|
|
|
if (tsiNodeAddVo == null) {
|
|
if (tsiNodeAddVo == null) {
|
|
|
// 연등지 정보가 없는 경우
|
|
// 연등지 정보가 없는 경우
|
|
|
// R25 인 경우 마지막 CPU 제조사 코드를 복사하지 않도록 수정
|
|
// R25 인 경우 마지막 CPU 제조사 코드를 복사하지 않도록 수정
|
|
@@ -357,8 +229,8 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
else {
|
|
else {
|
|
|
// 추가 노드 정보
|
|
// 추가 노드 정보
|
|
|
int originDirCode = status[INDEX_STATUS_DIRECTION]; // 원천방향코드
|
|
int originDirCode = status[INDEX_STATUS_DIRECTION]; // 원천방향코드
|
|
|
- int direction = originDirCode/10; // 인천공항 노드 확인용
|
|
|
|
|
- int addNodeIdx = originDirCode%10; // 인천공항 노드 확인용
|
|
|
|
|
|
|
+ int direction = originDirCode / 10; // 인천공항 노드 확인용
|
|
|
|
|
+ int addNodeIdx = originDirCode % 10; // 인천공항 노드 확인용
|
|
|
if (addNodeIdx > 4) {
|
|
if (addNodeIdx > 4) {
|
|
|
// 인천공항 연등지 인 경우 2개 이상이기 때문에 연등지1 = 15, 연등지2=16, ....
|
|
// 인천공항 연등지 인 경우 2개 이상이기 때문에 연등지1 = 15, 연등지2=16, ....
|
|
|
// 즉, 일의 자리 5,6,7,8,9로 설정하고 1,2,3,4,5로 된다. 십의자리는 *10을 해서 원천방향코드가 된다.
|
|
// 즉, 일의 자리 5,6,7,8,9로 설정하고 1,2,3,4,5로 된다. 십의자리는 *10을 해서 원천방향코드가 된다.
|
|
@@ -415,7 +287,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
|
|
|
|
|
TsiCpuAddPacket addPacket = new TsiCpuAddPacket(entry.getKey(), this.timespec, this.remoteIp, this.remotePort);
|
|
TsiCpuAddPacket addPacket = new TsiCpuAddPacket(entry.getKey(), this.timespec, this.remoteIp, this.remotePort);
|
|
|
|
|
|
|
|
- addPacket.setObj(this.nodeAddManager.get(entry.getKey()));
|
|
|
|
|
|
|
+ addPacket.setObj(TsiCpuPacket.nodeAddManager.get(entry.getKey()));
|
|
|
|
|
|
|
|
addPacket.setNodeData(new byte[SIZE_NODE_HEAD + (statusCount*SIZE_STATUS_DATA)]);
|
|
addPacket.setNodeData(new byte[SIZE_NODE_HEAD + (statusCount*SIZE_STATUS_DATA)]);
|
|
|
System.arraycopy(head, 0, addPacket.getNodeData(), 0, SIZE_NODE_HEAD);
|
|
System.arraycopy(head, 0, addPacket.getNodeData(), 0, SIZE_NODE_HEAD);
|
|
@@ -425,7 +297,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
System.arraycopy(entry.getValue().get(ii), 0, addPacket.getNodeData(), SIZE_NODE_HEAD+(ii*SIZE_STATUS_DATA), SIZE_STATUS_DATA);
|
|
System.arraycopy(entry.getValue().get(ii), 0, addPacket.getNodeData(), SIZE_NODE_HEAD+(ii*SIZE_STATUS_DATA), SIZE_STATUS_DATA);
|
|
|
}
|
|
}
|
|
|
makeAddNodeCvimPaket(addPacket, addPacket.getNodeData());
|
|
makeAddNodeCvimPaket(addPacket, addPacket.getNodeData());
|
|
|
- addNodes.add(addPacket);
|
|
|
|
|
|
|
+ this.addNodes.add(addPacket);
|
|
|
}
|
|
}
|
|
|
/*
|
|
/*
|
|
|
log.error(" RAW: {}, {}", this.nodeId, HexString.fromBytes(getBuf()));
|
|
log.error(" RAW: {}, {}", this.nodeId, HexString.fromBytes(getBuf()));
|
|
@@ -439,7 +311,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public TcsNodeStatus getNodeStatus() {
|
|
public TcsNodeStatus getNodeStatus() {
|
|
|
- int nodeLength = this.buf.length - TsiCpuPacket.SIZE_IPC_SIZE;
|
|
|
|
|
|
|
+ int nodeLength = this.buf.length - SIZE_IPC_SIZE;
|
|
|
byte[] msec = new byte[8];
|
|
byte[] msec = new byte[8];
|
|
|
byte[] nsec = new byte[8];
|
|
byte[] nsec = new byte[8];
|
|
|
System.arraycopy(this.cvimData, 0, msec, 0, 8);
|
|
System.arraycopy(this.cvimData, 0, msec, 0, 8);
|
|
@@ -452,8 +324,8 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
|
|
|
|
|
long milliSeconds = byteMSec.getLong();
|
|
long milliSeconds = byteMSec.getLong();
|
|
|
long nanoSeconds = byteNSec.getLong();
|
|
long nanoSeconds = byteNSec.getLong();
|
|
|
- this.remoteIp = ByteUtils.getUnsignedInt(this.cvimData, TsiCpuPacket.POS_IPC_IPADDR);
|
|
|
|
|
- this.remotePort = ByteUtils.getUnsignedShort(this.cvimData, TsiCpuPacket.POS_IPC_PORT);
|
|
|
|
|
|
|
+ this.remoteIp = ByteUtils.getUnsignedInt(this.cvimData, POS_IPC_IPADDR);
|
|
|
|
|
+ this.remotePort = ByteUtils.getUnsignedShort(this.cvimData, POS_IPC_PORT);
|
|
|
|
|
|
|
|
/////
|
|
/////
|
|
|
getTimespec().tv_nsec(nanoSeconds); // recv tcp,
|
|
getTimespec().tv_nsec(nanoSeconds); // recv tcp,
|
|
@@ -463,7 +335,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
sdf.setTimeZone(java.util.TimeZone.getTimeZone("GMT+9"));
|
|
sdf.setTimeZone(java.util.TimeZone.getTimeZone("GMT+9"));
|
|
|
String collectTime = sdf.format(date);
|
|
String collectTime = sdf.format(date);
|
|
|
|
|
|
|
|
- if (this.cvimData[TsiCpuPacket.POS_IPC_CONNECT] == TsiCpuPacket.DISCONNECT) {
|
|
|
|
|
|
|
+ if (this.cvimData[POS_IPC_CONNECT] == DISCONNECT) {
|
|
|
return TcsNodeStatus.builder()
|
|
return TcsNodeStatus.builder()
|
|
|
._id(this.nodeId)
|
|
._id(this.nodeId)
|
|
|
.nodeId(this.nodeId)
|
|
.nodeId(this.nodeId)
|
|
@@ -472,7 +344,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
.build();
|
|
.build();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (nodeLength < TsiCpuPacket.SIZE_HEAD + TsiCpuPacket.SIZE_STATUS_HDR) {
|
|
|
|
|
|
|
+ if (nodeLength < SIZE_HEAD + SIZE_STATUS_HDR) {
|
|
|
// packet error
|
|
// packet error
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
@@ -491,27 +363,27 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
//int length = ByteUtils.getUnsignedShort(this.nodeData, TsiCpuPacket.INDEX_LENGTH);
|
|
//int length = ByteUtils.getUnsignedShort(this.nodeData, TsiCpuPacket.INDEX_LENGTH);
|
|
|
//int count = (int)(this.nodeData[TsiCpuPacket.INDEX_STATUS_HDR+3] & 0x7F);
|
|
//int count = (int)(this.nodeData[TsiCpuPacket.INDEX_STATUS_HDR+3] & 0x7F);
|
|
|
|
|
|
|
|
- byte control = this.cvimData[TsiCpuPacket.SIZE_IPC_SIZE+TsiCpuPacket.INDEX_STATUS_HDR+0];
|
|
|
|
|
|
|
+ byte control = this.cvimData[SIZE_IPC_SIZE + INDEX_STATUS_HDR];
|
|
|
tscControlInfo.inManualControl = ((control ) & 0x01) == 0x01; //수동;
|
|
tscControlInfo.inManualControl = ((control ) & 0x01) == 0x01; //수동;
|
|
|
tscControlInfo.inFlashingControl = ((control >> 1) & 0x01) == 0x01; //점멸;
|
|
tscControlInfo.inFlashingControl = ((control >> 1) & 0x01) == 0x01; //점멸;
|
|
|
tscControlInfo.inLightsOutControl = ((control >> 2) & 0x01) == 0x01; //소등
|
|
tscControlInfo.inLightsOutControl = ((control >> 2) & 0x01) == 0x01; //소등
|
|
|
tscControlInfo.inActuationControl = ((control >> 3) & 0x01) == 0x01; //감응;
|
|
tscControlInfo.inActuationControl = ((control >> 3) & 0x01) == 0x01; //감응;
|
|
|
tscControlInfo.inTransitionControl = ((control >> 4) & 0x01) == 0x01; //전이;
|
|
tscControlInfo.inTransitionControl = ((control >> 4) & 0x01) == 0x01; //전이;
|
|
|
|
|
|
|
|
- byte abnormal = this.cvimData[TsiCpuPacket.SIZE_IPC_SIZE+TsiCpuPacket.INDEX_STATUS_HDR+1];
|
|
|
|
|
|
|
+ byte abnormal = this.cvimData[SIZE_IPC_SIZE + INDEX_STATUS_HDR + 1];
|
|
|
tscAbnormalInfo.inSignalConflict = ((abnormal ) & 0x01) == 0x01; //모순상태;
|
|
tscAbnormalInfo.inSignalConflict = ((abnormal ) & 0x01) == 0x01; //모순상태;
|
|
|
tscAbnormalInfo.inCenterComm = ((abnormal >> 1) & 0x01) == 0x01; //센터상태;
|
|
tscAbnormalInfo.inCenterComm = ((abnormal >> 1) & 0x01) == 0x01; //센터상태;
|
|
|
tscAbnormalInfo.inScuComm = ((abnormal >> 2) & 0x01) == 0x01; //SCU 상태
|
|
tscAbnormalInfo.inScuComm = ((abnormal >> 2) & 0x01) == 0x01; //SCU 상태
|
|
|
|
|
|
|
|
- cycleElapsedTime = (int)(this.cvimData[TsiCpuPacket.SIZE_IPC_SIZE+TsiCpuPacket.INDEX_STATUS_HDR+2] & 0xFF);
|
|
|
|
|
|
|
+ cycleElapsedTime = (int)(this.cvimData[SIZE_IPC_SIZE + INDEX_STATUS_HDR + 2] & 0xFF);
|
|
|
|
|
|
|
|
- byte stts = this.cvimData[TsiCpuPacket.SIZE_IPC_SIZE+TsiCpuPacket.INDEX_STATUS_HDR+3];;
|
|
|
|
|
|
|
+ byte stts = this.cvimData[SIZE_IPC_SIZE + INDEX_STATUS_HDR + 3];;
|
|
|
signalStatusInfoCount = (int)(stts & 0x7F);
|
|
signalStatusInfoCount = (int)(stts & 0x7F);
|
|
|
//divFlag = (int)((stts >> 7) & 0x01);
|
|
//divFlag = (int)((stts >> 7) & 0x01);
|
|
|
|
|
|
|
|
- localTime = ByteUtils.getUnsignedInt(this.cvimData, TsiCpuPacket.SIZE_IPC_SIZE+TsiCpuPacket.INDEX_STATUS_HDR+4);
|
|
|
|
|
|
|
+ localTime = ByteUtils.getUnsignedInt(this.cvimData, SIZE_IPC_SIZE + INDEX_STATUS_HDR + 4);
|
|
|
|
|
|
|
|
- int ii = TsiCpuPacket.SIZE_IPC_SIZE+TsiCpuPacket.INDEX_STATUS_DATA;
|
|
|
|
|
|
|
+ int ii = SIZE_IPC_SIZE + INDEX_STATUS_DATA;
|
|
|
|
|
|
|
|
for (int idx = 0; idx < signalStatusInfoCount; idx++) {
|
|
for (int idx = 0; idx < signalStatusInfoCount; idx++) {
|
|
|
TsiCvimStatus status = new TsiCvimStatus();
|
|
TsiCvimStatus status = new TsiCvimStatus();
|
|
@@ -539,7 +411,7 @@ public class TsiCpuPacket extends AbstractTsiPacket {
|
|
|
|
|
|
|
|
signalStatusInfos.add(status);
|
|
signalStatusInfos.add(status);
|
|
|
|
|
|
|
|
- ii += TsiCpuPacket.SIZE_STATUS_DATA;
|
|
|
|
|
|
|
+ ii += SIZE_STATUS_DATA;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
date = new Date(localTime * 1000L);
|
|
date = new Date(localTime * 1000L);
|