Commit c1cf0ef6 by Corey Koval

Receiver handling improvements

parent b3aa7c67
# DF Aggregator
## New Features 1 December 2020:
- Receivers can be added from the WebUI
- Click the + at the bottom of the receiver cards, enter the URL, click save.
Click the refresh button to update the cards and map.
- A list of receiver URLs is now optional. Receivers are saved to the database.
- Receivers are read from the database first. Duplicate receiver URLs are ignored.
- You can mark a receiver as mobile.
- Click the edit icon for the applicable receiver, click the checkbox to mark
it as mobile, then click save.
- You can now delete receivers from the list. This will remove it from the map
and database. No historical data is affected.
- You can now enable/disable LOB collection from individual receivers.
Click the power button to enable/disable.
- Black is enabled, red is disabled.
- If you lose connectivity to a receiver, that particular receiver will be disabled.
Click the power button to try to reconnect.
## Dependencies:
- Python >= 3.6
- [numpy](https://numpy.org/install/)
......
......@@ -46,15 +46,14 @@ class receiver:
self.isAuto = True
# hashed_url = hashlib.md5(station_url.encode('utf-8')).hexdigest()
# self.uid = hashed_url[:5] + hashed_url[-5:]
try:
self.update()
except:
raise IOError
self.update(first_run=True)
self.isActive = True
# Updates receiver from the remote URL
def update(self):
def update(self, first_run=False):
try:
xml_contents = etree.parse(self.station_url)
if first_run:
xml_station_id = xml_contents.find('STATION_ID')
self.station_id = xml_station_id.text
xml_doa_time = xml_contents.find('TIME')
......@@ -81,7 +80,20 @@ class receiver:
except KeyboardInterrupt:
finish()
except:
raise IOError
if first_run:
self.station_id = "Unknown"
self.latitude = 0.0
self.longitude = 0.0
self.heading = 0.0
self.raw_doa = 0.0
self.doa = 0.0
self.frequency = 0.0
self.power = 0.0
self.confidence = 0
self.doa_time = 0
self.isActive = False
print(f"Problem connecting to {self.station_url}, receiver deactivated. Reactivate in WebUI.")
# raise IOError
# Returns receivers properties as a dict,
# useful for passing data to the WebUI
......@@ -102,7 +114,6 @@ class receiver:
confidence = 0
doa_time = 0
isMobile = False
isActive = True
###############################################
# Converts Lat/Lon to polar coordinates
......@@ -473,9 +484,11 @@ def update_cesium():
###############################################
@get('/rx_params')
def rx_params():
write_czml(*process_data(database_name, geofile))
all_rx = {'receivers':{}}
rx_properties = []
for index, x in enumerate(receivers):
x.update()
rx = x.receiver_dict()
rx['uid'] = index
rx_properties.append(rx)
......@@ -497,6 +510,10 @@ def update_rx(action):
index = int(data['uid'])
del_receiver(receivers[index].station_id)
del receivers[index]
elif action == "activate":
index = int(data['uid'])
receivers[index].isActive = data['state']
# print(f"RX {index} changed state to {data['state']}")
else:
action = int(action)
try:
......@@ -564,10 +581,10 @@ def run_receiver(receivers):
for rx in receivers:
try:
rx.update()
if rx.isActive: rx.update()
except IOError:
print("Problem connecting to receiver.")
ms.receiving = False
# ms.receiving = False
time.sleep(1)
if dots > 5:
......@@ -607,8 +624,9 @@ def add_receiver(receiver_url):
[new_rx['station_id']]).fetchone()[0]
receivers[-1].isMobile = bool(mobile)
print("Created new DF Station at " + receiver_url)
except IOError:
ms.receiving = False
except AttributeError:
pass
conn.close()
###############################################
......@@ -716,7 +734,6 @@ if __name__ == '__main__':
###############################################
read_rx_table()
if rx_file:
print("I got a file!")
with open(rx_file, "r") as file2:
receiver_list = file2.readlines()
for x in receiver_list:
......
......@@ -110,6 +110,21 @@ body {
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0);
}
#add_station {
width: 23px;
height: 23px;
}
#new_rx_div {
position: relative;
background: #d4d4d4;
color: #111;
font-weight: bold;
padding: 5px;
margin: 5px;
vertical-align: middle;
}
.receiver {
position: relative;
background: #d4d4d4;
......@@ -138,6 +153,20 @@ body {
font-size: 23pt;
}
.delete-icon {
display: block;
position: absolute;
top: 5px;
right: 30px;
}
.activate-icon {
display: block;
position: absolute;
top: 5px;
right: 60px;
}
.edit-checkbox {
cursor: pointer;
opacity: 0; /* hide this */
......@@ -146,13 +175,6 @@ body {
height: 20px;
}
.delete-icon {
display: block;
position: absolute;
top: 5px;
right: 30px;
}
.no-select {
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
......
......@@ -37,7 +37,7 @@
loadRx(refreshRx);
clearOld();
loadCzml();
console.log(response);
// console.log(response);
}
})
}
......@@ -45,13 +45,13 @@
function loadCzml() {
var dataSourcePromise = Cesium.CzmlDataSource.load('/static/output.czml');
viewer.dataSources.add(dataSourcePromise);
console.log("Loaded CZML");
// console.log("Loaded CZML");
return dataSourcePromise;
}
function clearOld() {
viewer.dataSources.removeAll(true);
console.log("Cleared old");
// console.log("Cleared old");
}
// Add Cesium OSM Buildings, a global 3D buildings layer.
......@@ -71,7 +71,7 @@
<input id="add_station" class="edit-checkbox add-icon" type="checkbox" style="width: 23px; height: 23px;"/>
<span id="add_station_icon" class="material-icons add-icon no-select">add_circle_outline</span>
<div style="visibility: hidden; height: 0;" id="new_rx_div" style="padding: 0;" class="receiver">
<div style="visibility: hidden; height: 0;" id="new_rx_div" style="padding: 0;">
<span id="new-url">Station URL:
</span>
</div>
......
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