qkr7828(박재우)
1 year ago
6 changed files with 374 additions and 3 deletions
@ -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(); |
@ -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(); |
@ -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(); |
@ -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(); |
Loading…
Reference in new issue