Commit 06bc08ee by Corey Koval

Dynamic LOB Length

parent 981a4123
## Recent Changes: ## Recent Changes:
- LOB Length is now determined by the distance to the furthest intersection from
the receiver.
- Fixed bug where map lags behind the receiver.
- Changed the way ellipse and clustering parameters are handled. This allows for - Changed the way ellipse and clustering parameters are handled. This allows for
multi-user map interaction. multi-user map interaction.
- Updated to Cesium 1.79 - Updated to Cesium 1.79
......
# DF Aggregator # DF Aggregator
## Recent Changes: ## Recent Changes:
- LOB Length is now determined by the distance to the furthest intersection from
the receiver.
- Fixed bug where map lags behind the receiver.
- Changed the way ellipse and clustering parameters are handled. This allows for - Changed the way ellipse and clustering parameters are handled. This allows for
multi-user map interaction. multi-user map interaction.
- For previous changes see the [Change Log](CHANGELOG.md). - For previous changes see the [Change Log](CHANGELOG.md).
......
...@@ -55,6 +55,7 @@ class math_settings: ...@@ -55,6 +55,7 @@ class math_settings:
self.min_samp = min_samp self.min_samp = min_samp
self.min_conf = conf self.min_conf = conf
self.min_power = power self.min_power = power
rx_busy = False
receiving = True receiving = True
plotintersects = False plotintersects = False
...@@ -66,8 +67,6 @@ class receiver: ...@@ -66,8 +67,6 @@ class receiver:
def __init__(self, station_url): def __init__(self, station_url):
self.station_url = station_url self.station_url = station_url
self.isAuto = True self.isAuto = True
# hashed_url = hashlib.md5(station_url.encode('utf-8')).hexdigest()
# self.uid = hashed_url[:5] + hashed_url[-5:]
self.isActive = True self.isActive = True
self.flipped = False self.flipped = False
self.inverted = True self.inverted = True
...@@ -124,8 +123,7 @@ class receiver: ...@@ -124,8 +123,7 @@ class receiver:
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
# Returns receivers properties as a dict, # Returns receivers properties as a dict, useful for passing data to the WebUI
# useful for passing data to the WebUI
def receiver_dict(self): def receiver_dict(self):
return ({'station_id': self.station_id, 'station_url': self.station_url, return ({'station_id': self.station_id, 'station_url': self.station_url,
'latitude':self.latitude, 'longitude':self.longitude, 'heading':self.heading, 'latitude':self.latitude, 'longitude':self.longitude, 'heading':self.heading,
...@@ -134,6 +132,12 @@ class receiver: ...@@ -134,6 +132,12 @@ class receiver:
'active':self.isActive, 'auto':self.isAuto, 'inverted':self.inverted, 'active':self.isActive, 'auto':self.isAuto, 'inverted':self.inverted,
'single':self.isSingle}) 'single':self.isSingle})
def lob_length(self):
if self.d_2_last_intersection:
return round(max(self.d_2_last_intersection)) + 200
else:
return d
latitude = 0.0 latitude = 0.0
longitude = 0.0 longitude = 0.0
heading = 0.0 heading = 0.0
...@@ -147,6 +151,7 @@ class receiver: ...@@ -147,6 +151,7 @@ class receiver:
isSingle = False isSingle = False
previous_doa_time = 0 previous_doa_time = 0
last_processed_at = 0 last_processed_at = 0
d_2_last_intersection = [d]
############################################### ###############################################
# Converts Lat/Lon to polar coordinates # Converts Lat/Lon to polar coordinates
...@@ -548,7 +553,7 @@ def write_rx_czml(): ...@@ -548,7 +553,7 @@ def write_rx_czml():
"height": 48, "height": 48,
"width": 48, "width": 48,
} }
while not ms.rx_busy:
for index, x in enumerate(receivers): for index, x in enumerate(receivers):
if x.isActive and ms.receiving: if x.isActive and ms.receiving:
if (x.confidence > min_conf and x.power > min_power): if (x.confidence > min_conf and x.power > min_power):
...@@ -559,7 +564,7 @@ def write_rx_czml(): ...@@ -559,7 +564,7 @@ def write_rx_czml():
lob_color = red lob_color = red
lob_start_lat = x.latitude lob_start_lat = x.latitude
lob_start_lon = x.longitude lob_start_lon = x.longitude
lob_stop_lat, lob_stop_lon = v.direct(lob_start_lat, lob_start_lon, x.doa, d) lob_stop_lat, lob_stop_lon = v.direct(lob_start_lat, lob_start_lon, x.doa, x.lob_length())
lob_packets.append(Packet(id=f"LOB-{x.station_id}-{index}", lob_packets.append(Packet(id=f"LOB-{x.station_id}-{index}",
polyline=Polyline( polyline=Polyline(
material= Material( polylineOutline = material= Material( polylineOutline =
...@@ -863,6 +868,15 @@ def run_receiver(receivers): ...@@ -863,6 +868,15 @@ def run_receiver(receivers):
# Main loop to compute intersections between multiple receivers # Main loop to compute intersections between multiple receivers
intersect_list = np.array([]).reshape(0,3) intersect_list = np.array([]).reshape(0,3)
ms.rx_busy = True
for rx in receivers:
try:
if rx.isActive: rx.update()
except IOError:
print("Problem connecting to receiver.")
rx.d_2_last_intersection = []
for x in range(len(receivers)): for x in range(len(receivers)):
for y in range(x): for y in range(x):
if x != y: if x != y:
...@@ -876,6 +890,10 @@ def run_receiver(receivers): ...@@ -876,6 +890,10 @@ def run_receiver(receivers):
receivers[x].doa, receivers[y].latitude, receivers[y].longitude, receivers[y].doa) receivers[x].doa, receivers[y].latitude, receivers[y].longitude, receivers[y].doa)
if intersection: if intersection:
print(intersection) print(intersection)
receivers[x].d_2_last_intersection.append(v.haversine(
receivers[x].latitude, receivers[x].longitude, *intersection))
receivers[y].d_2_last_intersection.append(v.haversine(
receivers[y].latitude, receivers[y].longitude, *intersection))
intersection = list(intersection) intersection = list(intersection)
avg_conf = np.mean([receivers[x].confidence, receivers[y].confidence]) avg_conf = np.mean([receivers[x].confidence, receivers[y].confidence])
intersection.append(avg_conf) intersection.append(avg_conf)
...@@ -883,7 +901,6 @@ def run_receiver(receivers): ...@@ -883,7 +901,6 @@ def run_receiver(receivers):
if intersection.any() != None: if intersection.any() != None:
intersect_list = np.concatenate((intersect_list, intersection), axis=0) intersect_list = np.concatenate((intersect_list, intersection), axis=0)
if intersect_list.size != 0: if intersect_list.size != 0:
avg_coord = np.average(intersect_list[:,0:3], weights=intersect_list[:,2], axis = 0) avg_coord = np.average(intersect_list[:,0:3], weights=intersect_list[:,2], axis = 0)
keep, in_aoi = check_aoi(*avg_coord[0:2]) keep, in_aoi = check_aoi(*avg_coord[0:2])
...@@ -947,11 +964,12 @@ def run_receiver(receivers): ...@@ -947,11 +964,12 @@ def run_receiver(receivers):
DATABASE_RETURN.get(timeout=1) DATABASE_RETURN.get(timeout=1)
DATABASE_EDIT_Q.put(("done", None, False)) DATABASE_EDIT_Q.put(("done", None, False))
try: # try:
if rx.isActive: rx.update() # if rx.isActive: rx.update()
except IOError: # except IOError:
print("Problem connecting to receiver.") # print("Problem connecting to receiver.")
ms.rx_busy = False
time.sleep(1) time.sleep(1)
if dots > 5: if dots > 5:
dots = 1 dots = 1
......
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