Commit 70b10868 by Corey Koval

Separated Refresh of TX and RX CZML Data

parent 684d30e8
......@@ -5,8 +5,6 @@ function updateAoi(callBack, id) {
fetch("/interest_areas")
.then(data => { return data.json() })
.then(res => { callBack(res, id);
// console.log("updateRx Complete");
console.log(res);
})
}
......@@ -28,11 +26,11 @@ function makeNewAoi(aoi_type, latitude, longitude, radius) {
body: JSON.stringify(new_aoi),
method: "PUT"
};
clearOld();
// clearOld();
fetch("/interest_areas/new", otherParams)
.then(res => {
updateAoi(createAois, true);
loadAllCzml();
reloadRX();
})
}
......@@ -49,12 +47,12 @@ function deleteAoi(uid) {
body: JSON.stringify(del_aoi),
method: "PUT"
};
clearOld();
// clearOld();
fetch("/interest_areas/del", otherParams)
.then(res => {
// removerx(uid);
loadAoi(createAois);
loadAllCzml();
reloadRX();
})
}
......@@ -71,12 +69,12 @@ function purgeAoi(uid) {
body: JSON.stringify(del_aoi),
method: "PUT"
};
clearOld();
// clearOld();
fetch("/interest_areas/purge", otherParams)
.then(res => {
// removerx(uid);
loadAoi(createAois);
loadAllCzml();
reloadRX();
})
}
......@@ -84,12 +82,12 @@ function purgeAoi(uid) {
// * Runs all AOI rules on the backend and Reloads Map
// *******************************************
function runAoi(uid) {
clearOld();
// clearOld();
fetch("/run_all_aoi_rules")
.then(res => {
// removerx(uid);
loadAoi(createAois);
loadAllCzml();
reloadRX();
})
}
......
// Update Map every n milliseconds
var refreshrate = 600000;
// var autoRefresh = setInterval(function () { updateParams(); }, refreshrate);
var refreshrate = 5000;
var autoRefresh = setInterval(function () { reloadRX(); }, refreshrate);
// *************************************************
// * Gets Rx data from backend
......@@ -64,7 +64,7 @@ function editReceivers(rx_json, id) {
var isSingleCheck;
var editButton = document.getElementById(id + "-edit");
if (editButton.checked) {
// clearInterval(autoRefresh);
clearInterval(autoRefresh);
let isMobile = "";
if (receivers[id].mobile) isMobile = "checked";
let isInverted = "";
......@@ -106,7 +106,7 @@ function editReceivers(rx_json, id) {
// }
// }
} else {
// autoRefresh = setInterval(function () { updateParams(); }, refreshrate);
autoRefresh = setInterval(function () { reloadRX(); }, refreshrate);
isMobileCheck = document.getElementById("mobilerx_toggle_" + id);
if (isMobileCheck.checked) {
receivers[id].mobile = true;
......@@ -139,11 +139,11 @@ function editReceivers(rx_json, id) {
body: JSON.stringify(receivers[id]),
method: "PUT"
};
clearOld();
// clearOld();
fetch("/rx_params/" + id, otherParams)
.then(res => {
updateRx(showReceivers, id);
loadAllCzml();
reloadRX();
})
}
}
......@@ -161,11 +161,11 @@ function makeNewRx(url) {
body: JSON.stringify(new_rx),
method: "PUT"
};
clearOld();
// clearOld();
fetch("/rx_params/new", otherParams)
.then(res => {
updateRx(createReceivers, true);
loadAllCzml();
reloadRX();
})
}
......@@ -197,12 +197,12 @@ function deleteReceiver(uid) {
body: JSON.stringify(del_rx),
method: "PUT"
};
clearOld();
// clearOld();
fetch("/rx_params/del", otherParams)
.then(res => {
// removerx(uid);
loadRx(createReceivers);
loadAllCzml();
reloadRX();
})
}
......@@ -218,11 +218,11 @@ function activateReceiver(uid, state) {
body: JSON.stringify(activate_rx),
method: "PUT"
};
clearOld();
// clearOld();
fetch("/rx_params/activate", otherParams)
.then(res => {
loadRx(refreshRx);
loadAllCzml();
reloadRX();
})
}
......
......@@ -24,8 +24,9 @@
// var rxRefreshRate = 5000;
// var autoRxRefresh = setInterval(function () { reloadRX(); }, rxRefreshRate);
var transmittersDataSource;
var receiversDataSource;
var transmittersDataSource = new Cesium.CzmlDataSource;
var receiversDataSource = new Cesium.CzmlDataSource;
// Your access token can be found at: https://cesium.com/ion/tokens.
// Cesium.Ion.defaultAccessToken = '{{access_token}}';
// var hpr = new Cesium.HeadingPitchRange(0, 40, 0)
......@@ -190,26 +191,23 @@
}
function updateParams(parameter) {
clearOld();
fetch("/update?"+parameter)
.then(function(response) {
if (response.status == 200) {
loadRx(refreshRx);
clearOld();
loadAllCzml();
// console.log(response);
}
})
}
function loadTxCzml() {
transmittersDataSource = Cesium.CzmlDataSource.load('/output.czml');
transmittersDataSource.load('/output.czml');
viewer.dataSources.add(transmittersDataSource);
// console.log("Loaded CZML");
return transmittersDataSource;
}
function loadRxCzml() {
receiversDataSource = Cesium.CzmlDataSource.load('/receivers.czml');
receiversDataSource.load('/receivers.czml');
viewer.dataSources.add(receiversDataSource);
// console.log("Loaded CZML");
return receiversDataSource;
......@@ -226,8 +224,10 @@
// console.log("Cleared old");
}
// Add Cesium OSM Buildings, a global 3D buildings layer.
// const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
function reloadRX() {
viewer.dataSources.remove(receiversDataSource, true);
loadRxCzml();
}
</script>
<div id="cardsmenu">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment