From 50613a417530808841e22e53c6b5e13c3ade8c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?qkr7828=28=EB=B0=95=EC=9E=AC=EC=9A=B0=29?= Date: Tue, 16 May 2023 14:17:30 +0900 Subject: [PATCH] . --- .env.development | 4 +- test/pav-utils.js | 22 +++++++++- test/pav-warning copy 2.js | 89 ++++++++++++++++++++++++++++++++++++++ test/pav-warning copy 3.js | 87 +++++++++++++++++++++++++++++++++++++ test/pav-warning copy 4.js | 87 +++++++++++++++++++++++++++++++++++++ test/pav-warning copy.js | 88 +++++++++++++++++++++++++++++++++++++ 6 files changed, 374 insertions(+), 3 deletions(-) create mode 100644 test/pav-warning copy 2.js create mode 100644 test/pav-warning copy 3.js create mode 100644 test/pav-warning copy 4.js create mode 100644 test/pav-warning copy.js diff --git a/.env.development b/.env.development index 428207d..a19bc27 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,5 @@ -REACT_APP_HOST = http://192.168.0.26:8080/ -REACT_APP_WS_HOST = ws://192.168.0.26:8081/ws +REACT_APP_HOST = http://192.168.0.30:8080/ +REACT_APP_WS_HOST = ws://192.168.0.30:8081/ws REACT_APP_IMAGE_HOST = https://palnet-file.s3.ap-northeast-2.amazonaws.com/ diff --git a/test/pav-utils.js b/test/pav-utils.js index c7d10aa..0e858c2 100644 --- a/test/pav-utils.js +++ b/test/pav-utils.js @@ -44,6 +44,10 @@ const getCoordsFormBetweenCoord = (coord1, coord2, dist) => { const currentDist = currentDivDist * i; let x = coord1[0]; let y = coord1[1]; + // var heading = Math.atan2(dy, dx) * 180 / Math.PI; + // if (heading < 0) { + // heading += 360; + // } if (dx === 0) { y += currentDist * singY; } else if (dy === 0) { @@ -53,13 +57,29 @@ const getCoordsFormBetweenCoord = (coord1, coord2, dist) => { x += Math.cos(angle) * currentDist; y += Math.sin(angle) * currentDist; } - r.push([x, y]); + const heading = calculateHeading( + r[r.length - 1][0], + r[r.length - 1][1], + x, + y + ); + r.push([x, y, heading]); } // 마지막 좌표 r.push(coord2); return r; }; +function calculateHeading(x1, y1, x2, y2) { + var dx = x2 - x1; + var dy = y2 - y1; + var heading = (Math.atan2(dy, dx) * 180) / Math.PI; + if (heading < 0) { + heading += 360; + } + return heading; +} + const dumyData = { authKey: '1cc2e08e-0c5c-43b2-8d4d-cddd3de558e3', terminalId: 'SANDBOX-01', diff --git a/test/pav-warning copy 2.js b/test/pav-warning copy 2.js new file mode 100644 index 0000000..6373665 --- /dev/null +++ b/test/pav-warning copy 2.js @@ -0,0 +1,89 @@ +const { getConnection, writeData } = require('./pav-client'); +const { getCoordsFormBetweenCoord, dumyData } = require('./pav-utils'); + +// const host = '192.168.0.30'; +// const host = "localhost" +const host = '211.253.38.218'; +const port = 8082; + +// 기본정보 +const prefix = 'PALUTM-'; + +const pathSampleCoord = [ + [37.3450207, 126.6296542], + [37.2521693, 126.3218456], + [37.237675, 126.1280807], + [37.2521693, 126.3218456], + [37.3450207, 126.6296542] +]; +// const pathSampleCoord = [ +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655] +// ]; +const divDist = 10; // [m] + +// 특정거리에 따른 좌표 추출 +const getCoords = coords => { + if (!coords || coords.length < 1) return; + const totalCoords = []; + for (let j = 1; j < 500; j++) { + for (let i = 1; i < coords.length; i++) { + const divCoords = getCoordsFormBetweenCoord( + coords[i - 1], + coords[i], + divDist + ); + + totalCoords.push(...divCoords); + } + } + return totalCoords; +}; + +const getClient = () => { + const dronName = prefix + '002'; + + const client = {}; + client.dronName = dronName; + client.socket = getConnection(dronName, host, port); + client.data = getCoords(pathSampleCoord); + return client; +}; + +const sendData = (client, cnt) => { + const data = { + ...dumyData, + terminalId: client.dronName, + body: [ + { + ...dumyData.body[0], + objectId: client.dronName, + lat: client.data[cnt][0], + lon: client.data[cnt][1], + heading: client.data[cnt][2] + } + ] + }; + writeData(client.socket, JSON.stringify(data)); + iteratorSendData(++cnt); +}; + +const client = getClient(); + +const iteratorSendData = (cnt = 0) => { + if (cnt >= client.data.length) { + client.socket.destroy(); + return; + } + setTimeout(() => sendData(client, cnt), 1000); +}; + +iteratorSendData(); diff --git a/test/pav-warning copy 3.js b/test/pav-warning copy 3.js new file mode 100644 index 0000000..60ab342 --- /dev/null +++ b/test/pav-warning copy 3.js @@ -0,0 +1,87 @@ +const { getConnection, writeData } = require('./pav-client'); +const { getCoordsFormBetweenCoord, dumyData } = require('./pav-utils'); + +// const host = '192.168.0.30'; +// const host = "localhost" +const host = '211.253.38.218'; +const port = 8082; + +// 기본정보 +const prefix = 'PALUTM-'; + +const pathSampleCoord = [ + [37.3450207, 126.6296542], + [37.521245, 126.6107763], + [37.4891845, 126.5513135], + [37.3450207, 126.6296542] +]; +// const pathSampleCoord = [ +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655] +// ]; +const divDist = 10; // [m] + +// 특정거리에 따른 좌표 추출 +const getCoords = coords => { + if (!coords || coords.length < 1) return; + const totalCoords = []; + for (let j = 1; j < 500; j++) { + for (let i = 1; i < coords.length; i++) { + const divCoords = getCoordsFormBetweenCoord( + coords[i - 1], + coords[i], + divDist + ); + totalCoords.push(...divCoords); + } + } + return totalCoords; +}; + +const getClient = () => { + const dronName = prefix + '003'; + + const client = {}; + client.dronName = dronName; + client.socket = getConnection(dronName, host, port); + client.data = getCoords(pathSampleCoord); + return client; +}; + +const sendData = (client, cnt) => { + const data = { + ...dumyData, + terminalId: client.dronName, + body: [ + { + ...dumyData.body[0], + objectId: client.dronName, + lat: client.data[cnt][0], + lon: client.data[cnt][1], + heading: client.data[cnt][2] + } + ] + }; + writeData(client.socket, JSON.stringify(data)); + iteratorSendData(++cnt); +}; + +const client = getClient(); + +const iteratorSendData = (cnt = 0) => { + if (cnt >= client.data.length) { + client.socket.destroy(); + return; + } + setTimeout(() => sendData(client, cnt), 1000); +}; + +iteratorSendData(); diff --git a/test/pav-warning copy 4.js b/test/pav-warning copy 4.js new file mode 100644 index 0000000..4e04354 --- /dev/null +++ b/test/pav-warning copy 4.js @@ -0,0 +1,87 @@ +const { getConnection, writeData } = require('./pav-client'); +const { getCoordsFormBetweenCoord, dumyData } = require('./pav-utils'); + +// const host = '192.168.0.30'; +// const host = "localhost" +const host = '211.253.38.218'; +const port = 8082; + +// 기본정보 +const prefix = 'PALUTM-'; + +const pathSampleCoord = [ + [37.3450207, 126.6296542], + [37.521245, 126.6107763], + [37.4891845, 126.5513135], + [37.3450207, 126.6296542] +]; +// const pathSampleCoord = [ +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655] +// ]; +const divDist = 10; // [m] + +// 특정거리에 따른 좌표 추출 +const getCoords = coords => { + if (!coords || coords.length < 1) return; + const totalCoords = []; + for (let j = 1; j < 500; j++) { + for (let i = 1; i < coords.length; i++) { + const divCoords = getCoordsFormBetweenCoord( + coords[i - 1], + coords[i], + divDist + ); + totalCoords.push(...divCoords); + } + } + return totalCoords; +}; + +const getClient = () => { + const dronName = prefix + '004'; + + const client = {}; + client.dronName = dronName; + client.socket = getConnection(dronName, host, port); + client.data = getCoords(pathSampleCoord); + return client; +}; + +const sendData = (client, cnt) => { + const data = { + ...dumyData, + terminalId: client.dronName, + body: [ + { + ...dumyData.body[0], + objectId: client.dronName, + lat: client.data[cnt][0], + lon: client.data[cnt][1], + heading: client.data[cnt][2] + } + ] + }; + writeData(client.socket, JSON.stringify(data)); + iteratorSendData(++cnt); +}; + +const client = getClient(); + +const iteratorSendData = (cnt = 0) => { + if (cnt >= client.data.length) { + client.socket.destroy(); + return; + } + setTimeout(() => sendData(client, cnt), 1000); +}; + +iteratorSendData(); diff --git a/test/pav-warning copy.js b/test/pav-warning copy.js new file mode 100644 index 0000000..c3fd60f --- /dev/null +++ b/test/pav-warning copy.js @@ -0,0 +1,88 @@ +const { getConnection, writeData } = require('./pav-client'); +const { getCoordsFormBetweenCoord, dumyData } = require('./pav-utils'); + +// const host = '192.168.0.30'; +// const host = "localhost" +const host = '211.253.38.218'; +const port = 8082; + +// 기본정보 +const prefix = 'PALUTM-'; + +const pathSampleCoord = [ + [37.237675, 126.1280807], + [37.2521693, 126.3218456], + [37.3450207, 126.6296542], + [37.2521693, 126.3218456], + [37.237675, 126.1280807] +]; +// const pathSampleCoord = [ +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655], +// [42.5515, 126.655] +// ]; +const divDist = 10; // [m] + +// 특정거리에 따른 좌표 추출 +const getCoords = coords => { + if (!coords || coords.length < 1) return; + const totalCoords = []; + for (let j = 1; j < 500; j++) { + for (let i = 1; i < coords.length; i++) { + const divCoords = getCoordsFormBetweenCoord( + coords[i - 1], + coords[i], + divDist + ); + totalCoords.push(...divCoords); + } + } + return totalCoords; +}; + +const getClient = () => { + const dronName = prefix + '001'; + + const client = {}; + client.dronName = dronName; + client.socket = getConnection(dronName, host, port); + client.data = getCoords(pathSampleCoord); + return client; +}; + +const sendData = (client, cnt) => { + const data = { + ...dumyData, + terminalId: client.dronName, + body: [ + { + ...dumyData.body[0], + objectId: client.dronName, + lat: client.data[cnt][0], + lon: client.data[cnt][1], + heading: client.data[cnt][2] + } + ] + }; + writeData(client.socket, JSON.stringify(data)); + iteratorSendData(++cnt); +}; + +const client = getClient(); + +const iteratorSendData = (cnt = 0) => { + if (cnt >= client.data.length) { + client.socket.destroy(); + return; + } + setTimeout(() => sendData(client, cnt), 1000); +}; + +iteratorSendData();