Browse Source

관제 테스트파일 - 터미널ID 추가

ctrlDraw
이준희 2 years ago
parent
commit
54d75ab9b5
  1. 22
      src/components/map/naver/feature/FeatureAirZone.js
  2. 105
      test/pav-warning.js

22
src/components/map/naver/feature/FeatureAirZone.js

@ -149,28 +149,28 @@ export const FeatureAirZone = props => {
buffer buffer
); );
let tt = 0; let reduce = 0;
if (j === 0) { if (j === 0) {
tt = 218.6; reduce = 218.6;
} else if (j === 1) { } else if (j === 1) {
tt = 905.4; reduce = 905.4;
} else if (j === 2) { } else if (j === 2) {
tt = 2195; reduce = 2195;
} else if (j === 3) { } else if (j === 3) {
tt = 4560.2; reduce = 4560.2;
} }
if (angle % 180 == 0) { if (angle % 180 == 0) {
const polyES = new naver.maps.Polyline({ const polyEW = new naver.maps.Polyline({
path: [ path: [
new naver.maps.EPSG3857.getDestinationCoord( new naver.maps.EPSG3857.getDestinationCoord(
coord, coord,
90, 90,
SENSOR_RADIUS - tt SENSOR_RADIUS - reduce
), ),
new naver.maps.EPSG3857.getDestinationCoord( new naver.maps.EPSG3857.getDestinationCoord(
coord, coord,
270, 270,
SENSOR_RADIUS - tt SENSOR_RADIUS - reduce
) )
], ],
strokeWeight: 0.8, strokeWeight: 0.8,
@ -184,12 +184,12 @@ export const FeatureAirZone = props => {
new naver.maps.EPSG3857.getDestinationCoord( new naver.maps.EPSG3857.getDestinationCoord(
coord, coord,
0, 0,
SENSOR_RADIUS - tt SENSOR_RADIUS - reduce
), ),
new naver.maps.EPSG3857.getDestinationCoord( new naver.maps.EPSG3857.getDestinationCoord(
coord, coord,
180, 180,
SENSOR_RADIUS - tt SENSOR_RADIUS - reduce
) )
], ],
strokeWeight: 0.8, strokeWeight: 0.8,
@ -214,7 +214,7 @@ export const FeatureAirZone = props => {
strokeColor: color, strokeColor: color,
map: props.map map: props.map
}); });
const ES = new naver.maps.Polyline({ const EW = new naver.maps.Polyline({
path: [ path: [
new naver.maps.EPSG3857.getDestinationCoord( new naver.maps.EPSG3857.getDestinationCoord(
position, position,

105
test/pav-warning.js

@ -2,82 +2,83 @@ const { getConnection, writeData } = require('./pav-client');
const { getCoordsFormBetweenCoord, dumyData } = require('./pav-utils'); const { getCoordsFormBetweenCoord, dumyData } = require('./pav-utils');
// const host = "192.168.0.24" // const host = "192.168.0.24"
const host = "localhost" const host = 'localhost';
// const host = '192.168.0.34'; // const host = '192.168.0.34';
const port = 8082; const port = 8082;
// 기본정보 // 기본정보
const prefix = 'PASANGUU'; const prefix = 'PA';
const terminalId = 'SANDBOX-001';
const pathSampleCoord = [ const pathSampleCoord = [
[37.5215, 126.605], [37.5215, 126.605],
[37.5215, 126.61], [37.5215, 126.61], //비정상, 날릴 것
// [37.5215, 126.6082], // [37.5215, 126.6082], 계획서
[37.521, 126.6082], [37.521, 126.6082],
[37.521, 126.6057], [37.521, 126.6057],
[37.5205, 126.6057], [37.5205, 126.6057],
[37.5205, 126.6082], [37.5205, 126.6082],
[37.52, 126.6082], [37.52, 126.6082],
[37.52, 126.6057], [37.52, 126.6057],
[37.5195, 126.6057], [37.5195, 126.6057],
[37.5195, 126.6082], [37.5195, 126.6082],
[37.519, 126.6082], [37.519, 126.6082],
[37.519, 126.605] [37.519, 126.605]
]; ];
const divDist = 10; // [m] const divDist = 10; // [m]
// 특정거리에 따른 좌표 추출 // 특정거리에 따른 좌표 추출
const getCoords = coords => { const getCoords = coords => {
if (!coords || coords.length < 1) return; if (!coords || coords.length < 1) return;
const totalCoords = []; const totalCoords = [];
for (let i = 1; i < coords.length; i++) { for (let i = 1; i < coords.length; i++) {
const divCoords = getCoordsFormBetweenCoord( const divCoords = getCoordsFormBetweenCoord(
coords[i - 1], coords[i - 1],
coords[i], coords[i],
divDist divDist
); );
totalCoords.push(...divCoords); totalCoords.push(...divCoords);
} }
return totalCoords; return totalCoords;
}; };
const getClient = () => { const getClient = () => {
const dronName = prefix; const dronName = prefix + 'trmnlId';
// const dronName = prefix + '0000001A';
const client = {}; const client = {};
client.dronName = dronName; client.dronName = dronName;
client.socket = getConnection(dronName, host, port); client.socket = getConnection(dronName, host, port);
client.data = getCoords(pathSampleCoord); client.data = getCoords(pathSampleCoord);
return client; return client;
}; };
const sendData = (client, cnt) => { const sendData = (client, cnt) => {
const data = { const data = {
...dumyData, ...dumyData,
terminalId: client.dronName, terminalId: terminalId,
body: [ command: 'SANDBOX',
{ body: [
...dumyData.body[0], {
objectId: client.dronName, ...dumyData.body[0],
lat: client.data[cnt][0], objectId: client.dronName,
lon: client.data[cnt][1] lat: client.data[cnt][0],
} lon: client.data[cnt][1]
] }
}; ]
writeData(client.socket, JSON.stringify(data)); };
iteratorSendData(++cnt); writeData(client.socket, JSON.stringify(data));
iteratorSendData(++cnt);
}; };
const client = getClient(); const client = getClient();
const iteratorSendData = (cnt = 0) => { const iteratorSendData = (cnt = 0) => {
if (cnt >= client.data.length) { if (cnt >= client.data.length) {
client.socket.destroy(); client.socket.destroy();
return; return;
} }
setTimeout(() => sendData(client, cnt), 1000); setTimeout(() => sendData(client, cnt), 1000);
}; };
iteratorSendData(); iteratorSendData();

Loading…
Cancel
Save