|
|
@@ -1,10 +1,7 @@
|
|
|
package com.its.op.service.its.vds;
|
|
|
|
|
|
import com.its.op.config.VdsServerConfig;
|
|
|
-import com.its.op.dao.repository.its.vds.TbVdsCtlrRepository;
|
|
|
import com.its.op.dto.its.vds.VdsControlDto;
|
|
|
-import com.its.op.entity.its.vds.TbVdsCtlr;
|
|
|
-import com.its.op.xnettcp.client.VdsCommClientService;
|
|
|
import com.its.utils.SysUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -19,8 +16,6 @@ import java.net.SocketAddress;
|
|
|
import java.nio.ByteBuffer;
|
|
|
import java.nio.ByteOrder;
|
|
|
import java.util.Base64;
|
|
|
-import java.util.NoSuchElementException;
|
|
|
-import java.util.Optional;
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@@ -28,11 +23,11 @@ import java.util.concurrent.*;
|
|
|
@Service
|
|
|
public class VdsControlService {
|
|
|
|
|
|
- private final VdsCommClientService vdsCommClientService;
|
|
|
+ //private final VdsCommClientService vdsCommClientService;
|
|
|
+ //private final TbVdsCtlrRepository repo;
|
|
|
private final VdsServerConfig vdsServerConfig;
|
|
|
- private final TbVdsCtlrRepository repo;
|
|
|
|
|
|
- private static final int crc16_arc[] = {
|
|
|
+ private static final int[] crc16_arc = {
|
|
|
0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
|
|
|
0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
|
|
|
0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
|
|
|
@@ -69,15 +64,15 @@ public class VdsControlService {
|
|
|
|
|
|
/**
|
|
|
* VDS CRC16-ARC(https://crccalc.com/)
|
|
|
- * @param data
|
|
|
- * @param start
|
|
|
- * @param length
|
|
|
- * @return
|
|
|
+ * @param data : crc data array
|
|
|
+ * @param start : start index
|
|
|
+ * @param length : array length
|
|
|
+ * @return : crc result
|
|
|
*/
|
|
|
public int getCRC16ARC(byte[] data, int start, int length) {
|
|
|
int crc = 0x0000;
|
|
|
for (int ii = start; ii < (start+length); ii++) {
|
|
|
- int b = data[ii];
|
|
|
+ //int b = data[ii];
|
|
|
crc = (crc >> 8) ^ crc16_arc[(crc ^ data[ii]) & 0xff];
|
|
|
}
|
|
|
//log.error("{}", Integer.toHexString(crc));
|
|
|
@@ -85,18 +80,18 @@ public class VdsControlService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- // 데이터 1건 조회, 없으면 exception
|
|
|
- private TbVdsCtlr requireOne(String id) throws NoSuchElementException {
|
|
|
- Optional<TbVdsCtlr> info = this.repo.findById(id);
|
|
|
- if (info.isPresent()) {
|
|
|
- return info.get();
|
|
|
- }
|
|
|
- else {
|
|
|
- throw new NoSuchElementException("데이터가 존재하지 않습니다: " + id);
|
|
|
- }
|
|
|
-// return this.repo.findOne(id)
|
|
|
-// .orElseThrow(() -> new NoSuchElementException("데이터가 존재하지 않습니다: " + id));
|
|
|
- }
|
|
|
+// // 데이터 1건 조회, 없으면 exception
|
|
|
+// private TbVdsCtlr requireOne(String id) throws NoSuchElementException {
|
|
|
+// Optional<TbVdsCtlr> info = this.repo.findById(id);
|
|
|
+// if (info.isPresent()) {
|
|
|
+// return info.get();
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// throw new NoSuchElementException("데이터가 존재하지 않습니다: " + id);
|
|
|
+// }
|
|
|
+//// return this.repo.findOne(id)
|
|
|
+//// .orElseThrow(() -> new NoSuchElementException("데이터가 존재하지 않습니다: " + id));
|
|
|
+// }
|
|
|
|
|
|
public byte[] getCenterPacket(byte opCode, int length) {
|
|
|
|
|
|
@@ -116,12 +111,15 @@ public class VdsControlService {
|
|
|
|
|
|
/**
|
|
|
* VDS Center Communication protocol buffer create
|
|
|
- * @param opCode
|
|
|
- * @param address
|
|
|
- * @return
|
|
|
+ * @param opCode : opcode
|
|
|
+ * @param group : controller group no
|
|
|
+ * @param address : controller address
|
|
|
+ * @param frameNo : current frame no
|
|
|
+ * @param cameraNo : camera no
|
|
|
+ * @return : protocol buffer
|
|
|
*/
|
|
|
public ByteBuffer getCommand(byte opCode, Integer group, Integer address, Integer frameNo, Integer cameraNo) {
|
|
|
- int length = 0;
|
|
|
+ int length;
|
|
|
if (opCode == 0x0C) {
|
|
|
length = 11;
|
|
|
} else if (opCode == 0x16) {
|
|
|
@@ -167,8 +165,9 @@ public class VdsControlService {
|
|
|
|
|
|
/**
|
|
|
* VDS 제어기 리셋
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
+ * @param id : controller id
|
|
|
+ * @param req : request buffer
|
|
|
+ * @return : reset result
|
|
|
*/
|
|
|
public VdsControlDto.VdsControlRes controlReset(String id, VdsControlDto.VdsControlResetReq req) {
|
|
|
//TbVdsCtlr vds = this.requireOne(id);
|
|
|
@@ -388,6 +387,7 @@ public class VdsControlService {
|
|
|
try {
|
|
|
Integer taskResult = future.get(taskTimeout, TimeUnit.MILLISECONDS);
|
|
|
if (taskResult == 0) {
|
|
|
+ log.info("VDS Stop Image Request Task Future Result: {}", taskResult);
|
|
|
}
|
|
|
} catch (InterruptedException e) {
|
|
|
result.setResult(5, "VDS 정지영상 요청 작업 중 인터럽트가 발생하여 작업이 실패하였습니다.");
|
|
|
@@ -413,7 +413,7 @@ public class VdsControlService {
|
|
|
public byte[] receiveBytes(InputStream inStream, int buffSize) throws IOException {
|
|
|
byte[] buffer;
|
|
|
int bytesRead = 0;
|
|
|
- int readThisTime = 0;
|
|
|
+ int readThisTime;
|
|
|
buffer = new byte[buffSize];
|
|
|
while (bytesRead < buffSize)
|
|
|
{
|