Commit 6ad49ac3 by Corey Koval

Added option to invert bearing.

parent 0094ed8f
# DF Aggregator # DF Aggregator
## New Features December 2020: ## New Features December 2020:
- Added option to invert (uninvert?) the DOA bearing. If you're using a KerberosSDR,
keep this option checked.
- LOBs are drawn for each receiver. The orange lines extending from each receiver - LOBs are drawn for each receiver. The orange lines extending from each receiver
show the direction the signal is coming from. Currently the line is fixed to 40km show the direction the signal is coming from. Currently the line is fixed to 40km
draw distance. draw distance.
......
...@@ -20,7 +20,7 @@ from czml3 import Packet, Document, Preamble ...@@ -20,7 +20,7 @@ from czml3 import Packet, Document, Preamble
from czml3.properties import Position, Polyline, PolylineOutlineMaterial, Color, Material from czml3.properties import Position, Polyline, PolylineOutlineMaterial, Color, Material
from bottle import route, run, request, get, post, put, response, redirect, template, static_file from bottle import route, run, request, get, post, put, response, redirect, template, static_file
d = 40000 #meters d = 40000 #draw distance of LOBs in meters
receivers = [] receivers = []
############################################### ###############################################
...@@ -46,8 +46,10 @@ class receiver: ...@@ -46,8 +46,10 @@ class receiver:
self.isAuto = True self.isAuto = True
# hashed_url = hashlib.md5(station_url.encode('utf-8')).hexdigest() # hashed_url = hashlib.md5(station_url.encode('utf-8')).hexdigest()
# self.uid = hashed_url[:5] + hashed_url[-5:] # self.uid = hashed_url[:5] + hashed_url[-5:]
self.update(first_run=True)
self.isActive = True self.isActive = True
self.flipped = False
self.inverted = True
self.update(first_run=True)
# Updates receiver from the remote URL # Updates receiver from the remote URL
def update(self, first_run=False): def update(self, first_run=False):
...@@ -68,7 +70,12 @@ class receiver: ...@@ -68,7 +70,12 @@ class receiver:
self.heading = float(xml_heading.text) self.heading = float(xml_heading.text)
xml_doa = xml_contents.find('DOA') xml_doa = xml_contents.find('DOA')
self.raw_doa = float(xml_doa.text) self.raw_doa = float(xml_doa.text)
self.doa = self.heading + (360 - self.raw_doa) if self.inverted:
self.doa = self.heading + (360 - self.raw_doa)
elif self.flipped:
self.doa = self.heading + (180 + self.raw_doa)
else:
self.doa = self.heading + self.raw_doa
if self.doa < 0: if self.doa < 0:
self.doa += 360 self.doa += 360
elif self.doa > 359: elif self.doa > 359:
...@@ -79,7 +86,7 @@ class receiver: ...@@ -79,7 +86,7 @@ class receiver:
self.confidence = int(xml_conf.text) self.confidence = int(xml_conf.text)
except KeyboardInterrupt: except KeyboardInterrupt:
finish() finish()
except: except Exception as ex:
if first_run: if first_run:
self.station_id = "Unknown" self.station_id = "Unknown"
self.latitude = 0.0 self.latitude = 0.0
...@@ -92,6 +99,7 @@ class receiver: ...@@ -92,6 +99,7 @@ class receiver:
self.confidence = 0 self.confidence = 0
self.doa_time = 0 self.doa_time = 0
self.isActive = False self.isActive = False
print(ex)
print(f"Problem connecting to {self.station_url}, receiver deactivated. Reactivate in WebUI.") print(f"Problem connecting to {self.station_url}, receiver deactivated. Reactivate in WebUI.")
# raise IOError # raise IOError
...@@ -102,7 +110,7 @@ class receiver: ...@@ -102,7 +110,7 @@ class receiver:
'latitude':self.latitude, 'longitude':self.longitude, 'heading':self.heading, 'latitude':self.latitude, 'longitude':self.longitude, 'heading':self.heading,
'doa':self.doa, 'frequency':self.frequency, 'power':self.power, 'doa':self.doa, 'frequency':self.frequency, 'power':self.power,
'confidence':self.confidence, 'doa_time':self.doa_time, 'mobile': self.isMobile, 'confidence':self.confidence, 'doa_time':self.doa_time, 'mobile': self.isMobile,
'active':self.isActive, 'auto':self.isAuto}) 'active':self.isActive, 'auto':self.isAuto, 'inverted':self.inverted})
latitude = 0.0 latitude = 0.0
longitude = 0.0 longitude = 0.0
...@@ -532,11 +540,19 @@ def rx_params(): ...@@ -532,11 +540,19 @@ def rx_params():
response.headers['Content-Type'] = 'application/json' response.headers['Content-Type'] = 'application/json'
return json.dumps(all_rx) return json.dumps(all_rx)
###############################################
# Returns a CZML file that contains intersect
# and ellipse information for Cesium.
###############################################
@get('/output.czml') @get('/output.czml')
def tx_czml_out(): def tx_czml_out():
output = write_czml(*process_data(database_name, geofile)) output = write_czml(*process_data(database_name, geofile))
return str(output) return str(output)
###############################################
# Returns a CZML file that contains receiver
# and LOB information for Cesium.
###############################################
@get('/receivers.czml') @get('/receivers.czml')
def rx_czml_out(): def rx_czml_out():
output = write_rx_czml() output = write_rx_czml()
...@@ -564,7 +580,8 @@ def update_rx(action): ...@@ -564,7 +580,8 @@ def update_rx(action):
action = int(action) action = int(action)
try: try:
receivers[action].isMobile = data['mobile'] receivers[action].isMobile = data['mobile']
receivers[action].station_url = data['station_url'] receivers[action].inverted = data['inverted']
# receivers[action].station_url = data['station_url']
receivers[action].update() receivers[action].update()
update_rx_table() update_rx_table()
except IndexError: except IndexError:
......
...@@ -57,15 +57,22 @@ function editReceivers(rx_json, id) { ...@@ -57,15 +57,22 @@ function editReceivers(rx_json, id) {
"Frequency:<input style=\"width: 105px;\" type=\"text\" value=\"" + receivers[id].frequency + "\" name=\"frequency_" + id + "\" />"; "Frequency:<input style=\"width: 105px;\" type=\"text\" value=\"" + receivers[id].frequency + "\" name=\"frequency_" + id + "\" />";
var mobile = id + "-mobile"; var mobile = id + "-mobile";
var editButton = document.getElementById(id + "-edit");
var isMobileCheck = document.getElementById("mobilerx_toggle_" + id); var isMobileCheck = document.getElementById("mobilerx_toggle_" + id);
var isInvertedCheck;
var editButton = document.getElementById(id + "-edit");
if (editButton.checked) { if (editButton.checked) {
clearInterval(autoRefresh); clearInterval(autoRefresh);
let isMobile = ""; let isMobile = "";
if (receivers[id].mobile) isMobile = "checked"; if (receivers[id].mobile) isMobile = "checked";
let isInverted = "";
if (receivers[id].inverted) isInverted = "checked";
document.getElementById(id + "-editicon").innerHTML = "save"; document.getElementById(id + "-editicon").innerHTML = "save";
document.getElementById(mobile).innerHTML = document.getElementById(mobile).innerHTML =
"Mobile Receiver: <input " + isMobile + " id=\"mobilerx_toggle_" + id + "\" type=\"checkbox\" />"; "Mobile Receiver: <input " + isMobile + " id=\"mobilerx_toggle_" + id + "\" type=\"checkbox\" />";
document.getElementById(id + "-invert").innerHTML =
"Inverted DOA: <input " + isInverted + " id=\"invert_toggle_" + id + "\" type=\"checkbox\" />";
isInvertedCheck = document.getElementById("invert_toggle_" + id);
isInvertedCheck.setAttribute("title", "KerberosSDR users keep this checked.");
// document.getElementById(id + "-manual").innerHTML = edit_manualInfo; // document.getElementById(id + "-manual").innerHTML = edit_manualInfo;
// // document.getElementById(id + "-url").innerHTML = edit_stationUrlHtml; // // document.getElementById(id + "-url").innerHTML = edit_stationUrlHtml;
// document.getElementById("manual_toggle_" + id).onchange = function() { // document.getElementById("manual_toggle_" + id).onchange = function() {
...@@ -89,6 +96,13 @@ function editReceivers(rx_json, id) { ...@@ -89,6 +96,13 @@ function editReceivers(rx_json, id) {
} else { } else {
receivers[id].mobile = false; receivers[id].mobile = false;
} }
isInvertedCheck = document.getElementById("invert_toggle_" + id);
if (isInvertedCheck.checked) {
receivers[id].inverted = true;
} else {
receivers[id].inverted = false;
}
const otherParams = { const otherParams = {
headers: { headers: {
"content-type": "application/json" "content-type": "application/json"
...@@ -210,6 +224,7 @@ function showReceivers(rx_json, id) { ...@@ -210,6 +224,7 @@ function showReceivers(rx_json, id) {
const urlspan = document.getElementById(id + "-url"); const urlspan = document.getElementById(id + "-url");
const mobilespan = document.getElementById(id + "-mobile"); const mobilespan = document.getElementById(id + "-mobile");
const invertspan = document.getElementById(id + "-invert");
// const manualspan = document.getElementById(id + "-manual"); // const manualspan = document.getElementById(id + "-manual");
const idspan = document.getElementById(id + "-id"); const idspan = document.getElementById(id + "-id");
const locationspan = document.getElementById(id + "-location"); const locationspan = document.getElementById(id + "-location");
...@@ -228,7 +243,9 @@ function showReceivers(rx_json, id) { ...@@ -228,7 +243,9 @@ function showReceivers(rx_json, id) {
.setAttribute("title", "Click to enable this receiver."); .setAttribute("title", "Click to enable this receiver.");
} }
document.getElementById(id + "-mobile").innerHTML = ""; // document.getElementById(id + "-mobile").innerHTML = "";
mobilespan.innerHTML = "";
invertspan.innerHTML = "";
document.getElementById(id + "-editicon").innerHTML = "edit"; document.getElementById(id + "-editicon").innerHTML = "edit";
// document.getElementById(id + "-manual").innerHTML = manualInfo; // document.getElementById(id + "-manual").innerHTML = manualInfo;
// document.getElementById(id + "-url").innerHTML = stationUrlHtml; // document.getElementById(id + "-url").innerHTML = stationUrlHtml;
...@@ -255,6 +272,7 @@ function createReceivers(rx_json, id) { ...@@ -255,6 +272,7 @@ function createReceivers(rx_json, id) {
// const urlspan = document.createElement('span'); // const urlspan = document.createElement('span');
const mobilespan = document.createElement('span'); const mobilespan = document.createElement('span');
const invertspan = document.createElement('span');
// const manualspan = document.createElement('span'); // const manualspan = document.createElement('span');
const idspan = document.createElement('span'); const idspan = document.createElement('span');
const locationspan = document.createElement('span'); const locationspan = document.createElement('span');
...@@ -304,6 +322,7 @@ function createReceivers(rx_json, id) { ...@@ -304,6 +322,7 @@ function createReceivers(rx_json, id) {
// urlspan.id = receivers[i].uid + "-url"; // urlspan.id = receivers[i].uid + "-url";
mobilespan.id = receivers[i].uid + "-mobile"; mobilespan.id = receivers[i].uid + "-mobile";
invertspan.id = receivers[i].uid + "-invert";
// manualspan.id = receivers[i].uid + "-manual"; // manualspan.id = receivers[i].uid + "-manual";
idspan.id = receivers[i].uid + "-id"; idspan.id = receivers[i].uid + "-id";
locationspan.id = receivers[i].uid + "-location"; locationspan.id = receivers[i].uid + "-location";
...@@ -314,6 +333,7 @@ function createReceivers(rx_json, id) { ...@@ -314,6 +333,7 @@ function createReceivers(rx_json, id) {
// rxcard.appendChild(urlspan); // rxcard.appendChild(urlspan);
rxcard.appendChild(mobilespan); rxcard.appendChild(mobilespan);
rxcard.appendChild(invertspan);
// rxcard.appendChild(manualspan); // rxcard.appendChild(manualspan);
rxcard.appendChild(idspan); rxcard.appendChild(idspan);
rxcard.appendChild(locationspan); rxcard.appendChild(locationspan);
......
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